From fddbc09c4a9125fcb168fb31ff300d4132919ea6 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 27 Jan 2005 23:39:26 +0000 Subject: 2005-01-27 Havoc Pennington * dbus/dbus-message.c: byteswap the message if you init an iterator to read/write from it * dbus/dbus-marshal-byteswap.c: new file implementing _dbus_marshal_byteswap() * dbus/dbus-marshal-basic.c: add _dbus_swap_array() --- dbus/dbus-marshal-header.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'dbus/dbus-marshal-header.c') diff --git a/dbus/dbus-marshal-header.c b/dbus/dbus-marshal-header.c index 6102b6f0..b5a8d3d7 100644 --- a/dbus/dbus-marshal-header.c +++ b/dbus/dbus-marshal-header.c @@ -23,6 +23,7 @@ #include "dbus-marshal-header.h" #include "dbus-marshal-recursive.h" +#include "dbus-marshal-byteswap.h" /** * @addtogroup DBusMarshal @@ -1448,6 +1449,27 @@ _dbus_header_get_flag (DBusHeader *header, return (*flags_p & flag) != 0; } +/** + * Swaps the header into the given order if required. + * + * @param header the header + * @param new_order the new byte order + */ +void +_dbus_header_byteswap (DBusHeader *header, + int new_order) +{ + if (header->byte_order == new_order) + return; + + _dbus_marshal_byteswap (&_dbus_header_signature_str, + 0, header->byte_order, + new_order, + &header->data, 0); + + header->byte_order = new_order; +} + /** @} */ #ifdef DBUS_BUILD_TESTS -- cgit