26 #ifdef DBUS_BUILD_TESTS
28 #include "dbus-marshal-recursive.h"
29 #include "dbus-marshal-basic.h"
30 #include "dbus-signature.h"
31 #include "dbus-internals.h"
38 #ifdef DBUS_HAVE_INT64
47 basic_value_equal (
int type,
55 return strcmp (lhs->
str, rhs->
str) == 0;
59 #ifdef DBUS_HAVE_INT64
60 return lhs->u64 == rhs->u64;
78 if (lhs_type != rhs_type)
89 basic_value_zero (&lhs_value);
90 basic_value_zero (&rhs_value);
95 return basic_value_equal (lhs_type, &lhs_value, &rhs_value);
105 return equal_values_helper (&lhs_sub, &rhs_sub);
123 return equal_values_helper (©_lhs, ©_rhs);
128 #ifndef DOXYGEN_SHOULD_SKIP_THIS
130 #include "dbus-test.h"
131 #include "dbus-list.h"
136 #define TEST_OOM_HANDLING 0
140 #define MAX_INITIAL_OFFSET 9
146 #define MAX_ITERATIONS_FOR_EXPENSIVE_TESTS 1000
162 #define N_FENCE_BYTES 5
163 #define FENCE_BYTES_STR "abcde"
164 #define INITIAL_PADDING_BYTE '\0'
167 data_block_init (DataBlock *block,
181 INITIAL_PADDING_BYTE) ||
183 INITIAL_PADDING_BYTE) ||
192 block->byte_order = byte_order;
193 block->initial_offset = initial_offset;
199 data_block_save (DataBlock *block,
200 DataBlockState *state)
207 data_block_restore (DataBlock *block,
208 DataBlockState *state)
211 state->saved_sig_len,
214 state->saved_body_len,
219 data_block_verify (DataBlock *block)
251 0, block->initial_offset));
253 0, block->initial_offset));
257 data_block_free (DataBlock *block)
259 data_block_verify (block);
266 data_block_reset (DataBlock *block)
268 data_block_verify (block);
271 block->initial_offset,
274 block->initial_offset,
277 data_block_verify (block);
281 data_block_init_reader_writer (DataBlock *block,
289 block->initial_offset,
291 block->initial_offset);
305 const char *funcname,
314 _dbus_warn (
"Read type %s while expecting %s at %s line %d\n",
323 #define check_expected_type(reader, expected) real_check_expected_type (reader, expected, _DBUS_FUNCTION_NAME, __LINE__)
325 #define NEXT_EXPECTING_TRUE(reader) do { if (!_dbus_type_reader_next (reader)) \
327 _dbus_warn ("_dbus_type_reader_next() should have returned TRUE at %s %d\n", \
328 _DBUS_FUNCTION_NAME, __LINE__); \
329 _dbus_assert_not_reached ("test failed"); \
333 #define NEXT_EXPECTING_FALSE(reader) do { if (_dbus_type_reader_next (reader)) \
335 _dbus_warn ("_dbus_type_reader_next() should have returned FALSE at %s %d\n", \
336 _DBUS_FUNCTION_NAME, __LINE__); \
337 _dbus_assert_not_reached ("test failed"); \
339 check_expected_type (reader, DBUS_TYPE_INVALID); \
342 typedef struct TestTypeNode TestTypeNode;
343 typedef struct TestTypeNodeClass TestTypeNodeClass;
344 typedef struct TestTypeNodeContainer TestTypeNodeContainer;
345 typedef struct TestTypeNodeContainerClass TestTypeNodeContainerClass;
349 const TestTypeNodeClass *klass;
352 struct TestTypeNodeContainer
358 struct TestTypeNodeClass
367 void (* destroy) (TestTypeNode *node);
380 dbus_bool_t (* build_signature) (TestTypeNode *node,
393 struct TestTypeNodeContainerClass
395 TestTypeNodeClass base;
403 static dbus_bool_t int16_write_value (TestTypeNode *node,
407 static dbus_bool_t int16_read_value (TestTypeNode *node,
410 static dbus_bool_t int16_set_value (TestTypeNode *node,
414 static dbus_bool_t int16_write_multi (TestTypeNode *node,
419 static dbus_bool_t int16_read_multi (TestTypeNode *node,
423 static dbus_bool_t int32_write_value (TestTypeNode *node,
427 static dbus_bool_t int32_read_value (TestTypeNode *node,
430 static dbus_bool_t int32_set_value (TestTypeNode *node,
434 static dbus_bool_t int32_write_multi (TestTypeNode *node,
439 static dbus_bool_t int32_read_multi (TestTypeNode *node,
443 static dbus_bool_t int64_write_value (TestTypeNode *node,
447 static dbus_bool_t int64_read_value (TestTypeNode *node,
450 static dbus_bool_t int64_set_value (TestTypeNode *node,
454 static dbus_bool_t string_write_value (TestTypeNode *node,
458 static dbus_bool_t string_read_value (TestTypeNode *node,
461 static dbus_bool_t string_set_value (TestTypeNode *node,
465 static dbus_bool_t bool_write_value (TestTypeNode *node,
469 static dbus_bool_t bool_read_value (TestTypeNode *node,
472 static dbus_bool_t bool_set_value (TestTypeNode *node,
476 static dbus_bool_t byte_write_value (TestTypeNode *node,
480 static dbus_bool_t byte_read_value (TestTypeNode *node,
483 static dbus_bool_t byte_set_value (TestTypeNode *node,
487 static dbus_bool_t double_write_value (TestTypeNode *node,
491 static dbus_bool_t double_read_value (TestTypeNode *node,
494 static dbus_bool_t double_set_value (TestTypeNode *node,
498 static dbus_bool_t object_path_write_value (TestTypeNode *node,
502 static dbus_bool_t object_path_read_value (TestTypeNode *node,
505 static dbus_bool_t object_path_set_value (TestTypeNode *node,
509 static dbus_bool_t signature_write_value (TestTypeNode *node,
513 static dbus_bool_t signature_read_value (TestTypeNode *node,
516 static dbus_bool_t signature_set_value (TestTypeNode *node,
520 static dbus_bool_t struct_write_value (TestTypeNode *node,
524 static dbus_bool_t struct_read_value (TestTypeNode *node,
527 static dbus_bool_t struct_set_value (TestTypeNode *node,
531 static dbus_bool_t struct_build_signature (TestTypeNode *node,
533 static dbus_bool_t dict_write_value (TestTypeNode *node,
537 static dbus_bool_t dict_read_value (TestTypeNode *node,
540 static dbus_bool_t dict_set_value (TestTypeNode *node,
544 static dbus_bool_t dict_build_signature (TestTypeNode *node,
546 static dbus_bool_t array_write_value (TestTypeNode *node,
550 static dbus_bool_t array_read_value (TestTypeNode *node,
553 static dbus_bool_t array_set_value (TestTypeNode *node,
557 static dbus_bool_t array_build_signature (TestTypeNode *node,
559 static dbus_bool_t variant_write_value (TestTypeNode *node,
563 static dbus_bool_t variant_read_value (TestTypeNode *node,
566 static dbus_bool_t variant_set_value (TestTypeNode *node,
570 static void container_destroy (TestTypeNode *node);
574 static const TestTypeNodeClass int16_class = {
576 sizeof (TestTypeNode),
588 static const TestTypeNodeClass uint16_class = {
590 sizeof (TestTypeNode),
602 static const TestTypeNodeClass int32_class = {
604 sizeof (TestTypeNode),
616 static const TestTypeNodeClass uint32_class = {
618 sizeof (TestTypeNode),
630 static const TestTypeNodeClass int64_class = {
632 sizeof (TestTypeNode),
644 static const TestTypeNodeClass uint64_class = {
646 sizeof (TestTypeNode),
658 static const TestTypeNodeClass string_0_class = {
660 sizeof (TestTypeNode),
672 static const TestTypeNodeClass string_1_class = {
674 sizeof (TestTypeNode),
687 static const TestTypeNodeClass string_3_class = {
689 sizeof (TestTypeNode),
702 static const TestTypeNodeClass string_8_class = {
704 sizeof (TestTypeNode),
716 static const TestTypeNodeClass bool_class = {
718 sizeof (TestTypeNode),
730 static const TestTypeNodeClass byte_class = {
732 sizeof (TestTypeNode),
744 static const TestTypeNodeClass double_class = {
746 sizeof (TestTypeNode),
758 static const TestTypeNodeClass object_path_class = {
760 sizeof (TestTypeNode),
764 object_path_write_value,
765 object_path_read_value,
766 object_path_set_value,
772 static const TestTypeNodeClass signature_class = {
774 sizeof (TestTypeNode),
778 signature_write_value,
779 signature_read_value,
786 static const TestTypeNodeClass struct_1_class = {
788 sizeof (TestTypeNodeContainer),
795 struct_build_signature,
800 static const TestTypeNodeClass struct_2_class = {
802 sizeof (TestTypeNodeContainer),
809 struct_build_signature,
814 static const TestTypeNodeClass dict_1_class = {
816 sizeof (TestTypeNodeContainer),
823 dict_build_signature,
830 static const TestTypeNodeClass array_0_class = {
832 sizeof (TestTypeNodeContainer),
839 array_build_signature,
844 static const TestTypeNodeClass array_1_class = {
846 sizeof (TestTypeNodeContainer),
853 array_build_signature,
858 static const TestTypeNodeClass array_2_class = {
860 sizeof (TestTypeNodeContainer),
867 array_build_signature,
872 static const TestTypeNodeClass array_9_class = {
874 sizeof (TestTypeNodeContainer),
881 array_build_signature,
886 static const TestTypeNodeClass variant_class = {
888 sizeof (TestTypeNodeContainer),
900 static const TestTypeNodeClass*
const
918 #define N_BASICS (_DBUS_N_ELEMENTS (basic_nodes))
920 static const TestTypeNodeClass*
const
921 container_nodes[] = {
933 #define N_CONTAINERS (_DBUS_N_ELEMENTS (container_nodes))
936 node_new (
const TestTypeNodeClass *klass)
946 if (klass->construct)
948 if (!(* klass->construct) (node))
959 node_destroy (TestTypeNode *node)
961 if (node->klass->destroy)
962 (* node->klass->destroy) (node);
967 node_write_value (TestTypeNode *node,
974 retval = (* node->klass->write_value) (node, block, writer, seed);
978 data_block_verify (block);
985 node_read_value (TestTypeNode *node,
991 if (!(* node->klass->read_value) (node, reader, seed))
1002 node_set_value (TestTypeNode *node,
1007 if (!(* node->klass->set_value) (node, reader, realign_root, seed))
1014 node_build_signature (TestTypeNode *node,
1017 if (node->klass->build_signature)
1018 return (* node->klass->build_signature) (node, str);
1024 node_append_child (TestTypeNode *node,
1025 TestTypeNode *child)
1027 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
1029 _dbus_assert (node->klass->instance_size >= (
int) sizeof (TestTypeNodeContainer));
1038 node_write_multi (TestTypeNode *node,
1047 retval = (* node->klass->write_multi) (node, block, writer, seed, n_copies);
1051 data_block_verify (block);
1058 node_read_multi (TestTypeNode *node,
1065 if (!(* node->klass->read_multi) (node, reader, seed, n_copies))
1071 static int n_iterations_completed_total = 0;
1072 static int n_iterations_completed_this_test = 0;
1073 static int n_iterations_expected_this_test = 0;
1080 TestTypeNode **nodes;
1082 } NodeIterationData;
1085 run_test_copy (NodeIterationData *nid)
1093 _dbus_verbose (
"\n");
1099 if (!data_block_init (&dest, src->byte_order, src->initial_offset))
1102 data_block_init_reader_writer (src, &reader,
NULL);
1103 data_block_init_reader_writer (&dest,
NULL, &writer);
1109 dest.initial_offset,
'\0'))
1118 _dbus_verbose (
"SOURCE\n");
1121 _dbus_verbose (
"DEST\n");
1129 _dbus_verbose (
"SOURCE\n");
1132 _dbus_verbose (
"DEST\n");
1142 data_block_free (&dest);
1148 run_test_values_only_write (NodeIterationData *nid)
1156 _dbus_verbose (
"\n");
1160 data_block_reset (nid->block);
1173 nid->block->initial_offset);
1176 while (i < nid->n_nodes)
1178 if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
1189 while (i < nid->n_nodes)
1191 if (!node_read_value (nid->nodes[i], &reader, i))
1194 if (i + 1 == nid->n_nodes)
1195 NEXT_EXPECTING_FALSE (&reader);
1197 NEXT_EXPECTING_TRUE (&reader);
1205 data_block_reset (nid->block);
1217 run_test_set_values (NodeIterationData *nid)
1224 _dbus_verbose (
"\n");
1228 data_block_init_reader_writer (nid->block,
1231 realign_root = reader;
1234 while (i < nid->n_nodes)
1236 if (!node_set_value (nid->nodes[i],
1237 &reader, &realign_root,
1241 if (i + 1 == nid->n_nodes)
1242 NEXT_EXPECTING_FALSE (&reader);
1244 NEXT_EXPECTING_TRUE (&reader);
1251 reader = realign_root;
1254 while (i < nid->n_nodes)
1256 if (!node_read_value (nid->nodes[i], &reader,
1260 if (i + 1 == nid->n_nodes)
1261 NEXT_EXPECTING_FALSE (&reader);
1263 NEXT_EXPECTING_TRUE (&reader);
1275 run_test_delete_values (NodeIterationData *nid)
1281 _dbus_verbose (
"\n");
1285 data_block_init_reader_writer (nid->block,
1310 _dbus_verbose (
"recursing into deletion loop reader.value_pos = %d array.value_pos = %d array.u.start_pos = %d\n",
1315 static int cycle = 0;
1321 if (elem == 3 || elem >= n_elements)
1322 elem = n_elements - 1;
1324 _dbus_verbose (
"deleting array element %d of %d type %s cycle %d reader pos %d elem pos %d\n",
1352 data_block_init_reader_writer (nid->block,
1367 run_test_nodes_iteration (
void *data)
1369 NodeIterationData *nid = data;
1383 data_block_init_reader_writer (nid->block,
1390 nid->type_offset,
'\0'))
1394 while (i < nid->n_nodes)
1396 if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
1403 &nid->block->signature, nid->type_offset))
1405 _dbus_warn (
"Expected signature '%s' and got '%s' with initial offset %d\n",
1413 while (i < nid->n_nodes)
1415 if (!node_read_value (nid->nodes[i], &reader, i))
1418 if (i + 1 == nid->n_nodes)
1419 NEXT_EXPECTING_FALSE (&reader);
1421 NEXT_EXPECTING_TRUE (&reader);
1426 if (n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
1435 if (!run_test_set_values (nid))
1438 if (!run_test_delete_values (nid))
1441 if (!run_test_copy (nid))
1444 if (!run_test_values_only_write (nid))
1456 data_block_reset (nid->block);
1462 run_test_nodes_in_one_configuration (TestTypeNode **nodes,
1469 NodeIterationData nid;
1471 if (!data_block_init (&block, byte_order, initial_offset))
1474 nid.signature = signature;
1476 nid.type_offset = initial_offset;
1478 nid.n_nodes = n_nodes;
1480 if (TEST_OOM_HANDLING &&
1481 n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
1483 _dbus_test_oom_handling (
"running test node",
1484 run_test_nodes_iteration,
1489 if (!run_test_nodes_iteration (&nid))
1493 data_block_free (&block);
1497 run_test_nodes (TestTypeNode **nodes,
1509 if (! node_build_signature (nodes[i], &signature))
1515 _dbus_verbose (
">>> test nodes with signature '%s'\n",
1519 while (i <= MAX_INITIAL_OFFSET)
1521 run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
1523 run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
1529 n_iterations_completed_this_test += 1;
1530 n_iterations_completed_total += 1;
1532 if (n_iterations_completed_this_test == n_iterations_expected_this_test)
1534 fprintf (stderr,
" 100%% %d this test (%d cumulative)\n",
1535 n_iterations_completed_this_test,
1536 n_iterations_completed_total);
1539 else if ((n_iterations_completed_this_test %
1540 (
int)(n_iterations_expected_this_test / 10.0)) == 1)
1542 fprintf (stderr,
" %d%% ", (
int) (n_iterations_completed_this_test / (
double) n_iterations_expected_this_test * 100));
1548 #define N_VALUES (N_BASICS * N_CONTAINERS + N_BASICS)
1550 static TestTypeNode*
1551 value_generator (
int *ip)
1554 const TestTypeNodeClass *child_klass;
1555 const TestTypeNodeClass *container_klass;
1556 TestTypeNode *child;
1565 else if (i < N_BASICS)
1567 node = node_new (basic_nodes[i]);
1581 container_klass = container_nodes[i / N_BASICS];
1582 child_klass = basic_nodes[i % N_BASICS];
1584 node = node_new (container_klass);
1585 child = node_new (child_klass);
1587 node_append_child (node, child);
1596 build_body (TestTypeNode **nodes,
1610 if (! node_build_signature (nodes[i], signature))
1616 if (!data_block_init (&block, byte_order, 0))
1619 data_block_init_reader_writer (&block,
1632 if (!node_write_value (nodes[i], &block, &writer, i))
1643 data_block_free (&block);
1647 dbus_internal_do_not_use_generate_bodies (
int sequence,
1652 TestTypeNode *nodes[1];
1656 nodes[0] = value_generator (&sequence);
1658 if (nodes[0] ==
NULL)
1663 build_body (nodes, n_nodes, byte_order, signature, body);
1669 node_destroy (nodes[i]);
1677 make_and_run_values_inside_container (
const TestTypeNodeClass *container_klass,
1681 TestTypeNode *container;
1682 TestTypeNode *child;
1685 root = node_new (container_klass);
1687 for (i = 1; i < n_nested; i++)
1689 child = node_new (container_klass);
1690 node_append_child (container, child);
1697 while ((child = value_generator (&i)))
1699 node_append_child (container, child);
1701 run_test_nodes (&root, 1);
1704 node_destroy (child);
1707 node_destroy (root);
1711 start_next_test (
const char *format,
1714 n_iterations_completed_this_test = 0;
1715 n_iterations_expected_this_test = expected;
1717 fprintf (stderr,
">>> >>> ");
1718 fprintf (stderr, format,
1719 n_iterations_expected_this_test);
1723 make_and_run_test_nodes (
void)
1759 start_next_test (
"Each value by itself %d iterations\n", N_VALUES);
1763 while ((node = value_generator (&i)))
1765 run_test_nodes (&node, 1);
1767 node_destroy (node);
1771 start_next_test (
"Each value by itself with arrays as blocks %d iterations\n", N_VALUES);
1772 arrays_write_fixed_in_blocks =
TRUE;
1776 while ((node = value_generator (&i)))
1778 run_test_nodes (&node, 1);
1780 node_destroy (node);
1783 arrays_write_fixed_in_blocks =
FALSE;
1785 start_next_test (
"All values in one big toplevel %d iteration\n", 1);
1787 TestTypeNode *nodes[N_VALUES];
1791 while ((node = value_generator (&i)))
1793 nodes[i - 1] = node;
1796 run_test_nodes (nodes, N_VALUES);
1798 for (i = 0; i < N_VALUES; i++)
1799 node_destroy (nodes[i]);
1802 start_next_test (
"Each value,value pair combination as toplevel, in both orders %d iterations\n",
1803 N_VALUES * N_VALUES);
1805 TestTypeNode *nodes[2];
1808 while ((nodes[0] = value_generator (&i)))
1811 while ((nodes[1] = value_generator (&j)))
1813 run_test_nodes (nodes, 2);
1815 node_destroy (nodes[1]);
1818 node_destroy (nodes[0]);
1822 start_next_test (
"Each container containing each value %d iterations\n",
1823 N_CONTAINERS * N_VALUES);
1824 for (i = 0; i < N_CONTAINERS; i++)
1826 const TestTypeNodeClass *container_klass = container_nodes[i];
1828 make_and_run_values_inside_container (container_klass, 1);
1831 start_next_test (
"Each container containing each value with arrays as blocks %d iterations\n",
1832 N_CONTAINERS * N_VALUES);
1833 arrays_write_fixed_in_blocks =
TRUE;
1834 for (i = 0; i < N_CONTAINERS; i++)
1836 const TestTypeNodeClass *container_klass = container_nodes[i];
1838 make_and_run_values_inside_container (container_klass, 1);
1840 arrays_write_fixed_in_blocks =
FALSE;
1842 start_next_test (
"Each container of same container of each value %d iterations\n",
1843 N_CONTAINERS * N_VALUES);
1844 for (i = 0; i < N_CONTAINERS; i++)
1846 const TestTypeNodeClass *container_klass = container_nodes[i];
1848 make_and_run_values_inside_container (container_klass, 2);
1851 start_next_test (
"Each container of same container of same container of each value %d iterations\n",
1852 N_CONTAINERS * N_VALUES);
1853 for (i = 0; i < N_CONTAINERS; i++)
1855 const TestTypeNodeClass *container_klass = container_nodes[i];
1857 make_and_run_values_inside_container (container_klass, 3);
1860 start_next_test (
"Each value,value pair inside a struct %d iterations\n",
1861 N_VALUES * N_VALUES);
1863 TestTypeNode *val1, *val2;
1866 node = node_new (&struct_1_class);
1869 while ((val1 = value_generator (&i)))
1872 while ((val2 = value_generator (&j)))
1874 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
1876 node_append_child (node, val1);
1877 node_append_child (node, val2);
1879 run_test_nodes (&node, 1);
1882 node_destroy (val2);
1884 node_destroy (val1);
1886 node_destroy (node);
1889 start_next_test (
"All values in one big struct %d iteration\n",
1893 TestTypeNode *child;
1895 node = node_new (&struct_1_class);
1898 while ((child = value_generator (&i)))
1899 node_append_child (node, child);
1901 run_test_nodes (&node, 1);
1903 node_destroy (node);
1906 start_next_test (
"Each value in a large array %d iterations\n",
1912 node = node_new (&array_9_class);
1915 while ((val = value_generator (&i)))
1917 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
1919 node_append_child (node, val);
1921 run_test_nodes (&node, 1);
1927 node_destroy (node);
1933 fprintf (stderr,
"skipping remaining marshal-recursive tests, "
1934 "run with DBUS_TEST_SLOW=1 (or more) to enable\n");
1938 start_next_test (
"Each container of each container of each value %d iterations\n",
1939 N_CONTAINERS * N_CONTAINERS * N_VALUES);
1940 for (i = 0; i < N_CONTAINERS; i++)
1942 const TestTypeNodeClass *outer_container_klass = container_nodes[i];
1943 TestTypeNode *outer_container = node_new (outer_container_klass);
1945 for (j = 0; j < N_CONTAINERS; j++)
1947 TestTypeNode *child;
1948 const TestTypeNodeClass *inner_container_klass = container_nodes[j];
1949 TestTypeNode *inner_container = node_new (inner_container_klass);
1951 node_append_child (outer_container, inner_container);
1954 while ((child = value_generator (&m)))
1956 node_append_child (inner_container, child);
1958 run_test_nodes (&outer_container, 1);
1961 node_destroy (child);
1964 node_destroy (inner_container);
1966 node_destroy (outer_container);
1969 start_next_test (
"Each container of each container of each container of each value %d iterations\n",
1970 N_CONTAINERS * N_CONTAINERS * N_CONTAINERS * N_VALUES);
1971 for (i = 0; i < N_CONTAINERS; i++)
1973 const TestTypeNodeClass *outer_container_klass = container_nodes[i];
1974 TestTypeNode *outer_container = node_new (outer_container_klass);
1976 for (j = 0; j < N_CONTAINERS; j++)
1978 const TestTypeNodeClass *inner_container_klass = container_nodes[j];
1979 TestTypeNode *inner_container = node_new (inner_container_klass);
1981 node_append_child (outer_container, inner_container);
1983 for (k = 0; k < N_CONTAINERS; k++)
1985 TestTypeNode *child;
1986 const TestTypeNodeClass *center_container_klass = container_nodes[k];
1987 TestTypeNode *center_container = node_new (center_container_klass);
1989 node_append_child (inner_container, center_container);
1992 while ((child = value_generator (&m)))
1994 node_append_child (center_container, child);
1996 run_test_nodes (&outer_container, 1);
1999 node_destroy (child);
2002 node_destroy (center_container);
2005 node_destroy (inner_container);
2007 node_destroy (outer_container);
2014 fprintf (stderr,
"skipping really slow marshal-recursive test, "
2015 "run with DBUS_TEST_SLOW=2 (or more) to enable\n");
2019 start_next_test (
"Each value,value,value triplet combination as toplevel, in all orders %d iterations\n",
2020 N_VALUES * N_VALUES * N_VALUES);
2022 TestTypeNode *nodes[3];
2025 while ((nodes[0] = value_generator (&i)))
2028 while ((nodes[1] = value_generator (&j)))
2031 while ((nodes[2] = value_generator (&k)))
2033 run_test_nodes (nodes, 3);
2035 node_destroy (nodes[2]);
2037 node_destroy (nodes[1]);
2039 node_destroy (nodes[0]);
2044 fprintf (stderr,
"%d total iterations of recursive marshaling tests\n",
2045 n_iterations_completed_total);
2046 fprintf (stderr,
"each iteration ran at initial offsets 0 through %d in both big and little endian\n",
2047 MAX_INITIAL_OFFSET);
2048 fprintf (stderr,
"out of memory handling %s tested\n",
2049 TEST_OOM_HANDLING ?
"was" :
"was not");
2053 _dbus_marshal_recursive_test (
void)
2055 make_and_run_test_nodes ();
2068 #define MAX_MULTI_COUNT 5
2070 #define SAMPLE_INT16 1234
2071 #define SAMPLE_INT16_ALTERNATE 6785
2073 int16_from_seed (
int seed)
2088 v = SAMPLE_INT16_ALTERNATE;
2108 int16_write_value (TestTypeNode *node,
2116 v = int16_from_seed (seed);
2119 node->klass->typecode,
2124 int16_read_value (TestTypeNode *node,
2131 check_expected_type (reader, node->klass->typecode);
2142 int16_set_value (TestTypeNode *node,
2150 v = int16_from_seed (seed);
2158 int16_write_multi (TestTypeNode *node,
2169 for (i = 0; i < count; ++i)
2170 values[i] = int16_from_seed (seed + i);
2173 node->klass->typecode,
2174 &v_ARRAY_INT16, count);
2178 int16_read_multi (TestTypeNode *node,
2188 check_expected_type (reader, node->klass->typecode);
2194 if (n_elements != count)
2195 _dbus_warn (
"got %d elements expected %d\n", n_elements, count);
2198 for (i = 0; i < count; i++)
2200 (
const unsigned char*)values + (i * 2))) ==
2201 int16_from_seed (seed + i));
2207 #define SAMPLE_INT32 12345678
2208 #define SAMPLE_INT32_ALTERNATE 53781429
2210 int32_from_seed (
int seed)
2225 v = SAMPLE_INT32_ALTERNATE;
2245 int32_write_value (TestTypeNode *node,
2253 v = int32_from_seed (seed);
2256 node->klass->typecode,
2261 int32_read_value (TestTypeNode *node,
2268 check_expected_type (reader, node->klass->typecode);
2279 int32_set_value (TestTypeNode *node,
2287 v = int32_from_seed (seed);
2295 int32_write_multi (TestTypeNode *node,
2306 for (i = 0; i < count; ++i)
2307 values[i] = int32_from_seed (seed + i);
2310 node->klass->typecode,
2311 &v_ARRAY_INT32, count);
2315 int32_read_multi (TestTypeNode *node,
2325 check_expected_type (reader, node->klass->typecode);
2331 if (n_elements != count)
2332 _dbus_warn (
"got %d elements expected %d\n", n_elements, count);
2335 for (i = 0; i < count; i++)
2337 (
const unsigned char*)values + (i * 4))) ==
2338 int32_from_seed (seed + i));
2343 #ifdef DBUS_HAVE_INT64
2345 int64_from_seed (
int seed)
2350 v32 = int32_from_seed (seed);
2360 int64_write_value (TestTypeNode *node,
2365 #ifdef DBUS_HAVE_INT64
2369 v = int64_from_seed (seed);
2372 node->klass->typecode,
2380 int64_read_value (TestTypeNode *node,
2384 #ifdef DBUS_HAVE_INT64
2388 check_expected_type (reader, node->klass->typecode);
2402 int64_set_value (TestTypeNode *node,
2407 #ifdef DBUS_HAVE_INT64
2411 v = int64_from_seed (seed);
2421 #define MAX_SAMPLE_STRING_LEN 10
2423 string_from_seed (
char *buf,
2447 v = (
unsigned char) (
'A' + seed);
2452 if (v < 'A' || v >
'z')
2465 string_write_value (TestTypeNode *node,
2470 char buf[MAX_SAMPLE_STRING_LEN + 1]=
"";
2471 const char *v_string = buf;
2474 string_from_seed (buf, node->klass->subclass_detail,
2478 node->klass->typecode,
2483 string_read_value (TestTypeNode *node,
2488 char buf[MAX_SAMPLE_STRING_LEN + 1];
2491 check_expected_type (reader, node->klass->typecode);
2494 (
const char **) &v);
2496 string_from_seed (buf, node->klass->subclass_detail,
2499 if (strcmp (buf, v) != 0)
2501 _dbus_warn (
"read string '%s' expected '%s'\n",
2510 string_set_value (TestTypeNode *node,
2515 char buf[MAX_SAMPLE_STRING_LEN + 1];
2516 const char *v_string = buf;
2518 string_from_seed (buf, node->klass->subclass_detail,
2521 #if RECURSIVE_MARSHAL_WRITE_TRACE
2525 _dbus_verbose (
"SETTING new string '%s' len %d in place of '%s' len %d\n",
2526 v_string, strlen (v_string), old, strlen (old));
2535 #define BOOL_FROM_SEED(seed) ((dbus_bool_t)((seed) % 2))
2538 bool_write_value (TestTypeNode *node,
2545 v = BOOL_FROM_SEED (seed);
2548 node->klass->typecode,
2553 bool_read_value (TestTypeNode *node,
2559 check_expected_type (reader, node->klass->typecode);
2562 (
unsigned char*) &v);
2570 bool_set_value (TestTypeNode *node,
2577 v = BOOL_FROM_SEED (seed);
2584 #define BYTE_FROM_SEED(seed) ((unsigned char) int32_from_seed (seed))
2587 byte_write_value (TestTypeNode *node,
2594 v = BYTE_FROM_SEED (seed);
2597 node->klass->typecode,
2602 byte_read_value (TestTypeNode *node,
2608 check_expected_type (reader, node->klass->typecode);
2611 (
unsigned char*) &v);
2620 byte_set_value (TestTypeNode *node,
2627 v = BYTE_FROM_SEED (seed);
2635 double_from_seed (
int seed)
2637 return SAMPLE_INT32 * (double) seed + 0.3;
2641 double_write_value (TestTypeNode *node,
2648 v = double_from_seed (seed);
2651 node->klass->typecode,
2656 double_read_value (TestTypeNode *node,
2663 check_expected_type (reader, node->klass->typecode);
2668 expected = double_from_seed (seed);
2672 #ifdef DBUS_INT64_PRINTF_MODIFIER
2673 _dbus_warn (
"Expected double %g got %g\n bits = 0x%" DBUS_INT64_PRINTF_MODIFIER
"x vs.\n bits = 0x%" DBUS_INT64_PRINTF_MODIFIER
"x)\n",
2685 double_set_value (TestTypeNode *node,
2692 v = double_from_seed (seed);
2699 #define MAX_SAMPLE_OBJECT_PATH_LEN 10
2701 object_path_from_seed (
char *buf,
2711 v = (
unsigned char) (
'A' + seed);
2723 if (v < 'A' || v >
'z')
2739 object_path_write_value (TestTypeNode *node,
2744 char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
2745 const char *v_string = buf;
2747 object_path_from_seed (buf, seed);
2750 node->klass->typecode,
2755 object_path_read_value (TestTypeNode *node,
2760 char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
2762 check_expected_type (reader, node->klass->typecode);
2765 (
const char **) &v);
2767 object_path_from_seed (buf, seed);
2769 if (strcmp (buf, v) != 0)
2771 _dbus_warn (
"read object path '%s' expected '%s'\n",
2780 object_path_set_value (TestTypeNode *node,
2785 char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
2786 const char *v_string = buf;
2788 object_path_from_seed (buf, seed);
2795 #define MAX_SAMPLE_SIGNATURE_LEN 10
2797 signature_from_seed (
char *buf,
2801 const char *sample_signatures[] = {
2810 strcpy (buf, sample_signatures[seed %
_DBUS_N_ELEMENTS(sample_signatures)]);
2814 signature_write_value (TestTypeNode *node,
2819 char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
2820 const char *v_string = buf;
2822 signature_from_seed (buf, seed);
2825 node->klass->typecode,
2830 signature_read_value (TestTypeNode *node,
2835 char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
2837 check_expected_type (reader, node->klass->typecode);
2840 (
const char **) &v);
2842 signature_from_seed (buf, seed);
2844 if (strcmp (buf, v) != 0)
2846 _dbus_warn (
"read signature value '%s' expected '%s'\n",
2856 signature_set_value (TestTypeNode *node,
2861 char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
2862 const char *v_string = buf;
2864 signature_from_seed (buf, seed);
2872 struct_write_value (TestTypeNode *node,
2877 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
2878 DataBlockState saved;
2883 n_copies = node->klass->subclass_detail;
2887 data_block_save (block, &saved);
2895 while (i < n_copies)
2900 while (link !=
NULL)
2902 TestTypeNode *child = link->
data;
2905 if (!node_write_value (child, block, &sub, seed + i))
2907 data_block_restore (block, &saved);
2919 data_block_restore (block, &saved);
2927 struct_read_or_set_value (TestTypeNode *node,
2932 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
2937 n_copies = node->klass->subclass_detail;
2944 while (i < n_copies)
2949 while (link !=
NULL)
2951 TestTypeNode *child = link->
data;
2954 if (realign_root ==
NULL)
2956 if (!node_read_value (child, &sub, seed + i))
2961 if (!node_set_value (child, &sub, realign_root, seed + i))
2965 if (i == (n_copies - 1) && next ==
NULL)
2966 NEXT_EXPECTING_FALSE (&sub);
2968 NEXT_EXPECTING_TRUE (&sub);
2980 struct_read_value (TestTypeNode *node,
2984 return struct_read_or_set_value (node, reader,
NULL, seed);
2988 struct_set_value (TestTypeNode *node,
2993 return struct_read_or_set_value (node, reader, realign_root, seed);
2997 struct_build_signature (TestTypeNode *node,
3000 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3005 n_copies = node->klass->subclass_detail;
3013 while (i < n_copies)
3018 while (link !=
NULL)
3020 TestTypeNode *child = link->
data;
3023 if (!node_build_signature (child, str))
3043 array_write_value (TestTypeNode *node,
3048 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3049 DataBlockState saved;
3055 TestTypeNode *child;
3057 n_copies = node->klass->subclass_detail;
3061 data_block_save (block, &saved);
3068 if (!node_build_signature (child,
3069 &element_signature))
3075 &element_signature, 0,
3079 if (arrays_write_fixed_in_blocks &&
3081 child->klass->write_multi)
3083 if (!node_write_multi (child, block, &sub, seed, n_copies))
3089 while (i < n_copies)
3094 while (link !=
NULL)
3096 TestTypeNode *child = link->
data;
3099 if (!node_write_value (child, block, &sub, seed + i))
3116 data_block_restore (block, &saved);
3122 array_read_or_set_value (TestTypeNode *node,
3127 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3131 TestTypeNode *child;
3133 n_copies = node->klass->subclass_detail;
3143 if (realign_root ==
NULL && arrays_write_fixed_in_blocks &&
3145 child->klass->read_multi)
3147 if (!node_read_multi (child, &sub, seed, n_copies))
3153 while (i < n_copies)
3158 while (link !=
NULL)
3160 TestTypeNode *child = link->
data;
3166 if (realign_root ==
NULL)
3168 if (!node_read_value (child, &sub, seed + i))
3173 if (!node_set_value (child, &sub, realign_root, seed + i))
3177 if (i == (n_copies - 1) && next ==
NULL)
3178 NEXT_EXPECTING_FALSE (&sub);
3180 NEXT_EXPECTING_TRUE (&sub);
3194 array_read_value (TestTypeNode *node,
3198 return array_read_or_set_value (node, reader,
NULL, seed);
3202 array_set_value (TestTypeNode *node,
3207 return array_read_or_set_value (node, reader, realign_root, seed);
3211 array_build_signature (TestTypeNode *node,
3214 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3234 #define VARIANT_SEED 10
3237 variant_write_value (TestTypeNode *node,
3242 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3243 DataBlockState saved;
3246 TestTypeNode *child;
3253 data_block_save (block, &saved);
3258 if (!node_build_signature (child,
3259 &content_signature))
3263 &content_signature, 0,
3267 if (!node_write_value (child, block, &sub, seed + VARIANT_SEED))
3277 data_block_restore (block, &saved);
3283 variant_read_or_set_value (TestTypeNode *node,
3288 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3290 TestTypeNode *child;
3301 if (realign_root ==
NULL)
3303 if (!node_read_value (child, &sub, seed + VARIANT_SEED))
3308 if (!node_set_value (child, &sub, realign_root, seed + VARIANT_SEED))
3312 NEXT_EXPECTING_FALSE (&sub);
3318 variant_read_value (TestTypeNode *node,
3322 return variant_read_or_set_value (node, reader,
NULL, seed);
3326 variant_set_value (TestTypeNode *node,
3331 return variant_read_or_set_value (node, reader, realign_root, seed);
3335 dict_write_value (TestTypeNode *node,
3340 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3341 DataBlockState saved;
3347 TestTypeNode *child;
3349 n_entries = node->klass->subclass_detail;
3353 data_block_save (block, &saved);
3366 if (!node_build_signature (child,
3367 &entry_value_signature))
3376 &dict_entry_signature,
3385 &dict_entry_signature, 0,
3390 while (i < n_entries)
3400 key = int32_from_seed (seed + i);
3407 if (!node_write_value (child, block, &entry_sub, seed + i))
3424 data_block_restore (block, &saved);
3431 dict_read_or_set_value (TestTypeNode *node,
3436 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3440 TestTypeNode *child;
3442 n_entries = node->klass->subclass_detail;
3455 while (i < n_entries)
3463 if (realign_root ==
NULL)
3474 NEXT_EXPECTING_TRUE (&entry_sub);
3476 if (!node_read_value (child, &entry_sub, seed + i))
3479 NEXT_EXPECTING_FALSE (&entry_sub);
3485 v = int32_from_seed (seed + i);
3492 NEXT_EXPECTING_TRUE (&entry_sub);
3494 if (!node_set_value (child, &entry_sub, realign_root, seed + i))
3497 NEXT_EXPECTING_FALSE (&entry_sub);
3500 if (i == (n_entries - 1))
3501 NEXT_EXPECTING_FALSE (&sub);
3503 NEXT_EXPECTING_TRUE (&sub);
3513 dict_read_value (TestTypeNode *node,
3517 return dict_read_or_set_value (node, reader,
NULL, seed);
3521 dict_set_value (TestTypeNode *node,
3526 return dict_read_or_set_value (node, reader, realign_root, seed);
3530 dict_build_signature (TestTypeNode *node,
3533 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3559 container_destroy (TestTypeNode *node)
3561 TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
3565 while (link !=
NULL)
3567 TestTypeNode *child = link->
data;
3570 node_destroy (child);
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_insert_bytes(DBusString *str, int i, int n_bytes, unsigned char byte)
Inserts a number of bytes of a given value at the given position.
void _dbus_type_reader_read_fixed_multi(const DBusTypeReader *reader, void *value, int *n_elements)
Reads a block of fixed-length basic values, from the current point in an array to the end of the arra...
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
#define DBUS_TYPE_UINT16
Type code marking a 16-bit unsigned integer.
#define NULL
A null pointer, defined appropriately for C or C++.
dbus_bool_t _dbus_string_equal(const DBusString *a, const DBusString *b)
Tests two DBusString for equality.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
int _dbus_first_type_in_signature(const DBusString *str, int pos)
Get the first type in the signature.
The type writer is an iterator for writing to a block of values.
dbus_bool_t _dbus_list_length_is_one(DBusList **list)
Check whether length is exactly one.
void _dbus_type_reader_recurse(DBusTypeReader *reader, DBusTypeReader *sub)
Initialize a new reader pointing to the first type and corresponding value that's a child of the curr...
DBus8ByteStruct eight
as 8-byte struct
#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.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
void * data
Data stored at this element.
#define DBUS_TYPE_BYTE
Type code marking an 8-bit unsigned integer.
dbus_bool_t _dbus_type_writer_write_basic(DBusTypeWriter *writer, int type, const void *value)
Writes out a basic type.
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_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.
dbus_bool_t _dbus_string_ends_with_c_str(const DBusString *a, const char *c_str)
Returns whether a string ends with the given suffix.
void * _dbus_list_get_first(DBusList **list)
Gets the first data in the list.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
#define _DBUS_INT_MAX
Maximum value of type "int".
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
#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.
dbus_bool_t _dbus_type_reader_delete(DBusTypeReader *reader, const DBusTypeReader *realign_root)
Recursively deletes any value pointed to by the reader, leaving the reader valid to continue reading...
void _dbus_type_writer_init_values_only(DBusTypeWriter *writer, int byte_order, const DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing sign...
dbus_bool_t _dbus_type_reader_set_basic(DBusTypeReader *reader, const void *value, const DBusTypeReader *realign_root)
Sets a new value for the basic type value pointed to by the reader, leaving the reader valid to conti...
dbus_uint32_t first32
first 32 bits in the 8 bytes (beware endian issues)
dbus_bool_t _dbus_type_writer_unrecurse(DBusTypeWriter *writer, DBusTypeWriter *sub)
Closes a container created by _dbus_type_writer_recurse() and writes any additional information to th...
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_type_reader_read_basic(const DBusTypeReader *reader, void *value)
Reads a basic-typed value, as with _dbus_marshal_read_basic().
_DBUS_GNUC_EXTENSION typedef unsigned long long dbus_uint64_t
A 64-bit unsigned integer on all platforms that support it.
#define DBUS_TYPE_INT32_AS_STRING
DBUS_TYPE_INT32 as a string literal instead of a int literal
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.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
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.
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
dbus_bool_t _dbus_type_reader_next(DBusTypeReader *reader)
Skip to the next value on this "level".
dbus_uint32_t second32
second 32 bits in the 8 bytes (beware endian issues)
_DBUS_GNUC_EXTENSION typedef long long dbus_int64_t
A 64-bit signed integer on all platforms that support it.
#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_N_ELEMENTS(array)
Computes the number of elements in a fixed-size array using sizeof().
#define DBUS_TYPE_UINT32
Type code marking a 32-bit unsigned integer.
dbus_uint32_t byte_order
byte order of the block
dbus_bool_t _dbus_string_insert_byte(DBusString *str, int i, unsigned char byte)
Inserts a single byte at the given position.
short dbus_int16_t
A 16-bit signed integer on all platforms.
dbus_bool_t _dbus_string_append_byte(DBusString *str, unsigned char byte)
Appends a single byte to the string, returning FALSE if not enough memory.
dbus_uint32_t byte_order
byte order to write values with
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
The type reader is an iterator for reading values from a block of values.
#define TRUE
Expands to "1".
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#define DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
DBUS_DICT_ENTRY_BEGIN_CHAR as a string literal instead of a int literal
void _dbus_list_free_link(DBusList *link)
Frees a linked list node allocated with _dbus_list_alloc_link.
#define DBUS_TYPE_OBJECT_PATH
Type code marking a D-Bus object path.
dbus_bool_t _dbus_type_writer_write_reader(DBusTypeWriter *writer, DBusTypeReader *reader)
Iterate through all values in the given reader, writing a copy of each value to the writer...
#define DBUS_TYPE_INVALID
Type code that is never equal to a legitimate type code.
void _dbus_type_reader_init(DBusTypeReader *reader, int byte_order, const DBusString *type_str, int type_pos, const DBusString *value_str, int value_pos)
Initializes a type reader.
union DBusTypeReader::@1 u
class-specific data
const char * _dbus_string_get_const_data_len(const DBusString *str, int start, int len)
const version of _dbus_string_get_data_len().
#define DBUS_TYPE_INT16
Type code marking a 16-bit signed integer.
#define DBUS_TYPE_BOOLEAN
Type code marking a boolean.
int _dbus_type_reader_get_element_type(const DBusTypeReader *reader)
Gets the type of an element of the array the reader is currently pointing to.
void _dbus_type_writer_init(DBusTypeWriter *writer, int byte_order, DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
Initialize a write iterator, which is used to write out values in serialized D-Bus format...
A simple value union that lets you access bytes as if they were various types; useful when dealing wi...
dbus_bool_t _dbus_string_validate_nul(const DBusString *str, int start, int len)
Checks that the given range of the string is all nul bytes.
int _dbus_type_reader_get_current_type(const DBusTypeReader *reader)
Gets the type of the value the reader is currently pointing to; or for a types-only reader gets the t...
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
#define FALSE
Expands 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.
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_malloc0(size_t bytes)
Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero...
dbus_bool_t _dbus_type_writer_write_fixed_multi(DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
Writes a block of fixed-length basic values, i.e.
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_int32_t
A 32-bit signed integer on all platforms.
#define _DBUS_INT16_MAX
Maximum value of type "int16".
int value_pos
current position in values
const char * _dbus_string_get_const_data(const DBusString *str)
Gets the raw character buffer from a const string.
dbus_bool_t _dbus_type_writer_recurse(DBusTypeWriter *writer, int container_type, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
Opens a new container and writes out the initial information for that container.
#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...
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
#define DBUS_LITTLE_ENDIAN
Code marking LSB-first byte order in the wire protocol.