dbus/dbus dbus-arch-deps.h.in, 1.2, 1.3 dbus-bus.c, 1.38, 1.39 dbus-internals.c, 1.41, 1.42 dbus-internals.h, 1.50, 1.51 dbus-keyring.c, 1.26, 1.27 dbus-marshal-basic.c, 1.21, 1.22 dbus-marshal-basic.h, 1.18, 1.19 dbus-marshal-byteswap.c, 1.1, 1.2 dbus-marshal-header.c, 1.7, 1.8 dbus-marshal-recursive-util.c, 1.5, 1.6 dbus-marshal-validate-util.c, 1.1, 1.2 dbus-marshal-validate.c, 1.10, 1.11 dbus-message-util.c, 1.5, 1.6 dbus-protocol.h, 1.35, 1.36 dbus-string-private.h, 1.5, 1.6 dbus-string.c, 1.64, 1.65 dbus-string.h, 1.37, 1.38 dbus-test.c, 1.38, 1.39 dbus-transport.c, 1.42, 1.43 dbus-types.h, 1.12, 1.13

Havoc Pennington hp@freedesktop.org
Thu Jan 27 19:06:58 PST 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv3500/dbus

Modified Files:
	dbus-arch-deps.h.in dbus-bus.c dbus-internals.c 
	dbus-internals.h dbus-keyring.c dbus-marshal-basic.c 
	dbus-marshal-basic.h dbus-marshal-byteswap.c 
	dbus-marshal-header.c dbus-marshal-recursive-util.c 
	dbus-marshal-validate-util.c dbus-marshal-validate.c 
	dbus-message-util.c dbus-protocol.h dbus-string-private.h 
	dbus-string.c dbus-string.h dbus-test.c dbus-transport.c 
	dbus-types.h 
Log Message:
2005-01-27  Havoc Pennington  <hp@redhat.com>

	* dbus/dbus-arch-deps.h.in: add 16/32-bit types

	* configure.in: find the right type for 16 and 32 bit ints as well
	as 64

	* dbus/dbus-protocol.h (DBUS_TYPE_INT16, DBUS_TYPE_UINT16): add
	the 16-bit types so people don't have to stuff them in 32-bit or
	byte arrays.



Index: dbus-arch-deps.h.in
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-arch-deps.h.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbus-arch-deps.h.in	2 Dec 2003 10:44:21 -0000	1.2
+++ dbus-arch-deps.h.in	28 Jan 2005 03:06:55 -0000	1.3
@@ -27,7 +27,6 @@
 #ifndef DBUS_ARCH_DEPS_H
 #define DBUS_ARCH_DEPS_H
 
-#include <dbus/dbus-types.h>
 #include <dbus/dbus-macros.h>
 
 DBUS_BEGIN_DECLS;
@@ -46,6 +45,12 @@
 #undef DBUS_UINT64_CONSTANT
 #endif
 
+typedef @DBUS_INT32_TYPE@ dbus_int32_t;
+typedef unsigned @DBUS_INT32_TYPE@ dbus_uint32_t;
+
+typedef @DBUS_INT16_TYPE@ dbus_int16_t;
+typedef unsigned @DBUS_INT16_TYPE@ dbus_uint16_t;
+
 DBUS_END_DECLS;
 
 #endif /* DBUS_ARCH_DEPS_H */

Index: dbus-bus.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-bus.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- dbus-bus.c	21 Jan 2005 06:18:04 -0000	1.38
+++ dbus-bus.c	28 Jan 2005 03:06:55 -0000	1.39
@@ -26,6 +26,7 @@
 #include "dbus-protocol.h"
 #include "dbus-internals.h"
 #include "dbus-message.h"
+#include "dbus-marshal-validate.h"
 #include <string.h>
 
 /**

Index: dbus-internals.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- dbus-internals.c	17 Jan 2005 03:53:40 -0000	1.41
+++ dbus-internals.c	28 Jan 2005 03:06:55 -0000	1.42
@@ -98,6 +98,38 @@
  * @param object the object to be zeroed.
  */
 /**
+ * @def _DBUS_INT16_MIN
+ *
+ * Minimum value of type "int16"
+ */
+/**
+ * @def _DBUS_INT16_MAX
+ *
+ * Maximum value of type "int16"
+ */
+/**
+ * @def _DBUS_UINT16_MAX
+ *
+ * Maximum value of type "uint16"
+ */
+
+/**
+ * @def _DBUS_INT32_MIN
+ *
+ * Minimum value of type "int32"
+ */
+/**
+ * @def _DBUS_INT32_MAX
+ *
+ * Maximum value of type "int32"
+ */
+/**
+ * @def _DBUS_UINT32_MAX
+ *
+ * Maximum value of type "uint32"
+ */
+
+/**
  * @def _DBUS_INT_MIN
  *
  * Minimum value of type "int"
@@ -107,6 +139,11 @@
  *
  * Maximum value of type "int"
  */
+/**
+ * @def _DBUS_UINT_MAX
+ *
+ * Maximum value of type "uint"
+ */
 
 /**
  * @typedef DBusForeachFunction

Index: dbus-internals.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- dbus-internals.h	17 Jan 2005 03:53:40 -0000	1.50
+++ dbus-internals.h	28 Jan 2005 03:06:55 -0000	1.51
@@ -183,11 +183,18 @@
                                          const char  *str);
 char**      _dbus_dup_string_array      (const char **array);
 
-#define _DBUS_INT_MIN	 (-_DBUS_INT_MAX - 1)
-#define _DBUS_INT_MAX	 2147483647
-#define _DBUS_UINT_MAX	 0xffffffff
+#define _DBUS_INT16_MIN	 ((dbus_int16_t) 0x8000)
+#define _DBUS_INT16_MAX	 ((dbus_int16_t) 0x7fff)
+#define _DBUS_UINT16_MAX ((dbus_uint16_t)0xffff)
+#define _DBUS_INT32_MIN	 ((dbus_int32_t) 0x80000000)
+#define _DBUS_INT32_MAX	 ((dbus_int32_t) 0x7fffffff)
+#define _DBUS_UINT32_MAX ((dbus_uint32_t)0xffffffff)
+/* using 32-bit here is sort of bogus */
+#define _DBUS_INT_MIN	 _DBUS_INT32_MIN
+#define _DBUS_INT_MAX	 _DBUS_INT32_MAX
+#define _DBUS_UINT_MAX	 _DBUS_UINT32_MAX
 #ifdef DBUS_HAVE_INT64
