27#include "dbus-marshal-recursive.h"
28#include "dbus-marshal-basic.h"
29#include "dbus-signature.h"
30#include "dbus-internals.h"
37static dbus_bool_t _dbus_type_reader_greater_than (
const DBusTypeReader *lhs,
42static dbus_bool_t _dbus_type_writer_write_reader_partial (
DBusTypeWriter *writer,
45 int start_after_new_pos,
46 int start_after_new_len,
50#define RECURSIVE_MARSHAL_READ_TRACE 0
53#define RECURSIVE_MARSHAL_WRITE_TRACE 0
77apply_and_free_fixups (
DBusList **fixups,
82#if RECURSIVE_MARSHAL_WRITE_TRACE
84 _dbus_verbose (
" %d FIXUPS to apply\n",
101#if RECURSIVE_MARSHAL_WRITE_TRACE
102 _dbus_verbose (
" applying FIXUP to reader %p at pos %d new_len = %d old len %d\n",
140element_type_get_alignment (
const DBusString *str,
177struct_or_dict_entry_types_only_reader_recurse (
DBusTypeReader *sub,
180 base_reader_recurse (sub, parent);
194 struct_or_dict_entry_types_only_reader_recurse (sub, parent);
204 base_reader_recurse (sub, parent);
216#define ARRAY_READER_LEN_POS(reader) \
217 ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4)
222 dbus_uint32_t array_len;
227 _dbus_assert (_DBUS_ALIGN_VALUE (len_pos, 4) == (
unsigned) len_pos);
229 _dbus_string_get_const_udata_len (reader->
value_str, len_pos, 4));
231#if RECURSIVE_MARSHAL_READ_TRACE
232 _dbus_verbose (
" reader %p len_pos %d array len %u len_offset %d\n",
248 array_types_only_reader_recurse (sub, parent);
256 alignment = element_type_get_alignment (sub->
type_str,
265#if RECURSIVE_MARSHAL_READ_TRACE
266 _dbus_verbose (
" type reader %p array start = %d len_offset = %d array len = %d array element type = %s\n",
270 array_reader_get_array_len (sub),
281 int contained_alignment;
283 base_reader_recurse (sub, parent);
301#if RECURSIVE_MARSHAL_READ_TRACE
302 _dbus_verbose (
" type reader %p variant containing '%s'\n",
315 end_pos = reader->
u.array.
start_pos + array_reader_get_array_len (reader);
324skip_one_complete_type (
const DBusString *type_str,
343 const unsigned char *p;
344 const unsigned char *start;
349 start = (
const unsigned char *)type_str;
350 p = start + *type_pos;
420 *type_pos = (int) (p - start);
424find_len_of_complete_type (
const DBusString *type_str,
431 skip_one_complete_type (type_str, &end);
433 return end - type_pos;
440 switch (current_type)
507 base_reader_next (reader, current_type);
528 base_reader_next (reader, current_type);
562 end_pos = reader->
u.array.
start_pos + array_reader_get_array_len (reader);
564#if RECURSIVE_MARSHAL_READ_TRACE
565 _dbus_verbose (
" reader %p array next START start_pos = %d end_pos = %d value_pos = %d current_type = %s\n",
617#if RECURSIVE_MARSHAL_READ_TRACE
618 _dbus_verbose (
" reader %p array next END start_pos = %d end_pos = %d value_pos = %d current_type = %s\n",
629 skip_one_complete_type (reader->
type_str,
653 struct_or_dict_entry_reader_recurse,
661 struct_or_dict_entry_types_only_reader_recurse,
669 struct_or_dict_entry_reader_recurse,
671 dict_entry_reader_next
675 "dict_entry types", 5,
677 struct_or_dict_entry_types_only_reader_recurse,
679 dict_entry_reader_next
685 array_reader_recurse,
686 array_reader_check_finished,
693 array_types_only_reader_recurse,
695 array_types_only_reader_next
701 variant_reader_recurse,
706#ifndef DBUS_DISABLE_ASSERT
708all_reader_classes[] = {
710 &body_types_only_reader_class,
711 &struct_reader_class,
712 &struct_types_only_reader_class,
713 &dict_entry_reader_class,
714 &dict_entry_types_only_reader_class,
716 &array_types_only_reader_class,
717 &variant_reader_class
739 reader_init (reader, byte_order, type_str, type_pos,
740 value_str, value_pos);
742 reader->
klass = &body_reader_class;
744#if RECURSIVE_MARSHAL_READ_TRACE
745 _dbus_verbose (
" type reader %p init type_pos = %d value_pos = %d remaining sig '%s'\n",
764 reader_init (reader, DBUS_COMPILER_BYTE_ORDER ,
767 reader->
klass = &body_types_only_reader_class;
769#if RECURSIVE_MARSHAL_READ_TRACE
770 _dbus_verbose (
" type reader %p init types only type_pos = %d remaining sig '%s'\n",
803 _dbus_verbose (
" type reader %p current type_pos = %d type = %s\n",
853 const unsigned char **value_location)
857 *value_location = _dbus_string_get_const_udata_len (reader->
value_str,
885#if RECURSIVE_MARSHAL_READ_TRACE
886 _dbus_verbose (
" type reader %p read basic type_pos = %d value_pos = %d remaining sig '%s'\n",
904 return array_reader_get_array_len (reader);
946 total_len = array_reader_get_array_len (reader);
947 end_pos = reader->
u.array.
start_pos + total_len;
948 remaining_len = end_pos - reader->
value_pos;
950#if RECURSIVE_MARSHAL_READ_TRACE
951 _dbus_verbose (
"end_pos %d total_len %d remaining_len %d value_pos %d\n",
952 end_pos, total_len, remaining_len, reader->
value_pos);
957 if (remaining_len == 0)
964 *n_elements = remaining_len / alignment;
967#if RECURSIVE_MARSHAL_READ_TRACE
968 _dbus_verbose (
" type reader %p read fixed array type_pos = %d value_pos = %d remaining sig '%s'\n",
999 klass = &struct_types_only_reader_class;
1001 klass = &struct_reader_class;
1005 klass = &dict_entry_types_only_reader_class;
1007 klass = &dict_entry_reader_class;
1011 klass = &array_types_only_reader_class;
1013 klass = &array_reader_class;
1019 klass = &variant_reader_class;
1023#ifndef DBUS_DISABLE_CHECKS
1034 (* klass->
recurse) (sub, reader);
1037#if RECURSIVE_MARSHAL_READ_TRACE
1038 _dbus_verbose (
" type reader %p RECURSED type_pos = %d value_pos = %d remaining sig '%s'\n",
1059#if RECURSIVE_MARSHAL_READ_TRACE
1060 _dbus_verbose (
" type reader %p START next() { type_pos = %d value_pos = %d remaining sig '%s' current_type = %s\n",
1071#if RECURSIVE_MARSHAL_READ_TRACE
1072 _dbus_verbose (
" type reader %p END next() type_pos = %d value_pos = %d remaining sig '%s' current_type = %s\n",
1176 realign_reader = *realign_root;
1178#if RECURSIVE_MARSHAL_WRITE_TRACE
1179 _dbus_verbose (
"INITIALIZING replacement block writer %p at value_pos %d\n",
1191#if RECURSIVE_MARSHAL_WRITE_TRACE
1192 _dbus_verbose (
"COPYING from reader at value_pos %d to writer %p starting after value_pos %d\n",
1196 if (!_dbus_type_writer_write_reader_partial (&writer,
1204#if RECURSIVE_MARSHAL_WRITE_TRACE
1205 _dbus_verbose (
"REPLACEMENT at padding %d len %d\n", block->
padding,
1209 _dbus_verbose (
"TO BE REPLACED at value_pos = %d (align pad %d) len %d realign_reader.value_pos %d\n",
1229 apply_and_free_fixups (&fixups, reader);
1235 free_fixups (&fixups);
1282 if (!replacement_block_init (&block, reader))
1286#if RECURSIVE_MARSHAL_WRITE_TRACE
1287 _dbus_verbose (
"INITIALIZING writer %p to write basic value at value_pos %d of replacement string\n",
1296#if RECURSIVE_MARSHAL_WRITE_TRACE
1297 _dbus_verbose (
"WRITING basic value to writer %p (replacement string)\n", &writer);
1302 if (!replacement_block_replace (&block,
1310 replacement_block_free (&block);
1374#if RECURSIVE_MARSHAL_WRITE_TRACE
1375 _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",
1379 realign_root ? realign_root->
value_pos : -1,
1390 reader_set_basic_fixed_length (reader, current_type, value);
1396 return reader_set_basic_variable_length (reader, current_type,
1397 value, realign_root);
1430 if (!replacement_block_init (&block, reader))
1433 if (!replacement_block_replace (&block,
1441 replacement_block_free (&block);
1508#if RECURSIVE_MARSHAL_WRITE_TRACE
1509 _dbus_verbose (
"writer %p init remaining sig '%s'\n", writer,
1533 NULL, 0, value_str, value_pos);
1592 value_str, value_pos);
1598_dbus_type_writer_write_basic_no_typecode (
DBusTypeWriter *writer,
1656#ifndef DBUS_DISABLE_CHECKS
1667 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1673 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1682#if RECURSIVE_MARSHAL_WRITE_TRACE
1683 _dbus_verbose (
" type writer %p recurse parent %s type_pos = %d value_pos = %d is_expectation = %d remaining sig '%s' enabled = %d\n",
1691 _dbus_verbose (
" type writer %p recurse sub %s type_pos = %d value_pos = %d is_expectation = %d enabled = %d\n",
1709#if RECURSIVE_MARSHAL_WRITE_TRACE
1710 _dbus_verbose (
" type writer %p write_or_verify start type_pos = %d remaining sig '%s' enabled = %d\n",
1723#ifndef DBUS_DISABLE_CHECKS
1729 if (expected != typecode)
1733 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1737 _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"
1738 "The overall signature expected here was '%s' and we are on byte %d of that signature.",
1763#if RECURSIVE_MARSHAL_WRITE_TRACE
1764 _dbus_verbose (
" type writer %p write_or_verify end type_pos = %d remaining sig '%s'\n",
1776 int contained_type_start,
1777 int contained_type_len,
1792 if (!write_or_verify_typecode (sub, begin_char))
1812 int contained_type_start,
1813 int contained_type_len,
1815 dbus_bool_t is_array_append)
1817 dbus_uint32_t value = 0;
1821#ifndef DBUS_DISABLE_CHECKS
1826 contained_type_start,
1831 _dbus_warn_check_failed (
"Writing an array of '%s' but this is incompatible with the expected type of elements in the parent array",
1833 contained_type_start,
1834 contained_type_len));
1840 if (writer->
enabled && !is_array_append)
1871 contained_type_start, contained_type_len,
1883 writer->
type_pos += 1 + contained_type_len;
1893 if (is_array_append)
1910 alignment = element_type_get_alignment (contained_type, contained_type_start);
1912 aligned = _DBUS_ALIGN_VALUE (sub->
value_pos, alignment);
1915 if (!is_array_append)
1929 if (is_array_append)
1936 _dbus_string_get_const_udata_len (sub->
value_str,
1953#if RECURSIVE_MARSHAL_WRITE_TRACE
1954 _dbus_verbose (
" type writer %p recurse array done remaining sig '%s' array start_pos = %d len_pos = %d value_pos = %d\n", sub,
1958 sub->u.array.start_pos, sub->u.array.len_pos, sub->value_pos);
1985 int contained_type_start,
1986 int contained_type_len,
1989 int contained_alignment;
2019 contained_type_len))
2057 int contained_type_start,
2058 int contained_type_len,
2060 dbus_bool_t is_array_append)
2062 writer_recurse_init_and_check (writer, container_type, sub);
2064 switch (container_type)
2067 return writer_recurse_struct_or_dict_entry (writer,
2070 contained_type_start, contained_type_len,
2074 return writer_recurse_struct_or_dict_entry (writer,
2077 contained_type_start, contained_type_len,
2081 return writer_recurse_array (writer,
2082 contained_type, contained_type_start, contained_type_len,
2083 sub, is_array_append);
2086 return writer_recurse_variant (writer,
2087 contained_type, contained_type_start, contained_type_len,
2111 int contained_type_start,
2114 int contained_type_len;
2117 contained_type_len = find_len_of_complete_type (contained_type, contained_type_start);
2119 contained_type_len = 0;
2121 return _dbus_type_writer_recurse_contained_len (writer, container_type,
2123 contained_type_start,
2144 int contained_type_start,
2147 int contained_type_len;
2150 contained_type_len = find_len_of_complete_type (contained_type, contained_type_start);
2152 contained_type_len = 0;
2154 return _dbus_type_writer_recurse_contained_len (writer,
DBUS_TYPE_ARRAY,
2156 contained_type_start,
2185#if RECURSIVE_MARSHAL_WRITE_TRACE
2186 _dbus_verbose (
" type writer %p unrecurse type_pos = %d value_pos = %d is_expectation = %d container_type = %s\n",
2189 _dbus_verbose (
" type writer %p unrecurse sub type_pos = %d value_pos = %d is_expectation = %d container_type = %s\n",
2212 len = writer_get_array_len (sub);
2217#if RECURSIVE_MARSHAL_WRITE_TRACE
2218 _dbus_verbose (
" filled in sub array len to %u at len_pos %d\n",
2222#if RECURSIVE_MARSHAL_WRITE_TRACE
2225 _dbus_verbose (
" not filling in sub array len because we were disabled when we passed the len\n");
2290#if RECURSIVE_MARSHAL_WRITE_TRACE
2291 _dbus_verbose (
" type writer %p unrecursed type_pos = %d value_pos = %d remaining sig '%s'\n",
2325 if (!_dbus_type_writer_write_basic_no_typecode (writer, type, value))
2328 if (!write_or_verify_typecode (writer, type))
2334#if RECURSIVE_MARSHAL_WRITE_TRACE
2335 _dbus_verbose (
" type writer %p basic type_pos = %d value_pos = %d is_expectation = %d enabled = %d\n",
2368#if RECURSIVE_MARSHAL_WRITE_TRACE
2369 _dbus_verbose (
" type writer %p entering fixed multi type_pos = %d value_pos = %d n_elements %d\n",
2373 if (!write_or_verify_typecode (writer, element_type))
2388#if RECURSIVE_MARSHAL_WRITE_TRACE
2389 _dbus_verbose (
" type writer %p fixed multi written new type_pos = %d new value_pos = %d n_elements %d\n",
2403 if (!writer->
enabled && _dbus_type_reader_greater_than (reader, start_after))
2405 _dbus_type_writer_set_enabled (writer,
TRUE);
2406#if RECURSIVE_MARSHAL_WRITE_TRACE
2407 _dbus_verbose (
"ENABLING writer %p at %d because reader at value_pos %d is after reader at value_pos %d\n",
2412 _dbus_assert ((!writer->
enabled && !_dbus_type_reader_greater_than (reader, start_after)) ||
2413 (writer->
enabled && _dbus_type_reader_greater_than (reader, start_after)));
2448 int start_after_new_pos,
2449 int start_after_new_len,
2451 dbus_bool_t inside_start_after)
2464 dbus_bool_t enabled_at_recurse;
2465 dbus_bool_t past_start_after;
2466 int reader_array_len_pos;
2467 int reader_array_start_pos;
2468 dbus_bool_t this_is_start_after;
2475 if (!inside_start_after && start_after &&
2479 this_is_start_after =
TRUE;
2481 this_is_start_after =
FALSE;
2488 reader_array_start_pos = subreader.
u.array.
start_pos;
2493 reader_array_len_pos = -1;
2494 reader_array_start_pos = -1;
2498 &sig_start, &sig_len);
2500#if RECURSIVE_MARSHAL_WRITE_TRACE
2501 _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",
2506 start_after ? start_after->
value_pos : -1,
2508 inside_start_after, this_is_start_after);
2511 if (!inside_start_after && !this_is_start_after)
2512 enable_if_after (writer, &subreader, start_after);
2513 enabled_at_recurse = writer->
enabled;
2514 if (!_dbus_type_writer_recurse_contained_len (writer, current_type,
2515 sig_str, sig_start, sig_len,
2519#if RECURSIVE_MARSHAL_WRITE_TRACE
2520 _dbus_verbose (
"recursed into subwriter at %d write target len %d\n",
2525 if (!writer_write_reader_helper (&subwriter, &subreader, start_after,
2526 start_after_new_pos, start_after_new_len,
2528 inside_start_after ||
2529 this_is_start_after))
2532#if RECURSIVE_MARSHAL_WRITE_TRACE
2533 _dbus_verbose (
"about to unrecurse from %s subreader at %d writer at %d subwriter at %d write target len %d\n",
2541 if (!inside_start_after && !this_is_start_after)
2542 enable_if_after (writer, &subreader, start_after);
2543 past_start_after = writer->
enabled;
2552 if (start_after !=
NULL &&
2553 !enabled_at_recurse && past_start_after &&
2558 int bytes_written_after_start_after;
2559 int bytes_before_start_after;
2566 bytes_written_after_start_after = writer_get_array_len (&subwriter);
2568 bytes_before_start_after =
2569 start_after->
value_pos - reader_array_start_pos;
2573 bytes_before_start_after +
2574 start_after_new_len +
2575 bytes_written_after_start_after;
2581 _dbus_string_get_const_udata_len (reader->
value_str,
2584 if (old_len != fixup.
new_len && !append_fixup (fixups, &fixup))
2587#if RECURSIVE_MARSHAL_WRITE_TRACE
2588 _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",
2591 reader_array_start_pos,
2593 bytes_before_start_after,
2594 start_after_new_len,
2595 bytes_written_after_start_after);
2605#if RECURSIVE_MARSHAL_WRITE_TRACE
2606 _dbus_verbose (
"Reading basic value %s at %d\n",
2613#if RECURSIVE_MARSHAL_WRITE_TRACE
2614 _dbus_verbose (
"Writing basic value %s at %d write target len %d inside_start_after = %d\n",
2618 inside_start_after);
2620 if (!inside_start_after)
2621 enable_if_after (writer, reader, start_after);
2624#if RECURSIVE_MARSHAL_WRITE_TRACE
2625 _dbus_verbose (
"Wrote basic value %s, new value_pos %d write target len %d\n",
2639 apply_and_free_fixups (fixups,
NULL);
2679 int start_after_new_pos,
2680 int start_after_new_len,
2692 orig_enabled = writer->
enabled;
2695 _dbus_type_writer_set_enabled (writer,
FALSE);
2697 if (!writer_write_reader_helper (writer, reader, start_after,
2698 start_after_new_pos,
2699 start_after_new_len,
2703 _dbus_type_writer_set_enabled (writer, orig_enabled);
2733 return _dbus_type_writer_write_reader_partial (writer, reader,
NULL, 0, 0,
NULL);
2747 dbus_bool_t enabled)
#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, 2, 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_IN...
void _dbus_string_delete(DBusString *str, int start, int len)
Deletes a segment of a DBusString with length len starting at start.
dbus_bool_t _dbus_string_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.
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
dbus_bool_t _dbus_string_insert_byte(DBusString *str, int i, unsigned char byte)
Inserts a single byte at the given position.
const char * _dbus_string_get_const_data_len(const DBusString *str, int start, int len)
const version of _dbus_string_get_data_len().
const char * _dbus_string_get_const_data(const DBusString *str)
Gets the raw character buffer from a const string.
unsigned char _dbus_string_get_byte(const DBusString *str, int start)
Gets the 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.
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...