25#include "dbus-marshal-recursive.h"
26#include "dbus-marshal-basic.h"
27#include "dbus-signature.h"
28#include "dbus-internals.h"
43 int start_after_new_pos,
44 int start_after_new_len,
48#define RECURSIVE_MARSHAL_READ_TRACE 0
51#define RECURSIVE_MARSHAL_WRITE_TRACE 0
75apply_and_free_fixups (
DBusList **fixups,
80#if RECURSIVE_MARSHAL_WRITE_TRACE
82 _dbus_verbose (
" %d FIXUPS to apply\n",
99#if RECURSIVE_MARSHAL_WRITE_TRACE
100 _dbus_verbose (
" applying FIXUP to reader %p at pos %d new_len = %d old len %d\n",
138element_type_get_alignment (
const DBusString *str,
175struct_or_dict_entry_types_only_reader_recurse (
DBusTypeReader *sub,
178 base_reader_recurse (sub, parent);
182 _dbus_string_get_byte (sub->
type_str,
192 struct_or_dict_entry_types_only_reader_recurse (sub, parent);
202 base_reader_recurse (sub, parent);
214#define ARRAY_READER_LEN_POS(reader) \
215 ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4)
220 dbus_uint32_t array_len;
225 _dbus_assert (_DBUS_ALIGN_VALUE (len_pos, 4) == (
unsigned) len_pos);
227 _dbus_string_get_const_udata_len (reader->
value_str, len_pos, 4));
229#if RECURSIVE_MARSHAL_READ_TRACE
230 _dbus_verbose (
" reader %p len_pos %d array len %u len_offset %d\n",
246 array_types_only_reader_recurse (sub, parent);
254 alignment = element_type_get_alignment (sub->
type_str,
263#if RECURSIVE_MARSHAL_READ_TRACE
264 _dbus_verbose (
" type reader %p array start = %d len_offset = %d array len = %d array element type = %s\n",
268 array_reader_get_array_len (sub),
279 int contained_alignment;
281 base_reader_recurse (sub, parent);
299#if RECURSIVE_MARSHAL_READ_TRACE
300 _dbus_verbose (
" type reader %p variant containing '%s'\n",
302 _dbus_string_get_const_data_len (sub->
type_str,
316 end_pos = reader->
u.array.
start_pos + array_reader_get_array_len (reader);
325skip_one_complete_type (
const DBusString *type_str,
344 const unsigned char *p;
345 const unsigned char *start;
350 start = (
const unsigned char *)type_str;
351 p = start + *type_pos;
421 *type_pos = (int) (p - start);
425find_len_of_complete_type (
const DBusString *type_str,
432 skip_one_complete_type (type_str, &end);
434 return end - type_pos;
441 switch (current_type)
508 base_reader_next (reader, current_type);
529 base_reader_next (reader, current_type);
563 end_pos = reader->
u.array.
start_pos + array_reader_get_array_len (reader);
565#if RECURSIVE_MARSHAL_READ_TRACE
566 _dbus_verbose (
" reader %p array next START start_pos = %d end_pos = %d value_pos = %d current_type = %s\n",
618#if RECURSIVE_MARSHAL_READ_TRACE
619 _dbus_verbose (
" reader %p array next END start_pos = %d end_pos = %d value_pos = %d current_type = %s\n",
630 skip_one_complete_type (reader->
type_str,
654 struct_or_dict_entry_reader_recurse,
662 struct_or_dict_entry_types_only_reader_recurse,
670 struct_or_dict_entry_reader_recurse,
672 dict_entry_reader_next
676 "dict_entry types", 5,
678 struct_or_dict_entry_types_only_reader_recurse,
680 dict_entry_reader_next
686 array_reader_recurse,
687 array_reader_check_finished,
694 array_types_only_reader_recurse,
696 array_types_only_reader_next
702 variant_reader_recurse,
707#ifndef DBUS_DISABLE_ASSERT
709all_reader_classes[] = {
711 &body_types_only_reader_class,
712 &struct_reader_class,
713 &struct_types_only_reader_class,
714 &dict_entry_reader_class,
715 &dict_entry_types_only_reader_class,
717 &array_types_only_reader_class,
718 &variant_reader_class
740 reader_init (reader, byte_order, type_str, type_pos,
741 value_str, value_pos);
743 reader->
klass = &body_reader_class;
745#if RECURSIVE_MARSHAL_READ_TRACE
746 _dbus_verbose (
" type reader %p init type_pos = %d value_pos = %d remaining sig '%s'\n",
765 reader_init (reader, DBUS_COMPILER_BYTE_ORDER ,
768 reader->
klass = &body_types_only_reader_class;
770#if RECURSIVE_MARSHAL_READ_TRACE
771 _dbus_verbose (
" type reader %p init types only type_pos = %d remaining sig '%s'\n",
804 _dbus_verbose (
" type reader %p current type_pos = %d type = %s\n",
854 const unsigned char **value_location)
858 *value_location = _dbus_string_get_const_udata_len (reader->
value_str,
886#if RECURSIVE_MARSHAL_READ_TRACE
887 _dbus_verbose (
" type reader %p read basic type_pos = %d value_pos = %d remaining sig '%s'\n",
905 return array_reader_get_array_len (reader);
947 total_len = array_reader_get_array_len (reader);
948 end_pos = reader->
u.array.
start_pos + total_len;
949 remaining_len = end_pos - reader->
value_pos;
951#if RECURSIVE_MARSHAL_READ_TRACE
952 _dbus_verbose (
"end_pos %d total_len %d remaining_len %d value_pos %d\n",
953 end_pos, total_len, remaining_len, reader->
value_pos);
958 if (remaining_len == 0)
961 *value = _dbus_string_get_const_data_len (reader->
value_str,
965 *n_elements = remaining_len / alignment;
968#if RECURSIVE_MARSHAL_READ_TRACE
969 _dbus_verbose (
" type reader %p read fixed array type_pos = %d value_pos = %d remaining sig '%s'\n",
1000 klass = &struct_types_only_reader_class;
1002 klass = &struct_reader_class;
1006 klass = &dict_entry_types_only_reader_class;
1008 klass = &dict_entry_reader_class;
1012 klass = &array_types_only_reader_class;
1014 klass = &array_reader_class;
1020 klass = &variant_reader_class;
1024#ifndef DBUS_DISABLE_CHECKS
1035 (* klass->
recurse) (sub, reader);
1038#if RECURSIVE_MARSHAL_READ_TRACE
1039 _dbus_verbose (
" type reader %p RECURSED type_pos = %d value_pos = %d remaining sig '%s'\n",
1060#if RECURSIVE_MARSHAL_READ_TRACE
1061 _dbus_verbose (
" type reader %p START next() { type_pos = %d value_pos = %d remaining sig '%s' current_type = %s\n",
1072#if RECURSIVE_MARSHAL_READ_TRACE
1073 _dbus_verbose (
" type reader %p END next() type_pos = %d value_pos = %d remaining sig '%s' current_type = %s\n",
1175 orig_len = _dbus_string_get_length (&block->
replacement);
1177 realign_reader = *realign_root;
1179#if RECURSIVE_MARSHAL_WRITE_TRACE
1180 _dbus_verbose (
"INITIALIZING replacement block writer %p at value_pos %d\n",
1181 &writer, _dbus_string_get_length (&block->
replacement));
1192#if RECURSIVE_MARSHAL_WRITE_TRACE
1193 _dbus_verbose (
"COPYING from reader at value_pos %d to writer %p starting after value_pos %d\n",
1197 if (!_dbus_type_writer_write_reader_partial (&writer,
1205#if RECURSIVE_MARSHAL_WRITE_TRACE
1206 _dbus_verbose (
"REPLACEMENT at padding %d len %d\n", block->
padding,
1210 _dbus_verbose (
"TO BE REPLACED at value_pos = %d (align pad %d) len %d realign_reader.value_pos %d\n",
1230 apply_and_free_fixups (&fixups, reader);
1236 free_fixups (&fixups);
1283 if (!replacement_block_init (&block, reader))
1287#if RECURSIVE_MARSHAL_WRITE_TRACE
1288 _dbus_verbose (
"INITIALIZING writer %p to write basic value at value_pos %d of replacement string\n",
1289 &writer, _dbus_string_get_length (&block.
replacement));
1297#if RECURSIVE_MARSHAL_WRITE_TRACE
1298 _dbus_verbose (
"WRITING basic value to writer %p (replacement string)\n", &writer);
1303 if (!replacement_block_replace (&block,
1311 replacement_block_free (&block);
1375#if RECURSIVE_MARSHAL_WRITE_TRACE
1376 _dbus_verbose (
" SET BASIC type reader %p type_pos = %d value_pos = %d remaining sig '%s' realign_root = %p with value_pos %d current_type = %s\n",
1380 realign_root ? realign_root->
value_pos : -1,
1383 _dbus_string_get_length (realign_root->
value_str) -
1391 reader_set_basic_fixed_length (reader, current_type, value);
1397 return reader_set_basic_variable_length (reader, current_type,
1398 value, realign_root);
1431 if (!replacement_block_init (&block, reader))
1434 if (!replacement_block_replace (&block,
1442 replacement_block_free (&block);
1509#if RECURSIVE_MARSHAL_WRITE_TRACE
1510 _dbus_verbose (
"writer %p init remaining sig '%s'\n", writer,
1534 NULL, 0, value_str, value_pos);
1593 value_str, value_pos);
1599_dbus_type_writer_write_basic_no_typecode (
DBusTypeWriter *writer,
1657#ifndef DBUS_DISABLE_CHECKS
1668 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1674 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1683#if RECURSIVE_MARSHAL_WRITE_TRACE
1684 _dbus_verbose (
" type writer %p recurse parent %s type_pos = %d value_pos = %d is_expectation = %d remaining sig '%s' enabled = %d\n",
1692 _dbus_verbose (
" type writer %p recurse sub %s type_pos = %d value_pos = %d is_expectation = %d enabled = %d\n",
1710#if RECURSIVE_MARSHAL_WRITE_TRACE
1711 _dbus_verbose (
" type writer %p write_or_verify start type_pos = %d remaining sig '%s' enabled = %d\n",
1724#ifndef DBUS_DISABLE_CHECKS
1730 if (expected != typecode)
1734 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1738 _dbus_warn_check_failed (
"Array or variant type wasn't expecting any more values to be written into it, but a value %s was written.\n"
1739 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1764#if RECURSIVE_MARSHAL_WRITE_TRACE
1765 _dbus_verbose (
" type writer %p write_or_verify end type_pos = %d remaining sig '%s'\n",
1777 int contained_type_start,
1778 int contained_type_len,
1793 if (!write_or_verify_typecode (sub, begin_char))
1813 int contained_type_start,
1814 int contained_type_len,
1818 dbus_uint32_t value = 0;
1822#ifndef DBUS_DISABLE_CHECKS
1827 contained_type_start,
1832 _dbus_warn_check_failed (
"Writing an array of '%s' but this is incompatible with the expected type of elements in the parent array",
1833 _dbus_string_get_const_data_len (contained_type,
1834 contained_type_start,
1835 contained_type_len));
1841 if (writer->
enabled && !is_array_append)
1872 contained_type_start, contained_type_len,
1884 writer->
type_pos += 1 + contained_type_len;
1894 if (is_array_append)
1911 alignment = element_type_get_alignment (contained_type, contained_type_start);
1913 aligned = _DBUS_ALIGN_VALUE (sub->
value_pos, alignment);
1916 if (!is_array_append)
1930 if (is_array_append)
1937 _dbus_string_get_const_udata_len (sub->
value_str,
1954#if RECURSIVE_MARSHAL_WRITE_TRACE
1955 _dbus_verbose (
" type writer %p recurse array done remaining sig '%s' array start_pos = %d len_pos = %d value_pos = %d\n", sub,
1986 int contained_type_start,
1987 int contained_type_len,
1990 int contained_alignment;
2020 contained_type_len))
2058 int contained_type_start,
2059 int contained_type_len,
2063 writer_recurse_init_and_check (writer, container_type, sub);
2065 switch (container_type)
2068 return writer_recurse_struct_or_dict_entry (writer,
2071 contained_type_start, contained_type_len,
2075 return writer_recurse_struct_or_dict_entry (writer,
2078 contained_type_start, contained_type_len,
2082 return writer_recurse_array (writer,
2083 contained_type, contained_type_start, contained_type_len,
2084 sub, is_array_append);
2087 return writer_recurse_variant (writer,
2088 contained_type, contained_type_start, contained_type_len,
2112 int contained_type_start,
2115 int contained_type_len;
2118 contained_type_len = find_len_of_complete_type (contained_type, contained_type_start);
2120 contained_type_len = 0;
2122 return _dbus_type_writer_recurse_contained_len (writer, container_type,
2124 contained_type_start,
2145 int contained_type_start,
2148 int contained_type_len;
2151 contained_type_len = find_len_of_complete_type (contained_type, contained_type_start);
2153 contained_type_len = 0;
2155 return _dbus_type_writer_recurse_contained_len (writer,
DBUS_TYPE_ARRAY,
2157 contained_type_start,
2186#if RECURSIVE_MARSHAL_WRITE_TRACE
2187 _dbus_verbose (
" type writer %p unrecurse type_pos = %d value_pos = %d is_expectation = %d container_type = %s\n",
2190 _dbus_verbose (
" type writer %p unrecurse sub type_pos = %d value_pos = %d is_expectation = %d container_type = %s\n",
2213 len = writer_get_array_len (sub);
2218#if RECURSIVE_MARSHAL_WRITE_TRACE
2219 _dbus_verbose (
" filled in sub array len to %u at len_pos %d\n",
2223#if RECURSIVE_MARSHAL_WRITE_TRACE
2226 _dbus_verbose (
" not filling in sub array len because we were disabled when we passed the len\n");
2291#if RECURSIVE_MARSHAL_WRITE_TRACE
2292 _dbus_verbose (
" type writer %p unrecursed type_pos = %d value_pos = %d remaining sig '%s'\n",
2326 if (!_dbus_type_writer_write_basic_no_typecode (writer, type, value))
2329 if (!write_or_verify_typecode (writer, type))
2335#if RECURSIVE_MARSHAL_WRITE_TRACE
2336 _dbus_verbose (
" type writer %p basic type_pos = %d value_pos = %d is_expectation = %d enabled = %d\n",
2369#if RECURSIVE_MARSHAL_WRITE_TRACE
2370 _dbus_verbose (
" type writer %p entering fixed multi type_pos = %d value_pos = %d n_elements %d\n",
2374 if (!write_or_verify_typecode (writer, element_type))
2389#if RECURSIVE_MARSHAL_WRITE_TRACE
2390 _dbus_verbose (
" type writer %p fixed multi written new type_pos = %d new value_pos = %d n_elements %d\n",
2404 if (!writer->
enabled && _dbus_type_reader_greater_than (reader, start_after))
2406 _dbus_type_writer_set_enabled (writer,
TRUE);
2407#if RECURSIVE_MARSHAL_WRITE_TRACE
2408 _dbus_verbose (
"ENABLING writer %p at %d because reader at value_pos %d is after reader at value_pos %d\n",
2413 _dbus_assert ((!writer->
enabled && !_dbus_type_reader_greater_than (reader, start_after)) ||
2414 (writer->
enabled && _dbus_type_reader_greater_than (reader, start_after)));
2449 int start_after_new_pos,
2450 int start_after_new_len,
2467 int reader_array_len_pos;
2468 int reader_array_start_pos;
2476 if (!inside_start_after && start_after &&
2480 this_is_start_after =
TRUE;
2482 this_is_start_after =
FALSE;
2489 reader_array_start_pos = subreader.
u.array.
start_pos;
2494 reader_array_len_pos = -1;
2495 reader_array_start_pos = -1;
2499 &sig_start, &sig_len);
2501#if RECURSIVE_MARSHAL_WRITE_TRACE
2502 _dbus_verbose (
"about to recurse into %s reader at %d subreader at %d writer at %d start_after reader at %d write target len %d inside_start_after = %d this_is_start_after = %d\n",
2507 start_after ? start_after->
value_pos : -1,
2508 _dbus_string_get_length (writer->
value_str),
2509 inside_start_after, this_is_start_after);
2512 if (!inside_start_after && !this_is_start_after)
2513 enable_if_after (writer, &subreader, start_after);
2514 enabled_at_recurse = writer->
enabled;
2515 if (!_dbus_type_writer_recurse_contained_len (writer, current_type,
2516 sig_str, sig_start, sig_len,
2520#if RECURSIVE_MARSHAL_WRITE_TRACE
2521 _dbus_verbose (
"recursed into subwriter at %d write target len %d\n",
2523 _dbus_string_get_length (subwriter.
value_str));
2526 if (!writer_write_reader_helper (&subwriter, &subreader, start_after,
2527 start_after_new_pos, start_after_new_len,
2529 inside_start_after ||
2530 this_is_start_after))
2533#if RECURSIVE_MARSHAL_WRITE_TRACE
2534 _dbus_verbose (
"about to unrecurse from %s subreader at %d writer at %d subwriter at %d write target len %d\n",
2539 _dbus_string_get_length (writer->
value_str));
2542 if (!inside_start_after && !this_is_start_after)
2543 enable_if_after (writer, &subreader, start_after);
2544 past_start_after = writer->
enabled;
2553 if (start_after !=
NULL &&
2554 !enabled_at_recurse && past_start_after &&
2559 int bytes_written_after_start_after;
2560 int bytes_before_start_after;
2567 bytes_written_after_start_after = writer_get_array_len (&subwriter);
2569 bytes_before_start_after =
2570 start_after->
value_pos - reader_array_start_pos;
2574 bytes_before_start_after +
2575 start_after_new_len +
2576 bytes_written_after_start_after;
2582 _dbus_string_get_const_udata_len (reader->
value_str,
2585 if (old_len != fixup.
new_len && !append_fixup (fixups, &fixup))
2588#if RECURSIVE_MARSHAL_WRITE_TRACE
2589 _dbus_verbose (
"Generated fixup len_pos_in_reader = %d new_len = %d reader_array_start_pos = %d start_after->value_pos = %d bytes_before_start_after = %d start_after_new_len = %d bytes_written_after_start_after = %d\n",
2592 reader_array_start_pos,
2594 bytes_before_start_after,
2595 start_after_new_len,
2596 bytes_written_after_start_after);
2606#if RECURSIVE_MARSHAL_WRITE_TRACE
2607 _dbus_verbose (
"Reading basic value %s at %d\n",
2614#if RECURSIVE_MARSHAL_WRITE_TRACE
2615 _dbus_verbose (
"Writing basic value %s at %d write target len %d inside_start_after = %d\n",
2618 _dbus_string_get_length (writer->
value_str),
2619 inside_start_after);
2621 if (!inside_start_after)
2622 enable_if_after (writer, reader, start_after);
2625#if RECURSIVE_MARSHAL_WRITE_TRACE
2626 _dbus_verbose (
"Wrote basic value %s, new value_pos %d write target len %d\n",
2629 _dbus_string_get_length (writer->
value_str));
2640 apply_and_free_fixups (fixups,
NULL);
2680 int start_after_new_pos,
2681 int start_after_new_len,
2691 orig_type_len = _dbus_string_get_length (writer->
type_str);
2692 orig_value_len = _dbus_string_get_length (writer->
value_str);
2693 orig_enabled = writer->
enabled;
2696 _dbus_type_writer_set_enabled (writer,
FALSE);
2698 if (!writer_write_reader_helper (writer, reader, start_after,
2699 start_after_new_pos,
2700 start_after_new_len,
2704 _dbus_type_writer_set_enabled (writer, orig_enabled);
2710 new_bytes = _dbus_string_get_length (writer->
type_str) - orig_type_len;
2713 new_bytes = _dbus_string_get_length (writer->
value_str) - orig_value_len;
2734 return _dbus_type_writer_write_reader_partial (writer, reader,
NULL, 0, 0,
NULL);
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
#define _DBUS_INT_MAX
Maximum value of type "int".
void _dbus_warn_check_failed(const char *format,...)
Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
#define _DBUS_ZERO(object)
Sets all bits in an object to zero.
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
void _dbus_list_free_link(DBusList *link)
Frees a linked list node allocated with _dbus_list_alloc_link.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to 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 NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
dbus_bool_t _dbus_type_writer_write_basic(DBusTypeWriter *writer, int type, const void *value)
Writes out a basic type.
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...
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...
int _dbus_type_reader_get_value_pos(const DBusTypeReader *reader)
Gets the current position in the value block.
int _dbus_type_get_alignment(int typecode)
Gets the alignment requirement for the given type; will be 1, 4, or 8.
void _dbus_type_writer_remove_types(DBusTypeWriter *writer)
Removes type string from the writer.
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.
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.
void _dbus_type_reader_init_types_only(DBusTypeReader *reader, const DBusString *type_str, int type_pos)
Like _dbus_type_reader_init() but the iteration is over the signature, not over values.
void _dbus_type_reader_get_signature(const DBusTypeReader *reader, const DBusString **str_p, int *start_p, int *len_p)
Gets the string and range of said string containing the signature of the current value.
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.
void _dbus_marshal_set_uint32(DBusString *str, int pos, dbus_uint32_t value, int byte_order)
Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there ...
dbus_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.
dbus_uint32_t _dbus_unpack_uint32(int byte_order, const unsigned char *data)
Unpacks a 32 bit unsigned integer from a data pointer.
dbus_bool_t _dbus_marshal_write_basic(DBusString *str, int insert_at, int type, const void *value, int byte_order, int *pos_after)
Marshals a basic-typed value.
int _dbus_first_type_in_signature(const DBusString *str, int pos)
Get the first type in the signature.
void _dbus_type_reader_read_fixed_multi(const DBusTypeReader *reader, const 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_uint32_t _dbus_marshal_read_uint32(const DBusString *str, int pos, int byte_order, int *new_pos)
Convenience function to demarshal a 32 bit unsigned integer.
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.
dbus_bool_t _dbus_type_reader_next(DBusTypeReader *reader)
Skip to the next value on this "level".
int _dbus_type_reader_get_array_length(const DBusTypeReader *reader)
Returns the number of bytes in the array.
dbus_bool_t _dbus_marshal_set_basic(DBusString *str, int pos, int type, const void *value, int byte_order, int *old_end_pos, int *new_end_pos)
Sets an existing basic type value to a new value.
void _dbus_type_writer_add_types(DBusTypeWriter *writer, DBusString *type_str, int type_pos)
Adds type string to the writer, if it had none.
void _dbus_marshal_skip_array(const DBusString *str, int element_type, int byte_order, int *pos)
Skips an array, returning the next position.
dbus_bool_t _dbus_type_reader_has_next(const DBusTypeReader *reader)
Check whether there's another value on this "level".
dbus_bool_t _dbus_marshal_write_fixed_multi(DBusString *str, int insert_at, int element_type, const void *value, int n_elements, int byte_order, int *pos_after)
Marshals a block of values of fixed-length type all at once, as an optimization.
dbus_bool_t _dbus_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_reader_read_basic(const DBusTypeReader *reader, void *value)
Reads a basic-typed value, as with _dbus_marshal_read_basic().
void _dbus_type_writer_init_types_delayed(DBusTypeWriter *writer, int byte_order, DBusString *value_str, int value_pos)
Initialize a write iterator, with the signature to be provided later.
const char * _dbus_type_to_string(int typecode)
Returns a string describing the given type.
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...
void _dbus_marshal_read_basic(const DBusString *str, int pos, int type, void *value, int byte_order, int *new_pos)
Demarshals a basic-typed value.
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...
void _dbus_type_reader_read_raw(const DBusTypeReader *reader, const unsigned char **value_location)
Get the address of the marshaled value in the data being read.
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_writer_append_array(DBusTypeWriter *writer, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
Append to an existing array.
#define ARRAY_READER_LEN_POS(reader)
compute position of array length given array_len_offset, which is the offset back from start_pos to e...
dbus_bool_t _dbus_type_writer_write_fixed_multi(DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
Writes a block of fixed-length basic values, i.e.
void _dbus_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.
void _dbus_type_signature_next(const char *type_str, int *type_pos)
Skips to the next "complete" type inside a type signature.
void _dbus_marshal_skip_basic(const DBusString *str, int type, int byte_order, int *pos)
Skips over a basic-typed value, reporting the following position.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
#define DBUS_DICT_ENTRY_END_CHAR
Code marking the end of a dict entry type in a type signature.
#define DBUS_TYPE_VARIANT
Type code marking a D-Bus variant type.
#define DBUS_STRUCT_BEGIN_CHAR
Code marking the start of a struct type in a type signature.
#define DBUS_TYPE_ARRAY
Type code marking a D-Bus array type.
#define DBUS_TYPE_INVALID
Type code that is never equal to a legitimate type code.
#define DBUS_TYPE_DICT_ENTRY
Type code used to represent a dict entry; however, this type code does not appear in type signatures,...
#define DBUS_DICT_ENTRY_BEGIN_CHAR
Code marking the start of a dict entry type in a type signature.
#define DBUS_TYPE_STRUCT
STRUCT and DICT_ENTRY are sort of special since their codes can't appear in a type string,...
#define DBUS_STRUCT_END_CHAR
Code marking the end of a struct type in a type signature.
#define DBUS_TYPE_UINT32
Type code marking a 32-bit unsigned integer.
dbus_bool_t dbus_type_is_basic(int typecode)
A "basic type" is a somewhat arbitrary concept, but the intent is to include those types that are ful...
dbus_bool_t dbus_type_is_fixed(int typecode)
Tells you whether values of this type can change length if you set them to some other value.
dbus_bool_t dbus_type_is_container(int typecode)
A "container type" can contain basic types, or nested container types.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
dbus_bool_t _dbus_string_equal_substring(const DBusString *a, int a_start, int a_len, const DBusString *b, int b_start)
Tests two sub-parts of two DBusString for equality.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
dbus_bool_t _dbus_string_alloc_space(DBusString *str, int extra_bytes)
Preallocate extra_bytes such that a future lengthening of the string by extra_bytes is guaranteed to ...
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
void _dbus_string_delete(DBusString *str, int start, int len)
Deletes a segment of a DBusString with length len starting at start.
dbus_bool_t _dbus_string_lengthen(DBusString *str, int additional_length)
Makes a string longer by the given number of bytes.
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.
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_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
dbus_bool_t _dbus_string_replace_len(const DBusString *source, int start, int len, DBusString *dest, int replace_at, int replace_len)
Replaces a segment of dest string with a segment of source string.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
When modifying an existing block of values, array lengths may need to be adjusted; those adjustments ...
int new_len
the new value of the length in the written-out block
int len_pos_in_reader
where the length was in the original block
void * data
Data stored at this element.
Virtual table for a type reader.
void(* next)(DBusTypeReader *reader, int current_type)
go to the next value
int id
index in all_reader_classes
dbus_bool_t(* check_finished)(const DBusTypeReader *reader)
check whether reader is at the end
void(* recurse)(DBusTypeReader *sub, DBusTypeReader *parent)
recurse with this reader as sub
dbus_bool_t types_only
only iterates over types, not values
const char * name
name for debugging
The type reader is an iterator for reading values from a block of values.
int type_pos
current position in signature
const DBusTypeReaderClass * klass
the vtable for the reader
union DBusTypeReader::@1 u
class-specific data
const DBusString * value_str
string containing values of block
dbus_uint32_t finished
marks we're at end iterator for cases where we don't have another way to tell
int start_pos
for array readers, the start of the array values
dbus_uint32_t array_len_offset
bytes back from start_pos that len ends
int value_pos
current position in values
dbus_uint32_t byte_order
byte order of the block
const DBusString * type_str
string containing signature of block
The type writer is an iterator for writing to a block of values.
int element_type_pos
position of array element type in type_str
int start_pos
position of first element in the array
int value_pos
next position to write
dbus_uint32_t enabled
whether to write values
union DBusTypeWriter::@3 u
class-specific data
dbus_uint32_t byte_order
byte order to write values with
int type_pos
current pos in type_str
DBusString * type_str
where to write typecodes (or read type expectations)
int len_pos
position of length of the array
DBusString * value_str
where to write values
dbus_uint32_t container_type
what are we inside? (e.g.
dbus_uint32_t type_pos_is_expectation
type_pos can be either an insertion point for or an expected next type
int padding
How much of the replacement block is padding.
DBusString replacement
Marshaled value including alignment padding.
A simple value union that lets you access bytes as if they were various types; useful when dealing wi...