-#define _DBUS_INT64_MAX	 DBUS_INT64_CONSTANT (9223372036854775807)
+#define _DBUS_INT64_MAX	 DBUS_INT64_CONSTANT  (0x7fffffffffffffff)
 #define _DBUS_UINT64_MAX DBUS_UINT64_CONSTANT (0xffffffffffffffff)
 #endif
 #define _DBUS_ONE_KILOBYTE 1024

Index: dbus-keyring.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-keyring.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- dbus-keyring.c	26 Nov 2004 01:53:13 -0000	1.26
+++ dbus-keyring.c	28 Jan 2005 03:06:55 -0000	1.27
@@ -489,7 +489,7 @@
           continue;
         }
 
-      if (val > _DBUS_INT_MAX || val < 0)
+      if (val > _DBUS_INT32_MAX || val < 0)
         {
           _dbus_verbose ("invalid secret key ID at start of line\n");
           continue;

Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dbus-marshal-basic.c	27 Jan 2005 23:39:26 -0000	1.21
+++ dbus-marshal-basic.c	28 Jan 2005 03:06:55 -0000	1.22
@@ -43,6 +43,19 @@
  */
 
 static void
+pack_2_octets (dbus_uint16_t   value,
+               int             byte_order,
+               unsigned char  *data)
+{
+  _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 2) == data);
+
+  if ((byte_order) == DBUS_LITTLE_ENDIAN)
+    *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_LE (value);
+  else
+    *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_BE (value);
+}
+
+static void
 pack_4_octets (dbus_uint32_t   value,
                int             byte_order,
                unsigned char  *data)
@@ -147,6 +160,27 @@
 }
 #endif
 
+#ifndef _dbus_unpack_uint16
+/**
+ * Unpacks a 16 bit unsigned integer from a data pointer
+ *
+ * @param byte_order The byte order to use
+ * @param data the data pointer
+ * @returns the integer
+ */
+dbus_uint16_t
+_dbus_unpack_uint16 (int                  byte_order,
+                     const unsigned char *data)
+{
+  _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 4) == data);
+
+  if (byte_order == DBUS_LITTLE_ENDIAN)
+    return DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)data);
+  else
+    return DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)data);
+}
+#endif /* _dbus_unpack_uint16 */
+
 #ifndef _dbus_unpack_uint32
 /**
  * Unpacks a 32 bit unsigned integer from a data pointer
@@ -169,6 +203,22 @@
 #endif /* _dbus_unpack_uint32 */
 
 static void
+set_2_octets (DBusString          *str,
+              int                  offset,
+              dbus_uint16_t        value,
+              int                  byte_order)
+{
+  char *data;
+
+  _dbus_assert (byte_order == DBUS_LITTLE_ENDIAN ||
+                byte_order == DBUS_BIG_ENDIAN);
+
+  data = _dbus_string_get_data_len (str, offset, 2);
+
+  pack_2_octets (value, byte_order, data);
+}
+
+static void
 set_4_octets (DBusString          *str,
               int                  offset,
               dbus_uint32_t        value,
@@ -181,7 +231,7 @@
 
   data = _dbus_string_get_data_len (str, offset, 4);
 
-  _dbus_pack_uint32 (value, byte_order, data);
+  pack_4_octets (value, byte_order, data);
 }
 
 static void
@@ -350,6 +400,16 @@
         *new_end_pos = pos + 1;
       return TRUE;
       break;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      pos = _DBUS_ALIGN_VALUE (pos, 2);
+      set_2_octets (str, pos, vp->u16, byte_order);
+      if (old_end_pos)
+        *old_end_pos = pos + 2;
+      if (new_end_pos)
+        *new_end_pos = pos + 2;
+      return TRUE;
+      break;
     case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
@@ -460,6 +520,14 @@
       vp->byt = _dbus_string_get_byte (str, pos);
       (pos)++;
       break;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      pos = _DBUS_ALIGN_VALUE (pos, 2);
+      vp->u16 = *(dbus_uint16_t *)(str_data + pos);
+      if (byte_order != DBUS_COMPILER_BYTE_ORDER)
+	vp->u16 = DBUS_UINT16_SWAP_LE_BE (vp->u16);
+      pos += 2;
+      break;
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
     case DBUS_TYPE_BOOLEAN:
@@ -571,6 +639,35 @@
 }
 
 static dbus_bool_t
+marshal_2_octets (DBusString   *str,
+                  int           insert_at,
+                  dbus_uint16_t value,
+                  int           byte_order,
+                  int          *pos_after)
+{
+  dbus_bool_t retval;
+  int orig_len;
+
+  _dbus_assert (sizeof (value) == 2);
+
+  if (byte_order != DBUS_COMPILER_BYTE_ORDER)
+    value = DBUS_UINT16_SWAP_LE_BE (value);
+
+  orig_len = _dbus_string_get_length (str);
+
+  retval = _dbus_string_insert_2_aligned (str, insert_at,
+                                          (const unsigned char *)&value);
+
+  if (pos_after)
+    {
+      *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
+      _dbus_assert (*pos_after <= _dbus_string_get_length (str));
+    }
+
+  return retval;
+}
+
+static dbus_bool_t
 marshal_4_octets (DBusString   *str,
                   int           insert_at,
                   dbus_uint32_t value,
@@ -762,6 +859,11 @@
         *pos_after = insert_at + 1;
       return TRUE;
       break;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      return marshal_2_octets (str, insert_at, vp->u16,
+                               byte_order, pos_after);
+      break;
     case DBUS_TYPE_BOOLEAN:
       return marshal_4_octets (str, insert_at, vp->u32 != FALSE,
                                byte_order, pos_after);
@@ -855,16 +957,24 @@
           d += 8;
         }
     }
