26 #include "dbus-internals.h" 27 #include "dbus-marshal-basic.h" 28 #include "dbus-signature.h" 29 #include <dbus/dbus-test-tap.h> 33 #if !defined(PRIx64) && defined(DBUS_WIN) 37 #if defined(__GNUC__) && (__GNUC__ >= 4) 38 # define _DBUS_ASSERT_ALIGNMENT(type, op, val) \ 39 _DBUS_STATIC_ASSERT (__extension__ __alignof__ (type) op val) 43 # define _DBUS_ASSERT_ALIGNMENT(type, op, val) \ 44 _DBUS_STATIC_ASSERT (TRUE) 48 _DBUS_STATIC_ASSERT (
sizeof (
char) == 1);
49 _DBUS_ASSERT_ALIGNMENT (
char, ==, 1);
51 _DBUS_STATIC_ASSERT (
sizeof (dbus_int16_t) == 2);
52 _DBUS_ASSERT_ALIGNMENT (dbus_int16_t, <=, 2);
53 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint16_t) == 2);
54 _DBUS_ASSERT_ALIGNMENT (dbus_uint16_t, <=, 2);
56 _DBUS_STATIC_ASSERT (
sizeof (dbus_int32_t) == 4);
57 _DBUS_ASSERT_ALIGNMENT (dbus_int32_t, <=, 4);
58 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint32_t) == 4);
59 _DBUS_ASSERT_ALIGNMENT (dbus_uint32_t, <=, 4);
63 _DBUS_STATIC_ASSERT (
sizeof (
double) == 8);
64 _DBUS_ASSERT_ALIGNMENT (
double, <=, 8);
66 _DBUS_STATIC_ASSERT (
sizeof (dbus_int64_t) == 8);
67 _DBUS_ASSERT_ALIGNMENT (dbus_int64_t, <=, 8);
68 _DBUS_STATIC_ASSERT (
sizeof (dbus_uint64_t) == 8);
69 _DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8);
94 pack_2_octets (dbus_uint16_t value,
101 *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_LE (value);
103 *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_BE (value);
107 pack_4_octets (dbus_uint32_t value,
114 *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_LE (value);
116 *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_BE (value);
127 *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_LE (value.
u64);
129 *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.
u64);
144 pack_4_octets (value, byte_order, data);
151 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
153 value->
u64 = DBUS_UINT64_SWAP_LE_BE (value->
u64);
157 #ifndef _dbus_unpack_uint16 167 const unsigned char *data)
172 return DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)data);
174 return DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)data);
178 #ifndef _dbus_unpack_uint32 188 const unsigned char *data)
193 return DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)data);
195 return DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)data);
212 pack_2_octets (value, byte_order, (
unsigned char *) data);
228 pack_4_octets (value, byte_order, (
unsigned char *) data);
244 pack_8_octets (value, byte_order, (
unsigned char *) data);
263 set_4_octets (str, pos, value, byte_order);
293 int old_len, new_len;
298 _dbus_assert (_DBUS_ALIGN_VALUE (pos, 4) == (
unsigned) pos);
300 _dbus_string_get_const_udata_len (str, pos, 4));
302 new_len = _dbus_string_get_length (&dstr);
305 str, pos + 4, old_len))
311 *old_end_pos = pos + 4 + old_len + 1;
313 *new_end_pos = pos + 4 + new_len + 1;
339 int old_len, new_len;
344 old_len = _dbus_string_get_byte (str, pos);
345 new_len = _dbus_string_get_length (&dstr);
348 str, pos + 1, old_len))
351 _dbus_string_set_byte (str, pos, new_len);
354 *old_end_pos = pos + 1 + old_len + 1;
356 *new_end_pos = pos + 1 + new_len + 1;
390 _dbus_string_set_byte (str, pos, vp->
byt);
392 *old_end_pos = pos + 1;
394 *new_end_pos = pos + 1;
399 pos = _DBUS_ALIGN_VALUE (pos, 2);
400 set_2_octets (str, pos, vp->
u16, byte_order);
402 *old_end_pos = pos + 2;
404 *new_end_pos = pos + 2;
411 pos = _DBUS_ALIGN_VALUE (pos, 4);
412 set_4_octets (str, pos, vp->
u32, byte_order);
414 *old_end_pos = pos + 4;
416 *new_end_pos = pos + 4;
422 pos = _DBUS_ALIGN_VALUE (pos, 8);
423 set_8_octets (str, pos, *vp, byte_order);
425 *old_end_pos = pos + 8;
427 *new_end_pos = pos + 8;
432 pos = _DBUS_ALIGN_VALUE (pos, 4);
434 return set_string (str, pos, vp->
str, byte_order,
435 old_end_pos, new_end_pos);
439 return set_signature (str, pos, vp->
str, byte_order,
440 old_end_pos, new_end_pos);
464 pos = _DBUS_ALIGN_VALUE (pos, 4);
469 _dbus_assert (pos + 4 <= _dbus_string_get_length (str));
472 _dbus_string_get_const_udata (str) + pos);
504 const char *str_data;
508 str_data = _dbus_string_get_const_data (str);
518 volatile unsigned char *vp = value;
519 *vp = (
unsigned char) _dbus_string_get_byte (str, pos);
526 volatile dbus_uint16_t *vp = value;
527 pos = _DBUS_ALIGN_VALUE (pos, 2);
528 *vp = *(dbus_uint16_t *)(str_data + pos);
529 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
530 *vp = DBUS_UINT16_SWAP_LE_BE (*vp);
539 volatile dbus_uint32_t *vp = value;
540 pos = _DBUS_ALIGN_VALUE (pos, 4);
541 *vp = *(dbus_uint32_t *)(str_data + pos);
542 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
543 *vp = DBUS_UINT32_SWAP_LE_BE (*vp);
551 volatile dbus_uint64_t *vp = value;
552 pos = _DBUS_ALIGN_VALUE (pos, 8);
553 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
554 *vp = DBUS_UINT64_SWAP_LE_BE (*(dbus_uint64_t*)(str_data + pos));
556 *vp = *(dbus_uint64_t*)(str_data + pos);
564 volatile char **vp = value;
568 *vp = (
char*) str_data + pos;
576 volatile char **vp = value;
578 len = _dbus_string_get_byte (str, pos);
581 *vp = (
char*) str_data + pos;
607 _DBUS_STATIC_ASSERT (
sizeof (value) == 2);
609 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
610 value = DBUS_UINT16_SWAP_LE_BE (value);
612 orig_len = _dbus_string_get_length (str);
615 (
const unsigned char *)&value);
619 *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
620 _dbus_assert (*pos_after <= _dbus_string_get_length (str));
636 _DBUS_STATIC_ASSERT (
sizeof (value) == 4);
638 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
639 value = DBUS_UINT32_SWAP_LE_BE (value);
641 orig_len = _dbus_string_get_length (str);
644 (
const unsigned char *)&value);
648 *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
649 _dbus_assert (*pos_after <= _dbus_string_get_length (str));
665 _DBUS_STATIC_ASSERT (
sizeof (value) == 8);
667 swap_8_octets (&value, byte_order);
669 orig_len = _dbus_string_get_length (str);
672 (
const unsigned char *)&value);
675 *pos_after = insert_at + _dbus_string_get_length (str) - orig_len;
683 MARSHAL_AS_SIGNATURE,
684 MARSHAL_AS_BYTE_ARRAY
688 marshal_len_followed_by_bytes (
int marshal_as,
691 const unsigned char *value,
701 if (insert_at > _dbus_string_get_length (str))
702 _dbus_warn (
"insert_at = %d string len = %d data_len = %d",
703 insert_at, _dbus_string_get_length (str), data_len);
705 if (marshal_as == MARSHAL_AS_BYTE_ARRAY)
706 value_len = data_len;
708 value_len = data_len + 1;
714 if (marshal_as == MARSHAL_AS_SIGNATURE)
726 if (!marshal_4_octets (str, pos, data_len,
763 return marshal_len_followed_by_bytes (MARSHAL_AS_STRING,
764 str, insert_at, (
const unsigned char *) value,
766 byte_order, pos_after);
775 return marshal_len_followed_by_bytes (MARSHAL_AS_SIGNATURE,
776 str, insert_at, (
const unsigned char *) value,
778 DBUS_COMPILER_BYTE_ORDER,
818 *pos_after = insert_at + 1;
823 return marshal_2_octets (str, insert_at, vp->
u16,
824 byte_order, pos_after);
827 return marshal_4_octets (str, insert_at, vp->
u32 !=
FALSE,
828 byte_order, pos_after);
833 return marshal_4_octets (str, insert_at, vp->
u32,
834 byte_order, pos_after);
839 return marshal_8_octets (str, insert_at, *vp, byte_order, pos_after);
845 return marshal_string (str, insert_at, vp->
str, byte_order, pos_after);
849 return marshal_signature (str, insert_at, vp->
str, pos_after);
861 const unsigned char *value,
900 _dbus_assert (_DBUS_ALIGN_ADDRESS (data, alignment) == data);
906 end = d + (n_elements * alignment);
912 *((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d));
916 else if (alignment == 4)
920 *((dbus_uint32_t*)d) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)d));
930 *((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d));
943 _dbus_assert (_DBUS_ALIGN_VALUE (array_start, alignment) == (
unsigned) array_start);
945 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
950 _dbus_swap_array ((
unsigned char*) (_dbus_string_get_const_data (str) + array_start),
951 n_elements, alignment);
971 old_string_len = _dbus_string_get_length (str);
973 len_in_bytes = n_elements * alignment;
974 array_start = insert_at;
986 (
const char *) value,
993 swap_array (str, array_start, n_elements, byte_order, alignment);
996 *pos_after = array_start + len_in_bytes;
1002 _dbus_string_get_length (str) - old_string_len);
1039 _dbus_verbose (
"writing %d elements of %s\n",
1043 switch (element_type)
1046 return marshal_1_octets_array (str, insert_at, vp, n_elements, byte_order, pos_after);
1050 return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 2, pos_after);
1055 return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 4, pos_after);
1060 return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 8, pos_after);
1097 *pos = _DBUS_ALIGN_VALUE (*pos, 2);
1104 *pos = _DBUS_ALIGN_VALUE (*pos, 4);
1110 *pos = _DBUS_ALIGN_VALUE (*pos, 8);
1127 len = _dbus_string_get_byte (str, *pos);
1155 dbus_uint32_t array_len;
1159 i = _DBUS_ALIGN_VALUE (*pos, 4);
1165 i = _DBUS_ALIGN_VALUE (i, alignment);
1167 *pos = i + array_len;
1251 return "object_path";
1257 return "dict_entry";
1263 return "begin_struct";
1265 return "end_struct";
1267 return "begin_dict_entry";
1269 return "end_dict_entry";
1290 const unsigned char *aligned;
1294 if (!_dbus_is_verbose())
1298 aligned = _DBUS_ALIGN_ADDRESS (data, 4);
1303 if (aligned != data)
1305 _dbus_verbose (
"%4ld\t%p: ", - (
long)(data - aligned), aligned);
1306 while (aligned != data)
1308 _dbus_verbose (
" ");
1317 if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
1319 _dbus_verbose (
"%4d\t%p: ",
1320 offset + i, &data[i]);
1323 if (data[i] >= 32 &&
1325 _dbus_verbose (
" '%c' ", data[i]);
1327 _dbus_verbose (
"0x%s%x ",
1328 data[i] <= 0xf ?
"0" :
"", data[i]);
1332 if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
1335 _dbus_verbose (
"BE: %d LE: %d",
1340 _DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
1342 _dbus_verbose (
" u64: 0x%" PRIx64,
1343 *(dbus_uint64_t*)&data[i-8]);
1344 _dbus_verbose (
" dbl: %g",
1345 *(
double*)&data[i-8]);
1348 _dbus_verbose (
"\n");
1352 _dbus_verbose (
"\n");
1370 real_len = _dbus_string_get_length (str);
1374 if (start > real_len)
1376 _dbus_verbose (
" [%d,%d) is not inside string of length %d\n",
1377 start, len, real_len);
1381 if ((start + len) > real_len)
1383 _dbus_verbose (
" [%d,%d) extends outside string of length %d\n",
1384 start, len, real_len);
1385 len = real_len - start;
1388 d = _dbus_string_get_const_data_len (str, start, len);
1394 map_type_char_to_type (
int t)
1422 return map_type_char_to_type (_dbus_string_get_byte (str, pos));
1437 return map_type_char_to_type (str[pos]);
1442 #ifdef DBUS_ENABLE_EMBEDDED_TESTS 1443 #include "dbus-test.h" 1465 _dbus_marshal_read_fixed_multi (
const DBusString *str,
1480 _dbus_verbose (
"reading %d elements of %s\n",
1486 pos = _DBUS_ALIGN_VALUE (pos, alignment);
1488 array_len = n_elements * alignment;
1490 *(
const DBusBasicValue**) value = (
void*) _dbus_string_get_const_data_len (str, pos, array_len);
1492 *new_pos = pos + array_len;
1496 swap_test_array (
void *array,
1507 swap_array (&t, 0, len_bytes / alignment, byte_order, alignment);
1510 #define MARSHAL_BASIC(typename, byte_order, literal) \ 1512 v_##typename = literal; \ 1513 if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename, \ 1515 byte_order, NULL)) \ 1516 _dbus_test_fatal ("no memory"); \ 1519 #define DEMARSHAL_BASIC(typename, byte_order) \ 1521 _dbus_marshal_read_basic (&str, pos, DBUS_TYPE_##typename, &v_##typename, \ 1522 byte_order, &pos); \ 1525 #define DEMARSHAL_BASIC_AND_CHECK(typename, byte_order, literal) \ 1527 DEMARSHAL_BASIC (typename, byte_order); \ 1528 if (literal != v_##typename) \ 1530 _dbus_verbose_bytes_of_string (&str, dump_pos, \ 1531 _dbus_string_get_length (&str) - dump_pos); \ 1532 _dbus_test_fatal ("demarshaled wrong value"); \ 1536 #define MARSHAL_TEST(typename, byte_order, literal) \ 1538 MARSHAL_BASIC (typename, byte_order, literal); \ 1540 DEMARSHAL_BASIC_AND_CHECK (typename, byte_order, literal); \ 1543 #define MARSHAL_TEST_STRCMP(typename, byte_order, literal) \ 1545 MARSHAL_BASIC (typename, byte_order, literal); \ 1547 DEMARSHAL_BASIC (typename, byte_order); \ 1548 if (strcmp (literal, v_##typename) != 0) \ 1550 _dbus_verbose_bytes_of_string (&str, dump_pos, \ 1551 _dbus_string_get_length (&str) - dump_pos); \ 1552 _dbus_warn ("literal '%s'\nvalue '%s'", literal, v_##typename); \ 1553 _dbus_test_fatal ("demarshaled wrong value"); \ 1557 #define MARSHAL_FIXED_ARRAY(typename, byte_order, literal) \ 1560 v_UINT32 = sizeof(literal); \ 1561 if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_UINT32, &v_UINT32, \ 1562 byte_order, &next)) \ 1563 _dbus_test_fatal ("no memory"); \ 1564 v_ARRAY_##typename = literal; \ 1565 if (!_dbus_marshal_write_fixed_multi (&str, next, DBUS_TYPE_##typename, \ 1566 &v_ARRAY_##typename, _DBUS_N_ELEMENTS(literal), \ 1567 byte_order, NULL)) \ 1568 _dbus_test_fatal ("no memory"); \ 1571 #define DEMARSHAL_FIXED_ARRAY(typename, byte_order) \ 1574 alignment = _dbus_type_get_alignment (DBUS_TYPE_##typename); \ 1575 v_UINT32 = _dbus_marshal_read_uint32 (&str, dump_pos, byte_order, &next); \ 1576 _dbus_marshal_read_fixed_multi (&str, next, DBUS_TYPE_##typename, &v_ARRAY_##typename, \ 1577 v_UINT32/alignment, \ 1578 byte_order, NULL); \ 1579 swap_test_array (v_ARRAY_##typename, v_UINT32, \ 1580 byte_order, alignment); \ 1583 #define DEMARSHAL_FIXED_ARRAY_AND_CHECK(typename, byte_order, literal) \ 1585 DEMARSHAL_FIXED_ARRAY (typename, byte_order); \ 1586 if (memcmp (literal, v_ARRAY_##typename, sizeof (literal)) != 0) \ 1588 _dbus_verbose ("MARSHALED DATA\n"); \ 1589 _dbus_verbose_bytes_of_string (&str, dump_pos, \ 1590 _dbus_string_get_length (&str) - dump_pos); \ 1591 _dbus_verbose ("LITERAL DATA\n"); \ 1592 _dbus_verbose_bytes ((const unsigned char *) literal, sizeof (literal), 0); \ 1593 _dbus_verbose ("READ DATA\n"); \ 1594 _dbus_verbose_bytes ((const unsigned char *) v_ARRAY_##typename, sizeof (literal), 0); \ 1595 _dbus_test_fatal ("demarshaled wrong fixed array value"); \ 1599 #define MARSHAL_TEST_FIXED_ARRAY(typename, byte_order, literal) \ 1601 MARSHAL_FIXED_ARRAY (typename, byte_order, literal); \ 1603 DEMARSHAL_FIXED_ARRAY_AND_CHECK (typename, byte_order, literal); \ 1607 _dbus_marshal_test (
void)
1612 unsigned char array1[5] = { 3, 4, 0, 1, 9 };
1613 dbus_int16_t array2[3] = { 124, 457, 780 };
1614 dbus_uint16_t array2u[3] = { 124, 457, 780 };
1615 dbus_int32_t array4[3] = { 123, 456, 789 };
1616 dbus_uint32_t array4u[3] = { 123, 456, 789 };
1617 dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff),
1618 DBUS_INT64_CONSTANT (0x456ffffffff),
1619 DBUS_INT64_CONSTANT (0x789ffffffff) };
1620 dbus_int64_t *v_ARRAY_INT64;
1621 unsigned char *v_ARRAY_BYTE;
1622 dbus_int16_t *v_ARRAY_INT16;
1623 dbus_uint16_t *v_ARRAY_UINT16;
1624 dbus_int32_t *v_ARRAY_INT32;
1625 dbus_uint32_t *v_ARRAY_UINT32;
1629 dbus_int16_t v_INT16;
1630 dbus_uint16_t v_UINT16;
1631 dbus_int32_t v_INT32;
1632 dbus_uint32_t v_UINT32;
1633 dbus_int64_t v_INT64;
1634 dbus_uint64_t v_UINT64;
1635 unsigned char v_BYTE;
1637 const char *v_STRING;
1638 const char *v_SIGNATURE;
1639 const char *v_OBJECT_PATH;
1643 _dbus_test_fatal (
"failed to init string");
1652 _dbus_test_fatal (
"got wrong double value");
1658 _dbus_test_fatal (
"got wrong double value");
1677 MARSHAL_TEST (INT64,
DBUS_BIG_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7));
1681 MARSHAL_TEST (UINT64,
DBUS_BIG_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7));
1697 MARSHAL_TEST_STRCMP (STRING,
DBUS_BIG_ENDIAN,
"This is the dbus test string");
1738 0, DBUS_INT64_CONSTANT (-0x123456789abc7));
1740 _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
1742 _dbus_string_get_const_data (&str)));
1746 0, DBUS_INT64_CONSTANT (-0x123456789abc7));
1748 _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
1750 _dbus_string_get_const_data (&str)));
1753 _dbus_pack_int64 (DBUS_INT64_CONSTANT (-0x123456789abc7),
1755 _dbus_string_get_data (&str));
1757 _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
1759 _dbus_string_get_const_data (&str)));
1762 _dbus_pack_int64 (DBUS_INT64_CONSTANT (-0x123456789abc7),
1764 _dbus_string_get_data (&str));
1766 _dbus_assert (DBUS_INT64_CONSTANT (-0x123456789abc7) ==
1768 _dbus_string_get_const_data (&str)));
1772 0, DBUS_UINT64_CONSTANT (0x123456789abc7));
1774 _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
1776 _dbus_string_get_const_data (&str)));
1780 0, DBUS_UINT64_CONSTANT (0x123456789abc7));
1782 _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
1784 _dbus_string_get_const_data (&str)));
1787 _dbus_pack_uint64 (DBUS_UINT64_CONSTANT (0x123456789abc7),
1789 _dbus_string_get_data (&str));
1791 _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
1793 _dbus_string_get_const_data (&str)));
1796 _dbus_pack_uint64 (DBUS_UINT64_CONSTANT (0x123456789abc7),
1798 _dbus_string_get_data (&str));
1800 _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) ==
1802 _dbus_string_get_const_data (&str)));
1813 _dbus_string_get_const_data (&str)));
1821 _dbus_string_get_const_data (&str)));
1824 _dbus_pack_int32 (-0x123456,
1826 _dbus_string_get_data (&str));
1830 _dbus_string_get_const_data (&str)));
1833 _dbus_pack_int32 (-0x123456,
1835 _dbus_string_get_data (&str));
1839 _dbus_string_get_const_data (&str)));
1848 _dbus_string_get_const_data (&str)));
1857 _dbus_string_get_const_data (&str)));
1862 _dbus_string_get_data (&str));
1866 _dbus_string_get_const_data (&str)));
1871 _dbus_string_get_data (&str));
1875 _dbus_string_get_const_data (&str)));
1889 MARSHAL_TEST_STRCMP (STRING, byte_order,
"Hello world");
1894 v_STRING = _dbus_string_get_const_data (&t);
1896 &v_STRING, byte_order,
NULL,
NULL);
1899 &v_STRING, byte_order,
1901 _dbus_assert (strcmp (v_STRING,
"Hello world foo") == 0);
1906 v_STRING = _dbus_string_get_const_data (&t);
1908 &v_STRING, byte_order,
NULL,
NULL);
1910 &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(), and fills it with the same contents as #_DBUS_STRING_I...
#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.