D-Bus 1.15.8
dbus-marshal-recursive.h
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* dbus-marshal-recursive.h Marshalling routines for recursive types
3 *
4 * Copyright (C) 2004, 2005 Red Hat, Inc.
5 *
6 * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
7 *
8 * Licensed under the Academic Free License version 2.1
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 */
25
26#ifndef DBUS_MARSHAL_RECURSIVE_H
27#define DBUS_MARSHAL_RECURSIVE_H
28
29#include <dbus/dbus-protocol.h>
30#include <dbus/dbus-list.h>
31
32typedef struct DBusTypeReader DBusTypeReader;
33typedef struct DBusTypeWriter DBusTypeWriter;
36
42{
56 union
57 {
58 struct {
60 } array;
61 } u;
62};
63
68{
82 union
83 {
84 struct {
86 int len_pos;
88 } array;
89 } u;
90};
91
97{
99 int new_len;
100};
101
102DBUS_PRIVATE_EXPORT
104 int byte_order,
105 const DBusString *type_str,
106 int type_pos,
107 const DBusString *value_str,
108 int value_pos);
109DBUS_PRIVATE_EXPORT
111 const DBusString *type_str,
112 int type_pos);
113DBUS_PRIVATE_EXPORT
115DBUS_PRIVATE_EXPORT
117DBUS_PRIVATE_EXPORT
119DBUS_PRIVATE_EXPORT
121 void *value);
123DBUS_PRIVATE_EXPORT
125 const void **value,
126 int *n_elements);
128 const unsigned char **value_location);
129DBUS_PRIVATE_EXPORT
131 DBusTypeReader *subreader);
132DBUS_PRIVATE_EXPORT
135DBUS_PRIVATE_EXPORT
137 const DBusString **str_p,
138 int *start_p,
139 int *len_p);
140DBUS_PRIVATE_EXPORT
142 const void *value,
143 const DBusTypeReader *realign_root);
144DBUS_PRIVATE_EXPORT
146 const DBusTypeReader *realign_root);
147
148dbus_bool_t _dbus_type_reader_equal_values (const DBusTypeReader *lhs,
149 const DBusTypeReader *rhs);
150
151void _dbus_type_signature_next (const char *signature,
152 int *type_pos);
153
154DBUS_PRIVATE_EXPORT
156 int byte_order,
157 DBusString *type_str,
158 int type_pos,
159 DBusString *value_str,
160 int value_pos);
162 int byte_order,
163 DBusString *value_str,
164 int value_pos);
166 DBusString *type_str,
167 int type_pos);
169DBUS_PRIVATE_EXPORT
171 int byte_order,
172 const DBusString *type_str,
173 int type_pos,
174 DBusString *value_str,
175 int value_pos);
176DBUS_PRIVATE_EXPORT
178 int type,
179 const void *value);
180DBUS_PRIVATE_EXPORT
182 int element_type,
183 const void *value,
184 int n_elements);
185DBUS_PRIVATE_EXPORT
187 int container_type,
188 const DBusString *contained_type,
189 int contained_type_start,
190 DBusTypeWriter *sub);
191DBUS_PRIVATE_EXPORT
193 DBusTypeWriter *sub);
195 const DBusString *contained_type,
196 int contained_type_start,
197 DBusTypeWriter *sub);
198DBUS_PRIVATE_EXPORT
200 DBusTypeReader *reader);
201
202
203#endif /* DBUS_MARSHAL_RECURSIVE_H */
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_write_basic(DBusTypeWriter *writer, int type, const void *value)
Writes out a basic type.
DBUS_PRIVATE_EXPORT void _dbus_type_reader_recurse(DBusTypeReader *reader, DBusTypeReader *subreader)
Initialize a new reader pointing to the first type and corresponding value that's a child of the curr...
DBUS_PRIVATE_EXPORT 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_PRIVATE_EXPORT int _dbus_type_reader_get_value_pos(const DBusTypeReader *reader)
Gets the current position in the value block.
void _dbus_type_writer_remove_types(DBusTypeWriter *writer)
Removes type string from the writer.
DBUS_PRIVATE_EXPORT 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_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.
DBUS_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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.
DBUS_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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.
void _dbus_type_writer_add_types(DBusTypeWriter *writer, DBusString *type_str, int type_pos)
Adds type string to the writer, if it had none.
dbus_bool_t _dbus_type_reader_has_next(const DBusTypeReader *reader)
Check whether there's another value on this "level".
DBUS_PRIVATE_EXPORT 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.
DBUS_PRIVATE_EXPORT 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.
DBUS_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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_PRIVATE_EXPORT 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.
DBUS_PRIVATE_EXPORT 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_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 *signature, int *type_pos)
Skips to the next "complete" type inside a type signature.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:37
unsigned int dbus_uint32_t
A 32-bit unsigned integer on all platforms.
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
Virtual table for a type reader.
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