-  else
+  else if (alignment == 4)
     {
-      _dbus_assert (alignment == 4);
-      
       while (d != end)
         {
           *((dbus_uint32_t*)d) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)d));
           d += 4;
         }
     }
+  else
+    {
+      _dbus_assert (alignment == 2);
+      
+      while (d != end)
+        {
+          *((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d));
+          d += 2;
+        }
+    }
 }
 
 static void
@@ -979,6 +1089,9 @@
     case DBUS_TYPE_BYTE:
       return marshal_1_octets_array (str, insert_at, vp, n_elements, byte_order, pos_after);
       break;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 2, pos_after);
       /* FIXME: we canonicalize to 0 or 1 for the single boolean case
        * should we here too ? */
     case DBUS_TYPE_BOOLEAN:
@@ -1024,6 +1137,11 @@
     case DBUS_TYPE_BYTE:
       (*pos)++;
       break;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      *pos = _DBUS_ALIGN_VALUE (*pos, 2);
+      *pos += 2;
+      break;
     case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
@@ -1109,6 +1227,9 @@
     case DBUS_TYPE_VARIANT:
     case DBUS_TYPE_SIGNATURE:
       return 1;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+      return 2;
     case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
@@ -1150,6 +1271,8 @@
     {
     case DBUS_TYPE_BYTE:
     case DBUS_TYPE_BOOLEAN:
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
     case DBUS_TYPE_INT64:
@@ -1232,6 +1355,8 @@
     {
     case DBUS_TYPE_BYTE:
     case DBUS_TYPE_BOOLEAN:
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
     case DBUS_TYPE_INT64:
@@ -1260,6 +1385,10 @@
       return "boolean";
     case DBUS_TYPE_BYTE:
       return "byte";
+    case DBUS_TYPE_INT16:
+      return "int16";
+    case DBUS_TYPE_UINT16:
+      return "uint16";
     case DBUS_TYPE_INT32:
       return "int32";
     case DBUS_TYPE_UINT32:
@@ -1558,6 +1687,7 @@
   DBusString str;
   int pos, dump_pos;
   unsigned char array1[5] = { 3, 4, 0, 1, 9 };
+  dbus_int16_t array2[3] = { 124, 457, 780 };
   dbus_int32_t array4[3] = { 123, 456, 789 };
 #ifdef DBUS_HAVE_INT64
   dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff),
@@ -1566,11 +1696,16 @@
   dbus_int64_t *v_ARRAY_INT64;
 #endif
   unsigned char *v_ARRAY_BYTE;
+  dbus_int16_t *v_ARRAY_INT16;
+  dbus_uint16_t *v_ARRAY_UINT16;
   dbus_int32_t *v_ARRAY_INT32;
+  dbus_uint32_t *v_ARRAY_UINT32;
   double *v_ARRAY_DOUBLE;
   DBusString t;
   double v_DOUBLE;
   double t_DOUBLE;
+  dbus_int16_t v_INT16;
+  dbus_uint16_t v_UINT16;
   dbus_int32_t v_INT32;
   dbus_uint32_t v_UINT32;
   dbus_int64_t v_INT64;
@@ -1600,6 +1735,14 @@
   if (!_DBUS_DOUBLES_BITWISE_EQUAL (t_DOUBLE, v_DOUBLE))
     _dbus_assert_not_reached ("got wrong double value");
 
+  /* Marshal signed 16 integers */
+  MARSHAL_TEST (INT16, DBUS_BIG_ENDIAN, -12345);
+  MARSHAL_TEST (INT16, DBUS_LITTLE_ENDIAN, -12345);
+
+  /* Marshal unsigned 16 integers */
+  MARSHAL_TEST (UINT16, DBUS_BIG_ENDIAN, 0x1234);
+  MARSHAL_TEST (UINT16, DBUS_LITTLE_ENDIAN, 0x1234);
+  
   /* Marshal signed integers */
   MARSHAL_TEST (INT32, DBUS_BIG_ENDIAN, -12345678);
   MARSHAL_TEST (INT32, DBUS_LITTLE_ENDIAN, -12345678);
@@ -1645,8 +1788,15 @@
   MARSHAL_TEST_STRCMP (SIGNATURE, DBUS_LITTLE_ENDIAN, "a(ii)");
 
   /* Arrays */
+  MARSHAL_TEST_FIXED_ARRAY (INT16, DBUS_BIG_ENDIAN, array2);
+  MARSHAL_TEST_FIXED_ARRAY (INT16, DBUS_LITTLE_ENDIAN, array2);
+  MARSHAL_TEST_FIXED_ARRAY (UINT16, DBUS_BIG_ENDIAN, array2);
+  MARSHAL_TEST_FIXED_ARRAY (UINT16, DBUS_LITTLE_ENDIAN, array2);
+  
   MARSHAL_TEST_FIXED_ARRAY (INT32, DBUS_BIG_ENDIAN, array4);
   MARSHAL_TEST_FIXED_ARRAY (INT32, DBUS_LITTLE_ENDIAN, array4);
+  MARSHAL_TEST_FIXED_ARRAY (UINT32, DBUS_BIG_ENDIAN, array4);
+  MARSHAL_TEST_FIXED_ARRAY (UINT32, DBUS_LITTLE_ENDIAN, array4);
 
   MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_BIG_ENDIAN, array1);
   MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_LITTLE_ENDIAN, array1);

Index: dbus-marshal-basic.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dbus-marshal-basic.h	27 Jan 2005 23:39:26 -0000	1.18
+++ dbus-marshal-basic.h	28 Jan 2005 03:06:55 -0000	1.19
@@ -41,6 +41,10 @@
 #define DBUS_COMPILER_BYTE_ORDER DBUS_LITTLE_ENDIAN
 #endif
 
