dbus-marshal-byteswap: Byte-swap Unix fd indexes if needed
[platform/upstream/dbus.git] / dbus / dbus-marshal-byteswap.c
index 80cc1ce..7104e9c 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* dbus-marshal-byteswap.c  Swap a block of marshaled data
  *
  * Copyright (C) 2005 Red Hat, Inc.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
+#include <config.h>
 #include "dbus-marshal-byteswap.h"
 #include "dbus-marshal-basic.h"
 #include "dbus-signature.h"
@@ -60,6 +61,7 @@ byteswap_body_helper (DBusTypeReader       *reader,
         case DBUS_TYPE_BOOLEAN:
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:
+        case DBUS_TYPE_UNIX_FD:
           {
             p = _DBUS_ALIGN_ADDRESS (p, 4);
             *((dbus_uint32_t*)p) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)p));
@@ -72,11 +74,7 @@ byteswap_body_helper (DBusTypeReader       *reader,
         case DBUS_TYPE_DOUBLE:
           {
             p = _DBUS_ALIGN_ADDRESS (p, 8);
-#ifdef DBUS_HAVE_INT64
             *((dbus_uint64_t*)p) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)p));
-#else
-            _dbus_swap_array (p, 1, 8);
-#endif
             p += 8;
           }
           break;
@@ -164,7 +162,7 @@ byteswap_body_helper (DBusTypeReader       *reader,
             sig_len = *p;
             ++p;
 
-            _dbus_string_init_const_len (&sig, p, sig_len);
+            _dbus_string_init_const_len (&sig, (const char *) p, sig_len);
 
             p += (sig_len + 1); /* 1 for nul */
 
@@ -237,7 +235,7 @@ _dbus_marshal_byteswap (const DBusString *signature,
 
   byteswap_body_helper (&reader, TRUE,
                         old_byte_order, new_byte_order,
-                        _dbus_string_get_data_len (value_str, value_pos, 0),
+                        _dbus_string_get_udata_len (value_str, value_pos, 0),
                         NULL);
 }