26 #include "dbus-internals.h"    27 #include "dbus-marshal-basic.h"    28 #include "dbus-signature.h"    32 #if defined(__GNUC__) && (__GNUC__ >= 4)    33 # define _DBUS_ASSERT_ALIGNMENT(type, op, val) \    34   _DBUS_STATIC_ASSERT (__extension__ __alignof__ (type) op val)    38 # define _DBUS_ASSERT_ALIGNMENT(type, op, val) \    39   _DBUS_STATIC_ASSERT (TRUE)    43 _DBUS_STATIC_ASSERT (
sizeof (
char) == 1);
    44 _DBUS_ASSERT_ALIGNMENT (
char, ==, 1);
    46 _DBUS_STATIC_ASSERT (
sizeof (dbus_int16_t) == 2);
    47 _DBUS_ASSERT_ALIGNMENT (dbus_int16_t, <=, 2);
    48 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint16_t) == 2);
    49 _DBUS_ASSERT_ALIGNMENT (dbus_uint16_t, <=, 2);
    51 _DBUS_STATIC_ASSERT (
sizeof (dbus_int32_t) == 4);
    52 _DBUS_ASSERT_ALIGNMENT (dbus_int32_t, <=, 4);
    53 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint32_t) == 4);
    54 _DBUS_ASSERT_ALIGNMENT (dbus_uint32_t, <=, 4);
    58 _DBUS_STATIC_ASSERT (
sizeof (
double) == 8);
    59 _DBUS_ASSERT_ALIGNMENT (
double, <=, 8);
    61 _DBUS_STATIC_ASSERT (
sizeof (dbus_int64_t) == 8);
    62 _DBUS_ASSERT_ALIGNMENT (dbus_int64_t, <=, 8);
    63 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint64_t) == 8);
    64 _DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8);
    89 pack_2_octets (dbus_uint16_t   value,
    96     *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_LE (value);
    98     *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_BE (value);
   102 pack_4_octets (dbus_uint32_t   value,
   109     *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_LE (value);
   111     *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_BE (value);
   122     *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_LE (value.
u64);
   124     *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.
u64);
   139   pack_4_octets (value, byte_order, data);
   146   if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   148       value->
u64 = DBUS_UINT64_SWAP_LE_BE (value->
u64);
   152 #ifndef _dbus_unpack_uint16   162                      const unsigned char *data)
   167     return DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)data);
   169     return DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)data);
   173 #ifndef _dbus_unpack_uint32   183                      const unsigned char *data)
   188     return DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)data);
   190     return DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)data);
   207   pack_2_octets (value, byte_order, data);
   223   pack_4_octets (value, byte_order, data);
   239   pack_8_octets (value, byte_order, data);
   258   set_4_octets (str, pos, value, byte_order);
   288   int old_len, new_len;
   293   _dbus_assert (_DBUS_ALIGN_VALUE (pos, 4) == (
unsigned) pos);
   295                                  _dbus_string_get_const_data_len (str, pos, 4));
   297   new_len = _dbus_string_get_length (&dstr);
   300                                  str, pos + 4, old_len))
   306     *old_end_pos = pos + 4 + old_len + 1;
   308     *new_end_pos = pos + 4 + new_len + 1;
   334   int old_len, new_len;
   339   old_len = _dbus_string_get_byte (str, pos);
   340   new_len = _dbus_string_get_length (&dstr);
   343                                  str, pos + 1, old_len))
   346   _dbus_string_set_byte (str, pos, new_len);
   349     *old_end_pos = pos + 1 + old_len + 1;
   351     *new_end_pos = pos + 1 + new_len + 1;
   385       _dbus_string_set_byte (str, pos, vp->
byt);
   387         *old_end_pos = pos + 1;
   389         *new_end_pos = pos + 1;
   394       pos = _DBUS_ALIGN_VALUE (pos, 2);
   395       set_2_octets (str, pos, vp->
u16, byte_order);
   397         *old_end_pos = pos + 2;
   399         *new_end_pos = pos + 2;
   406       pos = _DBUS_ALIGN_VALUE (pos, 4);
   407       set_4_octets (str, pos, vp->
u32, byte_order);
   409         *old_end_pos = pos + 4;
   411         *new_end_pos = pos + 4;
   417       pos = _DBUS_ALIGN_VALUE (pos, 8);
   418       set_8_octets (str, pos, *vp, byte_order);
   420         *old_end_pos = pos + 8;
   422         *new_end_pos = pos + 8;
   427       pos = _DBUS_ALIGN_VALUE (pos, 4);
   429       return set_string (str, pos, vp->
str, byte_order,
   430                          old_end_pos, new_end_pos);
   434       return set_signature (str, pos, vp->
str, byte_order,
   435                             old_end_pos, new_end_pos);
   459   pos = _DBUS_ALIGN_VALUE (pos, 4);
   464   _dbus_assert (pos + 4 <= _dbus_string_get_length (str));
   467                               _dbus_string_get_const_data (str) + pos);
   499   const char *str_data;
   503   str_data = _dbus_string_get_const_data (str);
   513       volatile unsigned char *vp = value;
   514       *vp = (
unsigned char) _dbus_string_get_byte (str, pos);
   521       volatile dbus_uint16_t *vp = value;
   522       pos = _DBUS_ALIGN_VALUE (pos, 2);
   523       *vp = *(dbus_uint16_t *)(str_data + pos);
   524       if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   525         *vp = DBUS_UINT16_SWAP_LE_BE (*vp);
   534       volatile dbus_uint32_t *vp = value;
   535       pos = _DBUS_ALIGN_VALUE (pos, 4);
   536       *vp = *(dbus_uint32_t *)(str_data + pos);
   537       if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   538         *vp = DBUS_UINT32_SWAP_LE_BE (*vp);
   546       volatile dbus_uint64_t *vp = value;
   547       pos = _DBUS_ALIGN_VALUE (pos, 8);
   548       if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   549         *vp = DBUS_UINT64_SWAP_LE_BE (*(dbus_uint64_t*)(str_data + pos));
   551         *vp = *(dbus_uint64_t*)(str_data + pos);
   559         volatile char **vp = value;
   563         *vp = (
char*) str_data + pos;
   571         volatile char **vp = value;
   573         len = _dbus_string_get_byte (str, pos);
   576         *vp = (
char*) str_data + pos;
   602   _DBUS_STATIC_ASSERT (
sizeof (value) == 2);
   604   if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   605     value = DBUS_UINT16_SWAP_LE_BE (value);
   607   orig_len = _dbus_string_get_length (str);
   610                                           (
const unsigned char *)&value);
   614       *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
   615       _dbus_assert (*pos_after <= _dbus_string_get_length (str));
   631   _DBUS_STATIC_ASSERT (
sizeof (value) == 4);
   633   if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   634     value = DBUS_UINT32_SWAP_LE_BE (value);
   636   orig_len = _dbus_string_get_length (str);
   639                                           (
const unsigned char *)&value);
   643       *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
   644       _dbus_assert (*pos_after <= _dbus_string_get_length (str));
   660   _DBUS_STATIC_ASSERT (
sizeof (value) == 8);
   662   swap_8_octets (&value, byte_order);
   664   orig_len = _dbus_string_get_length (str);
   667                                           (
const unsigned char *)&value);
   670     *pos_after = insert_at + _dbus_string_get_length (str) - orig_len;
   678     MARSHAL_AS_SIGNATURE,
   679     MARSHAL_AS_BYTE_ARRAY
   683 marshal_len_followed_by_bytes (
int                  marshal_as,
   686                                const unsigned char *value,
   696   if (insert_at > _dbus_string_get_length (str))
   697     _dbus_warn (
"insert_at = %d string len = %d data_len = %d\n",
   698                 insert_at, _dbus_string_get_length (str), data_len);
   700   if (marshal_as == MARSHAL_AS_BYTE_ARRAY)
   701     value_len = data_len;
   703     value_len = data_len + 1; 
   709   if (marshal_as == MARSHAL_AS_SIGNATURE)
   721       if (!marshal_4_octets (str, pos, data_len,
   758   return marshal_len_followed_by_bytes (MARSHAL_AS_STRING,
   759                                         str, insert_at, value,
   761                                         byte_order, pos_after);
   770   return marshal_len_followed_by_bytes (MARSHAL_AS_SIGNATURE,
   771                                         str, insert_at, value,
   773                                         DBUS_COMPILER_BYTE_ORDER, 
   813         *pos_after = insert_at + 1;
   818       return marshal_2_octets (str, insert_at, vp->
u16,
   819                                byte_order, pos_after);
   822       return marshal_4_octets (str, insert_at, vp->
u32 != 
FALSE,
   823                                byte_order, pos_after);
   828       return marshal_4_octets (str, insert_at, vp->
u32,
   829                                byte_order, pos_after);
   834       return marshal_8_octets (str, insert_at, *vp, byte_order, pos_after);
   840       return marshal_string (str, insert_at, vp->
str, byte_order, pos_after);
   844       return marshal_signature (str, insert_at, vp->
str, pos_after);
   856                         const unsigned char *value,
   895   _dbus_assert (_DBUS_ALIGN_ADDRESS (data, alignment) == data);
   901   end = d + (n_elements * alignment);
   907           *((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d));
   911   else if (alignment == 4)
   915           *((dbus_uint32_t*)d) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)d));
   925           *((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d));
   938   _dbus_assert (_DBUS_ALIGN_VALUE (array_start, alignment) == (
unsigned) array_start);
   940   if (byte_order != DBUS_COMPILER_BYTE_ORDER)
   945       _dbus_swap_array ((
unsigned char*) (_dbus_string_get_const_data (str) + array_start),
   946                         n_elements, alignment);
   966   old_string_len = _dbus_string_get_length (str);
   968   len_in_bytes = n_elements * alignment;
   969   array_start = insert_at;
   981                                (
const unsigned char*) value,
   988   swap_array (str, array_start, n_elements, byte_order, alignment);
   991     *pos_after = array_start + len_in_bytes;
   997                        _dbus_string_get_length (str) - old_string_len);
  1034   _dbus_verbose (
"writing %d elements of %s\n",
  1038   switch (element_type)
  1041       return marshal_1_octets_array (str, insert_at, vp, n_elements, byte_order, pos_after);
  1045       return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 2, pos_after);
  1050       return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 4, pos_after);
  1055       return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 8, pos_after);
  1092       *pos = _DBUS_ALIGN_VALUE (*pos, 2);
  1099       *pos = _DBUS_ALIGN_VALUE (*pos, 4);
  1105       *pos = _DBUS_ALIGN_VALUE (*pos, 8);
  1122         len = _dbus_string_get_byte (str, *pos);
  1150   dbus_uint32_t array_len;
  1154   i = _DBUS_ALIGN_VALUE (*pos, 4);
  1160   i = _DBUS_ALIGN_VALUE (i, alignment);
  1162   *pos = i + array_len;
  1246       return "object_path";
  1252       return "dict_entry";
  1258       return "begin_struct";
  1260       return "end_struct";
  1262       return "begin_dict_entry";
  1264       return "end_dict_entry";
  1285   const unsigned char *aligned;
  1289   if (!_dbus_is_verbose())
  1293   aligned = _DBUS_ALIGN_ADDRESS (data, 4);
  1298   if (aligned != data)
  1300       _dbus_verbose (
"%4ld\t%p: ", - (
long)(data - aligned), aligned);
  1301       while (aligned != data)
  1303           _dbus_verbose (
"    ");
  1312       if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
  1314           _dbus_verbose (
"%4d\t%p: ",
  1315                          offset + i, &data[i]);
  1318       if (data[i] >= 32 &&
  1320         _dbus_verbose (
" '%c' ", data[i]);
  1322         _dbus_verbose (
"0x%s%x ",
  1323                        data[i] <= 0xf ? 
"0" : 
"", data[i]);
  1327       if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
  1330             _dbus_verbose (
"BE: %d LE: %d",
  1335               _DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
  1337 #ifdef DBUS_INT64_PRINTF_MODIFIER  1338               _dbus_verbose (
" u64: 0x%" DBUS_INT64_PRINTF_MODIFIER 
"x",
  1339                              *(dbus_uint64_t*)&data[i-8]);
  1341               _dbus_verbose (
" dbl: %g",
  1342                              *(
double*)&data[i-8]);
  1345           _dbus_verbose (
"\n");
  1349   _dbus_verbose (
"\n");
  1367   real_len = _dbus_string_get_length (str);
  1371   if (start > real_len)
  1373       _dbus_verbose (
"  [%d,%d) is not inside string of length %d\n",
  1374                      start, len, real_len);
  1378   if ((start + len) > real_len)
  1380       _dbus_verbose (
"  [%d,%d) extends outside string of length %d\n",
  1381                      start, len, real_len);
  1382       len = real_len - start;
  1385   d = _dbus_string_get_const_data_len (str, start, len);
  1391 map_type_char_to_type (
int t)
  1419   return map_type_char_to_type (_dbus_string_get_byte (str, pos));
  1434   return map_type_char_to_type (str[pos]);
  1439 #ifdef DBUS_ENABLE_EMBEDDED_TESTS  1440 #include "dbus-test.h"  1462 _dbus_marshal_read_fixed_multi  (
const DBusString *str,
  1477   _dbus_verbose (
"reading %d elements of %s\n",
  1483   pos = _DBUS_ALIGN_VALUE (pos, alignment);
  1485   array_len = n_elements * alignment;
  1487   *(
const DBusBasicValue**) value = (
void*) _dbus_string_get_const_data_len (str, pos, array_len);
  1489     *new_pos = pos + array_len;
  1493 swap_test_array (
void *array,
  1504   swap_array (&t, 0, len_bytes / alignment, byte_order, alignment);
  1507 #define MARSHAL_BASIC(typename, byte_order, literal)                    \  1509      v_##typename = literal;                                            \  1510      if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename,   \  1512                                     byte_order, NULL))                  \  1513        _dbus_assert_not_reached ("no memory");                          \  1516 #define DEMARSHAL_BASIC(typename, byte_order)                                   \  1518     _dbus_marshal_read_basic (&str, pos, DBUS_TYPE_##typename, &v_##typename,   \  1519                               byte_order, &pos);                                \  1522 #define DEMARSHAL_BASIC_AND_CHECK(typename, byte_order, literal)                        \  1524     DEMARSHAL_BASIC (typename, byte_order);                                             \  1525     if (literal != v_##typename)                                                        \  1527         _dbus_verbose_bytes_of_string (&str, dump_pos,                                  \  1528                                      _dbus_string_get_length (&str) - dump_pos);        \  1529         _dbus_assert_not_reached ("demarshaled wrong value");                           \  1533 #define MARSHAL_TEST(typename, byte_order, literal)             \  1535     MARSHAL_BASIC (typename, byte_order, literal);              \  1537     DEMARSHAL_BASIC_AND_CHECK (typename, byte_order, literal);  \  1540 #define MARSHAL_TEST_STRCMP(typename, byte_order, literal)                              \  1542     MARSHAL_BASIC (typename, byte_order, literal);                                      \  1544     DEMARSHAL_BASIC (typename, byte_order);                                             \  1545     if (strcmp (literal, v_##typename) != 0)                                            \  1547         _dbus_verbose_bytes_of_string (&str, dump_pos,                                  \  1548                                        _dbus_string_get_length (&str) - dump_pos);      \  1549         _dbus_warn ("literal '%s'\nvalue  '%s'\n", literal, v_##typename);              \  1550         _dbus_assert_not_reached ("demarshaled wrong value");                           \  1554 #define MARSHAL_FIXED_ARRAY(typename, byte_order, literal)                                      \  1557      v_UINT32 = sizeof(literal);                                                                \  1558      if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_UINT32, &v_UINT32,                    \  1559                                      byte_order, &next))                                        \  1560        _dbus_assert_not_reached ("no memory");                                                  \  1561      v_ARRAY_##typename = literal;                                                              \  1562      if (!_dbus_marshal_write_fixed_multi (&str, next, DBUS_TYPE_##typename,                    \  1563                                            &v_ARRAY_##typename, _DBUS_N_ELEMENTS(literal),      \  1564                                            byte_order, NULL))                                   \  1565        _dbus_assert_not_reached ("no memory");                                                  \  1568 #define DEMARSHAL_FIXED_ARRAY(typename, byte_order)                                             \  1571     alignment = _dbus_type_get_alignment (DBUS_TYPE_##typename);                                \  1572     v_UINT32 = _dbus_marshal_read_uint32 (&str, dump_pos, byte_order, &next);                   \  1573     _dbus_marshal_read_fixed_multi (&str, next, DBUS_TYPE_##typename, &v_ARRAY_##typename,      \  1574                                     v_UINT32/alignment,                                         \  1575                                     byte_order, NULL);                                          \  1576     swap_test_array (v_ARRAY_##typename, v_UINT32,                                              \  1577                      byte_order, alignment);                                                    \  1580 #define DEMARSHAL_FIXED_ARRAY_AND_CHECK(typename, byte_order, literal)                  \  1582     DEMARSHAL_FIXED_ARRAY (typename, byte_order);                                       \  1583     if (memcmp (literal, v_ARRAY_##typename, sizeof (literal)) != 0)                    \  1585         _dbus_verbose ("MARSHALED DATA\n");                                             \  1586         _dbus_verbose_bytes_of_string (&str, dump_pos,                                  \  1587                                       _dbus_string_get_length (&str) - dump_pos);       \  1588         _dbus_verbose ("LITERAL DATA\n");                                               \  1589         _dbus_verbose_bytes ((char*)literal, sizeof (literal), 0);                      \  1590         _dbus_verbose ("READ DATA\n");                                                  \  1591         _dbus_verbose_bytes ((char*)v_ARRAY_##typename, sizeof (literal), 0);           \  1592         _dbus_assert_not_reached ("demarshaled wrong fixed array value");               \  1596 #define MARSHAL_TEST_FIXED_ARRAY(typename, byte_order, literal)         \  1598     MARSHAL_FIXED_ARRAY (typename, byte_order, literal);                \  1600     DEMARSHAL_FIXED_ARRAY_AND_CHECK (typename, byte_order, literal);    \  1604 _dbus_marshal_test (
void)
  1609   unsigned char array1[5] = { 3, 4, 0, 1, 9 };
  1610   dbus_int16_t array2[3] = { 124, 457, 780 };
  1611   dbus_int32_t array4[3] = { 123, 456, 789 };
  1612   dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff),
  1613                              DBUS_INT64_CONSTANT (0x456ffffffff),
  1614                              DBUS_INT64_CONSTANT (0x789ffffffff) };
  1615   dbus_int64_t *v_ARRAY_INT64;
  1616   unsigned char *v_ARRAY_BYTE;
  1617   dbus_int16_t *v_ARRAY_INT16;
  1618   dbus_uint16_t *v_ARRAY_UINT16;
  1619   dbus_int32_t *v_ARRAY_INT32;
  1620   dbus_uint32_t *v_ARRAY_UINT32;
  1624   dbus_int16_t v_INT16;
  1625   dbus_uint16_t v_UINT16;
  1626   dbus_int32_t v_INT32;
  1627   dbus_uint32_t v_UINT32;
  1628   dbus_int64_t v_INT64;
  1629   dbus_uint64_t v_UINT64;
  1630   unsigned char v_BYTE;
  1632   const char *v_STRING;
  1633   const char *v_SIGNATURE;
  1634   const char *v_OBJECT_PATH;
  1672   MARSHAL_TEST (INT64, 
DBUS_BIG_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7));
  1676   MARSHAL_TEST (UINT64, 
DBUS_BIG_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7));
  1692   MARSHAL_TEST_STRCMP (STRING, 
DBUS_BIG_ENDIAN, 
"This is the dbus test string");
  1733                            0, DBUS_INT64_CONSTANT (-0x123456789abc7));
  1735   _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
  1737                                     _dbus_string_get_const_data (&str)));
  1741                            0, DBUS_INT64_CONSTANT (-0x123456789abc7));
  1743   _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
  1745                                     _dbus_string_get_const_data (&str)));
  1748   _dbus_pack_int64 (DBUS_INT64_CONSTANT (-0x123456789abc7),
  1750                     _dbus_string_get_data (&str));
  1752   _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
  1754                                     _dbus_string_get_const_data (&str)));
  1757   _dbus_pack_int64 (DBUS_INT64_CONSTANT (-0x123456789abc7),
  1759                     _dbus_string_get_data (&str));
  1761   _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
  1763                                     _dbus_string_get_const_data (&str)));
  1767                             0, DBUS_UINT64_CONSTANT (0x123456789abc7));
  1769   _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
  1771                                      _dbus_string_get_const_data (&str)));
  1775                             0, DBUS_UINT64_CONSTANT (0x123456789abc7));
  1777   _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
  1779                                      _dbus_string_get_const_data (&str)));
  1782   _dbus_pack_uint64 (DBUS_UINT64_CONSTANT (0x123456789abc7),
  1784                      _dbus_string_get_data (&str));
  1786   _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
  1788                                      _dbus_string_get_const_data (&str)));
  1791   _dbus_pack_uint64 (DBUS_UINT64_CONSTANT (0x123456789abc7),
  1793                      _dbus_string_get_data (&str));
  1795   _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
  1797                                      _dbus_string_get_const_data (&str)));
  1808                                     _dbus_string_get_const_data (&str)));
  1816                                     _dbus_string_get_const_data (&str)));
  1819   _dbus_pack_int32 (-0x123456,
  1821                     _dbus_string_get_data (&str));
  1825                                     _dbus_string_get_const_data (&str)));
  1828   _dbus_pack_int32 (-0x123456,
  1830                     _dbus_string_get_data (&str));
  1834                                     _dbus_string_get_const_data (&str)));
  1843                                      _dbus_string_get_const_data (&str)));
  1852                                      _dbus_string_get_const_data (&str)));
  1857                      _dbus_string_get_data (&str));
  1861                                      _dbus_string_get_const_data (&str)));
  1866                      _dbus_string_get_data (&str));
  1870                                      _dbus_string_get_const_data (&str)));
  1884       MARSHAL_TEST_STRCMP (STRING, byte_order, 
"Hello world");
  1889       v_STRING = _dbus_string_get_const_data (&t);
  1891                                &v_STRING, byte_order, 
