28#include "dbus-internals.h"
29#include "dbus-marshal-basic.h"
30#include "dbus-signature.h"
31#include <dbus/dbus-test-tap.h>
35#define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
36 _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (type) op val)
37#define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
38 _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (left) op _DBUS_ALIGNOF (right))
41_DBUS_STATIC_ASSERT (
sizeof (
char) == 1);
42_DBUS_ASSERT_ALIGNMENT (
char, ==, 1);
44_DBUS_STATIC_ASSERT (
sizeof (dbus_int16_t) == 2);
45_DBUS_ASSERT_ALIGNMENT (dbus_int16_t, <=, 2);
46_DBUS_STATIC_ASSERT (
sizeof (dbus_uint16_t) == 2);
47_DBUS_ASSERT_ALIGNMENT (dbus_uint16_t, <=, 2);
48_DBUS_ASSERT_CMP_ALIGNMENT (dbus_uint16_t, ==, dbus_int16_t);
50_DBUS_STATIC_ASSERT (
sizeof (dbus_int32_t) == 4);
51_DBUS_ASSERT_ALIGNMENT (dbus_int32_t, <=, 4);
52_DBUS_STATIC_ASSERT (
sizeof (dbus_uint32_t) == 4);
53_DBUS_ASSERT_ALIGNMENT (dbus_uint32_t, <=, 4);
54_DBUS_ASSERT_CMP_ALIGNMENT (dbus_uint32_t, ==, dbus_int32_t);
55_DBUS_STATIC_ASSERT (
sizeof (dbus_bool_t) == 4);
56_DBUS_ASSERT_ALIGNMENT (dbus_bool_t, <=, 4);
57_DBUS_ASSERT_CMP_ALIGNMENT (dbus_uint32_t, ==, dbus_bool_t);
59_DBUS_STATIC_ASSERT (
sizeof (
double) == 8);
60_DBUS_ASSERT_ALIGNMENT (
double, <=, 8);
65_DBUS_ASSERT_CMP_ALIGNMENT (dbus_uint64_t, <=,
double);
67_DBUS_STATIC_ASSERT (
sizeof (dbus_int64_t) == 8);
68_DBUS_ASSERT_ALIGNMENT (dbus_int64_t, <=, 8);
69_DBUS_STATIC_ASSERT (
sizeof (dbus_uint64_t) == 8);
70_DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8);
71_DBUS_ASSERT_CMP_ALIGNMENT (dbus_uint64_t, ==, dbus_int64_t);
96pack_2_octets (dbus_uint16_t value,
103 *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_LE (value);
105 *((dbus_uint16_t*)(data)) = DBUS_UINT16_TO_BE (value);
109pack_4_octets (dbus_uint32_t value,
116 *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_LE (value);
118 *((dbus_uint32_t*)(data)) = DBUS_UINT32_TO_BE (value);
122pack_8_octets (dbus_uint64_t value,
129 *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_LE (value);
131 *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value);
146 pack_4_octets (value, byte_order, data);
150swap_8_octets (dbus_uint64_t *value,
153 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
155 *value = DBUS_UINT64_SWAP_LE_BE (*value);
159#ifndef _dbus_unpack_uint16
169 const unsigned char *data)
174 return DBUS_UINT16_FROM_LE (*(dbus_uint16_t *) (
void *) data);
176 return DBUS_UINT16_FROM_BE (*(dbus_uint16_t *) (
void *) data);
180#ifndef _dbus_unpack_uint32
190 const unsigned char *data)
195 return DBUS_UINT32_FROM_LE (*(dbus_uint32_t *) (
void *) data);
197 return DBUS_UINT32_FROM_BE (*(dbus_uint32_t *) (
void *) data);
214 pack_2_octets (value, byte_order, (
unsigned char *) data);
230 pack_4_octets (value, byte_order, (
unsigned char *) data);
246 pack_8_octets (value, byte_order, (
unsigned char *) data);
265 set_4_octets (str, pos, value, byte_order);
295 int old_len, new_len;
300 _dbus_assert (_DBUS_ALIGN_VALUE (pos, 4) == (
unsigned) pos);
302 _dbus_string_get_const_udata_len (str, pos, 4));
304 new_len = _dbus_string_get_length (&dstr);
307 str, pos + 4, old_len))
313 *old_end_pos = pos + 4 + old_len + 1;
315 *new_end_pos = pos + 4 + new_len + 1;
341 int old_len, new_len;
346 old_len = _dbus_string_get_byte (str, pos);
347 new_len = _dbus_string_get_length (&dstr);
350 str, pos + 1, old_len))
353 _dbus_string_set_byte (str, pos, new_len);
356 *old_end_pos = pos + 1 + old_len + 1;
358 *new_end_pos = pos + 1 + new_len + 1;
392 const unsigned char *u8_p;
393 const dbus_uint16_t *u16_p;
394 const dbus_uint32_t *u32_p;
395 const dbus_uint64_t *u64_p;
396 const char *
const *string_p;
402 _dbus_string_set_byte (str, pos, *u8_p);
404 *old_end_pos = pos + 1;
406 *new_end_pos = pos + 1;
412 pos = _DBUS_ALIGN_VALUE (pos, 2);
413 set_2_octets (str, pos, *u16_p, byte_order);
415 *old_end_pos = pos + 2;
417 *new_end_pos = pos + 2;
425 pos = _DBUS_ALIGN_VALUE (pos, 4);
426 set_4_octets (str, pos, *u32_p, byte_order);
428 *old_end_pos = pos + 4;
430 *new_end_pos = pos + 4;
437 pos = _DBUS_ALIGN_VALUE (pos, 8);
438 set_8_octets (str, pos, *u64_p, byte_order);
440 *old_end_pos = pos + 8;
442 *new_end_pos = pos + 8;
448 pos = _DBUS_ALIGN_VALUE (pos, 4);
450 return set_string (str, pos, *string_p, byte_order,
451 old_end_pos, new_end_pos);
456 return set_signature (str, pos, *string_p, byte_order,
457 old_end_pos, new_end_pos);
481 pos = _DBUS_ALIGN_VALUE (pos, 4);
486 _dbus_assert (pos + 4 <= _dbus_string_get_length (str));
489 _dbus_string_get_const_udata (str) + pos);
521 const char *str_data;
525 str_data = _dbus_string_get_const_data (str);
535 volatile unsigned char *vp = value;
536 *vp = (
unsigned char) _dbus_string_get_byte (str, pos);
543 volatile dbus_uint16_t *vp = value;
544 pos = _DBUS_ALIGN_VALUE (pos, 2);
545 *vp = *(dbus_uint16_t *) (
void *) (str_data + pos);
546 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
547 *vp = DBUS_UINT16_SWAP_LE_BE (*vp);
556 volatile dbus_uint32_t *vp = value;
557 pos = _DBUS_ALIGN_VALUE (pos, 4);
558 *vp = *(dbus_uint32_t *) (
void *) (str_data + pos);
559 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
560 *vp = DBUS_UINT32_SWAP_LE_BE (*vp);
568 volatile dbus_uint64_t *vp = value;
569 pos = _DBUS_ALIGN_VALUE (pos, 8);
570 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
571 *vp = DBUS_UINT64_SWAP_LE_BE (
572 *(dbus_uint64_t *) (
void *) (str_data + pos));
574 *vp = *(dbus_uint64_t *) (
void *) (str_data + pos);
582 volatile char **vp = value;
586 *vp = (
char*) str_data + pos;
594 volatile char **vp = value;
596 len = _dbus_string_get_byte (str, pos);
599 *vp = (
char*) str_data + pos;
625 _DBUS_STATIC_ASSERT (
sizeof (value) == 2);
627 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
628 value = DBUS_UINT16_SWAP_LE_BE (value);
630 orig_len = _dbus_string_get_length (str);
633 (
const unsigned char *)&value);
637 *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
638 _dbus_assert (*pos_after <= _dbus_string_get_length (str));
654 _DBUS_STATIC_ASSERT (
sizeof (value) == 4);
656 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
657 value = DBUS_UINT32_SWAP_LE_BE (value);
659 orig_len = _dbus_string_get_length (str);
662 (
const unsigned char *)&value);
666 *pos_after = insert_at + (_dbus_string_get_length (str) - orig_len);
667 _dbus_assert (*pos_after <= _dbus_string_get_length (str));
683 _DBUS_STATIC_ASSERT (
sizeof (value) == 8);
685 swap_8_octets (&value, byte_order);
687 orig_len = _dbus_string_get_length (str);
690 (
const unsigned char *)&value);
693 *pos_after = insert_at + _dbus_string_get_length (str) - orig_len;
701 MARSHAL_AS_SIGNATURE,
702 MARSHAL_AS_BYTE_ARRAY
706marshal_len_followed_by_bytes (
int marshal_as,
709 const unsigned char *value,
719 if (insert_at > _dbus_string_get_length (str))
720 _dbus_warn (
"insert_at = %d string len = %d data_len = %d",
721 insert_at, _dbus_string_get_length (str), data_len);
723 if (marshal_as == MARSHAL_AS_BYTE_ARRAY)
724 value_len = data_len;
726 value_len = data_len + 1;
732 if (marshal_as == MARSHAL_AS_SIGNATURE)
744 if (!marshal_4_octets (str, pos, data_len,
781 return marshal_len_followed_by_bytes (MARSHAL_AS_STRING,
782 str, insert_at, (
const unsigned char *) value,
784 byte_order, pos_after);
793 return marshal_len_followed_by_bytes (MARSHAL_AS_SIGNATURE,
794 str, insert_at, (
const unsigned char *) value,
796 DBUS_COMPILER_BYTE_ORDER,
831 const unsigned char *u8_p;
832 const dbus_uint16_t *u16_p;
833 const dbus_uint32_t *u32_p;
834 const dbus_uint64_t *u64_p;
835 const char *
const *string_p;
846 *pos_after = insert_at + 1;
852 return marshal_2_octets (str, insert_at, *u16_p,
853 byte_order, pos_after);
857 return marshal_4_octets (str, insert_at, (*u32_p !=
FALSE),
858 byte_order, pos_after);
864 return marshal_4_octets (str, insert_at, *u32_p,
865 byte_order, pos_after);
871 return marshal_8_octets (str, insert_at, *u64_p, byte_order, pos_after);
878 return marshal_string (str, insert_at, *string_p, byte_order, pos_after);
883 return marshal_signature (str, insert_at, *string_p, pos_after);
895 const unsigned char *value,
934 _dbus_assert (_DBUS_ALIGN_ADDRESS (data, alignment) == data);
940 end = data + (n_elements * alignment);
946 *((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d));
947 d = ((
unsigned char *) d) + 8;
950 else if (alignment == 4)
954 *((dbus_uint32_t*)d) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)d));
955 d = ((
unsigned char *) d) + 4;
964 *((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d));
965 d = ((
unsigned char *) d) + 2;
977 _dbus_assert (_DBUS_ALIGN_VALUE (array_start, alignment) == (
unsigned) array_start);
979 if (byte_order != DBUS_COMPILER_BYTE_ORDER)
984 _dbus_swap_array ((
unsigned char*) (_dbus_string_get_const_data (str) + array_start),
985 n_elements, alignment);
1005 old_string_len = _dbus_string_get_length (str);
1007 len_in_bytes = n_elements * alignment;
1008 array_start = insert_at;
1020 (
const char *) value,
1027 swap_array (str, array_start, n_elements, byte_order, alignment);
1030 *pos_after = array_start + len_in_bytes;
1036 _dbus_string_get_length (str) - old_string_len);
1074 const unsigned char *
const *u8_pp;
1075 const dbus_uint16_t *
const *u16_pp;
1076 const dbus_uint32_t *
const *u32_pp;
1077 const dbus_uint64_t *
const *u64_pp;
1083 _dbus_verbose (
"writing %d elements of %s\n",
1087 switch (element_type)
1091 return marshal_1_octets_array (str, insert_at, *u8_pp, n_elements, byte_order, pos_after);
1096 return marshal_fixed_multi (str, insert_at, *u16_pp, n_elements, byte_order, 2, pos_after);
1102 return marshal_fixed_multi (str, insert_at, *u32_pp, n_elements, byte_order, 4, pos_after);
1108 return marshal_fixed_multi (str, insert_at, *u64_pp, n_elements, byte_order, 8, pos_after);
1146 *pos = _DBUS_ALIGN_VALUE (*pos, 2);
1153 *pos = _DBUS_ALIGN_VALUE (*pos, 4);
1159 *pos = _DBUS_ALIGN_VALUE (*pos, 8);
1178 len = _dbus_string_get_byte (str, *pos);
1210 dbus_uint32_t array_len;
1215 i = _DBUS_ALIGN_VALUE (*pos, 4);
1226 i = _DBUS_ALIGN_VALUE (i, alignment);
1229 *pos = i + array_len;
1317 return "object_path";
1323 return "dict_entry";
1329 return "begin_struct";
1331 return "end_struct";
1333 return "begin_dict_entry";
1335 return "end_dict_entry";
1356 const unsigned char *aligned;
1360 if (!_dbus_is_verbose())
1364 aligned = _DBUS_ALIGN_ADDRESS (data, 4);
1369 if (aligned != data)
1371 _dbus_verbose (
"%4ld\t%p: ", - (
long)(data - aligned), aligned);
1372 while (aligned != data)
1374 _dbus_verbose (
" ");
1383 if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
1385 _dbus_verbose (
"%4d\t%p: ",
1386 offset + i, &data[i]);
1389 if (data[i] >= 32 &&
1391 _dbus_verbose (
" '%c' ", data[i]);
1393 _dbus_verbose (
"0x%s%x ",
1394 data[i] <= 0xf ?
"0" :
"", data[i]);
1398 if (_DBUS_ALIGN_ADDRESS (&data[i], 4) == &data[i])
1401 _dbus_verbose (
"BE: %d LE: %d",
1406 _DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
1409 *(dbus_uint64_t *) (
void *) &data[i - 8]);
1410 _dbus_verbose (
" dbl: %g", *(
double *) (
void *) &data[i - 8]);
1413 _dbus_verbose (
"\n");
1417 _dbus_verbose (
"\n");
1435 real_len = _dbus_string_get_length (str);
1439 if (start > real_len)
1441 _dbus_verbose (
" [%d,%d) is not inside string of length %d\n",
1442 start, len, real_len);
1446 if ((start + len) > real_len)
1448 _dbus_verbose (
" [%d,%d) extends outside string of length %d\n",
1449 start, len, real_len);
1450 len = real_len - start;
1453 d = _dbus_string_get_const_data_len (str, start, len);
1459map_type_char_to_type (
int t)
1487 return map_type_char_to_type (_dbus_string_get_byte (str, pos));
1502 return map_type_char_to_type (str[pos]);
1507#ifdef DBUS_ENABLE_EMBEDDED_TESTS
1508#include "dbus-test.h"
1530_dbus_marshal_read_fixed_multi (
const DBusString *str,
1545 _dbus_verbose (
"reading %d elements of %s\n",
1551 pos = _DBUS_ALIGN_VALUE (pos, alignment);
1553 array_len = n_elements * alignment;
1555 *value = _dbus_string_get_const_data_len (str, pos, array_len);
1557 *new_pos = pos + array_len;
1561swap_test_array (
void *array,
1572 swap_array (&t, 0, len_bytes / alignment, byte_order, alignment);
1575#define MARSHAL_BASIC(typename, byte_order, literal) \
1577 v_##typename = literal; \
1578 if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename, \
1580 byte_order, NULL)) \
1581 _dbus_test_fatal ("no memory"); \
1584#define DEMARSHAL_BASIC(typename, byte_order) \
1586 _dbus_marshal_read_basic (&str, pos, DBUS_TYPE_##typename, &v_##typename, \
1587 byte_order, &pos); \
1590#define DEMARSHAL_BASIC_AND_CHECK(typename, byte_order, literal) \
1592 DEMARSHAL_BASIC (typename, byte_order); \
1593 if (literal != v_##typename) \
1595 _dbus_verbose_bytes_of_string (&str, dump_pos, \
1596 _dbus_string_get_length (&str) - dump_pos); \
1597 _dbus_test_fatal ("demarshaled wrong value"); \
1601#define MARSHAL_TEST(typename, byte_order, literal) \
1603 MARSHAL_BASIC (typename, byte_order, literal); \
1605 DEMARSHAL_BASIC_AND_CHECK (typename, byte_order, literal); \
1608#define MARSHAL_TEST_STRCMP(typename, byte_order, literal) \
1610 MARSHAL_BASIC (typename, byte_order, literal); \
1612 DEMARSHAL_BASIC (typename, byte_order); \
1613 if (strcmp (literal, v_##typename) != 0) \
1615 _dbus_verbose_bytes_of_string (&str, dump_pos, \
1616 _dbus_string_get_length (&str) - dump_pos); \
1617 _dbus_warn ("literal '%s'\nvalue '%s'", literal, v_##typename); \
1618 _dbus_test_fatal ("demarshaled wrong value"); \
1622#define MARSHAL_FIXED_ARRAY(typename, byte_order, literal) \
1625 v_UINT32 = sizeof(literal); \
1626 if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_UINT32, &v_UINT32, \
1627 byte_order, &next)) \
1628 _dbus_test_fatal ("no memory"); \
1629 v_ARRAY_##typename = literal; \
1630 if (!_dbus_marshal_write_fixed_multi (&str, next, DBUS_TYPE_##typename, \
1631 &v_ARRAY_##typename, _DBUS_N_ELEMENTS(literal), \
1632 byte_order, NULL)) \
1633 _dbus_test_fatal ("no memory"); \
1636#define DEMARSHAL_FIXED_ARRAY(typename, byte_order) \
1639 alignment = _dbus_type_get_alignment (DBUS_TYPE_##typename); \
1640 v_UINT32 = _dbus_marshal_read_uint32 (&str, dump_pos, byte_order, &next); \
1641 _dbus_marshal_read_fixed_multi (&str, next, DBUS_TYPE_##typename, \
1642 (const void **) &v_ARRAY_##typename, \
1643 v_UINT32/alignment, \
1644 byte_order, NULL); \
1645 swap_test_array (v_ARRAY_##typename, v_UINT32, \
1646 byte_order, alignment); \
1649#define DEMARSHAL_FIXED_ARRAY_AND_CHECK(typename, byte_order, literal) \
1651 DEMARSHAL_FIXED_ARRAY (typename, byte_order); \
1652 if (memcmp (literal, v_ARRAY_##typename, sizeof (literal)) != 0) \
1654 _dbus_verbose ("MARSHALED DATA\n"); \
1655 _dbus_verbose_bytes_of_string (&str, dump_pos, \
1656 _dbus_string_get_length (&str) - dump_pos); \
1657 _dbus_verbose ("LITERAL DATA\n"); \
1658 _dbus_verbose_bytes ((const unsigned char *) literal, sizeof (literal), 0); \
1659 _dbus_verbose ("READ DATA\n"); \
1660 _dbus_verbose_bytes ((const unsigned char *) v_ARRAY_##typename, sizeof (literal), 0); \
1661 _dbus_test_fatal ("demarshaled wrong fixed array value"); \
1665#define MARSHAL_TEST_FIXED_ARRAY(typename, byte_order, literal) \
1667 MARSHAL_FIXED_ARRAY (typename, byte_order, literal); \
1669 DEMARSHAL_FIXED_ARRAY_AND_CHECK (typename, byte_order, literal); \
1673_dbus_marshal_test (
const char *test_data_dir _DBUS_GNUC_UNUSED)
1678 unsigned char array1[5] = { 3, 4, 0, 1, 9 };
1679 dbus_int16_t array2[3] = { 124, 457, 780 };
1680 dbus_uint16_t array2u[3] = { 124, 457, 780 };
1681 dbus_int32_t array4[3] = { 123, 456, 789 };
1682 dbus_uint32_t array4u[3] = { 123, 456, 789 };
1686 dbus_int64_t *v_ARRAY_INT64;
1687 unsigned char *v_ARRAY_BYTE;
1688 dbus_int16_t *v_ARRAY_INT16;
1689 dbus_uint16_t *v_ARRAY_UINT16;
1690 dbus_int32_t *v_ARRAY_INT32;
1691 dbus_uint32_t *v_ARRAY_UINT32;
1695 dbus_int16_t v_INT16;
1696 dbus_uint16_t v_UINT16;
1697 dbus_int32_t v_INT32;
1698 dbus_uint32_t v_UINT32;
1699 dbus_int64_t v_INT64;
1700 dbus_uint64_t v_UINT64;
1701 unsigned char v_BYTE;
1702 dbus_bool_t v_BOOLEAN;
1703 const char *v_STRING;
1704 const char *v_SIGNATURE;
1705 const char *v_OBJECT_PATH;
1709 _dbus_test_fatal (
"failed to init string");
1718 _dbus_test_fatal (
"got wrong double value");
1724 _dbus_test_fatal (
"got wrong double value");
1763 MARSHAL_TEST_STRCMP (STRING,
DBUS_BIG_ENDIAN,
"This is the dbus test string");
1808 _dbus_string_get_const_data (&str)));
1816 _dbus_string_get_const_data (&str)));
1821 _dbus_string_get_data (&str));
1825 _dbus_string_get_const_data (&str)));
1830 _dbus_string_get_data (&str));
1834 _dbus_string_get_const_data (&str)));
1842 _dbus_string_get_const_data (&str)));
1850 _dbus_string_get_const_data (&str)));
1855 _dbus_string_get_data (&str));
1859 _dbus_string_get_const_data (&str)));
1864 _dbus_string_get_data (&str));
1868 _dbus_string_get_const_data (&str)));
1879 _dbus_string_get_const_data (&str)));
1887 _dbus_string_get_const_data (&str)));
1890 _dbus_pack_int32 (-0x123456,
1892 _dbus_string_get_data (&str));
1896 _dbus_string_get_const_data (&str)));
1899 _dbus_pack_int32 (-0x123456,
1901 _dbus_string_get_data (&str));
1905 _dbus_string_get_const_data (&str)));
1914 _dbus_string_get_const_data (&str)));
1923 _dbus_string_get_const_data (&str)));
1928 _dbus_string_get_data (&str));
1932 _dbus_string_get_const_data (&str)));
1937 _dbus_string_get_data (&str));
1941 _dbus_string_get_const_data (&str)));
1955 MARSHAL_TEST_STRCMP (STRING, byte_order,
"Hello world");
1960 v_STRING = _dbus_string_get_const_data (&t);
1962 &v_STRING, byte_order,
NULL,
NULL);
1965 &v_STRING, byte_order,
1967 _dbus_assert (strcmp (v_STRING,
"Hello world foo") == 0);
1972 v_STRING = _dbus_string_get_const_data (&t);
1974 &v_STRING, byte_order,
NULL,
NULL);
1976 &v_STRING, byte_order,
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#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...
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
dbus_uint16_t _dbus_unpack_uint16(int byte_order, const unsigned char *data)
Unpacks a 16 bit unsigned integer from a data pointer.
int _dbus_type_get_alignment(int typecode)
Gets the alignment requirement for the given type; will be 1, 2, 4, or 8.
void _dbus_verbose_bytes_of_string(const DBusString *str, int start, int len)
Dump the given part of the string to verbose log.
void _dbus_pack_uint32(dbus_uint32_t value, int byte_order, unsigned char *data)
Packs a 32 bit unsigned integer into a data pointer.
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 ...
dbus_uint32_t _dbus_unpack_uint32(int byte_order, const unsigned char *data)
Unpacks a 32 bit unsigned integer from a data pointer.
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.
int _dbus_first_type_in_signature(const DBusString *str, int pos)
Get the first type in the signature.
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_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.
void _dbus_verbose_bytes(const unsigned char *data, int len, int offset)
If in verbose mode, print a block of binary data.
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.
void _dbus_marshal_skip_array(const DBusString *str, int element_type, int byte_order, int *pos)
Skips an array, returning the next position.
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.
const char * _dbus_type_to_string(int typecode)
Returns a string describing the given type.
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.
void _dbus_swap_array(unsigned char *data, int n_elements, int alignment)
Swaps the elements of an array to the opposite byte order.
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 DBUS_TYPE_SIGNATURE
Type code marking a D-Bus type signature.
#define DBUS_MAXIMUM_SIGNATURE_LENGTH
This one is 255 so it fits in a byte.
#define DBUS_DICT_ENTRY_END_CHAR
Code marking the end of a dict entry type in a type signature.
#define DBUS_TYPE_OBJECT_PATH
Type code marking a D-Bus object path.
#define DBUS_TYPE_BYTE
Type code marking an 8-bit unsigned integer.
#define DBUS_TYPE_INT16
Type code marking a 16-bit signed integer.
#define DBUS_TYPE_VARIANT
Type code marking a D-Bus variant type.
#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_INT32
Type code marking a 32-bit signed integer.
#define DBUS_TYPE_UNIX_FD
Type code marking a unix file descriptor.
#define DBUS_TYPE_BOOLEAN
Type code marking a boolean.
#define DBUS_STRUCT_BEGIN_CHAR
Code marking the start of a struct type in a type signature.
#define DBUS_TYPE_STRING
Type code marking a UTF-8 encoded, nul-terminated Unicode string.
#define DBUS_TYPE_ARRAY
Type code marking a D-Bus array type.
#define DBUS_TYPE_INVALID
Type code that is never equal to a legitimate type code.
#define DBUS_LITTLE_ENDIAN
Code marking LSB-first byte order in the wire protocol.
#define DBUS_TYPE_INT64
Type code marking a 64-bit signed integer.
#define DBUS_TYPE_DOUBLE
Type code marking an 8-byte double in IEEE 754 format.
#define DBUS_TYPE_UINT64
Type code marking a 64-bit unsigned integer.
#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_DICT_ENTRY_BEGIN_CHAR
Code marking the start of a dict entry type in a type signature.
#define DBUS_TYPE_UINT16
Type code marking a 16-bit unsigned integer.
#define DBUS_TYPE_STRUCT
STRUCT and DICT_ENTRY are sort of special since their codes can't appear in a type string,...
#define DBUS_STRUCT_END_CHAR
Code marking the end of a struct type in a type signature.
#define DBUS_BIG_ENDIAN
Code marking MSB-first byte order in the wire protocol.
#define DBUS_TYPE_UINT32
Type code marking a 32-bit unsigned integer.
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_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.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a 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.
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.
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.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
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...
char * _dbus_string_get_data_len(DBusString *str, int start, int len)
Gets a sub-portion of the raw character buffer from the string.
void _dbus_string_init_const_len(DBusString *str, const char *value, int len)
Initializes a constant string with a length.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
void _dbus_string_delete(DBusString *str, int start, int len)
Deletes a segment of a DBusString with length len starting at start.
dbus_bool_t _dbus_string_insert_byte(DBusString *str, int i, unsigned char byte)
Inserts a single byte at the given position.
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.
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.
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.
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.
#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,...
#define DBUS_UINT64_CONSTANT(val)
Declare a 64-bit unsigned integer constant.
#define DBUS_INT64_MODIFIER
A string literal for a length modifier that is appropriate to print the dbus_int64_t and dbus_uint64_...
#define DBUS_INT64_CONSTANT(val)
Declare a 64-bit signed integer constant.
An 8-byte struct you could use to access int64 without having int64 support.
A simple value union that lets you access bytes as if they were various types; useful when dealing wi...