+#define DBUS_UINT16_SWAP_LE_BE_CONSTANT(val)	((dbus_uint16_t) (      \
+    (dbus_uint16_t) ((dbus_uint16_t) (val) >> 8) |                      \
+    (dbus_uint16_t) ((dbus_uint16_t) (val) << 8)))
+
 #define DBUS_UINT32_SWAP_LE_BE_CONSTANT(val)	((dbus_uint32_t) (      \
     (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x000000ffU) << 24) |     \
     (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x0000ff00U) <<  8) |     \
@@ -68,48 +72,66 @@
 	(dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56)))
 #endif /* DBUS_HAVE_INT64 */
 
+#define DBUS_UINT16_SWAP_LE_BE(val) (DBUS_UINT16_SWAP_LE_BE_CONSTANT (val))
+#define DBUS_INT16_SWAP_LE_BE(val)  ((dbus_int16_t)DBUS_UINT16_SWAP_LE_BE_CONSTANT (val))
+
 #define DBUS_UINT32_SWAP_LE_BE(val) (DBUS_UINT32_SWAP_LE_BE_CONSTANT (val))
 #define DBUS_INT32_SWAP_LE_BE(val)  ((dbus_int32_t)DBUS_UINT32_SWAP_LE_BE_CONSTANT (val))
 
 #ifdef DBUS_HAVE_INT64
-#define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
-#define DBUS_INT64_SWAP_LE_BE(val)  ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
+#  define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
+#  define DBUS_INT64_SWAP_LE_BE(val)  ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
 #endif /* DBUS_HAVE_INT64 */
 
 #ifdef WORDS_BIGENDIAN
-#define DBUS_INT32_TO_BE(val)	((dbus_int32_t) (val))
-#define DBUS_UINT32_TO_BE(val)	((dbus_uint32_t) (val))
-#define DBUS_INT32_TO_LE(val)	(DBUS_INT32_SWAP_LE_BE (val))
-#define DBUS_UINT32_TO_LE(val)	(DBUS_UINT32_SWAP_LE_BE (val))
+
+#  define DBUS_INT16_TO_BE(val)	((dbus_int16_t) (val))
+#  define DBUS_UINT16_TO_BE(val)	((dbus_uint16_t) (val))
+#  define DBUS_INT16_TO_LE(val)	(DBUS_INT16_SWAP_LE_BE (val))
+#  define DBUS_UINT16_TO_LE(val)	(DBUS_UINT16_SWAP_LE_BE (val))
+#  define DBUS_INT32_TO_BE(val)	((dbus_int32_t) (val))
+#  define DBUS_UINT32_TO_BE(val)	((dbus_uint32_t) (val))
+#  define DBUS_INT32_TO_LE(val)	(DBUS_INT32_SWAP_LE_BE (val))
+#  define DBUS_UINT32_TO_LE(val)	(DBUS_UINT32_SWAP_LE_BE (val))
 #  ifdef DBUS_HAVE_INT64
-#define DBUS_INT64_TO_BE(val)	((dbus_int64_t) (val))
-#define DBUS_UINT64_TO_BE(val)	((dbus_uint64_t) (val))
-#define DBUS_INT64_TO_LE(val)	(DBUS_INT64_SWAP_LE_BE (val))
-#define DBUS_UINT64_TO_LE(val)	(DBUS_UINT64_SWAP_LE_BE (val))
+#    define DBUS_INT64_TO_BE(val)	((dbus_int64_t) (val))
+#    define DBUS_UINT64_TO_BE(val)	((dbus_uint64_t) (val))
+#    define DBUS_INT64_TO_LE(val)	(DBUS_INT64_SWAP_LE_BE (val))
+#    define DBUS_UINT64_TO_LE(val)	(DBUS_UINT64_SWAP_LE_BE (val))
 #  endif /* DBUS_HAVE_INT64 */
-#else
-#define DBUS_INT32_TO_LE(val)	((dbus_int32_t) (val))
-#define DBUS_UINT32_TO_LE(val)	((dbus_uint32_t) (val))
-#define DBUS_INT32_TO_BE(val)	((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val))
-#define DBUS_UINT32_TO_BE(val)	(DBUS_UINT32_SWAP_LE_BE (val))
+
+#else /* WORDS_BIGENDIAN */
+
+#  define DBUS_INT16_TO_LE(val)	((dbus_int16_t) (val))
+#  define DBUS_UINT16_TO_LE(val)	((dbus_uint16_t) (val))
+#  define DBUS_INT16_TO_BE(val)	((dbus_int16_t) DBUS_UINT16_SWAP_LE_BE (val))
+#  define DBUS_UINT16_TO_BE(val)	(DBUS_UINT16_SWAP_LE_BE (val))
+#  define DBUS_INT32_TO_LE(val)	((dbus_int32_t) (val))
+#  define DBUS_UINT32_TO_LE(val)	((dbus_uint32_t) (val))
+#  define DBUS_INT32_TO_BE(val)	((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val))
+#  define DBUS_UINT32_TO_BE(val)	(DBUS_UINT32_SWAP_LE_BE (val))
 #  ifdef DBUS_HAVE_INT64
-#define DBUS_INT64_TO_LE(val)	((dbus_int64_t) (val))
-#define DBUS_UINT64_TO_LE(val)	((dbus_uint64_t) (val))
-#define DBUS_INT64_TO_BE(val)	((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val))
-#define DBUS_UINT64_TO_BE(val)	(DBUS_UINT64_SWAP_LE_BE (val))
+#    define DBUS_INT64_TO_LE(val)	((dbus_int64_t) (val))
+#    define DBUS_UINT64_TO_LE(val)	((dbus_uint64_t) (val))
+#    define DBUS_INT64_TO_BE(val)	((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val))
+#    define DBUS_UINT64_TO_BE(val)	(DBUS_UINT64_SWAP_LE_BE (val))
 #  endif /* DBUS_HAVE_INT64 */
 #endif
 
 /* The transformation is symmetric, so the FROM just maps to the TO. */
