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"    41 basic_value_equal (
int             type,
    49       return strcmp (lhs->
str, rhs->
str) == 0;
    53       return lhs->
u64 == rhs->
u64;
    67   if (lhs_type != rhs_type)
    78       basic_value_zero (&lhs_value);
    79       basic_value_zero (&rhs_value);
    84       return basic_value_equal (lhs_type, &lhs_value, &rhs_value);
    94       return equal_values_helper (&lhs_sub, &rhs_sub);
   112   return equal_values_helper (©_lhs, ©_rhs);
   117 #ifndef DOXYGEN_SHOULD_SKIP_THIS   119 #include "dbus-test.h"   120 #include "dbus-list.h"   125 #define TEST_OOM_HANDLING 0   129 #define MAX_INITIAL_OFFSET 9   135 #define MAX_ITERATIONS_FOR_EXPENSIVE_TESTS 1000   151 #define N_FENCE_BYTES 5   152 #define FENCE_BYTES_STR "abcde"   153 #define INITIAL_PADDING_BYTE '\0'   156 data_block_init (DataBlock *block,
   170                                   INITIAL_PADDING_BYTE) ||
   172                                   INITIAL_PADDING_BYTE) ||
   181   block->byte_order = byte_order;
   182   block->initial_offset = initial_offset;
   188 data_block_save (DataBlock      *block,
   189                  DataBlockState *state)
   191   state->saved_sig_len = _dbus_string_get_length (&block->signature) - N_FENCE_BYTES;
   192   state->saved_body_len = _dbus_string_get_length (&block->body) - N_FENCE_BYTES;
   196 data_block_restore (DataBlock      *block,
   197                     DataBlockState *state)
   200                        state->saved_sig_len,
   201                        _dbus_string_get_length (&block->signature) - state->saved_sig_len - N_FENCE_BYTES);
   203                        state->saved_body_len,
   204                        _dbus_string_get_length (&block->body) - state->saved_body_len - N_FENCE_BYTES);
   208 data_block_verify (DataBlock *block)
   215       offset = _dbus_string_get_length (&block->signature) - N_FENCE_BYTES - 8;
   221                                      _dbus_string_get_length (&block->signature) - offset);
   229       offset = _dbus_string_get_length (&block->body) - N_FENCE_BYTES - 8;
   235                                      _dbus_string_get_length (&block->body) - offset);
   240                                            0, block->initial_offset));
   242                                            0, block->initial_offset));
   246 data_block_free (DataBlock *block)
   248   data_block_verify (block);
   255 data_block_reset (DataBlock *block)
   257   data_block_verify (block);
   260                        block->initial_offset,
   261                        _dbus_string_get_length (&block->signature) - N_FENCE_BYTES - block->initial_offset);
   263                        block->initial_offset,
   264                        _dbus_string_get_length (&block->body) - N_FENCE_BYTES - block->initial_offset);
   266   data_block_verify (block);
   270 data_block_init_reader_writer (DataBlock      *block,
   278                             block->initial_offset,
   280                             block->initial_offset);
   286                             _dbus_string_get_length (&block->signature) - N_FENCE_BYTES,
   288                             _dbus_string_get_length (&block->body) - N_FENCE_BYTES);
   294                           const char     *funcname,
   303       _dbus_warn (
"Read type %s while expecting %s at %s line %d\n",
   312 #define check_expected_type(reader, expected) real_check_expected_type (reader, expected, _DBUS_FUNCTION_NAME, __LINE__)   314 #define NEXT_EXPECTING_TRUE(reader)  do { if (!_dbus_type_reader_next (reader))         \   316     _dbus_warn ("_dbus_type_reader_next() should have returned TRUE at %s %d\n",        \   317                               _DBUS_FUNCTION_NAME, __LINE__);                           \   318     _dbus_assert_not_reached ("test failed");                                           \   322 #define NEXT_EXPECTING_FALSE(reader) do { if (_dbus_type_reader_next (reader))          \   324     _dbus_warn ("_dbus_type_reader_next() should have returned FALSE at %s %d\n",       \   325                               _DBUS_FUNCTION_NAME, __LINE__);                           \   326     _dbus_assert_not_reached ("test failed");                                           \   328  check_expected_type (reader, DBUS_TYPE_INVALID);                                       \   331 typedef struct TestTypeNode               TestTypeNode;
   332 typedef struct TestTypeNodeClass          TestTypeNodeClass;
   333 typedef struct TestTypeNodeContainer      TestTypeNodeContainer;
   334 typedef struct TestTypeNodeContainerClass TestTypeNodeContainerClass;
   338   const TestTypeNodeClass *klass;
   341 struct TestTypeNodeContainer
   347 struct TestTypeNodeClass
   356   void          (* destroy)       (TestTypeNode   *node);
   369   dbus_bool_t (* build_signature) (TestTypeNode   *node,
   382 struct TestTypeNodeContainerClass
   384   TestTypeNodeClass base;
   392 static dbus_bool_t int16_write_value       (TestTypeNode   *node,
   396 static dbus_bool_t int16_read_value        (TestTypeNode   *node,
   399 static dbus_bool_t int16_set_value         (TestTypeNode   *node,
   403 static dbus_bool_t int16_write_multi       (TestTypeNode   *node,
   408 static dbus_bool_t int16_read_multi        (TestTypeNode   *node,
   412 static dbus_bool_t int32_write_value       (TestTypeNode   *node,
   416 static dbus_bool_t int32_read_value        (TestTypeNode   *node,
   419 static dbus_bool_t int32_set_value         (TestTypeNode   *node,
   423 static dbus_bool_t int32_write_multi       (TestTypeNode   *node,
   428 static dbus_bool_t int32_read_multi        (TestTypeNode   *node,
   432 static dbus_bool_t int64_write_value       (TestTypeNode   *node,
   436 static dbus_bool_t int64_read_value        (TestTypeNode   *node,
   439 static dbus_bool_t int64_set_value         (TestTypeNode   *node,
   443 static dbus_bool_t string_write_value      (TestTypeNode   *node,
   447 static dbus_bool_t string_read_value       (TestTypeNode   *node,
   450 static dbus_bool_t string_set_value        (TestTypeNode   *node,
   454 static dbus_bool_t bool_write_value        (TestTypeNode   *node,
   458 static dbus_bool_t bool_read_value         (TestTypeNode   *node,
   461 static dbus_bool_t bool_set_value          (TestTypeNode   *node,
   465 static dbus_bool_t byte_write_value        (TestTypeNode   *node,
   469 static dbus_bool_t byte_read_value         (TestTypeNode   *node,
   472 static dbus_bool_t byte_set_value          (TestTypeNode   *node,
   476 static dbus_bool_t double_write_value      (TestTypeNode   *node,
   480 static dbus_bool_t double_read_value       (TestTypeNode   *node,
   483 static dbus_bool_t double_set_value        (TestTypeNode   *node,
   487 static dbus_bool_t object_path_write_value (TestTypeNode   *node,
   491 static dbus_bool_t object_path_read_value  (TestTypeNode   *node,
   494 static dbus_bool_t object_path_set_value   (TestTypeNode   *node,
   498 static dbus_bool_t signature_write_value   (TestTypeNode   *node,
   502 static dbus_bool_t signature_read_value    (TestTypeNode   *node,
   505 static dbus_bool_t signature_set_value     (TestTypeNode   *node,
   509 static dbus_bool_t struct_write_value      (TestTypeNode   *node,
   513 static dbus_bool_t struct_read_value       (TestTypeNode   *node,
   516 static dbus_bool_t struct_set_value        (TestTypeNode   *node,
   520 static dbus_bool_t struct_build_signature  (TestTypeNode   *node,
   522 static dbus_bool_t dict_write_value        (TestTypeNode   *node,
   526 static dbus_bool_t dict_read_value         (TestTypeNode   *node,
   529 static dbus_bool_t dict_set_value          (TestTypeNode   *node,
   533 static dbus_bool_t dict_build_signature    (TestTypeNode   *node,
   535 static dbus_bool_t array_write_value       (TestTypeNode   *node,
   539 static dbus_bool_t array_read_value        (TestTypeNode   *node,
   542 static dbus_bool_t array_set_value         (TestTypeNode   *node,
   546 static dbus_bool_t array_build_signature   (TestTypeNode   *node,
   548 static dbus_bool_t variant_write_value     (TestTypeNode   *node,
   552 static dbus_bool_t variant_read_value      (TestTypeNode   *node,
   555 static dbus_bool_t variant_set_value       (TestTypeNode   *node,
   559 static void        container_destroy       (TestTypeNode   *node);
   563 static const TestTypeNodeClass int16_class = {
   565   sizeof (TestTypeNode),
   577 static const TestTypeNodeClass uint16_class = {
   579   sizeof (TestTypeNode),
   591 static const TestTypeNodeClass int32_class = {
   593   sizeof (TestTypeNode),
   605 static const TestTypeNodeClass uint32_class = {
   607   sizeof (TestTypeNode),
   619 static const TestTypeNodeClass int64_class = {
   621   sizeof (TestTypeNode),
   633 static const TestTypeNodeClass uint64_class = {
   635   sizeof (TestTypeNode),
   647 static const TestTypeNodeClass string_0_class = {
   649   sizeof (TestTypeNode),
   661 static const TestTypeNodeClass string_1_class = {
   663   sizeof (TestTypeNode),
   676 static const TestTypeNodeClass string_3_class = {
   678   sizeof (TestTypeNode),
   691 static const TestTypeNodeClass string_8_class = {
   693   sizeof (TestTypeNode),
   705 static const TestTypeNodeClass bool_class = {
   707   sizeof (TestTypeNode),
   719 static const TestTypeNodeClass byte_class = {
   721   sizeof (TestTypeNode),
   733 static const TestTypeNodeClass double_class = {
   735   sizeof (TestTypeNode),
   747 static const TestTypeNodeClass object_path_class = {
   749   sizeof (TestTypeNode),
   753   object_path_write_value,
   754   object_path_read_value,
   755   object_path_set_value,
   761 static const TestTypeNodeClass signature_class = {
   763   sizeof (TestTypeNode),
   767   signature_write_value,
   768   signature_read_value,
   775 static const TestTypeNodeClass struct_1_class = {
   777   sizeof (TestTypeNodeContainer),
   784   struct_build_signature,
   789 static const TestTypeNodeClass struct_2_class = {
   791   sizeof (TestTypeNodeContainer),
   798   struct_build_signature,
   803 static const TestTypeNodeClass dict_1_class = {
   805   sizeof (TestTypeNodeContainer),
   812   dict_build_signature,
   819 static const TestTypeNodeClass array_0_class = {
   821   sizeof (TestTypeNodeContainer),
   828   array_build_signature,
   833 static const TestTypeNodeClass array_1_class = {
   835   sizeof (TestTypeNodeContainer),
   842   array_build_signature,
   847 static const TestTypeNodeClass array_2_class = {
   849   sizeof (TestTypeNodeContainer),
   856   array_build_signature,
   861 static const TestTypeNodeClass array_9_class = {
   863   sizeof (TestTypeNodeContainer),
   870   array_build_signature,
   875 static const TestTypeNodeClass variant_class = {
   877   sizeof (TestTypeNodeContainer),
   889 static const TestTypeNodeClass* 
const   907 #define N_BASICS (_DBUS_N_ELEMENTS (basic_nodes))   909 static const TestTypeNodeClass* 
const   910 container_nodes[] = {
   922 #define N_CONTAINERS (_DBUS_N_ELEMENTS (container_nodes))   925 node_new (
const TestTypeNodeClass *klass)
   935   if (klass->construct)
   937       if (!(* klass->construct) (node))
   948 node_destroy (TestTypeNode *node)
   950   if (node->klass->destroy)
   951     (* node->klass->destroy) (node);
   956 node_write_value (TestTypeNode   *node,
   963   retval = (* node->klass->write_value) (node, block, writer, seed);
   967   data_block_verify (block);
   974 node_read_value (TestTypeNode   *node,
   980   if (!(* node->klass->read_value) (node, reader, seed))
   991 node_set_value (TestTypeNode   *node,
   996   if (!(* node->klass->set_value) (node, reader, realign_root, seed))
  1003 node_build_signature (TestTypeNode *node,
  1006   if (node->klass->build_signature)
  1007     return (* node->klass->build_signature) (node, str);
  1013 node_append_child (TestTypeNode *node,
  1014                    TestTypeNode *child)
  1016   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1018   _dbus_assert (node->klass->instance_size >= (
int) sizeof (TestTypeNodeContainer));
  1027 node_write_multi (TestTypeNode   *node,
  1036   retval = (* node->klass->write_multi) (node, block, writer, seed, n_copies);
  1040   data_block_verify (block);
  1047 node_read_multi (TestTypeNode   *node,
  1054   if (!(* node->klass->read_multi) (node, reader, seed, n_copies))
  1060 static int n_iterations_completed_total = 0;
  1061 static int n_iterations_completed_this_test = 0;
  1062 static int n_iterations_expected_this_test = 0;
  1069   TestTypeNode      **nodes;
  1071 } NodeIterationData;
  1074 run_test_copy (NodeIterationData *nid)
  1082   _dbus_verbose (
"\n");
  1088   if (!data_block_init (&dest, src->byte_order, src->initial_offset))
  1091   data_block_init_reader_writer (src, &reader, 
NULL);
  1092   data_block_init_reader_writer (&dest, 
NULL, &writer);
  1098                                  dest.initial_offset, 
'\0'))
  1107       _dbus_verbose (
"SOURCE\n");
  1109                                      _dbus_string_get_length (&src->signature));
  1110       _dbus_verbose (
"DEST\n");
  1112                                      _dbus_string_get_length (&dest.signature));
  1118       _dbus_verbose (
"SOURCE\n");
  1120                                      _dbus_string_get_length (&src->body));
  1121       _dbus_verbose (
"DEST\n");
  1123                                      _dbus_string_get_length (&dest.body));
  1131   data_block_free (&dest);
  1137 run_test_values_only_write (NodeIterationData *nid)
  1145   _dbus_verbose (
"\n");
  1149   data_block_reset (nid->block);
  1151   sig_len = _dbus_string_get_length (nid->signature);
  1157                                       _dbus_string_get_length (&nid->block->body) - N_FENCE_BYTES);
  1162                           nid->block->initial_offset);
  1165   while (i < nid->n_nodes)
  1167       if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
  1174   _dbus_assert (sig_len == _dbus_string_get_length (nid->signature));
  1178   while (i < nid->n_nodes)
  1180       if (!node_read_value (nid->nodes[i], &reader, i))
  1183       if (i + 1 == nid->n_nodes)
  1184         NEXT_EXPECTING_FALSE (&reader);
  1186         NEXT_EXPECTING_TRUE (&reader);
  1194   data_block_reset (nid->block);
  1206 run_test_set_values (NodeIterationData *nid)
  1213   _dbus_verbose (
"\n");
  1217   data_block_init_reader_writer (nid->block,
  1220   realign_root = reader;
  1223   while (i < nid->n_nodes)
  1225       if (!node_set_value (nid->nodes[i],
  1226                            &reader, &realign_root,
  1230       if (i + 1 == nid->n_nodes)
  1231         NEXT_EXPECTING_FALSE (&reader);
  1233         NEXT_EXPECTING_TRUE (&reader);
  1240   reader = realign_root;
  1243   while (i < nid->n_nodes)
  1245       if (!node_read_value (nid->nodes[i], &reader,
  1249       if (i + 1 == nid->n_nodes)
  1250         NEXT_EXPECTING_FALSE (&reader);
  1252         NEXT_EXPECTING_TRUE (&reader);
  1264 run_test_delete_values (NodeIterationData *nid)
  1270   _dbus_verbose (
"\n");
  1274   data_block_init_reader_writer (nid->block,
  1299           _dbus_verbose (
"recursing into deletion loop reader.value_pos = %d array.value_pos = %d array.u.start_pos = %d\n",
  1304               static int cycle = 0;
  1310               if (elem == 3 || elem >= n_elements) 
  1311                 elem = n_elements - 1;
  1313               _dbus_verbose (
"deleting array element %d of %d type %s cycle %d reader pos %d elem pos %d\n",
  1341   data_block_init_reader_writer (nid->block,
  1356 run_test_nodes_iteration (
void *data)
  1358   NodeIterationData *nid = data;
  1372   data_block_init_reader_writer (nid->block,
  1379                                  nid->type_offset, 
'\0'))
  1383   while (i < nid->n_nodes)
  1385       if (!node_write_value (nid->nodes[i], nid->block, &writer, i))
  1392                                      &nid->block->signature, nid->type_offset))
  1394       _dbus_warn (
"Expected signature '%s' and got '%s' with initial offset %d\n",
  1395                   _dbus_string_get_const_data (nid->signature),
  1396                   _dbus_string_get_const_data_len (&nid->block->signature, nid->type_offset, 0),
  1402   while (i < nid->n_nodes)
  1404       if (!node_read_value (nid->nodes[i], &reader, i))
  1407       if (i + 1 == nid->n_nodes)
  1408         NEXT_EXPECTING_FALSE (&reader);
  1410         NEXT_EXPECTING_TRUE (&reader);
  1415   if (n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
  1424       if (!run_test_set_values (nid))
  1427       if (!run_test_delete_values (nid))
  1430       if (!run_test_copy (nid))
  1433       if (!run_test_values_only_write (nid))
  1445   data_block_reset (nid->block);
  1451 run_test_nodes_in_one_configuration (TestTypeNode    **nodes,
  1458   NodeIterationData nid;
  1460   if (!data_block_init (&block, byte_order, initial_offset))
  1463   nid.signature = signature;
  1465   nid.type_offset = initial_offset;
  1467   nid.n_nodes = n_nodes;
  1469   if (TEST_OOM_HANDLING &&
  1470       n_iterations_expected_this_test <= MAX_ITERATIONS_FOR_EXPENSIVE_TESTS)
  1472       _dbus_test_oom_handling (
"running test node",
  1473                                run_test_nodes_iteration,
  1478       if (!run_test_nodes_iteration (&nid))
  1482   data_block_free (&block);
  1486 run_test_nodes (TestTypeNode **nodes,
  1498       if (! node_build_signature (nodes[i], &signature))
  1504   _dbus_verbose (
">>> test nodes with signature '%s'\n",
  1505                  _dbus_string_get_const_data (&signature));
  1508   while (i <= MAX_INITIAL_OFFSET)
  1510       run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
  1512       run_test_nodes_in_one_configuration (nodes, n_nodes, &signature,
  1518   n_iterations_completed_this_test += 1;
  1519   n_iterations_completed_total += 1;
  1521   if (n_iterations_completed_this_test == n_iterations_expected_this_test)
  1523       fprintf (stderr, 
" 100%% %d this test (%d cumulative)\n",
  1524                n_iterations_completed_this_test,
  1525                n_iterations_completed_total);
  1528   else if ((n_iterations_completed_this_test %
  1529             (
int)(n_iterations_expected_this_test / 10.0)) == 1)
  1531       fprintf (stderr, 
" %d%% ", (
int) (n_iterations_completed_this_test / (
double) n_iterations_expected_this_test * 100));
  1537 #define N_VALUES (N_BASICS * N_CONTAINERS + N_BASICS)  1539 static TestTypeNode*
  1540 value_generator (
int *ip)
  1543   const TestTypeNodeClass *child_klass;
  1544   const TestTypeNodeClass *container_klass;
  1545   TestTypeNode *child;
  1554   else if (i < N_BASICS)
  1556       node = node_new (basic_nodes[i]);
  1570       container_klass = container_nodes[i / N_BASICS];
  1571       child_klass = basic_nodes[i % N_BASICS];
  1573       node = node_new (container_klass);
  1574       child = node_new (child_klass);
  1576       node_append_child (node, child);
  1585 build_body (TestTypeNode **nodes,
  1599       if (! node_build_signature (nodes[i], signature))
  1605   if (!data_block_init (&block, byte_order, 0))
  1608   data_block_init_reader_writer (&block,
  1621       if (!node_write_value (nodes[i], &block, &writer, i))
  1628                               _dbus_string_get_length (&block.body) - N_FENCE_BYTES,
  1632   data_block_free (&block);  
  1636 dbus_internal_do_not_use_generate_bodies (
int           sequence,
  1641   TestTypeNode *nodes[1];
  1645   nodes[0] = value_generator (&sequence);
  1647   if (nodes[0] == 
NULL)
  1652   build_body (nodes, n_nodes, byte_order, signature, body);
  1658       node_destroy (nodes[i]);
  1666 make_and_run_values_inside_container (
const TestTypeNodeClass *container_klass,
  1670   TestTypeNode *container;
  1671   TestTypeNode *child;
  1674   root = node_new (container_klass);
  1676   for (i = 1; i < n_nested; i++)
  1678       child = node_new (container_klass);
  1679       node_append_child (container, child);
  1686   while ((child = value_generator (&i)))
  1688       node_append_child (container, child);
  1690       run_test_nodes (&root, 1);
  1693       node_destroy (child);
  1696   node_destroy (root);
  1700 start_next_test (
const char *format,
  1703   n_iterations_completed_this_test = 0;
  1704   n_iterations_expected_this_test = expected;
  1706   fprintf (stderr, 
">>> >>> ");
  1707   fprintf (stderr, format,
  1708            n_iterations_expected_this_test);
  1712 make_and_run_test_nodes (
void)
  1748   start_next_test (
"Each value by itself %d iterations\n", N_VALUES);
  1752     while ((node = value_generator (&i)))
  1754         run_test_nodes (&node, 1);
  1756         node_destroy (node);
  1760   start_next_test (
"Each value by itself with arrays as blocks %d iterations\n", N_VALUES);
  1761   arrays_write_fixed_in_blocks = 
TRUE;
  1765     while ((node = value_generator (&i)))
  1767         run_test_nodes (&node, 1);
  1769         node_destroy (node);
  1772   arrays_write_fixed_in_blocks = 
FALSE;
  1774   start_next_test (
"All values in one big toplevel %d iteration\n", 1);
  1776     TestTypeNode *nodes[N_VALUES];
  1780     while ((node = value_generator (&i)))
  1782         nodes[i - 1] = node;
  1785     run_test_nodes (nodes, N_VALUES);
  1787     for (i = 0; i < N_VALUES; i++)
  1788       node_destroy (nodes[i]);
  1791   start_next_test (
"Each value,value pair combination as toplevel, in both orders %d iterations\n",
  1792                    N_VALUES * N_VALUES);
  1794     TestTypeNode *nodes[2];
  1797     while ((nodes[0] = value_generator (&i)))
  1800         while ((nodes[1] = value_generator (&j)))
  1802             run_test_nodes (nodes, 2);
  1804             node_destroy (nodes[1]);
  1807         node_destroy (nodes[0]);
  1811   start_next_test (
"Each container containing each value %d iterations\n",
  1812                    N_CONTAINERS * N_VALUES);
  1813   for (i = 0; i < N_CONTAINERS; i++)
  1815       const TestTypeNodeClass *container_klass = container_nodes[i];
  1817       make_and_run_values_inside_container (container_klass, 1);
  1820   start_next_test (
"Each container containing each value with arrays as blocks %d iterations\n",
  1821                    N_CONTAINERS * N_VALUES);
  1822   arrays_write_fixed_in_blocks = 
TRUE;
  1823   for (i = 0; i < N_CONTAINERS; i++)
  1825       const TestTypeNodeClass *container_klass = container_nodes[i];
  1827       make_and_run_values_inside_container (container_klass, 1);
  1829   arrays_write_fixed_in_blocks = 
FALSE;
  1831   start_next_test (
"Each container of same container of each value %d iterations\n",
  1832                    N_CONTAINERS * N_VALUES);
  1833   for (i = 0; i < N_CONTAINERS; i++)
  1835       const TestTypeNodeClass *container_klass = container_nodes[i];
  1837       make_and_run_values_inside_container (container_klass, 2);
  1840   start_next_test (
"Each container of same container of same container of each value %d iterations\n",
  1841                    N_CONTAINERS * N_VALUES);
  1842   for (i = 0; i < N_CONTAINERS; i++)
  1844       const TestTypeNodeClass *container_klass = container_nodes[i];
  1846       make_and_run_values_inside_container (container_klass, 3);
  1849   start_next_test (
"Each value,value pair inside a struct %d iterations\n",
  1850                    N_VALUES * N_VALUES);
  1852     TestTypeNode *val1, *val2;
  1855     node = node_new (&struct_1_class);
  1858     while ((val1 = value_generator (&i)))
  1861         while ((val2 = value_generator (&j)))
  1863             TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1865             node_append_child (node, val1);
  1866             node_append_child (node, val2);
  1868             run_test_nodes (&node, 1);
  1871             node_destroy (val2);
  1873         node_destroy (val1);
  1875     node_destroy (node);
  1878   start_next_test (
"All values in one big struct %d iteration\n",
  1882     TestTypeNode *child;
  1884     node = node_new (&struct_1_class);
  1887     while ((child = value_generator (&i)))
  1888       node_append_child (node, child);
  1890     run_test_nodes (&node, 1);
  1892     node_destroy (node);
  1895   start_next_test (
"Each value in a large array %d iterations\n",
  1901     node = node_new (&array_9_class);
  1904     while ((val = value_generator (&i)))
  1906         TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  1908         node_append_child (node, val);
  1910         run_test_nodes (&node, 1);
  1916     node_destroy (node);
  1922       fprintf (stderr, 
"skipping remaining marshal-recursive tests, "  1923           "run with DBUS_TEST_SLOW=1 (or more) to enable\n");
  1927   start_next_test (
"Each container of each container of each value %d iterations\n",
  1928                    N_CONTAINERS * N_CONTAINERS * N_VALUES);
  1929   for (i = 0; i < N_CONTAINERS; i++)
  1931       const TestTypeNodeClass *outer_container_klass = container_nodes[i];
  1932       TestTypeNode *outer_container = node_new (outer_container_klass);
  1934       for (j = 0; j < N_CONTAINERS; j++)
  1936           TestTypeNode *child;
  1937           const TestTypeNodeClass *inner_container_klass = container_nodes[j];
  1938           TestTypeNode *inner_container = node_new (inner_container_klass);
  1940           node_append_child (outer_container, inner_container);
  1943           while ((child = value_generator (&m)))
  1945               node_append_child (inner_container, child);
  1947               run_test_nodes (&outer_container, 1);
  1950               node_destroy (child);
  1953           node_destroy (inner_container);
  1955       node_destroy (outer_container);
  1958   start_next_test (
"Each container of each container of each container of each value %d iterations\n",
  1959                    N_CONTAINERS * N_CONTAINERS * N_CONTAINERS * N_VALUES);
  1960   for (i = 0; i < N_CONTAINERS; i++)
  1962       const TestTypeNodeClass *outer_container_klass = container_nodes[i];
  1963       TestTypeNode *outer_container = node_new (outer_container_klass);
  1965       for (j = 0; j < N_CONTAINERS; j++)
  1967           const TestTypeNodeClass *inner_container_klass = container_nodes[j];
  1968           TestTypeNode *inner_container = node_new (inner_container_klass);
  1970           node_append_child (outer_container, inner_container);
  1972           for (k = 0; k < N_CONTAINERS; k++)
  1974               TestTypeNode *child;
  1975               const TestTypeNodeClass *center_container_klass = container_nodes[k];
  1976               TestTypeNode *center_container = node_new (center_container_klass);
  1978               node_append_child (inner_container, center_container);
  1981               while ((child = value_generator (&m)))
  1983                   node_append_child (center_container, child);
  1985                   run_test_nodes (&outer_container, 1);
  1988                   node_destroy (child);
  1991               node_destroy (center_container);
  1994           node_destroy (inner_container);
  1996       node_destroy (outer_container);
  2003       fprintf (stderr, 
"skipping really slow marshal-recursive test, "  2004           "run with DBUS_TEST_SLOW=2 (or more) to enable\n");
  2008   start_next_test (
"Each value,value,value triplet combination as toplevel, in all orders %d iterations\n",
  2009                    N_VALUES * N_VALUES * N_VALUES);
  2011     TestTypeNode *nodes[3];
  2014     while ((nodes[0] = value_generator (&i)))
  2017         while ((nodes[1] = value_generator (&j)))
  2020             while ((nodes[2] = value_generator (&k)))
  2022                 run_test_nodes (nodes, 3);
  2024                 node_destroy (nodes[2]);
  2026             node_destroy (nodes[1]);
  2028         node_destroy (nodes[0]);
  2033   fprintf (stderr, 
"%d total iterations of recursive marshaling tests\n",
  2034            n_iterations_completed_total);
  2035   fprintf (stderr, 
"each iteration ran at initial offsets 0 through %d in both big and little endian\n",
  2036            MAX_INITIAL_OFFSET);
  2037   fprintf (stderr, 
"out of memory handling %s tested\n",
  2038            TEST_OOM_HANDLING ? 
"was" : 
"was not");
  2042 _dbus_marshal_recursive_test (
void)
  2044   make_and_run_test_nodes ();
  2057 #define MAX_MULTI_COUNT 5  2059 #define SAMPLE_INT16           1234  2060 #define SAMPLE_INT16_ALTERNATE 6785  2062 int16_from_seed (
int seed)
  2077       v = SAMPLE_INT16_ALTERNATE;
  2097 int16_write_value (TestTypeNode   *node,
  2105   v = int16_from_seed (seed);
  2108                                         node->klass->typecode,
  2113 int16_read_value (TestTypeNode   *node,
  2120   check_expected_type (reader, node->klass->typecode);
  2123                                 (dbus_int16_t*) &v);
  2131 int16_set_value (TestTypeNode   *node,
  2139   v = int16_from_seed (seed);
  2147 int16_write_multi (TestTypeNode   *node,
  2154   dbus_int16_t values[MAX_MULTI_COUNT];
  2155   dbus_int16_t *v_ARRAY_INT16 = values;
  2158   for (i = 0; i < count; ++i)
  2159     values[i] = int16_from_seed (seed + i);
  2162                                               node->klass->typecode,
  2163                                               &v_ARRAY_INT16, count);
  2167 int16_read_multi (TestTypeNode   *node,
  2173   dbus_int16_t *values;
  2177   check_expected_type (reader, node->klass->typecode);
  2183   if (n_elements != count)
  2184     _dbus_warn (
"got %d elements expected %d\n", n_elements, count);
  2187   for (i = 0; i < count; i++)
  2189                                                       (
const unsigned char*)values + (i * 2))) ==
  2190                   int16_from_seed (seed + i));
  2196 #define SAMPLE_INT32           12345678  2197 #define SAMPLE_INT32_ALTERNATE 53781429  2199 int32_from_seed (
int seed)
  2214       v = SAMPLE_INT32_ALTERNATE;
  2234 int32_write_value (TestTypeNode   *node,
  2242   v = int32_from_seed (seed);
  2245                                         node->klass->typecode,
  2250 int32_read_value (TestTypeNode   *node,
  2257   check_expected_type (reader, node->klass->typecode);
  2260                                 (dbus_int32_t*) &v);
  2268 int32_set_value (TestTypeNode   *node,
  2276   v = int32_from_seed (seed);
  2284 int32_write_multi (TestTypeNode   *node,
  2291   dbus_int32_t values[MAX_MULTI_COUNT];
  2292   dbus_int32_t *v_ARRAY_INT32 = values;
  2295   for (i = 0; i < count; ++i)
  2296     values[i] = int32_from_seed (seed + i);
  2299                                               node->klass->typecode,
  2300                                               &v_ARRAY_INT32, count);
  2304 int32_read_multi (TestTypeNode   *node,
  2310   dbus_int32_t *values;
  2314   check_expected_type (reader, node->klass->typecode);
  2320   if (n_elements != count)
  2321     _dbus_warn (
"got %d elements expected %d\n", n_elements, count);
  2324   for (i = 0; i < count; i++)
  2326                                              (
const unsigned char*)values + (i * 4))) ==
  2327                   int32_from_seed (seed + i));
  2333 int64_from_seed (
int seed)
  2338   v32 = int32_from_seed (seed);
  2340   v = - (dbus_int32_t) ~ v32;
  2341   v |= (((dbus_int64_t)v32) << 32);
  2347 int64_write_value (TestTypeNode   *node,
  2355   v = int64_from_seed (seed);
  2358                                         node->klass->typecode,
  2363 int64_read_value (TestTypeNode   *node,
  2370   check_expected_type (reader, node->klass->typecode);
  2373                                 (dbus_int64_t*) &v);
  2381 int64_set_value (TestTypeNode   *node,
  2389   v = int64_from_seed (seed);
  2396 #define MAX_SAMPLE_STRING_LEN 10  2398 string_from_seed (
char *buf,
  2422   v = (
unsigned char) (
'A' + seed);
  2427       if (v < 'A' || v > 
'z')
  2440 string_write_value (TestTypeNode   *node,
  2445   char buf[MAX_SAMPLE_STRING_LEN + 1]=
"";
  2446   const char *v_string = buf;
  2449   string_from_seed (buf, node->klass->subclass_detail,
  2453                                         node->klass->typecode,
  2458 string_read_value (TestTypeNode   *node,
  2463   char buf[MAX_SAMPLE_STRING_LEN + 1];
  2466   check_expected_type (reader, node->klass->typecode);
  2469                                 (
const char **) &v);
  2471   string_from_seed (buf, node->klass->subclass_detail,
  2474   if (strcmp (buf, v) != 0)
  2476       _dbus_warn (
"read string '%s' expected '%s'\n",
  2485 string_set_value (TestTypeNode   *node,
  2490   char buf[MAX_SAMPLE_STRING_LEN + 1];
  2491   const char *v_string = buf;
  2493   string_from_seed (buf, node->klass->subclass_detail,
  2496 #if RECURSIVE_MARSHAL_WRITE_TRACE  2500    _dbus_verbose (
"SETTING new string '%s' len %d in place of '%s' len %d\n",
  2501                   v_string, strlen (v_string), old, strlen (old));
  2510 #define BOOL_FROM_SEED(seed) ((dbus_bool_t)((seed) % 2))  2513 bool_write_value (TestTypeNode   *node,
  2520   v = BOOL_FROM_SEED (seed);
  2523                                         node->klass->typecode,
  2528 bool_read_value (TestTypeNode   *node,
  2534   check_expected_type (reader, node->klass->typecode);
  2537                                 (
unsigned char*) &v);
  2545 bool_set_value (TestTypeNode   *node,
  2552   v = BOOL_FROM_SEED (seed);
  2559 #define BYTE_FROM_SEED(seed) ((unsigned char) int32_from_seed (seed))  2562 byte_write_value (TestTypeNode   *node,
  2569   v = BYTE_FROM_SEED (seed);
  2572                                         node->klass->typecode,
  2577 byte_read_value (TestTypeNode   *node,
  2583   check_expected_type (reader, node->klass->typecode);
  2586                                 (
unsigned char*) &v);
  2595 byte_set_value (TestTypeNode   *node,
  2602   v = BYTE_FROM_SEED (seed);
  2610 double_from_seed (
int seed)
  2612   return SAMPLE_INT32 * (double) seed + 0.3;
  2616 double_write_value (TestTypeNode   *node,
  2623   v = double_from_seed (seed);
  2626                                         node->klass->typecode,
  2631 double_read_value (TestTypeNode   *node,
  2638   check_expected_type (reader, node->klass->typecode);
  2643   expected = double_from_seed (seed);
  2647 #ifdef DBUS_INT64_PRINTF_MODIFIER  2648       _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",
  2650                   *(dbus_uint64_t*)(
char*)&expected,
  2651                   *(dbus_uint64_t*)(
char*)&v);
  2660 double_set_value (TestTypeNode   *node,
  2667   v = double_from_seed (seed);
  2674 #define MAX_SAMPLE_OBJECT_PATH_LEN 10  2676 object_path_from_seed (
char *buf,
  2686   v = (
unsigned char) (
'A' + seed);
  2698           if (v < 'A' || v > 
'z')
  2714 object_path_write_value (TestTypeNode   *node,
  2719   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2720   const char *v_string = buf;
  2722   object_path_from_seed (buf, seed);
  2725                                         node->klass->typecode,
  2730 object_path_read_value (TestTypeNode   *node,
  2735   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2737   check_expected_type (reader, node->klass->typecode);
  2740                                 (
const char **) &v);
  2742   object_path_from_seed (buf, seed);
  2744   if (strcmp (buf, v) != 0)
  2746       _dbus_warn (
"read object path '%s' expected '%s'\n",
  2755 object_path_set_value (TestTypeNode   *node,
  2760   char buf[MAX_SAMPLE_OBJECT_PATH_LEN + 1];
  2761   const char *v_string = buf;
  2763   object_path_from_seed (buf, seed);
  2770 #define MAX_SAMPLE_SIGNATURE_LEN 10  2772 signature_from_seed (
char *buf,
  2776   const char *sample_signatures[] = {
  2785   strcpy (buf, sample_signatures[seed % 
_DBUS_N_ELEMENTS(sample_signatures)]);
  2789 signature_write_value (TestTypeNode   *node,
  2794   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2795   const char *v_string = buf;
  2797   signature_from_seed (buf, seed);
  2800                                         node->klass->typecode,
  2805 signature_read_value (TestTypeNode   *node,
  2810   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2812   check_expected_type (reader, node->klass->typecode);
  2815                                 (
const char **) &v);
  2817   signature_from_seed (buf, seed);
  2819   if (strcmp (buf, v) != 0)
  2821       _dbus_warn (
"read signature value '%s' expected '%s'\n",
  2831 signature_set_value (TestTypeNode   *node,
  2836   char buf[MAX_SAMPLE_SIGNATURE_LEN + 1];
  2837   const char *v_string = buf;
  2839   signature_from_seed (buf, seed);
  2847 struct_write_value (TestTypeNode   *node,
  2852   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2853   DataBlockState saved;
  2858   n_copies = node->klass->subclass_detail;
  2862   data_block_save (block, &saved);
  2870   while (i < n_copies)
  2875       while (link != 
NULL)
  2877           TestTypeNode *child = link->
data;
  2880           if (!node_write_value (child, block, &sub, seed + i))
  2882               data_block_restore (block, &saved);
  2894       data_block_restore (block, &saved);
  2902 struct_read_or_set_value (TestTypeNode   *node,
  2907   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2912   n_copies = node->klass->subclass_detail;
  2919   while (i < n_copies)
  2924       while (link != 
NULL)
  2926           TestTypeNode *child = link->
data;
  2929           if (realign_root == 
NULL)
  2931               if (!node_read_value (child, &sub, seed + i))
  2936               if (!node_set_value (child, &sub, realign_root, seed + i))
  2940           if (i == (n_copies - 1) && next == 
NULL)
  2941             NEXT_EXPECTING_FALSE (&sub);
  2943             NEXT_EXPECTING_TRUE (&sub);
  2955 struct_read_value (TestTypeNode   *node,
  2959   return struct_read_or_set_value (node, reader, 
NULL, seed);
  2963 struct_set_value (TestTypeNode   *node,
  2968   return struct_read_or_set_value (node, reader, realign_root, seed);
  2972 struct_build_signature (TestTypeNode   *node,
  2975   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  2980   n_copies = node->klass->subclass_detail;
  2982   orig_len = _dbus_string_get_length (str);
  2988   while (i < n_copies)
  2993       while (link != 
NULL)
  2995           TestTypeNode *child = link->
data;
  2998           if (!node_build_signature (child, str))
  3018 array_write_value (TestTypeNode   *node,
  3023   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3024   DataBlockState saved;
  3030   TestTypeNode *child;
  3032   n_copies = node->klass->subclass_detail;
  3036   data_block_save (block, &saved);
  3043   if (!node_build_signature (child,
  3044                              &element_signature))
  3050                                   &element_signature, 0,
  3054   if (arrays_write_fixed_in_blocks &&
  3056       child->klass->write_multi)
  3058       if (!node_write_multi (child, block, &sub, seed, n_copies))
  3064       while (i < n_copies)
  3069           while (link != 
NULL)
  3071               TestTypeNode *child = link->
data;
  3074               if (!node_write_value (child, block, &sub, seed + i))
  3091   data_block_restore (block, &saved);
  3097 array_read_or_set_value (TestTypeNode   *node,
  3102   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3106   TestTypeNode *child;
  3108   n_copies = node->klass->subclass_detail;
  3118       if (realign_root == 
NULL && arrays_write_fixed_in_blocks &&
  3120           child->klass->read_multi)
  3122           if (!node_read_multi (child, &sub, seed, n_copies))
  3128           while (i < n_copies)
  3133               while (link != 
NULL)
  3135                   TestTypeNode *child = link->
data;
  3141                   if (realign_root == 
NULL)
  3143                       if (!node_read_value (child, &sub, seed + i))
  3148                       if (!node_set_value (child, &sub, realign_root, seed + i))
  3152                   if (i == (n_copies - 1) && next == 
NULL)
  3153                     NEXT_EXPECTING_FALSE (&sub);
  3155                     NEXT_EXPECTING_TRUE (&sub);
  3169 array_read_value (TestTypeNode   *node,
  3173   return array_read_or_set_value (node, reader, 
NULL, seed);
  3177 array_set_value (TestTypeNode   *node,
  3182   return array_read_or_set_value (node, reader, realign_root, seed);
  3186 array_build_signature (TestTypeNode   *node,
  3189   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3192   orig_len = _dbus_string_get_length (str);
  3209 #define VARIANT_SEED 10  3212 variant_write_value (TestTypeNode   *node,
  3217   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3218   DataBlockState saved;
  3221   TestTypeNode *child;
  3228   data_block_save (block, &saved);
  3233   if (!node_build_signature (child,
  3234                              &content_signature))
  3238                                   &content_signature, 0,
  3242   if (!node_write_value (child, block, &sub, seed + VARIANT_SEED))
  3252   data_block_restore (block, &saved);
  3258 variant_read_or_set_value (TestTypeNode   *node,
  3263   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3265   TestTypeNode *child;
  3276   if (realign_root == 
NULL)
  3278       if (!node_read_value (child, &sub, seed + VARIANT_SEED))
  3283       if (!node_set_value (child, &sub, realign_root, seed + VARIANT_SEED))
  3287   NEXT_EXPECTING_FALSE (&sub);
  3293 variant_read_value (TestTypeNode   *node,
  3297   return variant_read_or_set_value (node, reader, 
NULL, seed);
  3301 variant_set_value (TestTypeNode   *node,
  3306   return variant_read_or_set_value (node, reader, realign_root, seed);
  3310 dict_write_value (TestTypeNode   *node,
  3315   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3316   DataBlockState saved;
  3322   TestTypeNode *child;
  3324   n_entries = node->klass->subclass_detail;
  3328   data_block_save (block, &saved);
  3341   if (!node_build_signature (child,
  3342                              &entry_value_signature))
  3351                           &dict_entry_signature,
  3352                           _dbus_string_get_length (&dict_entry_signature)))
  3360                                   &dict_entry_signature, 0,
  3365   while (i < n_entries)
  3375       key = int32_from_seed (seed + i);
  3382       if (!node_write_value (child, block, &entry_sub, seed + i))
  3399   data_block_restore (block, &saved);
  3406 dict_read_or_set_value (TestTypeNode   *node,
  3411   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3415   TestTypeNode *child;
  3417   n_entries = node->klass->subclass_detail;
  3430       while (i < n_entries)
  3438           if (realign_root == 
NULL)
  3445                                             (dbus_int32_t*) &v);
  3449               NEXT_EXPECTING_TRUE (&entry_sub);
  3451               if (!node_read_value (child, &entry_sub, seed + i))
  3454               NEXT_EXPECTING_FALSE (&entry_sub);
  3460               v = int32_from_seed (seed + i);
  3467               NEXT_EXPECTING_TRUE (&entry_sub);
  3469               if (!node_set_value (child, &entry_sub, realign_root, seed + i))
  3472               NEXT_EXPECTING_FALSE (&entry_sub);
  3475           if (i == (n_entries - 1))
  3476             NEXT_EXPECTING_FALSE (&sub);
  3478             NEXT_EXPECTING_TRUE (&sub);
  3488 dict_read_value (TestTypeNode   *node,
  3492   return dict_read_or_set_value (node, reader, 
NULL, seed);
  3496 dict_set_value (TestTypeNode   *node,
  3501   return dict_read_or_set_value (node, reader, realign_root, seed);
  3505 dict_build_signature (TestTypeNode   *node,
  3508   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3511   orig_len = _dbus_string_get_length (str);
  3534 container_destroy (TestTypeNode *node)
  3536   TestTypeNodeContainer *container = (TestTypeNodeContainer*) node;
  3540   while (link != 
NULL)
  3542       TestTypeNode *child = link->
data;
  3545       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(). 
#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". 
#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. 
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 
#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. 
#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.