26 #ifdef DBUS_ENABLE_EMBEDDED_TESTS    28 #include "dbus-marshal-recursive.h"    29 #include "dbus-marshal-basic.h"    30 #include "dbus-signature.h"    31 #include "dbus-internals.h"    34 #if !defined(PRIx64) && defined(DBUS_WIN)    39 #define RECURSIVE_MARSHAL_WRITE_TRACE 0    48 basic_value_equal (
int             type,
    56       return strcmp (lhs->
str, rhs->
str) == 0;
    60       return lhs->
u64 == rhs->
u64;
    74   if (lhs_type != rhs_type)
    85       basic_value_zero (&lhs_value);
    86       basic_value_zero (&rhs_value);
    91       return basic_value_equal (lhs_type, &lhs_value, &rhs_value);
   101       return equal_values_helper (&lhs_sub, &rhs_sub);
   119   return equal_values_helper (©_lhs, ©_rhs);
   124 #ifndef DOXYGEN_SHOULD_SKIP_THIS   126 #include "dbus-test.h"   127 #include "dbus-list.h"   132 #define TEST_OOM_HANDLING 0   136 #define MAX_INITIAL_OFFSET 9   142 #define MAX_ITERATIONS_FOR_EXPENSIVE_TESTS 1000   158 #define N_FENCE_BYTES 5   159 #define FENCE_BYTES_STR "abcde"   160 #define INITIAL_PADDING_BYTE '\0'   163 data_block_init (DataBlock *block,
   177                                   INITIAL_PADDING_BYTE) ||
   179                                   INITIAL_PADDING_BYTE) ||
   188   block->byte_order = byte_order;
   189   block->initial_offset = initial_offset;
   195 data_block_save (DataBlock      *block,
   196                  DataBlockState *state)
   198   state->saved_sig_len = _dbus_string_get_length (&block->signature) - N_FENCE_BYTES;
   199   state->saved_body_len = _dbus_string_get_length (&block->body) - N_FENCE_BYTES;
   203 data_block_restore (DataBlock      *block,
   204                     DataBlockState *state)
   207                        state->saved_sig_len,
   208                        _dbus_string_get_length (&block->signature) - state->saved_sig_len - N_FENCE_BYTES);
   210                        state->saved_body_len,
   211                        _dbus_string_get_length (&block->body) - state->saved_body_len - N_FENCE_BYTES);
   215 data_block_verify (DataBlock *block)
   222       offset = _dbus_string_get_length (&block->signature) - N_FENCE_BYTES - 8;
   228                                      _dbus_string_get_length (&block->signature) - offset);
   236       offset = _dbus_string_get_length (&block->body) - N_FENCE_BYTES - 8;
   242                                      _dbus_string_get_length (&block->body) - offset);
   247                                            0, block->initial_offset));
   249                                            0, block->initial_offset));
   253 data_block_free (DataBlock *block)
   255   data_block_verify (block);
   262 data_block_reset (DataBlock *block)
   264   data_block_verify (block);
   267                        block->initial_offset,
   268                        _dbus_string_get_length (&block->signature) - N_FENCE_BYTES - block->initial_offset);
   270                        block->initial_offset,
   271                        _dbus_string_get_length (&block->body) - N_FENCE_BYTES - block->initial_offset);
   273   data_block_verify (block);
   277 data_block_init_reader_writer (DataBlock      *block,
   285                             block->initial_offset,
   287                             block->initial_offset);
   293                             _dbus_string_get_length (&block->signature) - N_FENCE_BYTES,
   295                             _dbus_string_get_length (&block->body) - N_FENCE_BYTES);
   301                           const char     *funcname,
   310       _dbus_warn (
"Read type %s while expecting %s at %s line %d",
   319 #define check_expected_type(reader, expected) real_check_expected_type (reader, expected, _DBUS_FUNCTION_NAME, __LINE__)   321 #define NEXT_EXPECTING_TRUE(reader)  do { if (!_dbus_type_reader_next (reader))         \   323     _dbus_warn ("_dbus_type_reader_next() should have returned TRUE at %s %d",          \   324                               _DBUS_FUNCTION_NAME, __LINE__);                           \   325     _dbus_assert_not_reached ("test failed");                                           \   329 #define NEXT_EXPECTING_FALSE(reader) do { if (_dbus_type_reader_next (reader))          \   331     _dbus_warn ("_dbus_type_reader_next() should have returned FALSE at %s %d",         \   332                               _DBUS_FUNCTION_NAME, __LINE__);                           \   333     _dbus_assert_not_reached ("test failed");                                           \   335  check_expected_type (reader, DBUS_TYPE_INVALID);                                       \   338 typedef struct TestTypeNode               TestTypeNode;
   339 typedef struct TestTypeNodeClass          TestTypeNodeClass;
   340 typedef struct TestTypeNodeContainer      TestTypeNodeContainer;
   341 typedef struct TestTypeNodeContainerClass TestTypeNodeContainerClass;
   345   const TestTypeNodeClass *klass;
   348 struct TestTypeNodeContainer
   354 struct TestTypeNodeClass
   363   void          (* destroy)       (TestTypeNode   *node);
   376   dbus_bool_t (* build_signature) (TestTypeNode   *node,
   389 struct TestTypeNodeContainerClass
   391   TestTypeNodeClass base;
   399 static dbus_bool_t int16_write_value       (TestTypeNode   *node,
   403 static dbus_bool_t int16_read_value        (TestTypeNode   *node,
   406 static dbus_bool_t int16_set_value         (TestTypeNode   *node,
   410 static dbus_bool_t int16_write_multi       (TestTypeNode   *node,
   415 static dbus_bool_t int16_read_multi        (TestTypeNode   *node,
   419 static dbus_bool_t int32_write_value       (TestTypeNode   *node,
   423 static dbus_bool_t int32_read_value        (TestTypeNode   *node,
   426 static dbus_bool_t int32_set_value         (TestTypeNode   *node,
   430 static dbus_bool_t int32_write_multi       (TestTypeNode   *node,
   435 static dbus_bool_t int32_read_multi        (TestTypeNode   *node,
   439 static dbus_bool_t int64_write_value       (TestTypeNode   *node,
   443 static dbus_bool_t int64_read_value        (TestTypeNode   *node,
   446 static dbus_bool_t int64_set_value         (TestTypeNode   *node,
   450 static dbus_bool_t string_write_value      (TestTypeNode   *node,
   454 static dbus_bool_t string_read_value       (TestTypeNode   *node,
   457 static dbus_bool_t string_set_value        (TestTypeNode   *node,
   461 static dbus_bool_t bool_write_value        (TestTypeNode   *node,
   465 static dbus_bool_t bool_read_value         (TestTypeNode   *node,
   468 static dbus_bool_t bool_set_value          (TestTypeNode   *node,
   472 static dbus_bool_t byte_write_value        (TestTypeNode   *node,
   476 static dbus_bool_t byte_read_value         (TestTypeNode   *node,
   479 static dbus_bool_t byte_set_value          (TestTypeNode   *node,
   483 static dbus_bool_t double_write_value      (TestTypeNode   *node,
   487 static dbus_bool_t double_read_value       (TestTypeNode   *node,
   490 static dbus_bool_t double_set_value        (TestTypeNode   *node,
   494 static dbus_bool_t object_path_write_value (TestTypeNode   *node,
   498 static dbus_bool_t object_path_read_value  (TestTypeNode   *node,
   501 static dbus_bool_t object_path_set_value   (TestTypeNode   *node,
   505 static dbus_bool_t signature_write_value   (TestTypeNode   *node,
   509 static dbus_bool_t signature_read_value    (TestTypeNode   *node,
   512 static dbus_bool_t signature_set_value     (TestTypeNode   *node,
   516 static dbus_bool_t struct_write_value      (TestTypeNode   *node,
   520 static dbus_bool_t struct_read_value       (TestTypeNode   *node,
   523 static dbus_bool_t struct_set_value        (TestTypeNode   *node,
   527 static dbus_bool_t struct_build_signature  (TestTypeNode   *node,
   529 static dbus_bool_t dict_write_value        (TestTypeNode   *node,
   533 static dbus_bool_t dict_read_value         (TestTypeNode   *node,
   536 static dbus_bool_t dict_set_value          (TestTypeNode   *node,
   540 static dbus_bool_t dict_build_signature    (TestTypeNode   *node,
   542 static dbus_bool_t array_write_value       (TestTypeNode   *node,
   546 static dbus_bool_t array_read_value        (TestTypeNode   *node,
   549 static dbus_bool_t array_set_value         (TestTypeNode   *node,
   553 static dbus_bool_t array_build_signature   (TestTypeNode   *node,
   555 static dbus_bool_t variant_write_value     (TestTypeNode   *node,
   559 static dbus_bool_t variant_read_value      (TestTypeNode   *node,
   562 static dbus_bool_t variant_set_value       (TestTypeNode   *node,
   566 static void        container_destroy       (TestTypeNode   *node);
   570 static const TestTypeNodeClass int16_class = {
   572   sizeof (TestTypeNode),
   584 static const TestTypeNodeClass uint16_class = {
   586   sizeof (TestTypeNode),
   598 static const TestTypeNodeClass int32_class = {
   600   sizeof (TestTypeNode),
   612 static const TestTypeNodeClass uint32_class = {
   614   sizeof (TestTypeNode),
   626 static const TestTypeNodeClass int64_class = {
   628   sizeof (TestTypeNode),
   640 static const TestTypeNodeClass uint64_class = {
   642   sizeof (TestTypeNode),
   654 static const TestTypeNodeClass string_0_class = {
   656   sizeof (TestTypeNode),
   668 static const TestTypeNodeClass string_1_class = {
   670   sizeof (TestTypeNode),
   683 static const TestTypeNodeClass string_3_class = {
   685   sizeof (TestTypeNode),
   698 static const TestTypeNodeClass string_8_class = {
   700   sizeof (TestTypeNode),
   712 static const TestTypeNodeClass bool_class = {
   714   sizeof (TestTypeNode),
   726 static const TestTypeNodeClass byte_class = {
   728   sizeof (TestTypeNode),
   740 static const TestTypeNodeClass double_class = {
   742   sizeof (TestTypeNode),
   754 static const TestTypeNodeClass object_path_class = {
   756   sizeof (TestTypeNode),
   760   object_path_write_value,
   761   object_path_read_value,
   762   object_path_set_value,
   768 static const TestTypeNodeClass signature_class = {
   770   sizeof (TestTypeNode),
   774   signature_write_value,
   775   signature_read_value,
   782 static const TestTypeNodeClass struct_1_class = {
   784   sizeof (TestTypeNodeContainer),
   791   struct_build_signature,
   796 static const TestTypeNodeClass struct_2_class = {
   798   sizeof (TestTypeNodeContainer),
   805   struct_build_signature,
   810 static const TestTypeNodeClass dict_1_class = {
   812   sizeof (TestTypeNodeContainer),
   819   dict_build_signature,
   826 static const TestTypeNodeClass array_0_class = {
   828   sizeof (TestTypeNodeContainer),
   835   array_build_signature,
   840 static const TestTypeNodeClass array_1_class = {
   842   sizeof (TestTypeNodeContainer),
   849   array_build_signature,
   854 static const TestTypeNodeClass array_2_class = {
   856   sizeof (TestTypeNodeContainer),
   863   array_build_signature,
   868 static const TestTypeNodeClass array_9_class = {
   870   sizeof (TestTypeNodeContainer),
   877   array_build_signature,
   882 static const TestTypeNodeClass variant_class = {
   884   sizeof (TestTypeNodeContainer),
   896 static const TestTypeNodeClass* 
const   914 #define N_BASICS (_DBUS_N_ELEMENTS (basic_nodes))   916 static const TestTypeNodeClass* 
const   917 container_nodes[] = {
   929 #define N_CONTAINERS (_DBUS_N_ELEMENTS (container_nodes))   932 node_new (
const TestTypeNodeClass *klass)
   942   if (klass->construct)
   944       if (!(* klass->construct) (node))
   955 node_destroy (TestTypeNode *node)
   957   if (node->klass->destroy)
   958     (* node->klass->destroy) (node);
   963 node_write_value (TestTypeNode   *node,
   970   retval = (* node->klass->write_value) (node, block, writer, seed);
   974   data_block_verify (block);
   981 node_read_value (TestTypeNode   *node,
   987   if (!(* node->klass->read_value) (node, reader, seed))
   998 node_set_value (TestTypeNode   *node,
  1003   if (!(* node->klass->set_value) (node, reader, realign_root, seed))
  1010 node_build_signature (TestTypeNode *node,
  1013   if (node->klass->build_signature)
  1014     return (* node->klass->build_signature) (node, str);
  1020 node_append_child (TestTypeNode *node,
  1021                    TestTypeNode *child)
  1023   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1025   _dbus_assert (node->klass->instance_size >= (
int) sizeof (TestTypeNodeContainer));
  1034 node_write_multi (TestTypeNode   *node,
  1043   retval = (* node->klass->write_multi) (node, block, writer, seed, n_copies);
  1047   data_block_verify (block);
  1054 node_read_multi (TestTypeNode   *node,
  1061   if (!(* node->klass->read_multi) (node, reader, seed, n_copies))
  1067 static int n_iterations_completed_total = 0;
  1068 static int n_iterations_completed_this_test = 0;
  1069 static int n_iterations_expected_this_test = 0;
  1076   TestTypeNode      **nodes;
  1078 } NodeIterationData;
  1081 run_test_copy (NodeIterationData *nid)
  1089   _dbus_verbose (
"\n");
  1095   if (!data_block_init (&dest, src->byte_order, src->initial_offset))
  1098   data_block_init_reader_writer (src, &reader, 
NULL);
  1099   data_block_init_reader_writer (&dest, 
NULL, &writer);
  1105                                  dest.initial_offset, 
'\0'))
  1114       _dbus_verbose (
"SOURCE\n");
  1116                                      _dbus_string_get_length (&src->signature));
  1117       _dbus_verbose (
"DEST\n");
  1119                                      _dbus_string_get_length (&dest.signature));
  1125       _dbus_verbose (
"SOURCE\n");
  1127                                      _dbus_string_get_length (&src->body));
  1128       _dbus_verbose (
"DEST\n");
  1130                                      _dbus_string_get_length (&dest.body));
  1138   data_block_free (&dest);
  1144 run_test_values_only_write (NodeIterationData *nid)
  1152   _dbus_verbose (
"\n");
  1156   data_block_reset (nid->block);
  1158   sig_len = _dbus_string_get_length (nid->signature);
  1161                                       nid->block->byte_order,
  1164                                       _dbus_string_get_length (&nid->block->body) - N_FENCE_BYTES);
  1166                           nid->block->byte_order,
  1169                           nid->block->initial_offset);
  1172   while (i < nid->n_nodes)
  1174       if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
  1181   _dbus_assert (sig_len == _dbus_string_get_length (nid->signature));
  1185   while (i < nid->n_nodes)
  1187       if (!node_read_value (nid->nodes[i], &reader, i))
  1190       if (i + 1 == nid->n_nodes)
  1191         NEXT_EXPECTING_FALSE (&reader);
  1193         NEXT_EXPECTING_TRUE (&reader);
  1201   data_block_reset (nid->block);
  1213 run_test_set_values (NodeIterationData *nid)
  1220   _dbus_verbose (
"\n");
  1224   data_block_init_reader_writer (nid->block,
  1227   realign_root = reader;
  1230   while (i < nid->n_nodes)
  1232       if (!node_set_value (nid->nodes[i],
  1233                            &reader, &realign_root,
  1237       if (i + 1 == nid->n_nodes)
  1238         NEXT_EXPECTING_FALSE (&reader);
  1240         NEXT_EXPECTING_TRUE (&reader);
  1247   reader = realign_root;
  1250   while (i < nid->n_nodes)
  1252       if (!node_read_value (nid->nodes[i], &reader,
  1256       if (i + 1 == nid->n_nodes)
  1257         NEXT_EXPECTING_FALSE (&reader);
  1259         NEXT_EXPECTING_TRUE (&reader);
  1271 run_test_delete_values (NodeIterationData *nid)
  1277   _dbus_verbose (
"\n");
  1281   data_block_init_reader_writer (nid->block,
  1306           _dbus_verbose (
"recursing into deletion loop reader.value_pos = %d array.value_pos = %d array.u.start_pos = %d\n",
  1311               static int cycle = 0;
  1317               if (elem == 3 || elem >= n_elements) 
  1318                 elem = n_elements - 1;
  1320               _dbus_verbose (
"deleting array element %d of %d type %s cycle %d reader pos %d elem pos %d\n",
  1348   data_block_init_reader_writer (nid->block,
  1363 run_test_nodes_iteration (
void *data)
  1365   NodeIterationData *nid = data;
  1379   data_block_init_reader_writer (nid->block,
  1386                                  nid->type_offset, 
'\0'))
  1390   while (i < nid->n_nodes)
  1392       if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
  1399                                      &nid->block->signature, nid->type_offset))
  1401       _dbus_warn (
"Expected signature '%s' and got '%s' with initial offset %d",
  1402                   _dbus_string_get_const_data (nid->signature),
  1403                   _dbus_string_get_const_data_len (&nid->block->signature, nid->type_offset, 0),
  1409   while (i < nid->n_nodes)
  1411       if (!node_read_value (nid->nodes[i], &reader, i))
  1414       if (i + 1 == nid->n_nodes)
  1415         NEXT_EXPECTING_FALSE (&reader);
  1417         NEXT_EXPECTING_TRUE (&reader);
  1422   if (n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
  1431       if (!run_test_set_values (nid))
  1434       if (!run_test_delete_values (nid))
  1437       if (!run_test_copy (nid))
  1440       if (!run_test_values_only_write (nid))
  1452   data_block_reset (nid->block);
  1458 run_test_nodes_in_one_configuration (TestTypeNode    **nodes,
  1465   NodeIterationData nid;
  1467   if (!data_block_init (&block, byte_order, initial_offset))
  1470   nid.signature = signature;
  1472   nid.type_offset = initial_offset;
  1474   nid.n_nodes = n_nodes;
  1476   if (TEST_OOM_HANDLING &&
  1477       n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
  1479       _dbus_test_oom_handling (
"running test node",
  1480                                run_test_nodes_iteration,
  1485       if (!run_test_nodes_iteration (&nid))
  1489   data_block_free (&block);
  1493 run_test_nodes (TestTypeNode **nodes,
  1505       if (! node_build_signature (nodes[i], &signature))
  1511   _dbus_verbose (
">>> test nodes with signature '%s'\n",
  1512                  _dbus_string_get_const_data (&signature));
  1515   while (i <= MAX_INITIAL_OFFSET)
  1517       run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
  1519       run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
  1525   n_iterations_completed_this_test += 1;
  1526   n_iterations_completed_total += 1;
  1528   if (n_iterations_completed_this_test == n_iterations_expected_this_test)
  1530       fprintf (stderr, 
" 100%% %d this test (%d cumulative)\n",
  1531                n_iterations_completed_this_test,
  1532                n_iterations_completed_total);
  1535   else if ((n_iterations_completed_this_test %
  1536             (
int)(n_iterations_expected_this_test / 10.0)) == 1)
  1538       fprintf (stderr, 
" %d%% ", (
int) (n_iterations_completed_this_test / (
double) n_iterations_expected_this_test * 100));
  1544 #define N_VALUES (N_BASICS * N_CONTAINERS + N_BASICS)  1546 static TestTypeNode*
  1547 value_generator (
int *ip)
  1550   const TestTypeNodeClass *child_klass;
  1551   const TestTypeNodeClass *container_klass;
  1552   TestTypeNode *child;
  1561   else if (i < N_BASICS)
  1563       node = node_new (basic_nodes[i]);
  1577       container_klass = container_nodes[i / N_BASICS];
  1578       child_klass = basic_nodes[i % N_BASICS];
  1580       node = node_new (container_klass);
  1581       child = node_new (child_klass);
  1583       node_append_child (node, child);
  1592 build_body (TestTypeNode **nodes,
  1606       if (! node_build_signature (nodes[i], signature))
  1612   if (!data_block_init (&block, byte_order, 0))
  1615   data_block_init_reader_writer (&block,
  1628       if (!node_write_value (nodes[i], &block, &writer, i))
  1635                               _dbus_string_get_length (&block.body) - N_FENCE_BYTES,
  1639   data_block_free (&block);  
  1643 dbus_internal_do_not_use_generate_bodies (
int           sequence,
  1648   TestTypeNode *nodes[1];
  1652   nodes[0] = value_generator (&sequence);
  1654   if (nodes[0] == 
NULL)
  1659   build_body (nodes, n_nodes, byte_order, signature, body);
  1665       node_destroy (nodes[i]);
  1673 make_and_run_values_inside_container (
const TestTypeNodeClass *container_klass,
  1677   TestTypeNode *container;
  1678   TestTypeNode *child;
  1681   root = node_new (container_klass);
  1683   for (i = 1; i < n_nested; i++)
  1685       child = node_new (container_klass);
  1686       node_append_child (container, child);
  1693   while ((child = value_generator (&i)))
  1695       node_append_child (container, child);
  1697       run_test_nodes (&root, 1);
  1700       node_destroy (child);
  1703   node_destroy (root);
  1707 start_next_test (
const char *description,
  1710   n_iterations_completed_this_test = 0;
  1711   n_iterations_expected_this_test = expected;
  1713   fprintf (stderr, 
">>> >>> %s %d iterations\n",
  1715            n_iterations_expected_this_test);
  1719 make_and_run_test_nodes (
void)
  1755   start_next_test (
"Each value by itself", N_VALUES);
  1759     while ((node = value_generator (&i)))
  1761         run_test_nodes (&node, 1);
  1763         node_destroy (node);
  1767   start_next_test (
"Each value by itself with arrays as blocks", N_VALUES);
  1768   arrays_write_fixed_in_blocks = 
TRUE;
  1772     while ((node = value_generator (&i)))
  1774         run_test_nodes (&node, 1);
  1776         node_destroy (node);
  1779   arrays_write_fixed_in_blocks = 
FALSE;
  1781   start_next_test (
"All values in one big toplevel", 1);
  1783     TestTypeNode *nodes[N_VALUES];
  1787     while ((node = value_generator (&i)))
  1789         nodes[i - 1] = node;
  1792     run_test_nodes (nodes, N_VALUES);
  1794     for (i = 0; i < N_VALUES; i++)
  1795       node_destroy (nodes[i]);
  1798   start_next_test (
"Each value,value pair combination as toplevel, in both orders",
  1799                    N_VALUES * N_VALUES);
  1801     TestTypeNode *nodes[2];
  1804     while ((nodes[0] = value_generator (&i)))
  1807         while ((nodes[1] = value_generator (&j)))
  1809             run_test_nodes (nodes, 2);
  1811             node_destroy (nodes[1]);
  1814         node_destroy (nodes[0]);
  1818   start_next_test (
"Each container containing each value",
  1819                    N_CONTAINERS * N_VALUES);
  1820   for (i = 0; i < N_CONTAINERS; i++)
  1822       const TestTypeNodeClass *container_klass = container_nodes[i];
  1824       make_and_run_values_inside_container (container_klass, 1);
  1827   start_next_test (
"Each container containing each value with arrays as blocks",
  1828                    N_CONTAINERS * N_VALUES);
  1829   arrays_write_fixed_in_blocks = 
TRUE;
  1830   for (i = 0; i < N_CONTAINERS; i++)
  1832       const TestTypeNodeClass *container_klass = container_nodes[i];
  1834       make_and_run_values_inside_container (container_klass, 1);
  1836   arrays_write_fixed_in_blocks = 
FALSE;
  1838   start_next_test (
"Each container of same container of each value",
  1839                    N_CONTAINERS * N_VALUES);
  1840   for (i = 0; i < N_CONTAINERS; i++)
  1842       const TestTypeNodeClass *container_klass = container_nodes[i];
  1844       make_and_run_values_inside_container (container_klass, 2);
  1847   start_next_test (
"Each container of same container of same container of each value",
  1848                    N_CONTAINERS * N_VALUES);
  1849   for (i = 0; i < N_CONTAINERS; i++)
  1851       const TestTypeNodeClass *container_klass = container_nodes[i];
  1853       make_and_run_values_inside_container (container_klass, 3);
  1856   start_next_test (
"Each value,value pair inside a struct",
  1857                    N_VALUES * N_VALUES);
  1859     TestTypeNode *val1, *val2;
  1862     node = node_new (&struct_1_class);
  1865     while ((val1 = value_generator (&i)))
  1868         while ((val2 = value_generator (&j)))
  1870             TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1872             node_append_child (node, val1);
  1873             node_append_child (node, val2);
  1875             run_test_nodes (&node, 1);
  1878             node_destroy (val2);
  1880         node_destroy (val1);
  1882     node_destroy (node);
  1885   start_next_test (
"All values in one big struct", 1);
  1888     TestTypeNode *child;
  1890     node = node_new (&struct_1_class);
  1893     while ((child = value_generator (&i)))
  1894       node_append_child (node, child);
  1896     run_test_nodes (&node, 1);
  1898     node_destroy (node);
  1901   start_next_test (
"Each value in a large array", N_VALUES);
  1906     node = node_new (&array_9_class);
  1909     while ((val = value_generator (&i)))
  1911         TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1913         node_append_child (node, val);
  1915         run_test_nodes (&node, 1);
  1921     node_destroy (node);
  1927       fprintf (stderr, 
"skipping remaining marshal-recursive tests, "  1928           "run with DBUS_TEST_SLOW=1 (or more) to enable\n");
  1932   start_next_test (
"Each container of each container of each value",
  1933                    N_CONTAINERS * N_CONTAINERS * N_VALUES);
  1934   for (i = 0; i < N_CONTAINERS; i++)
  1936       const TestTypeNodeClass *outer_container_klass = container_nodes[i];
  1937       TestTypeNode *outer_container = node_new (outer_container_klass);
  1939       for (j = 0; j < N_CONTAINERS; j++)
  1941           TestTypeNode *child;
  1942           const TestTypeNodeClass *inner_container_klass = container_nodes[j];
  1943           TestTypeNode *inner_container = node_new (inner_container_klass);
  1945           node_append_child (outer_container, inner_container);
  1948           while ((child = value_generator (&m)))
  1950               node_append_child (inner_container, child);
  1952               run_test_nodes (&outer_container, 1);
  1955               node_destroy (child);
  1958           node_destroy (inner_container);
  1960       node_destroy (outer_container);
  1963   start_next_test (
"Each container of each container of each container of each value",
  1964                    N_CONTAINERS * N_CONTAINERS * N_CONTAINERS * N_VALUES);
  1965   for (i = 0; i < N_CONTAINERS; i++)
  1967       const TestTypeNodeClass *outer_container_klass = container_nodes[i];
  1968       TestTypeNode *outer_container = node_new (outer_container_klass);
  1970       for (j = 0; j < N_CONTAINERS; j++)
  1972           const TestTypeNodeClass *inner_container_klass = container_nodes[j];
  1973           TestTypeNode *inner_container = node_new (inner_container_klass);
  1975           node_append_child (outer_container, inner_container);
  1977           for (k = 0; k < N_CONTAINERS; k++)
  1979               TestTypeNode *child;
  1980               const TestTypeNodeClass *center_container_klass = container_nodes[k];
  1981               TestTypeNode *center_container = node_new (center_container_klass);
  1983               node_append_child (inner_container, center_container);
  1986               while ((child = value_generator (&m)))
  1988                   node_append_child (center_container, child);
  1990                   run_test_nodes (&outer_container, 1);
  1993                   node_destroy (child);
  1996               node_destroy (center_container);
  1999           node_destroy (inner_container);
  2001       node_destroy (outer_container);
  2008       fprintf (stderr, 
"skipping really slow marshal-recursive test, "  2009           "run with DBUS_TEST_SLOW=2 (or more) to enable\n");
  2013   start_next_test (
"Each value,value,value triplet combination as toplevel, in all orders",
  2014                    N_VALUES * N_VALUES * N_VALUES);
  2016     TestTypeNode *nodes[3];
  2019     while ((nodes[0] = value_generator (&i)))
  2022         while ((nodes[1] = value_generator (&j)))
  2025             while ((nodes[2] = value_generator (&k)))
  2027                 run_test_nodes (nodes, 3);
  2029                 node_destroy (nodes[2]);
  2031             node_destroy (nodes[1]);
  2033         node_destroy (nodes[0]);
  2038   fprintf (stderr, 
"%d total iterations of recursive marshaling tests\n",
  2039            n_iterations_completed_total);
  2040   fprintf (stderr, 
"each iteration ran at initial offsets 0 through %d in both big and little endian\n",
  2041            MAX_INITIAL_OFFSET);
  2042   fprintf (stderr, 
"out of memory handling %s tested\n",
  2043            TEST_OOM_HANDLING ? 
"was" : 
"was not");
  2047 _dbus_marshal_recursive_test (
void)
  2049   make_and_run_test_nodes ();
  2062 #define MAX_MULTI_COUNT 5  2064 #define SAMPLE_INT16           1234  2065 #define SAMPLE_INT16_ALTERNATE 6785  2067 int16_from_seed (
int seed)
  2075     SAMPLE_INT16_ALTERNATE,
  2090 int16_write_value (TestTypeNode   *node,
  2098   v = int16_from_seed (seed);
  2101                                         node->klass->typecode,
  2106 int16_read_value (TestTypeNode   *node,
  2113   check_expected_type (reader, node->klass->typecode);
  2124 int16_set_value (TestTypeNode   *node,
  2132   v = int16_from_seed (seed);
  2140 int16_write_multi (TestTypeNode   *node,
  2151   for (i = 0; i < count; ++i)
  2152     values[i] = int16_from_seed (seed + i);
  2155                                               node->klass->typecode,
  2156                                               &v_ARRAY_INT16, count);
  2160 int16_read_multi (TestTypeNode   *node,
  2170   check_expected_type (reader, node->klass->typecode);
  2176   if (n_elements != count)
  2177     _dbus_warn (
"got %d elements expected %d", n_elements, count);
  2180   for (i = 0; i < count; i++)
  2182                                                       (
const unsigned char*)values + (i * 2))) ==
  2183                   int16_from_seed (seed + i));
  2189 #define SAMPLE_INT32           12345678  2190 #define SAMPLE_INT32_ALTERNATE 53781429  2192 int32_from_seed (
int seed)
  2200     SAMPLE_INT32_ALTERNATE,
  2215 int32_write_value (TestTypeNode   *node,
  2223   v = int32_from_seed (seed);
  2226                                         node->klass->typecode,
  2231 int32_read_value (TestTypeNode   *node,
  2238   check_expected_type (reader, node->klass->typecode);
  2249 int32_set_value (TestTypeNode   *node,
  2257   v = int32_from_seed (seed);
  2265 int32_write_multi (TestTypeNode   *node,
  2276   for (i = 0; i < count; ++i)
  2277     values[i] = int32_from_seed (seed + i);
  2280                                               node->klass->typecode,
  2281                                               &v_ARRAY_INT32, count);
  2285 int32_read_multi (TestTypeNode   *node,
  2295   check_expected_type (reader, node->klass->typecode);
  2301   if (n_elements != count)
  2302     _dbus_warn (
"got %d elements expected %d", n_elements, count);
  2305   for (i = 0; i < count; i++)
  2307                                              (
const unsigned char*)values + (i * 4))) ==
  2308                   int32_from_seed (seed + i));
  2314 int64_from_seed (
int seed)
  2319   v32 = int32_from_seed (seed);
  2328 int64_write_value (TestTypeNode   *node,
  2336   v = int64_from_seed (seed);
  2339                                         node->klass->typecode,
  2344 int64_read_value (TestTypeNode   *node,
  2351   check_expected_type (reader, node->klass->typecode);
  2362 int64_set_value (TestTypeNode   *node,
  2370   v = int64_from_seed (seed);
  2377 #define MAX_SAMPLE_STRING_LEN 10  2379 string_from_seed (
char *buf,
  2406   v = (
unsigned char) (
'A' + seed);
  2411       if (v < 'A' || v > 
'z')
  2424 string_write_value (TestTypeNode   *node,
  2429   char buf[MAX_SAMPLE_STRING_LEN + 1]=
"";
  2430   const char *v_string = buf;
  2433   string_from_seed (buf, node->klass->subclass_detail,
  2437                                         node->klass->typecode,
  2442 string_read_value (TestTypeNode   *node,
  2447   char buf[MAX_SAMPLE_STRING_LEN + 1];
  2450   check_expected_type (reader, node->klass->typecode);
  2453                                 (
const char **) &v);
  2455   string_from_seed (buf, node->klass->subclass_detail,
  2458   if (strcmp (buf, v) != 0)
  2460       _dbus_warn (
"read string '%s' expected '%s'",
  2469 string_set_value (TestTypeNode   *node,
  2474   char buf[MAX_SAMPLE_STRING_LEN + 1];
  2475   const char *v_string = buf;
  2477   string_from_seed (buf, node->klass->subclass_detail,
  2480 #if RECURSIVE_MARSHAL_WRITE_TRACE  2484    _dbus_verbose (
"SETTING new string '%s' len %d in place of '%s' len %d\n",
  2485                   v_string, strlen (v_string), old, strlen (old));
  2494 #define BOOL_FROM_SEED(seed) ((dbus_bool_t)((seed) % 2))  2497 bool_write_value (TestTypeNode   *node,
  2504   v = BOOL_FROM_SEED (seed);
  2507                                         node->klass->typecode,
  2512 bool_read_value (TestTypeNode   *node,
  2518   check_expected_type (reader, node->klass->typecode);
  2521                                 (
unsigned char*) &v);
  2529 bool_set_value (TestTypeNode   *node,
  2536   v = BOOL_FROM_SEED (seed);
  2543 #define BYTE_FROM_SEED(seed) ((unsigned char) int32_from_seed (seed))  2546 byte_write_value (TestTypeNode   *node,
  2553   v = BYTE_FROM_SEED (seed);
  2556                                         node->klass->typecode,
  2561 byte_read_value (TestTypeNode   *node,
  2567   check_expected_type (reader, node->klass->typecode);
  2570                                 (
unsigned char*) &v);
  2579 byte_set_value (TestTypeNode   *node,
  2586   v = BYTE_FROM_SEED (seed);
  2594 double_from_seed (
int seed)
  2596   return SAMPLE_INT32 * (double) seed + 0.3;
  2600 double_write_value (TestTypeNode   *node,
  2607   v = double_from_seed (seed);
  2610                                         node->klass->typecode,
  2615 double_read_value (TestTypeNode   *node,
  2622   check_expected_type (reader, node->klass->typecode);
  2627   expected = double_from_seed (seed);
  2631       _dbus_warn (
"Expected double %g got %g\n bits = 0x%" PRIx64 
" vs.\n bits = 0x%" PRIx64,
  2642 double_set_value (TestTypeNode   *node,
  2649   v = double_from_seed (seed);
  2656 #define MAX_SAMPLE_OBJECT_PATH_LEN 10  2658 object_path_from_seed (
char *buf,
  2668   v = (
unsigned char) (
'A' + seed);
  2680           if (v < 'A' || v > 
'z')
  2696 object_path_write_value (TestTypeNode   *node,
  2701   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2702   const char *v_string = buf;
  2704   object_path_from_seed (buf, seed);
  2707                                         node->klass->typecode,
  2712 object_path_read_value (TestTypeNode   *node,
  2717   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2719   check_expected_type (reader, node->klass->typecode);
  2722                                 (
const char **) &v);
  2724   object_path_from_seed (buf, seed);
  2726   if (strcmp (buf, v) != 0)
  2728       _dbus_warn (
"read object path '%s' expected '%s'",
  2737 object_path_set_value (TestTypeNode   *node,
  2742   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2743   const char *v_string = buf;
  2745   object_path_from_seed (buf, seed);
  2752 #define MAX_SAMPLE_SIGNATURE_LEN 10  2754 signature_from_seed (
char *buf,
  2758   const char *sample_signatures[] = {
  2767   strcpy (buf, sample_signatures[seed % 
_DBUS_N_ELEMENTS(sample_signatures)]);
  2771 signature_write_value (TestTypeNode   *node,
  2776   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2777   const char *v_string = buf;
  2779   signature_from_seed (buf, seed);
  2782                                         node->klass->typecode,
  2787 signature_read_value (TestTypeNode   *node,
  2792   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2794   check_expected_type (reader, node->klass->typecode);
  2797                                 (
const char **) &v);
  2799   signature_from_seed (buf, seed);
  2801   if (strcmp (buf, v) != 0)
  2803       _dbus_warn (
"read signature value '%s' expected '%s'",
  2813 signature_set_value (TestTypeNode   *node,
  2818   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2819   const char *v_string = buf;
  2821   signature_from_seed (buf, seed);
  2829 struct_write_value (TestTypeNode   *node,
  2834   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2835   DataBlockState saved;
  2840   n_copies = node->klass->subclass_detail;
  2844   data_block_save (block, &saved);
  2852   while (i < n_copies)
  2857       while (link != 
NULL)
  2859           TestTypeNode *child = link->
data;
  2862           if (!node_write_value (child, block, &sub, seed + i))
  2864               data_block_restore (block, &saved);
  2876       data_block_restore (block, &saved);
  2884 struct_read_or_set_value (TestTypeNode   *node,
  2889   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2894   n_copies = node->klass->subclass_detail;
  2901   while (i < n_copies)
  2906       while (link != 
NULL)
  2908           TestTypeNode *child = link->
data;
  2911           if (realign_root == 
NULL)
  2913               if (!node_read_value (child, &sub, seed + i))
  2918               if (!node_set_value (child, &sub, realign_root, seed + i))
  2922           if (i == (n_copies - 1) && next == 
NULL)
  2923             NEXT_EXPECTING_FALSE (&sub);
  2925             NEXT_EXPECTING_TRUE (&sub);
  2937 struct_read_value (TestTypeNode   *node,
  2941   return struct_read_or_set_value (node, reader, 
NULL, seed);
  2945 struct_set_value (TestTypeNode   *node,
  2950   return struct_read_or_set_value (node, reader, realign_root, seed);
  2954 struct_build_signature (TestTypeNode   *node,
  2957   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2962   n_copies = node->klass->subclass_detail;
  2964   orig_len = _dbus_string_get_length (str);
  2970   while (i < n_copies)
  2975       while (link != 
NULL)
  2977           TestTypeNode *child = link->
data;
  2980           if (!node_build_signature (child, str))
  3000 array_write_value (TestTypeNode   *node,
  3005   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3006   DataBlockState saved;
  3012   TestTypeNode *child;
  3014   n_copies = node->klass->subclass_detail;
  3018   data_block_save (block, &saved);
  3025   if (!node_build_signature (child,
  3026                              &element_signature))
  3032                                   &element_signature, 0,
  3036   if (arrays_write_fixed_in_blocks &&
  3038       child->klass->write_multi)
  3040       if (!node_write_multi (child, block, &sub, seed, n_copies))
  3046       while (i < n_copies)
  3051           while (link != 
NULL)
  3053               TestTypeNode *child2 = link->
data;
  3056               if (!node_write_value (child2, block, &sub, seed + i))
  3073   data_block_restore (block, &saved);
  3079 array_read_or_set_value (TestTypeNode   *node,
  3084   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3088   TestTypeNode *child;
  3090   n_copies = node->klass->subclass_detail;
  3100       if (realign_root == 
NULL && arrays_write_fixed_in_blocks &&
  3102           child->klass->read_multi)
  3104           if (!node_read_multi (child, &sub, seed, n_copies))
  3110           while (i < n_copies)
  3115               while (link != 
NULL)
  3117                   TestTypeNode *child2 = link->
data;
  3123                   if (realign_root == 
NULL)
  3125                       if (!node_read_value (child2, &sub, seed + i))
  3130                       if (!node_set_value (child2, &sub, realign_root, seed + i))
  3134                   if (i == (n_copies - 1) && next == 
NULL)
  3135                     NEXT_EXPECTING_FALSE (&sub);
  3137                     NEXT_EXPECTING_TRUE (&sub);
  3151 array_read_value (TestTypeNode   *node,
  3155   return array_read_or_set_value (node, reader, 
NULL, seed);
  3159 array_set_value (TestTypeNode   *node,
  3164   return array_read_or_set_value (node, reader, realign_root, seed);
  3168 array_build_signature (TestTypeNode   *node,
  3171   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3174   orig_len = _dbus_string_get_length (str);
  3191 #define VARIANT_SEED 10  3194 variant_write_value (TestTypeNode   *node,
  3199   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3200   DataBlockState saved;
  3203   TestTypeNode *child;
  3210   data_block_save (block, &saved);
  3215   if (!node_build_signature (child,
  3216                              &content_signature))
  3220                                   &content_signature, 0,
  3224   if (!node_write_value (child, block, &sub, seed + VARIANT_SEED))
  3234   data_block_restore (block, &saved);
  3240 variant_read_or_set_value (TestTypeNode   *node,
  3245   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3247   TestTypeNode *child;
  3258   if (realign_root == 
NULL)
  3260       if (!node_read_value (child, &sub, seed + VARIANT_SEED))
  3265       if (!node_set_value (child, &sub, realign_root, seed + VARIANT_SEED))
  3269   NEXT_EXPECTING_FALSE (&sub);
  3275 variant_read_value (TestTypeNode   *node,
  3279   return variant_read_or_set_value (node, reader, 
NULL, seed);
  3283 variant_set_value (TestTypeNode   *node,
  3288   return variant_read_or_set_value (node, reader, realign_root, seed);
  3292 dict_write_value (TestTypeNode   *node,
  3297   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3298   DataBlockState saved;
  3304   TestTypeNode *child;
  3306   n_entries = node->klass->subclass_detail;
  3310   data_block_save (block, &saved);
  3323   if (!node_build_signature (child,
  3324                              &entry_value_signature))
  3333                           &dict_entry_signature,
  3334                           _dbus_string_get_length (&dict_entry_signature)))
  3342                                   &dict_entry_signature, 0,
  3347   while (i < n_entries)
  3357       key = int32_from_seed (seed + i);
  3364       if (!node_write_value (child, block, &entry_sub, seed + i))
  3381   data_block_restore (block, &saved);
  3388 dict_read_or_set_value (TestTypeNode   *node,
  3393   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3397   TestTypeNode *child;
  3399   n_entries = node->klass->subclass_detail;
  3412       while (i < n_entries)
  3420           if (realign_root == 
NULL)
  3431               NEXT_EXPECTING_TRUE (&entry_sub);
  3433               if (!node_read_value (child, &entry_sub, seed + i))
  3436               NEXT_EXPECTING_FALSE (&entry_sub);
  3442               v = int32_from_seed (seed + i);
  3449               NEXT_EXPECTING_TRUE (&entry_sub);
  3451               if (!node_set_value (child, &entry_sub, realign_root, seed + i))
  3454               NEXT_EXPECTING_FALSE (&entry_sub);
  3457           if (i == (n_entries - 1))
  3458             NEXT_EXPECTING_FALSE (&sub);
  3460             NEXT_EXPECTING_TRUE (&sub);
  3470 dict_read_value (TestTypeNode   *node,
  3474   return dict_read_or_set_value (node, reader, 
NULL, seed);
  3478 dict_set_value (TestTypeNode   *node,
  3483   return dict_read_or_set_value (node, reader, realign_root, seed);
  3487 dict_build_signature (TestTypeNode   *node,
  3490   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3493   orig_len = _dbus_string_get_length (str);
  3516 container_destroy (TestTypeNode *node)
  3518   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3522   while (link != 
NULL)
  3524       TestTypeNode *child = link->
data;
  3527       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...
#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_uint64_t u64
as int64 
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". 
#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_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. 
#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. 
dbus_bool_t _dbus_type_reader_next(DBusTypeReader *reader)
Skip to the next value on this "level". 
_DBUS_GNUC_EXTENSION typedef long long dbus_int64_t
A 64-bit signed integer. 
#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. 
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 
#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. 
DBUS_PRIVATE_EXPORT 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_getenv(const char *varname)
Wrapper for getenv(). 
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.