NULL, 
NULL);
  1894                                 &v_STRING, byte_order,
  1896       _dbus_assert (strcmp (v_STRING, 
"Hello world foo") == 0);
  1901       v_STRING = _dbus_string_get_const_data (&t);
  1903                                &v_STRING, byte_order, 
NULL, 
NULL);
  1905                                 &v_STRING, byte_order,
 dbus_bool_t dbus_type_is_fixed(int typecode)
Tells you whether values of this type can change length if you set them to some other value...
#define DBUS_TYPE_UINT16
Type code marking a 16-bit unsigned integer. 
void _dbus_marshal_skip_basic(const DBusString *str, int type, int byte_order, int *pos)
Skips over a basic-typed value, reporting the following position. 
#define NULL
A null pointer, defined appropriately for C or C++. 
void _dbus_marshal_set_uint32(DBusString *str, int pos, dbus_uint32_t value, int byte_order)
Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there ...
int _dbus_first_type_in_signature(const DBusString *str, int pos)
Get the first type in the signature. 
#define DBUS_TYPE_STRUCT
STRUCT and DICT_ENTRY are sort of special since their codes can't appear in a type string...
#define DBUS_TYPE_DICT_ENTRY
Type code used to represent a dict entry; however, this type code does not appear in type signatures...
#define DBUS_TYPE_STRING
Type code marking a UTF-8 encoded, nul-terminated Unicode string. 
dbus_bool_t _dbus_string_insert_8_aligned(DBusString *str, int insert_at, const unsigned char octets[8])
Inserts 8 bytes aligned on an 8 byte boundary with any alignment padding initialized to 0...
#define _dbus_assert(condition)
Aborts with an error message if the condition is false. 
void _dbus_warn_check_failed(const char *format,...)
Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
#define DBUS_TYPE_BYTE
Type code marking an 8-bit unsigned integer. 
void _dbus_swap_array(unsigned char *data, int n_elements, int alignment)
Swaps the elements of an array to the opposite byte order. 
dbus_uint64_t u64
as int64 
char * _dbus_string_get_data_len(DBusString *str, int start, int len)
Gets a sub-portion of the raw character buffer from the string. 
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string. 
char * str
as char* (string, object path or signature) 
dbus_bool_t _dbus_string_copy(const DBusString *source, int start, DBusString *dest, int insert_at)
Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...
#define DBUS_DICT_ENTRY_BEGIN_CHAR
Code marking the start of a dict entry type in a type signature. 
#define DBUS_STRUCT_END_CHAR
Code marking the end of a struct type in a type signature. 
#define DBUS_TYPE_DOUBLE
Type code marking an 8-byte double in IEEE 754 format. 
#define DBUS_TYPE_ARRAY
Type code marking a D-Bus array type. 
#define DBUS_TYPE_INT64
Type code marking a 64-bit signed integer. 
dbus_uint32_t _dbus_unpack_uint32(int byte_order, const unsigned char *data)
Unpacks a 32 bit unsigned integer from a data pointer. 
int _dbus_first_type_in_signature_c_str(const char *str, int pos)
Similar to _dbus_first_type_in_signature, but operates on a C string buffer. 
dbus_bool_t dbus_type_is_basic(int typecode)
A "basic type" is a somewhat arbitrary concept, but the intent is to include those types that are ful...
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE. 
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string. 
dbus_bool_t _dbus_string_replace_len(const DBusString *source, int start, int len, DBusString *dest, int replace_at, int replace_len)
Replaces a segment of dest string with a segment of source string. 
void _dbus_marshal_skip_array(const DBusString *str, int element_type, int byte_order, int *pos)
Skips an array, returning the next position. 
void _dbus_warn(const char *format,...)
Prints a warning message to stderr. 
void _dbus_string_delete(DBusString *str, int start, int len)
Deletes a segment of a DBusString with length len starting at start. 
void _dbus_marshal_read_basic(const DBusString *str, int pos, int type, void *value, int byte_order, int *new_pos)
Demarshals a basic-typed value. 
dbus_uint16_t _dbus_unpack_uint16(int byte_order, const unsigned char *data)
Unpacks a 16 bit unsigned integer from a data pointer. 
#define DBUS_TYPE_INT32
Type code marking a 32-bit signed integer. 
#define DBUS_MAXIMUM_SIGNATURE_LENGTH
This one is 255 so it fits in a byte. 
dbus_uint16_t u16
as int16 
void _dbus_pack_uint32(dbus_uint32_t value, int byte_order, unsigned char *data)
Packs a 32 bit unsigned integer into a data pointer. 
#define DBUS_BIG_ENDIAN
Code marking MSB-first byte order in the wire protocol. 
#define DBUS_TYPE_SIGNATURE
Type code marking a D-Bus type signature. 
dbus_bool_t _dbus_string_equal_substring(const DBusString *a, int a_start, int a_len, const DBusString *b, int b_start)
Tests two sub-parts of two DBusString for equality. 
#define DBUS_TYPE_UINT64
Type code marking a 64-bit unsigned integer. 
#define DBUS_STRUCT_BEGIN_CHAR
Code marking the start of a struct type in a type signature. 
#define DBUS_TYPE_VARIANT
Type code marking a D-Bus variant type. 
#define DBUS_TYPE_UINT32
Type code marking a 32-bit unsigned integer. 
dbus_bool_t _dbus_marshal_write_fixed_multi(DBusString *str, int insert_at, int element_type, const void *value, int n_elements, int byte_order, int *pos_after)
Marshals a block of values of fixed-length type all at once, as an optimization. 
dbus_bool_t _dbus_string_insert_byte(DBusString *str, int i, unsigned char byte)
Inserts a single byte at the given position. 
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(). 
#define TRUE
Expands to "1". 
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called. 
An 8-byte struct you could use to access int64 without having int64 support. 
#define DBUS_TYPE_OBJECT_PATH
Type code marking a D-Bus object path. 
#define DBUS_TYPE_UNIX_FD
Type code marking a unix file descriptor. 
#define DBUS_TYPE_INVALID
Type code that is never equal to a legitimate type code. 
#define DBUS_MAXIMUM_ARRAY_LENGTH
Max length of a marshaled array in bytes (64M, 2^26) We use signed int for lengths so must be INT_MAX...
#define DBUS_TYPE_INT16
Type code marking a 16-bit signed integer. 
#define DBUS_TYPE_BOOLEAN
Type code marking a boolean. 
A simple value union that lets you access bytes as if they were various types; useful when dealing wi...
#define FALSE
Expands to "0". 
dbus_bool_t _dbus_string_insert_4_aligned(DBusString *str, int insert_at, const unsigned char octets[4])
Inserts 4 bytes aligned on a 4 byte boundary with any alignment padding initialized to 0...
#define DBUS_DICT_ENTRY_END_CHAR
Code marking the end of a dict entry type in a type signature. 
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string. 
dbus_bool_t _dbus_string_insert_2_aligned(DBusString *str, int insert_at, const unsigned char octets[2])
Inserts 2 bytes aligned on a 2 byte boundary with any alignment padding initialized to 0...
const char * _dbus_type_to_string(int typecode)
Returns a string describing the given type. 
dbus_bool_t _dbus_string_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string. 
void _dbus_verbose_bytes_of_string(const DBusString *str, int start, int len)
Dump the given part of the string to verbose log. 
int _dbus_type_get_alignment(int typecode)
Gets the alignment requirement for the given type; will be 1, 4, or 8. 
dbus_bool_t _dbus_string_insert_alignment(DBusString *str, int *insert_at, int alignment)
Inserts padding at *insert_at such to align it to the given boundary. 
void _dbus_string_init_const_len(DBusString *str, const char *value, int len)
Initializes a constant string with a length. 
dbus_bool_t _dbus_marshal_set_basic(DBusString *str, int pos, int type, const void *value, int byte_order, int *old_end_pos, int *new_end_pos)
Sets an existing basic type value to a new value. 
dbus_uint32_t u32
as int32 
#define _DBUS_DOUBLES_BITWISE_EQUAL(a, b)
On x86 there is an 80-bit FPU, and if you do "a == b" it may have a or b in an 80-bit register...
dbus_bool_t _dbus_marshal_write_basic(DBusString *str, int insert_at, int type, const void *value, int byte_order, int *pos_after)
Marshals a basic-typed value. 
#define DBUS_LITTLE_ENDIAN
Code marking LSB-first byte order in the wire protocol. 
void _dbus_verbose_bytes(const unsigned char *data, int len, int offset)
If in verbose mode, print a block of binary data. 
dbus_uint32_t _dbus_marshal_read_uint32(const DBusString *str, int pos, int byte_order, int *new_pos)
Convenience function to demarshal a 32 bit unsigned integer.