+#define DBUS_INT16_FROM_LE(val)	 (DBUS_INT16_TO_LE (val))
+#define DBUS_UINT16_FROM_LE(val) (DBUS_UINT16_TO_LE (val))
+#define DBUS_INT16_FROM_BE(val)	 (DBUS_INT16_TO_BE (val))
+#define DBUS_UINT16_FROM_BE(val) (DBUS_UINT16_TO_BE (val))
 #define DBUS_INT32_FROM_LE(val)	 (DBUS_INT32_TO_LE (val))
 #define DBUS_UINT32_FROM_LE(val) (DBUS_UINT32_TO_LE (val))
 #define DBUS_INT32_FROM_BE(val)	 (DBUS_INT32_TO_BE (val))
 #define DBUS_UINT32_FROM_BE(val) (DBUS_UINT32_TO_BE (val))
 #ifdef DBUS_HAVE_INT64
-#define DBUS_INT64_FROM_LE(val)	 (DBUS_INT64_TO_LE (val))
-#define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val))
-#define DBUS_INT64_FROM_BE(val)	 (DBUS_INT64_TO_BE (val))
-#define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val))
+#  define DBUS_INT64_FROM_LE(val)	 (DBUS_INT64_TO_LE (val))
+#  define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val))
+#  define DBUS_INT64_FROM_BE(val)	 (DBUS_INT64_TO_BE (val))
+#  define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val))
 #endif /* DBUS_HAVE_INT64 */
 
 #ifndef DBUS_HAVE_INT64
@@ -131,11 +153,13 @@
  */
 typedef union
 {
+  dbus_int16_t  i16;   /**< as int16 */
+  dbus_uint16_t u16;   /**< as int16 */
   dbus_int32_t  i32;   /**< as int32 */
   dbus_uint32_t u32;   /**< as int32 */
 #ifdef DBUS_HAVE_INT64
-  dbus_int64_t  i64;   /**< as int32 */
-  dbus_uint64_t u64;   /**< as int32 */
+  dbus_int64_t  i64;   /**< as int64 */
+  dbus_uint64_t u64;   /**< as int64 */
 #else
   DBus8ByteStruct u64; /**< as 8-byte-struct */
 #endif
@@ -145,12 +169,22 @@
 } DBusBasicValue;
 
 #ifdef DBUS_DISABLE_ASSERT
+#define _dbus_unpack_uint16(byte_order, data)           \
+   (((byte_order) == DBUS_LITTLE_ENDIAN) ?              \
+     DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)(data)) :    \
+     DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)(data)))
+
 #define _dbus_unpack_uint32(byte_order, data)           \
    (((byte_order) == DBUS_LITTLE_ENDIAN) ?              \
      DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)(data)) :    \
      DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)(data)))
 #endif
 
+#ifndef _dbus_unpack_uint16
+dbus_uint16_t _dbus_unpack_uint16 (int                  byte_order,
+                                   const unsigned char *data);
+#endif
+
 void          _dbus_pack_uint32   (dbus_uint32_t        value,
                                    int                  byte_order,
                                    unsigned char       *data);

Index: dbus-marshal-byteswap.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-byteswap.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-marshal-byteswap.c	27 Jan 2005 23:39:26 -0000	1.1
+++ dbus-marshal-byteswap.c	28 Jan 2005 03:06:55 -0000	1.2
@@ -47,6 +47,15 @@
           ++p;
           break;
 
+        case DBUS_TYPE_INT16:
+        case DBUS_TYPE_UINT16:
+          {
+            p = _DBUS_ALIGN_ADDRESS (p, 2);
+            *((dbus_uint16_t*)p) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)p));
+            p += 2;
+          }
+          break;
+          
         case DBUS_TYPE_BOOLEAN:
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:

Index: dbus-marshal-header.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-header.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-marshal-header.c	27 Jan 2005 23:39:26 -0000	1.7
+++ dbus-marshal-header.c	28 Jan 2005 03:06:55 -0000	1.8
@@ -672,7 +672,7 @@
   dbus_uint32_t body_len_unsigned;
 
   _dbus_assert (start >= 0);
-  _dbus_assert (start < _DBUS_INT_MAX / 2);
+  _dbus_assert (start < _DBUS_INT32_MAX / 2);
   _dbus_assert (len >= 0);
 
   _dbus_assert (start == (int) _DBUS_ALIGN_VALUE (start, 8));
@@ -711,16 +711,16 @@
   /* overflow should be impossible since the lengths aren't allowed to
    * be huge.
    */
-  _dbus_assert (max_message_length < _DBUS_INT_MAX / 2);
+  _dbus_assert (max_message_length < _DBUS_INT32_MAX / 2);
   if (body_len_unsigned + header_len_unsigned > (unsigned) max_message_length)
     {
       *validity = DBUS_INVALID_MESSAGE_TOO_LONG;
       return FALSE;
     }
 
-  _dbus_assert (body_len_unsigned < (unsigned) _DBUS_INT_MAX);
-  _dbus_assert (fields_array_len_unsigned < (unsigned) _DBUS_INT_MAX);
-  _dbus_assert (header_len_unsigned < (unsigned) _DBUS_INT_MAX);
+  _dbus_assert (body_len_unsigned < (unsigned) _DBUS_INT32_MAX);
+  _dbus_assert (fields_array_len_unsigned < (unsigned) _DBUS_INT32_MAX);
+  _dbus_assert (header_len_unsigned < (unsigned) _DBUS_INT32_MAX);
 
   *body_len = body_len_unsigned;
   *fields_array_len = fields_array_len_unsigned;

Index: dbus-marshal-recursive-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive-util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-marshal-recursive-util.c	27 Jan 2005 23:39:26 -0000	1.5
+++ dbus-marshal-recursive-util.c	28 Jan 2005 03:06:55 -0000	1.6
@@ -396,6 +396,26 @@
  * and by merging read_value and set_value into one function
  * taking a flag argument.
  */
+static dbus_bool_t int16_write_value       (TestTypeNode   *node,
+                                            DataBlock      *block,
+                                            DBusTypeWriter *writer,
+                                            int             seed);
+static dbus_bool_t int16_read_value        (TestTypeNode   *node,
+                                            DBusTypeReader *reader,
+                                            int             seed);
+static dbus_bool_t int16_set_value         (TestTypeNode   *node,
+                                            DBusTypeReader *reader,
+                                            DBusTypeReader *realign_root,
+                                            int             seed);
+static dbus_bool_t int16_write_multi       (TestTypeNode   *node,
+                                            DataBlock      *block,
+                                            DBusTypeWriter *writer,
+                                            int             seed,
+                                            int             count);
+static dbus_bool_t int16_read_multi        (TestTypeNode   *node,
+                                            DBusTypeReader *reader,
+                                            int             seed,
+                                            int             count);
 static dbus_bool_t int32_write_value       (TestTypeNode   *node,
                                             DataBlock      *block,
                                             DBusTypeWriter *writer,
@@ -533,6 +553,34 @@
 static void        container_destroy       (TestTypeNode   *node);
 
 
+static const TestTypeNodeClass int16_class = {
+  DBUS_TYPE_INT16,
+  sizeof (TestTypeNode),
+  0,
+  NULL,
+  NULL,
+  int16_write_value,
+  int16_read_value,
+  int16_set_value,
+  NULL,
+  int16_write_multi,
+  int16_read_multi
+};
+
+static const TestTypeNodeClass uint16_class = {
+  DBUS_TYPE_UINT16,
+  sizeof (TestTypeNode),
+  0,
+  NULL,
+  NULL,
+  int16_write_value, /* recycle from int16 */
+  int16_read_value,  /* recycle from int16 */
+  int16_set_value,   /* recycle from int16 */
+  NULL,
+  int16_write_multi, /* recycle from int16 */
+  int16_read_multi   /* recycle from int16 */
+};
+
 static const TestTypeNodeClass int32_class = {
   DBUS_TYPE_INT32,
   sizeof (TestTypeNode),
@@ -819,6 +867,8 @@
 
 static const TestTypeNodeClass* const
 basic_nodes[] = {
+  &int16_class,
+  &uint16_class,
   &int32_class,
   &uint32_class,
   &int64_class,
@@ -1978,6 +2028,142 @@
  */
 #define MAX_MULTI_COUNT 5
 
+#define SAMPLE_INT16           1234
+#define SAMPLE_INT16_ALTERNATE 6785
+static dbus_int16_t
+int16_from_seed (int seed)
+{
+  /* Generate an integer value that's predictable from seed.  We could
+   * just use seed itself, but that would only ever touch one byte of
+   * the int so would miss some kinds of bug.
+   */
+  dbus_int16_t v;
+
+  v = 42; /* just to quiet compiler afaik */
+  switch (seed % 5)
+    {
+    case 0:
+      v = SAMPLE_INT16;
+      break;
+    case 1:
+      v = SAMPLE_INT16_ALTERNATE;
+      break;
+    case 2:
+      v = -1;
+      break;
+    case 3:
+      v = _DBUS_INT16_MAX;
+      break;
+    case 4:
+      v = 1;
+      break;
+    }
+
+  if (seed > 1)
+    v *= seed; /* wraps around eventually, which is fine */
+
+  return v;
+}
+
+static dbus_bool_t
+int16_write_value (TestTypeNode   *node,
+                   DataBlock      *block,
+                   DBusTypeWriter *writer,
+                   int             seed)
+{
+  /* also used for uint16 */
+  dbus_int16_t v;
+
+  v = int16_from_seed (seed);
+
+  return _dbus_type_writer_write_basic (writer,
+                                        node->klass->typecode,
+                                        &v);
+}
+
+static dbus_bool_t
+int16_read_value (TestTypeNode   *node,
+                  DBusTypeReader *reader,
+                  int             seed)
+{
+  /* also used for uint16 */
+  dbus_int16_t v;
+
+  check_expected_type (reader, node->klass->typecode);
+
+  _dbus_type_reader_read_basic (reader,
+                                (dbus_int16_t*) &v);
+
+  _dbus_assert (v == int16_from_seed (seed));
+
+  return TRUE;
+}
+
+static dbus_bool_t
+int16_set_value (TestTypeNode   *node,
+                 DBusTypeReader *reader,
+                 DBusTypeReader *realign_root,
+                 int             seed)
+{
+  /* also used for uint16 */
+  dbus_int16_t v;
+
+  v = int16_from_seed (seed);
+
+  return _dbus_type_reader_set_basic (reader,
+                                      &v,
+                                      realign_root);
+}
+
+static dbus_bool_t
+int16_write_multi (TestTypeNode   *node,
+                   DataBlock      *block,
+                   DBusTypeWriter *writer,
+                   int             seed,
+                   int             count)
+{
+  /* also used for uint16 */
+  dbus_int16_t values[MAX_MULTI_COUNT];
+  dbus_int16_t *v_ARRAY_INT16 = values;
+  int i;
+
+  for (i = 0; i < count; ++i)
+    values[i] = int16_from_seed (seed + i);
+
+  return _dbus_type_writer_write_fixed_multi (writer,
+                                              node->klass->typecode,
+                                              &v_ARRAY_INT16, count);
+}
+
+static dbus_bool_t
+int16_read_multi (TestTypeNode   *node,
+                  DBusTypeReader *reader,
+                  int             seed,
+                  int             count)
+{
+  /* also used for uint16 */
+  dbus_int16_t *values;
+  int n_elements;
+  int i;
+
+  check_expected_type (reader, node->klass->typecode);
+
+  _dbus_type_reader_read_fixed_multi (reader,
+                                      &values,
+                                      &n_elements);
+
+  if (n_elements != count)
+    _dbus_warn ("got %d elements expected %d\n", n_elements, count);
+  _dbus_assert (n_elements == count);
+
+  for (i = 0; i < count; i++)
+    _dbus_assert (((int)_dbus_unpack_uint16 (reader->byte_order,
+                                             (const unsigned char*)values + (i * 2))) ==
+                  int16_from_seed (seed + i));
+
+  return TRUE;
+}
+
 
 #define SAMPLE_INT32           12345678
 #define SAMPLE_INT32_ALTERNATE 53781429

Index: dbus-marshal-validate-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-validate-util.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-marshal-validate-util.c	27 Jan 2005 01:50:01 -0000	1.1
+++ dbus-marshal-validate-util.c	28 Jan 2005 03:06:55 -0000	1.2
@@ -68,7 +68,7 @@
   { "i", DBUS_VALID },
   { "ai", DBUS_VALID },
   { "(i)", DBUS_VALID },
-  { "q", DBUS_INVALID_UNKNOWN_TYPECODE },
+  { "w", DBUS_INVALID_UNKNOWN_TYPECODE },
   { "a", DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE },
   { "aaaaaa", DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE },
   { "ii(ii)a", DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE },

Index: dbus-marshal-validate.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-validate.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-marshal-validate.c	27 Jan 2005 23:39:26 -0000	1.10
+++ dbus-marshal-validate.c	28 Jan 2005 03:06:55 -0000	1.11
@@ -57,7 +57,7 @@
   int array_depth;
 
   _dbus_assert (type_str != NULL);
-  _dbus_assert (type_pos < _DBUS_INT_MAX - len);
+  _dbus_assert (type_pos < _DBUS_INT32_MAX - len);
   _dbus_assert (len >= 0);
   _dbus_assert (type_pos >= 0);
 
@@ -76,6 +76,8 @@
         {
         case DBUS_TYPE_BYTE:
         case DBUS_TYPE_BOOLEAN:
+        case DBUS_TYPE_INT16:
+        case DBUS_TYPE_UINT16:
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:
         case DBUS_TYPE_INT64:
@@ -159,8 +161,10 @@
         case DBUS_TYPE_BYTE:
           ++p;
           break;
-
+          
         case DBUS_TYPE_BOOLEAN:
+        case DBUS_TYPE_INT16:
+        case DBUS_TYPE_UINT16:
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:
         case DBUS_TYPE_INT64:

Index: dbus-message-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message-util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-message-util.c	24 Jan 2005 05:56:25 -0000	1.5
+++ dbus-message-util.c	28 Jan 2005 03:06:55 -0000	1.6
@@ -591,6 +591,8 @@
   DBusMessageIter iter, array, array2;
   const char *v_STRING;
   double v_DOUBLE;
+  dbus_int16_t v_INT16;
+  dbus_uint16_t v_UINT16;
   dbus_int32_t v_INT32;
   dbus_uint32_t v_UINT32;
 #ifdef DBUS_HAVE_INT64
@@ -656,6 +658,8 @@
 {
   DBusMessageIter iter;
   DBusError error;
+  dbus_int16_t our_int16;
+  dbus_uint16_t our_uint16;
   dbus_int32_t our_int;
   dbus_uint32_t our_uint;
   const char *our_str;
@@ -686,6 +690,8 @@
 
   dbus_error_init (&error);
   if (!dbus_message_iter_get_args (&iter, &error,
+                                   DBUS_TYPE_INT16, &our_int16,
+                                   DBUS_TYPE_UINT16, &our_uint16,
 				   DBUS_TYPE_INT32, &our_int,
                                    DBUS_TYPE_UINT32, &our_uint,
 #ifdef DBUS_HAVE_INT64
@@ -720,6 +726,12 @@
       _dbus_assert_not_reached ("Could not get arguments");
     }
 
+  if (our_int16 != -0x123)
+    _dbus_assert_not_reached ("16-bit integers differ!");
+
+  if (our_uint16 != 0x123)
+    _dbus_assert_not_reached ("16-bit uints differ!");
+  
   if (our_int != -0x12345678)
     _dbus_assert_not_reached ("integers differ!");
 
@@ -860,6 +872,8 @@
   const char *s;
   const char *v_STRING;
   double v_DOUBLE;
+  dbus_int16_t v_INT16;
+  dbus_uint16_t v_UINT16;
   dbus_int32_t v_INT32;
   dbus_uint32_t v_UINT32;
 #ifdef DBUS_HAVE_INT64
@@ -974,6 +988,8 @@
   _dbus_message_set_serial (message, 1);
   dbus_message_set_reply_serial (message, 5678);
 
+  v_INT16 = -0x123;
+  v_UINT16 = 0x123;
   v_INT32 = -0x12345678;
   v_UINT32 = 0x12300042;
 #ifdef DBUS_HAVE_INT64
@@ -987,6 +1003,8 @@
   v2_BYTE = 24;
 
   dbus_message_append_args (message,
+                            DBUS_TYPE_INT16, &v_INT16,
+                            DBUS_TYPE_UINT16, &v_UINT16,
 			    DBUS_TYPE_INT32, &v_INT32,
                             DBUS_TYPE_UINT32, &v_UINT32,
 #ifdef DBUS_HAVE_INT64
@@ -1017,6 +1035,8 @@
 			    DBUS_TYPE_INVALID);
 
   i = 0;
+  sig[i++] = DBUS_TYPE_INT16;
+  sig[i++] = DBUS_TYPE_UINT16;
   sig[i++] = DBUS_TYPE_INT32;
   sig[i++] = DBUS_TYPE_UINT32;
 #ifdef DBUS_HAVE_INT64

Index: dbus-protocol.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-protocol.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- dbus-protocol.h	24 Jan 2005 05:56:25 -0000	1.35
+++ dbus-protocol.h	28 Jan 2005 03:06:55 -0000	1.36
@@ -49,9 +49,12 @@
 #define DBUS_TYPE_BYTE_AS_STRING           "y"
 #define DBUS_TYPE_BOOLEAN       ((int) 'b')
 #define DBUS_TYPE_BOOLEAN_AS_STRING        "b"
+#define DBUS_TYPE_INT16         ((int) 'n')
+#define DBUS_TYPE_INT16_AS_STRING          "n"
+#define DBUS_TYPE_UINT16        ((int) 'q')
+#define DBUS_TYPE_UINT16_AS_STRING         "q"
 #define DBUS_TYPE_INT32         ((int) 'i')
 #define DBUS_TYPE_INT32_AS_STRING          "i"
-
 #define DBUS_TYPE_UINT32        ((int) 'u')
 #define DBUS_TYPE_UINT32_AS_STRING         "u"
 #define DBUS_TYPE_INT64         ((int) 'x')
@@ -81,7 +84,7 @@
 #define DBUS_TYPE_STRUCT_AS_STRING         "r"
 
 /* Does not count INVALID */
-#define DBUS_NUMBER_OF_TYPES    (13)
+#define DBUS_NUMBER_OF_TYPES    (15)
 
 /* characters other than typecodes that appear in type signatures */
 #define DBUS_STRUCT_BEGIN_CHAR   ((int) '(')

Index: dbus-string-private.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string-private.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-string-private.h	17 Jan 2005 03:53:40 -0000	1.5
+++ dbus-string-private.h	28 Jan 2005 03:06:55 -0000	1.6
@@ -68,7 +68,7 @@
  * This is the maximum max length (and thus also the maximum length)
  * of a DBusString
  */
-#define _DBUS_STRING_MAX_MAX_LENGTH (_DBUS_INT_MAX - _DBUS_STRING_ALLOCATION_PADDING)
+#define _DBUS_STRING_MAX_MAX_LENGTH (_DBUS_INT32_MAX - _DBUS_STRING_ALLOCATION_PADDING)
 
 /**
  * Checks a bunch of assertions about a string object

Index: dbus-string.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- dbus-string.c	17 Jan 2005 03:53:40 -0000	1.64
+++ dbus-string.c	28 Jan 2005 03:06:56 -0000	1.65
@@ -974,6 +974,9 @@
   return append (real, buffer, buffer_len);
 }
 
+/** assign 2 bytes from one string to another */
+#define ASSIGN_2_OCTETS(p, octets) \
+  *((dbus_uint16_t*)(p)) = *((dbus_uint16_t*)(octets));
 
 /** assign 4 bytes from one string to another */
 #define ASSIGN_4_OCTETS(p, octets) \
@@ -1052,6 +1055,30 @@
 #endif /* DBUS_BUILD_TESTS */
 
 /**
+ * Inserts 2 bytes aligned on a 2 byte boundary
+ * with any alignment padding initialized to 0.
+ *
+ * @param str the DBusString
+ * @param insert_at where to insert
+ * @param octets 2 bytes to insert
+ * @returns #FALSE if not enough memory.
+ */
+dbus_bool_t
+_dbus_string_insert_2_aligned (DBusString         *str,
+                               int                 insert_at,
+                               const unsigned char octets[4])
+{
+  DBUS_STRING_PREAMBLE (str);
+  
+  if (!align_insert_point_then_open_gap (str, &insert_at, 2, 2))
+    return FALSE;
+
+  ASSIGN_2_OCTETS (real->str + insert_at, octets);
+
+  return TRUE;
+}
+
+/**
  * Inserts 4 bytes aligned on a 4 byte boundary
  * with any alignment padding initialized to 0.
  *
@@ -1109,7 +1136,7 @@
  *
  * @param str the DBusString
  * @param insert_at location to be aligned
- * @param alignment alignment boundary (1, 4, or 8)
+ * @param alignment alignment boundary (1, 2, 4, or 8)
  * @returns #FALSE if not enough memory.
  */
 dbus_bool_t

Index: dbus-string.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- dbus-string.h	17 Jan 2005 03:53:40 -0000	1.37
+++ dbus-string.h	28 Jan 2005 03:06:56 -0000	1.38
@@ -156,6 +156,9 @@
 dbus_bool_t   _dbus_string_append_printf_valist  (DBusString        *str,
                                                   const char        *format,
                                                   va_list            args);
+dbus_bool_t   _dbus_string_insert_2_aligned      (DBusString        *str,
+                                                  int                insert_at,
+                                                  const unsigned char octets[2]);
 dbus_bool_t   _dbus_string_insert_4_aligned      (DBusString        *str,
                                                   int                insert_at,
                                                   const unsigned char octets[4]);

Index: dbus-test.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-test.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- dbus-test.c	27 Jan 2005 23:39:26 -0000	1.38
+++ dbus-test.c	28 Jan 2005 03:06:56 -0000	1.39
@@ -118,7 +118,7 @@
 
   check_memleaks ();
 
-#if 0
+#if 1
   printf ("%s: running recursive marshalling tests\n", "dbus-test");
   if (!_dbus_marshal_recursive_test ())
     die ("recursive marshal");
@@ -140,7 +140,7 @@
   
   check_memleaks ();
 
-#if 0
+#if 1
   printf ("%s: running memory pool tests\n", "dbus-test");
   if (!_dbus_mem_pool_test ())
     die ("memory pools");

Index: dbus-transport.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- dbus-transport.c	26 Nov 2004 01:53:13 -0000	1.42
+++ dbus-transport.c	28 Jan 2005 03:06:56 -0000	1.43
@@ -920,10 +920,10 @@
 {
   DBusCredentials auth_identity;
 
-  *uid = _DBUS_INT_MAX; /* better than some root or system user in
-                         * case of bugs in the caller. Caller should
-                         * never use this value on purpose, however.
-                         */
+  *uid = _DBUS_INT32_MAX; /* better than some root or system user in
+                           * case of bugs in the caller. Caller should
+                           * never use this value on purpose, however.
+                           */
   
   if (!transport->authenticated)
     return FALSE;

Index: dbus-types.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-types.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbus-types.h	18 Jan 2005 03:03:07 -0000	1.12
+++ dbus-types.h	28 Jan 2005 03:06:56 -0000	1.13
@@ -28,9 +28,8 @@
 #define DBUS_TYPES_H
 
 #include <stddef.h>
+#include <dbus/dbus-arch-deps.h>
 
-typedef unsigned int   dbus_uint32_t;
-typedef int            dbus_int32_t;
 typedef dbus_uint32_t  dbus_unichar_t;
 /* boolean size must be fixed at 4 bytes due to wire protocol! */
 typedef dbus_uint32_t  dbus_bool_t;



More information about the dbus-commit mailing list