Data Structures | |
struct | HeaderFieldType |
struct | DBusTypeReaderClass |
Virtual table for a type reader. More... | |
struct | ReplacementBlock |
Defines | |
#define | FIELDS_ARRAY_SIGNATURE_OFFSET 6 |
Offset from start of _dbus_header_signature_str to the signature of the fields array. | |
#define | FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET 7 |
Offset from start of _dbus_header_signature_str to the signature of an element of the fields array. | |
#define | BYTE_ORDER_OFFSET 0 |
Offset to byte order from start of header. | |
#define | TYPE_OFFSET 1 |
Offset to type from start of header. | |
#define | FLAGS_OFFSET 2 |
Offset to flags from start of header. | |
#define | VERSION_OFFSET 3 |
Offset to version from start of header. | |
#define | BODY_LENGTH_OFFSET 4 |
Offset to body length from start of header. | |
#define | SERIAL_OFFSET 8 |
Offset to client serial from start of header. | |
#define | FIELDS_ARRAY_LENGTH_OFFSET 12 |
Offset to fields array length from start of header. | |
#define | FIRST_FIELD_OFFSET 16 |
Offset to first field in header. | |
#define | EXPECTED_TYPE_OF_FIELD(field) (_dbus_header_field_types[field].type) |
Macro to look up the correct type for a field. | |
#define | MAX_POSSIBLE_HEADER_PADDING 7 |
The most padding we could ever need for a header. | |
#define | HEADER_END_BEFORE_PADDING(header) (_dbus_string_get_length (&(header)->data) - (header)->padding) |
Compute the end of the header, ignoring padding. | |
#define | RECURSIVE_MARSHAL_READ_TRACE 0 |
turn this on to get deluged in TypeReader verbose spam | |
#define | RECURSIVE_MARSHAL_WRITE_TRACE 0 |
turn this on to get deluged in TypeWriter verbose spam | |
#define | ARRAY_READER_LEN_POS(reader) ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4) |
compute position of array length given array_len_offset, which is the offset back from start_pos to end of the len | |
#define | VALID_INITIAL_NAME_CHARACTER(c) |
Determine wether the given character is valid as the first character in a name. | |
#define | VALID_NAME_CHARACTER(c) |
Determine wether the given character is valid as a second or later character in a name. | |
#define | VALID_INITIAL_BUS_NAME_CHARACTER(c) |
Determine wether the given character is valid as the first character in a bus name. | |
#define | VALID_BUS_NAME_CHARACTER(c) |
Determine wether the given character is valid as a second or later character in a bus name. | |
#define | DECLARE_DBUS_NAME_CHECK(what) dbus_bool_t _dbus_check_is_valid_##what (const char *name) |
A name check is used in _dbus_return_if_fail(), it's not suitable for validating untrusted data. | |
#define | DEFINE_DBUS_NAME_CHECK(what) |
Define a name check to be used in _dbus_return_if_fail() statements. | |
Enumerations | |
enum | { MARSHAL_AS_STRING, MARSHAL_AS_SIGNATURE, MARSHAL_AS_BYTE_ARRAY } |
enum | DBusValidationMode { DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY, DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED } |
This is used rather than a bool for high visibility. | |
enum | DBusValidity { DBUS_VALIDITY_UNKNOWN_OOM_ERROR = -4, DBUS_INVALID_FOR_UNKNOWN_REASON = -3, DBUS_VALID_BUT_INCOMPLETE = -2, DBUS_VALIDITY_UNKNOWN = -1, DBUS_VALID = 0, DBUS_INVALID_UNKNOWN_TYPECODE = 1, DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE = 2, DBUS_INVALID_SIGNATURE_TOO_LONG = 3, DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION = 4, DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION = 5, DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED = 6, DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED = 7, DBUS_INVALID_STRUCT_HAS_NO_FIELDS = 8, DBUS_INVALID_ALIGNMENT_PADDING_NOT_NUL = 9, DBUS_INVALID_BOOLEAN_NOT_ZERO_OR_ONE = 10, DBUS_INVALID_NOT_ENOUGH_DATA = 11, DBUS_INVALID_TOO_MUCH_DATA = 12, DBUS_INVALID_BAD_BYTE_ORDER = 13, DBUS_INVALID_BAD_PROTOCOL_VERSION = 14, DBUS_INVALID_BAD_MESSAGE_TYPE = 15, DBUS_INVALID_BAD_SERIAL = 16, DBUS_INVALID_INSANE_FIELDS_ARRAY_LENGTH = 17, DBUS_INVALID_INSANE_BODY_LENGTH = 18, DBUS_INVALID_MESSAGE_TOO_LONG = 19, DBUS_INVALID_HEADER_FIELD_CODE = 20, DBUS_INVALID_HEADER_FIELD_HAS_WRONG_TYPE = 21, DBUS_INVALID_USES_LOCAL_INTERFACE = 22, DBUS_INVALID_USES_LOCAL_PATH = 23, DBUS_INVALID_HEADER_FIELD_APPEARS_TWICE = 24, DBUS_INVALID_BAD_DESTINATION = 25, DBUS_INVALID_BAD_INTERFACE = 26, DBUS_INVALID_BAD_MEMBER = 27, DBUS_INVALID_BAD_ERROR_NAME = 28, DBUS_INVALID_BAD_SENDER = 29, DBUS_INVALID_MISSING_PATH = 30, DBUS_INVALID_MISSING_INTERFACE = 31, DBUS_INVALID_MISSING_MEMBER = 32, DBUS_INVALID_MISSING_ERROR_NAME = 33, DBUS_INVALID_MISSING_REPLY_SERIAL = 34, DBUS_INVALID_LENGTH_OUT_OF_BOUNDS = 35, DBUS_INVALID_ARRAY_LENGTH_EXCEEDS_MAXIMUM = 36, DBUS_INVALID_BAD_PATH = 37, DBUS_INVALID_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 38, DBUS_INVALID_BAD_UTF8_IN_STRING = 39, DBUS_INVALID_ARRAY_LENGTH_INCORRECT = 40, DBUS_INVALID_VARIANT_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 41, DBUS_INVALID_VARIANT_SIGNATURE_BAD = 42, DBUS_INVALID_VARIANT_SIGNATURE_EMPTY = 43, DBUS_INVALID_VARIANT_SIGNATURE_SPECIFIES_MULTIPLE_VALUES = 44, DBUS_INVALID_VARIANT_SIGNATURE_MISSING_NUL = 45, DBUS_INVALID_STRING_MISSING_NUL = 46, DBUS_INVALID_SIGNATURE_MISSING_NUL = 47, DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION = 48, DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED = 49, DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED = 50, DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS = 51, DBUS_INVALID_DICT_ENTRY_HAS_ONLY_ONE_FIELD = 52, DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS = 53, DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY = 54, DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE = 55, DBUS_VALIDITY_LAST } |
This is primarily used in unit testing, so we can verify that each invalid message is invalid for the expected reasons. More... | |
Functions | |
void | _dbus_pack_uint32 (dbus_uint32_t value, int byte_order, unsigned char *data) |
Packs a 32 bit unsigned integer into a data pointer. | |
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 previously. | |
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. | |
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. | |
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. | |
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. | |
void | _dbus_swap_array (unsigned char *data, int n_elements, int alignment) |
Swaps the elements of an array to the opposite byte order. | |
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. | |
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_marshal_skip_array (const DBusString *str, int element_type, int byte_order, int *pos) |
Skips an array, returning the next position. | |
int | _dbus_type_get_alignment (int typecode) |
Gets the alignment requirement for the given type; will be 1, 4, or 8. | |
dbus_bool_t | _dbus_type_is_valid (int typecode) |
Return TRUE if the typecode is a valid typecode. | |
const char * | _dbus_type_to_string (int typecode) |
Returns a string describing the given type. | |
void | _dbus_verbose_bytes (const unsigned char *data, int len, int offset) |
If in verbose mode, print a block of binary data. | |
void | _dbus_verbose_bytes_of_string (const DBusString *str, int start, int len) |
Dump the given part of the string to verbose log. | |
int | _dbus_first_type_in_signature (const DBusString *str, int pos) |
Get the first type in the signature. | |
int | _dbus_first_type_in_signature_c_str (const char *str, int pos) |
Similar to _dbus_first_type_in_signature, but operates on a C string buffer. | |
void | _dbus_marshal_byteswap (const DBusString *signature, int signature_start, int old_byte_order, int new_byte_order, DBusString *value_str, int value_pos) |
Byteswaps the marshaled data in the given value_str. | |
_DBUS_STRING_DEFINE_STATIC (_dbus_header_signature_str, DBUS_HEADER_SIGNATURE) | |
Static DBusString containing the signature of a message header. | |
_DBUS_STRING_DEFINE_STATIC (_dbus_local_interface_str, DBUS_INTERFACE_LOCAL) | |
Static DBusString containing the local interface. | |
_DBUS_STRING_DEFINE_STATIC (_dbus_local_path_str, DBUS_PATH_LOCAL) | |
Static DBusString containing the local path. | |
int | _dbus_header_get_message_type (DBusHeader *header) |
Gets the type of the message. | |
void | _dbus_header_set_serial (DBusHeader *header, dbus_uint32_t serial) |
Sets the serial number of a header. | |
dbus_uint32_t | _dbus_header_get_serial (DBusHeader *header) |
See dbus_message_get_serial(). | |
void | _dbus_header_reinit (DBusHeader *header, int byte_order) |
Re-initializes a header that was previously initialized and never freed. | |
dbus_bool_t | _dbus_header_init (DBusHeader *header, int byte_order) |
Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create(). | |
void | _dbus_header_free (DBusHeader *header) |
Frees a header. | |
dbus_bool_t | _dbus_header_copy (const DBusHeader *header, DBusHeader *dest) |
Initializes dest with a copy of the given header. | |
dbus_bool_t | _dbus_header_create (DBusHeader *header, int message_type, const char *destination, const char *path, const char *interface, const char *member, const char *error_name) |
Fills in the primary fields of the header, so the header is ready for use. | |
dbus_bool_t | _dbus_header_have_message_untrusted (int max_message_length, DBusValidity *validity, int *byte_order, int *fields_array_len, int *header_len, int *body_len, const DBusString *str, int start, int len) |
Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate). | |
dbus_bool_t | _dbus_header_load (DBusHeader *header, DBusValidationMode mode, DBusValidity *validity, int byte_order, int fields_array_len, int header_len, int body_len, const DBusString *str, int start, int len) |
Creates a message header from potentially-untrusted data. | |
void | _dbus_header_update_lengths (DBusHeader *header, int body_len) |
Fills in the correct body length. | |
dbus_bool_t | _dbus_header_set_field_basic (DBusHeader *header, int field, int type, const void *value) |
Sets the value of a field with basic type. | |
dbus_bool_t | _dbus_header_get_field_basic (DBusHeader *header, int field, int type, void *value) |
Gets the value of a field with basic type. | |
dbus_bool_t | _dbus_header_get_field_raw (DBusHeader *header, int field, const DBusString **str, int *pos) |
Gets the raw marshaled data for a field. | |
dbus_bool_t | _dbus_header_delete_field (DBusHeader *header, int field) |
Deletes a field, if it exists. | |
void | _dbus_header_toggle_flag (DBusHeader *header, dbus_uint32_t flag, dbus_bool_t value) |
Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE. | |
dbus_bool_t | _dbus_header_get_flag (DBusHeader *header, dbus_uint32_t flag) |
Gets a message flag bit, returning TRUE if the bit is set. | |
void | _dbus_header_byteswap (DBusHeader *header, int new_order) |
Swaps the header into the given order if required. | |
void | _dbus_type_signature_next (const char *type_str, int *type_pos) |
Skips to the next "complete" type inside a type signature. | |
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. | |
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. | |
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 type it's currently pointing to. | |
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. | |
int | _dbus_type_reader_get_value_pos (const DBusTypeReader *reader) |
Gets the current position in the value block. | |
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. | |
void | _dbus_type_reader_read_basic (const DBusTypeReader *reader, void *value) |
Reads a basic-typed value, as with _dbus_marshal_read_basic(). | |
int | _dbus_type_reader_get_array_length (const DBusTypeReader *reader) |
Returns the number of bytes in the array. | |
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 array. | |
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 current container. | |
dbus_bool_t | _dbus_type_reader_next (DBusTypeReader *reader) |
Skip to the next value on this "level". | |
dbus_bool_t | _dbus_type_reader_has_next (const DBusTypeReader *reader) |
Check whether there's another value on this "level". | |
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_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 continue reading. | |
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_bool_t | _dbus_type_reader_greater_than (const DBusTypeReader *lhs, const DBusTypeReader *rhs) |
Compares two readers, which must be iterating over the same value data. | |
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_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. | |
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_type_writer_remove_types (DBusTypeWriter *writer) |
Removes type string from the writer. | |
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 signature that matches what you're going to write out. | |
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_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_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 the values block. | |
dbus_bool_t | _dbus_type_writer_write_basic (DBusTypeWriter *writer, int type, const void *value) |
Writes out a basic type. | |
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_bool_t | _dbus_type_writer_write_reader_partial (DBusTypeWriter *writer, DBusTypeReader *reader, const DBusTypeReader *start_after, int start_after_new_pos, int start_after_new_len, DBusList **fixups) |
Iterate through all values in the given reader, writing a copy of each value to the writer. | |
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_type_writer_set_enabled (DBusTypeWriter *writer, dbus_bool_t enabled) |
If disabled, a writer can still be iterated forward and recursed/unrecursed but won't write any values. | |
DBusValidity | _dbus_validate_signature_with_reason (const DBusString *type_str, int type_pos, int len) |
Verifies that the range of type_str from type_pos to type_end is a valid signature. | |
DBusValidity | _dbus_validate_body_with_reason (const DBusString *expected_signature, int expected_signature_start, int byte_order, int *bytes_remaining, const DBusString *value_str, int value_pos, int len) |
Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expected_signature. | |
dbus_bool_t | _dbus_validate_path (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid object path name in the D-Bus protocol. | |
dbus_bool_t | _dbus_validate_interface (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid interface name in the D-Bus protocol. | |
dbus_bool_t | _dbus_validate_member (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid member name in the D-Bus protocol. | |
dbus_bool_t | _dbus_validate_error_name (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid error name in the D-Bus protocol. | |
dbus_bool_t | _dbus_validate_bus_name (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid bus name in the D-Bus protocol. | |
dbus_bool_t | _dbus_validate_signature (const DBusString *str, int start, int len) |
Checks that the given range of the string is a valid message type signature in the D-Bus protocol. | |
DEFINE_DBUS_NAME_CHECK (path) | |
define _dbus_check_is_valid_path() | |
DEFINE_DBUS_NAME_CHECK (interface) | |
define _dbus_check_is_valid_interface() | |
DEFINE_DBUS_NAME_CHECK (member) | |
define _dbus_check_is_valid_member() | |
DEFINE_DBUS_NAME_CHECK (error_name) | |
define _dbus_check_is_valid_error_name() | |
DEFINE_DBUS_NAME_CHECK (bus_name) | |
define _dbus_check_is_valid_bus_name() | |
DEFINE_DBUS_NAME_CHECK (signature) | |
define _dbus_check_is_valid_signature() | |
DECLARE_DBUS_NAME_CHECK (path) | |
defines _dbus_check_is_valid_path() | |
DECLARE_DBUS_NAME_CHECK (interface) | |
defines _dbus_check_is_valid_interface() | |
DECLARE_DBUS_NAME_CHECK (member) | |
defines _dbus_check_is_valid_member() | |
DECLARE_DBUS_NAME_CHECK (error_name) | |
defines _dbus_check_is_valid_error_name() | |
DECLARE_DBUS_NAME_CHECK (bus_name) | |
defines _dbus_check_is_valid_bus_name() | |
DECLARE_DBUS_NAME_CHECK (signature) | |
defines _dbus_check_is_valid_signature() |
Types and functions related to converting primitive data types from wire format to native machine format, and vice versa.
A signature is just a string with multiple types one after the other. for example a type is "i" or "(ii)", a signature is "i(ii)" where i is int and (ii) is struct { int; int; }
#define DECLARE_DBUS_NAME_CHECK | ( | what | ) | dbus_bool_t _dbus_check_is_valid_##what (const char *name) |
A name check is used in _dbus_return_if_fail(), it's not suitable for validating untrusted data.
use _dbus_validate_whatever for that.
Definition at line 166 of file dbus-marshal-validate.h.
#define DEFINE_DBUS_NAME_CHECK | ( | what | ) |
Value:
dbus_bool_t \ _dbus_check_is_valid_##what (const char *name) \ { \ DBusString str; \ \ if (name == NULL) \ return FALSE; \ \ _dbus_string_init_const (&str, name); \ return _dbus_validate_##what (&str, 0, \ _dbus_string_get_length (&str)); \ }
Definition at line 171 of file dbus-marshal-validate.h.
#define VALID_BUS_NAME_CHARACTER | ( | c | ) |
Value:
( ((c) >= '0' && (c) <= '9') || \ ((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z') || \ ((c) == '_') || ((c) == '-'))
Definition at line 934 of file dbus-marshal-validate.c.
Referenced by _dbus_validate_bus_name().
#define VALID_INITIAL_BUS_NAME_CHARACTER | ( | c | ) |
Value:
( ((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z') || \ ((c) == '_') || ((c) == '-'))
Definition at line 925 of file dbus-marshal-validate.c.
Referenced by _dbus_validate_bus_name().
#define VALID_INITIAL_NAME_CHARACTER | ( | c | ) |
Value:
( ((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z') || \ ((c) == '_') )
Definition at line 679 of file dbus-marshal-validate.c.
Referenced by _dbus_validate_interface(), and _dbus_validate_member().
#define VALID_NAME_CHARACTER | ( | c | ) |
Value:
( ((c) >= '0' && (c) <= '9') || \ ((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z') || \ ((c) == '_') )
Definition at line 688 of file dbus-marshal-validate.c.
Referenced by _dbus_validate_interface(), _dbus_validate_member(), and _dbus_validate_path().
enum DBusValidity |
This is primarily used in unit testing, so we can verify that each invalid message is invalid for the expected reasons.
Thus we really want a distinct enum value for every codepath leaving the validator functions. Enum values are specified manually for ease of debugging (so you can see the enum value given a printf)
DBUS_VALIDITY_UNKNOWN_OOM_ERROR | can't determine validity due to OOM |
DBUS_VALID | the data is valid |
DBUS_INVALID_TOO_MUCH_DATA | trailing junk makes it invalid |
Definition at line 55 of file dbus-marshal-validate.h.
int _dbus_first_type_in_signature | ( | const DBusString * | str, | |
int | pos | |||
) |
Get the first type in the signature.
The difference between this and just getting the first byte of the signature is that you won't get DBUS_STRUCT_BEGIN_CHAR, you'll get DBUS_TYPE_STRUCT instead.
str | string containing signature | |
pos | where the signature starts |
Definition at line 1458 of file dbus-marshal-basic.c.
Referenced by _dbus_type_reader_get_current_type(), _dbus_type_reader_get_element_type(), _dbus_type_reader_read_fixed_multi(), and _dbus_type_reader_recurse().
int _dbus_first_type_in_signature_c_str | ( | const char * | str, | |
int | pos | |||
) |
Similar to _dbus_first_type_in_signature, but operates on a C string buffer.
str | a C string buffer | |
pos | where the signature starts |
Definition at line 1473 of file dbus-marshal-basic.c.
Referenced by dbus_signature_iter_get_current_type(), and dbus_signature_iter_get_element_type().
void _dbus_header_byteswap | ( | DBusHeader * | header, | |
int | new_order | |||
) |
Swaps the header into the given order if required.
header | the header | |
new_order | the new byte order |
Definition at line 1462 of file dbus-marshal-header.c.
References _dbus_marshal_byteswap(), DBusHeader::byte_order, and DBusHeader::data.
dbus_bool_t _dbus_header_copy | ( | const DBusHeader * | header, | |
DBusHeader * | dest | |||
) |
Initializes dest with a copy of the given header.
Resets the message serial to 0 on the copy.
header | header to copy | |
dest | destination for copy |
Definition at line 477 of file dbus-marshal-header.c.
References _dbus_header_set_serial(), _dbus_string_copy(), _dbus_string_free(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.
Referenced by dbus_message_copy().
dbus_bool_t _dbus_header_create | ( | DBusHeader * | header, | |
int | message_type, | |||
const char * | destination, | |||
const char * | path, | |||
const char * | interface, | |||
const char * | member, | |||
const char * | error_name | |||
) |
Fills in the primary fields of the header, so the header is ready for use.
NULL may be specified for some or all of the fields to avoid adding those fields. Some combinations of fields don't make sense, and passing them in will trigger an assertion failure.
header | the header | |
message_type | the message type | |
destination | destination field or NULL | |
path | path field or NULL | |
interface | interface field or NULL | |
member | member field or NULL | |
error_name | error name or NULL |
Definition at line 514 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_string_delete(), _dbus_type_writer_init_values_only(), _dbus_type_writer_recurse(), _dbus_type_writer_unrecurse(), _dbus_type_writer_write_basic(), DBusTypeWriter::byte_order, DBusHeader::data, DBUS_HEADER_FIELD_DESTINATION, DBUS_HEADER_FIELD_ERROR_NAME, DBUS_HEADER_FIELD_INTERFACE, DBUS_HEADER_FIELD_MEMBER, DBUS_HEADER_FIELD_PATH, DBUS_MAJOR_PROTOCOL_VERSION, DBUS_MESSAGE_TYPE_SIGNAL, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_STRING, DBUS_TYPE_UINT32, FALSE, FIELDS_ARRAY_SIGNATURE_OFFSET, HEADER_END_BEFORE_PADDING, NULL, and TRUE.
Referenced by dbus_message_new(), dbus_message_new_error(), dbus_message_new_method_call(), dbus_message_new_method_return(), and dbus_message_new_signal().
dbus_bool_t _dbus_header_delete_field | ( | DBusHeader * | header, | |
int | field | |||
) |
Deletes a field, if it exists.
header | the header | |
field | the field to delete |
Definition at line 1382 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_type_reader_delete(), FALSE, and TRUE.
void _dbus_header_free | ( | DBusHeader * | header | ) |
Frees a header.
header | the header |
Definition at line 463 of file dbus-marshal-header.c.
References _dbus_string_free(), and DBusHeader::data.
Referenced by dbus_message_copy().
dbus_bool_t _dbus_header_get_field_basic | ( | DBusHeader * | header, | |
int | field, | |||
int | type, | |||
void * | value | |||
) |
Gets the value of a field with basic type.
If the field doesn't exist, returns FALSE, otherwise returns TRUE.
header | the header | |
field | the field to get | |
type | the type of the value | |
value | the value as for _dbus_marshal_read_basic() |
Definition at line 1317 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_marshal_read_basic(), DBUS_HEADER_FIELD_INVALID, DBUS_HEADER_FIELD_LAST, EXPECTED_TYPE_OF_FIELD, FALSE, NULL, and TRUE.
Referenced by dbus_message_get_destination(), dbus_message_get_error_name(), dbus_message_get_interface(), dbus_message_get_member(), dbus_message_get_path(), dbus_message_get_reply_serial(), and dbus_message_get_sender().
dbus_bool_t _dbus_header_get_field_raw | ( | DBusHeader * | header, | |
int | field, | |||
const DBusString ** | str, | |||
int * | pos | |||
) |
Gets the raw marshaled data for a field.
If the field doesn't exist, returns FALSE, otherwise returns TRUE. Returns the start of the marshaled data, i.e. usually the byte where the length starts (for strings and arrays) or for basic types just the value itself.
header | the header | |
field | the field to get | |
str | return location for the data string | |
pos | return location for start of field value |
Definition at line 1358 of file dbus-marshal-header.c.
dbus_bool_t _dbus_header_get_flag | ( | DBusHeader * | header, | |
dbus_uint32_t | flag | |||
) |
Gets a message flag bit, returning TRUE if the bit is set.
header | the header | |
flag | the message flag to get |
Definition at line 1445 of file dbus-marshal-header.c.
References DBusHeader::data, and FLAGS_OFFSET.
Referenced by dbus_message_get_auto_start(), and dbus_message_get_no_reply().
int _dbus_header_get_message_type | ( | DBusHeader * | header | ) |
Gets the type of the message.
header | the header |
Definition at line 368 of file dbus-marshal-header.c.
References _dbus_assert, DBusHeader::data, DBUS_MESSAGE_TYPE_INVALID, and TYPE_OFFSET.
Referenced by dbus_message_get_type().
dbus_uint32_t _dbus_header_get_serial | ( | DBusHeader * | header | ) |
See dbus_message_get_serial().
header | the header |
Definition at line 409 of file dbus-marshal-header.c.
References _dbus_marshal_read_uint32(), DBusHeader::byte_order, DBusHeader::data, NULL, and SERIAL_OFFSET.
Referenced by _dbus_header_set_serial(), and dbus_message_get_serial().
dbus_bool_t _dbus_header_have_message_untrusted | ( | int | max_message_length, | |
DBusValidity * | validity, | |||
int * | byte_order, | |||
int * | fields_array_len, | |||
int * | header_len, | |||
int * | body_len, | |||
const DBusString * | str, | |||
int | start, | |||
int | len | |||
) |
Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate).
Also checks that the lengths are in sanity parameters.
max_message_length | maximum length of a valid message | |
validity | return location for why the data is invalid if it is | |
byte_order | return location for byte order | |
fields_array_len | return location for claimed fields array length | |
header_len | return location for claimed header length | |
body_len | return location for claimed body length | |
str | the data | |
start | start of data, 8-aligned | |
len | length of data |
Definition at line 656 of file dbus-marshal-header.c.
References _dbus_assert, _DBUS_INT32_MAX, _dbus_marshal_read_uint32(), BODY_LENGTH_OFFSET, BYTE_ORDER_OFFSET, DBUS_BIG_ENDIAN, DBUS_LITTLE_ENDIAN, DBUS_VALID, FALSE, FIELDS_ARRAY_LENGTH_OFFSET, FIRST_FIELD_OFFSET, and NULL.
Referenced by _dbus_message_loader_queue_messages().
dbus_bool_t _dbus_header_init | ( | DBusHeader * | header, | |
int | byte_order | |||
) |
Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create().
header | header to initialize | |
byte_order | byte order of the header |
Definition at line 446 of file dbus-marshal-header.c.
References _dbus_header_reinit(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.
dbus_bool_t _dbus_header_load | ( | DBusHeader * | header, | |
DBusValidationMode | mode, | |||
DBusValidity * | validity, | |||
int | byte_order, | |||
int | fields_array_len, | |||
int | header_len, | |||
int | body_len, | |||
const DBusString * | str, | |||
int | start, | |||
int | len | |||
) |
Creates a message header from potentially-untrusted data.
The return value is TRUE if there was enough memory and the data was valid. If it returns TRUE, the header will be created. If it returns FALSE and *validity == DBUS_VALIDITY_UNKNOWN_OOM_ERROR, then there wasn't enough memory. If it returns FALSE and *validity != DBUS_VALIDITY_UNKNOWN_OOM_ERROR then the data was invalid.
The byte_order, fields_array_len, and body_len args should be from _dbus_header_have_message_untrusted(). Validation performed in _dbus_header_have_message_untrusted() is assumed to have been already done.
header | the header (must be initialized) | |
mode | whether to do validation | |
validity | return location for invalidity reason | |
byte_order | byte order from header | |
fields_array_len | claimed length of fields array | |
body_len | claimed length of body | |
header_len | claimed length of header | |
str | a string | |
start | start of header, 8-aligned | |
len | length of string to look at |
Definition at line 948 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_string_copy_len(), _dbus_string_set_length(), _dbus_string_validate_nul(), _dbus_type_reader_get_current_type(), _dbus_type_reader_get_value_pos(), _dbus_type_reader_init(), _dbus_type_reader_next(), _dbus_type_reader_read_basic(), _dbus_type_reader_recurse(), _dbus_validate_body_with_reason(), BODY_LENGTH_OFFSET, DBusHeader::byte_order, BYTE_ORDER_OFFSET, DBusHeader::data, DBUS_HEADER_FIELD_INVALID, DBUS_HEADER_FIELD_LAST, DBUS_MAJOR_PROTOCOL_VERSION, DBUS_MESSAGE_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, DBUS_TYPE_INVALID, DBUS_TYPE_STRUCT, DBUS_TYPE_UINT32, DBUS_TYPE_VARIANT, DBUS_VALID, DBUS_VALIDITY_UNKNOWN_OOM_ERROR, FALSE, DBusHeader::fields, FIELDS_ARRAY_LENGTH_OFFSET, FIRST_FIELD_OFFSET, FLAGS_OFFSET, DBusHeader::padding, SERIAL_OFFSET, TRUE, TYPE_OFFSET, DBusHeaderField::value_pos, and VERSION_OFFSET.
void _dbus_header_reinit | ( | DBusHeader * | header, | |
int | byte_order | |||
) |
Re-initializes a header that was previously initialized and never freed.
After this, to make the header valid you have to call _dbus_header_create().
header | header to re-initialize | |
byte_order | byte order of the header |
Definition at line 426 of file dbus-marshal-header.c.
References _dbus_string_set_length(), DBusHeader::byte_order, DBusHeader::data, and DBusHeader::padding.
Referenced by _dbus_header_init().
dbus_bool_t _dbus_header_set_field_basic | ( | DBusHeader * | header, | |
int | field, | |||
int | type, | |||
const void * | value | |||
) |
Sets the value of a field with basic type.
If the value is a string value, it isn't allowed to be NULL. If the field doesn't exist, it will be created.
header | the header | |
field | the field to set | |
type | the type of the value | |
value | the value as for _dbus_marshal_set_basic() |
Definition at line 1239 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_type_writer_append_array(), _dbus_type_writer_init_values_only(), _dbus_type_writer_unrecurse(), DBusTypeWriter::array, DBusTypeWriter::byte_order, DBUS_HEADER_FIELD_LAST, FALSE, FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET, FIELDS_ARRAY_LENGTH_OFFSET, FIELDS_ARRAY_SIGNATURE_OFFSET, FIRST_FIELD_OFFSET, HEADER_END_BEFORE_PADDING, TRUE, DBusTypeWriter::u, and DBusTypeWriter::value_pos.
Referenced by dbus_message_set_reply_serial().
void _dbus_header_set_serial | ( | DBusHeader * | header, | |
dbus_uint32_t | serial | |||
) |
Sets the serial number of a header.
This can only be done once on a header.
header | the header | |
serial | the serial |
Definition at line 386 of file dbus-marshal-header.c.
References _dbus_assert, _dbus_header_get_serial(), _dbus_marshal_set_uint32(), and SERIAL_OFFSET.
Referenced by _dbus_header_copy(), and _dbus_message_set_serial().
void _dbus_header_toggle_flag | ( | DBusHeader * | header, | |
dbus_uint32_t | flag, | |||
dbus_bool_t | value | |||
) |
Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE.
header | the header | |
flag | the message flag to toggle | |
value | toggle on or off |
Definition at line 1423 of file dbus-marshal-header.c.
References _dbus_string_get_data_len(), DBusHeader::data, and FLAGS_OFFSET.
Referenced by dbus_message_set_auto_start(), and dbus_message_set_no_reply().
void _dbus_header_update_lengths | ( | DBusHeader * | header, | |
int | body_len | |||
) |
Fills in the correct body length.
header | the header | |
body_len | the length of the body |
Definition at line 1175 of file dbus-marshal-header.c.
References _dbus_marshal_set_uint32(), BODY_LENGTH_OFFSET, DBusHeader::byte_order, and DBusHeader::data.
Referenced by _dbus_message_lock().
void _dbus_marshal_byteswap | ( | const DBusString * | signature, | |
int | signature_start, | |||
int | old_byte_order, | |||
int | new_byte_order, | |||
DBusString * | value_str, | |||
int | value_pos | |||
) |
Byteswaps the marshaled data in the given value_str.
signature | the types in the value_str | |
signature_start | where in signature is the signature | |
old_byte_order | the old byte order | |
new_byte_order | the new byte order | |
value_str | the string containing the body | |
value_pos | where the values start |
Definition at line 220 of file dbus-marshal-byteswap.c.
References _dbus_assert, _dbus_string_get_data_len(), _dbus_type_reader_init_types_only(), NULL, and TRUE.
Referenced by _dbus_header_byteswap().
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.
The "value" pointer is always the address of a variable of the basic type. So e.g. if the basic type is "double" then the pointer is a double*, and if it's "char*" then the pointer is a "char**".
A value of type DBusBasicValue is guaranteed to be large enough to hold any of the types that may be returned, which is handy if you are trying to do things generically. For example you can pass a DBusBasicValue* in to this function, and then pass the same DBusBasicValue* in to _dbus_marshal_basic_type() in order to move a value from one place to another.
str | the string containing the data | |
pos | position in the string | |
type | type of value to demarshal | |
value | pointer to return value data | |
byte_order | the byte order | |
new_pos | pointer to update with new position, or NULL |
Definition at line 503 of file dbus-marshal-basic.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_marshal_read_uint32(), _dbus_type_to_string(), _dbus_warn_check_failed(), DBusBasicValue::byt, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, dbus_type_is_basic(), DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, DBusBasicValue::str, DBusBasicValue::u16, DBusBasicValue::u32, and DBusBasicValue::u64.
Referenced by _dbus_header_get_field_basic(), and _dbus_type_reader_read_basic().
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.
str | the string containing the data | |
byte_order | the byte order | |
pos | the position in the string | |
new_pos | the new position of the string |
Definition at line 465 of file dbus-marshal-basic.c.
References _dbus_assert.
Referenced by _dbus_header_get_serial(), _dbus_header_have_message_untrusted(), _dbus_marshal_read_basic(), _dbus_marshal_skip_array(), and _dbus_marshal_skip_basic().
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.
Arguments work the same way as _dbus_marshal_basic_type().
str | the string | |
pos | location of the current value | |
type | the type of the current and new values | |
value | the address of the new value | |
byte_order | byte order for marshaling | |
old_end_pos | location to store end position of the old value, or NULL | |
new_end_pos | location to store end position of the new value, or NULL |
Definition at line 382 of file dbus-marshal-basic.c.
References _dbus_assert, _dbus_assert_not_reached, DBusBasicValue::byt, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, FALSE, NULL, DBusBasicValue::str, TRUE, DBusBasicValue::u16, and DBusBasicValue::u32.
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 previously.
str | the string to write the marshalled int to | |
pos | the byte offset where int should be written | |
value | the value | |
byte_order | the byte order to use |
Definition at line 265 of file dbus-marshal-basic.c.
Referenced by _dbus_header_set_serial(), _dbus_header_update_lengths(), and _dbus_type_writer_unrecurse().
void _dbus_marshal_skip_array | ( | const DBusString * | str, | |
int | element_type, | |||
int | byte_order, | |||
int * | pos | |||
) |
Skips an array, returning the next position.
str | the string containing the data | |
element_type | the type of array elements | |
byte_order | the byte order | |
pos | pointer to position in the string, updated on return to new position |
Definition at line 1147 of file dbus-marshal-basic.c.
References _dbus_marshal_read_uint32(), and _dbus_type_get_alignment().
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.
str | the string containing the data | |
type | type of value to read | |
byte_order | the byte order | |
pos | pointer to position in the string, updated on return to new position |
Definition at line 1080 of file dbus-marshal-basic.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_marshal_read_uint32(), _dbus_type_to_string(), _dbus_warn(), DBUS_BIG_ENDIAN, DBUS_LITTLE_ENDIAN, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, and DBUS_TYPE_UINT64.
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.
The "value" pointer is always the address of a variable containing the basic type value. So for example for int32 it will be dbus_int32_t*, and for string it will be const char**. This is for symmetry with _dbus_marshal_read_basic() and to have a simple consistent rule.
str | string to marshal to | |
insert_at | where to insert the value | |
type | type of value | |
value | pointer to a variable containing the value | |
byte_order | byte order | |
pos_after | NULL or the position after the type |
Definition at line 793 of file dbus-marshal-basic.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_string_insert_byte(), DBusBasicValue::byt, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, dbus_type_is_basic(), DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, FALSE, NULL, DBusBasicValue::str, TRUE, DBusBasicValue::u16, and DBusBasicValue::u32.
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_type_is_fixed() returns TRUE for fixed-length types, which are the basic types minus the string-like types.
The value argument should be the adddress of an array, so e.g. "const dbus_uint32_t**"
str | string to marshal to | |
insert_at | where to insert the value | |
element_type | type of array elements | |
value | address of an array to marshal | |
n_elements | number of elements in the array | |
byte_order | byte order | |
pos_after | NULL or the position after the type |
Definition at line 1022 of file dbus-marshal-basic.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_type_to_string(), DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, dbus_type_is_fixed(), DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, and FALSE.
Referenced by _dbus_type_writer_write_fixed_multi().
void _dbus_pack_uint32 | ( | dbus_uint32_t | value, | |
int | byte_order, | |||
unsigned char * | data | |||
) |
Packs a 32 bit unsigned integer into a data pointer.
value | the value | |
byte_order | the byte order to use | |
data | the data pointer |
Definition at line 98 of file dbus-marshal-basic.c.
void _dbus_swap_array | ( | unsigned char * | data, | |
int | n_elements, | |||
int | alignment | |||
) |
Swaps the elements of an array to the opposite byte order.
data | start of array | |
n_elements | number of elements | |
alignment | size of each element |
Definition at line 886 of file dbus-marshal-basic.c.
References _dbus_assert.
int _dbus_type_get_alignment | ( | int | typecode | ) |
Gets the alignment requirement for the given type; will be 1, 4, or 8.
typecode | the type |
Definition at line 1175 of file dbus-marshal-basic.c.
References _dbus_assert_not_reached, DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_STRUCT, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, and DBUS_TYPE_VARIANT.
Referenced by _dbus_marshal_skip_array(), _dbus_type_reader_read_fixed_multi(), and dbus_message_iter_append_fixed_array().
dbus_bool_t _dbus_type_is_valid | ( | int | typecode | ) |
Return TRUE if the typecode is a valid typecode.
DBUS_TYPE_INVALID surprisingly enough is not considered valid, and random unknown bytes aren't either. This function is safe with untrusted data.
Definition at line 1223 of file dbus-marshal-basic.c.
References DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_STRUCT, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, DBUS_TYPE_VARIANT, FALSE, and TRUE.
Referenced by dbus_type_is_basic(), dbus_type_is_container(), and dbus_type_is_fixed().
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.
Any other readers will be invalidated.
The provided realign_root is the reader to start from when realigning the data that follows the newly-set value. See _dbus_type_reader_set_basic() for more details on the realign_root paramter.
reader | reader indicating where to delete a value | |
realign_root | realign from here |
Definition at line 1402 of file dbus-marshal-recursive.c.
References _dbus_assert, FALSE, DBusTypeReader::klass, NULL, and TRUE.
Referenced by _dbus_header_delete_field().
int _dbus_type_reader_get_array_length | ( | const DBusTypeReader * | reader | ) |
Returns the number of bytes in the array.
reader | the reader to read from |
Definition at line 884 of file dbus-marshal-recursive.c.
References _dbus_assert, DBusTypeReader::klass, and DBusTypeReaderClass::types_only.
Referenced by dbus_message_iter_get_array_len().
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 type it's currently pointing to.
If the reader is at the end of a block or end of a container such as an array, returns DBUS_TYPE_INVALID.
reader | the reader |
Definition at line 770 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_first_type_in_signature(), _dbus_type_to_string(), DBusTypeReaderClass::check_finished, DBUS_DICT_ENTRY_BEGIN_CHAR, DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_BEGIN_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_INVALID, DBusTypeReader::finished, DBusTypeReader::klass, DBusTypeReader::type_pos, and DBusTypeReader::type_str.
Referenced by _dbus_header_load(), _dbus_message_iter_get_args_valist(), _dbus_type_reader_get_element_type(), _dbus_type_reader_next(), _dbus_type_reader_read_basic(), _dbus_type_reader_set_basic(), dbus_message_iter_get_arg_type(), dbus_message_iter_get_fixed_array(), and dbus_message_iter_init().
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.
It's an error to call this if _dbus_type_reader_get_current_type() doesn't return DBUS_TYPE_ARRAY for this reader.
reader | the reader |
Definition at line 805 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_first_type_in_signature(), _dbus_type_reader_get_current_type(), and DBUS_TYPE_ARRAY.
Referenced by _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_element_type().
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.
Essentially a more complete version of _dbus_type_reader_get_current_type() (returns the full type rather than only the outside of the onion).
Note though that the first byte in a struct signature is DBUS_STRUCT_BEGIN_CHAR while the current type will be DBUS_TYPE_STRUCT so it isn't true that the first byte of the signature is always the same as the current type. Another difference is that this function will still return a signature when inside an empty array; say you recurse into empty array of int32, the signature is "i" but the current type will always be DBUS_TYPE_INVALID since there are no elements to be currently pointing to.
reader | the reader | |
str_p | place to return the string with the type in it | |
start_p | place to return start of the type | |
len_p | place to return the length of the type |
Definition at line 1107 of file dbus-marshal-recursive.c.
References DBusTypeReader::type_pos, and DBusTypeReader::type_str.
Referenced by dbus_message_iter_get_signature().
int _dbus_type_reader_get_value_pos | ( | const DBusTypeReader * | reader | ) |
Gets the current position in the value block.
reader | the reader |
Definition at line 822 of file dbus-marshal-recursive.c.
References DBusTypeReader::value_pos.
Referenced by _dbus_header_load().
dbus_bool_t _dbus_type_reader_greater_than | ( | const DBusTypeReader * | lhs, | |
const DBusTypeReader * | rhs | |||
) |
Compares two readers, which must be iterating over the same value data.
Returns TRUE if the first parameter is further along than the second parameter.
lhs | left-hand-side (first) parameter | |
rhs | left-hand-side (first) parameter |
Definition at line 1437 of file dbus-marshal-recursive.c.
References _dbus_assert, DBusTypeReader::value_pos, and DBusTypeReader::value_str.
dbus_bool_t _dbus_type_reader_has_next | ( | const DBusTypeReader * | reader | ) |
Check whether there's another value on this "level".
e.g. the next field in a struct, the next value in an array. Returns FALSE at the end of the current container.
You probably don't want to use this; it makes for an awkward for/while loop. A nicer one is "while ((current_type = get_current_type()) != INVALID)"
reader | the reader |
Definition at line 1076 of file dbus-marshal-recursive.c.
References _dbus_type_reader_next().
Referenced by dbus_message_iter_has_next().
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.
reader | the reader | |
byte_order | the byte order of the block to read | |
type_str | the signature of the block to read | |
type_pos | location of signature | |
value_str | the string containing values block | |
value_pos | start of values block |
Definition at line 717 of file dbus-marshal-recursive.c.
References DBusTypeReader::klass, DBusTypeReader::type_pos, DBusTypeReader::type_str, and DBusTypeReader::value_pos.
Referenced by _dbus_header_load(), and dbus_message_iter_init().
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.
reader | the reader | |
type_str | the signature string | |
type_pos | location in the signature string |
Definition at line 745 of file dbus-marshal-recursive.c.
References _DBUS_INT_MAX, DBusTypeReader::klass, NULL, DBusTypeReader::type_pos, and DBusTypeReader::type_str.
Referenced by _dbus_marshal_byteswap(), and _dbus_validate_body_with_reason().
dbus_bool_t _dbus_type_reader_next | ( | DBusTypeReader * | reader | ) |
Skip to the next value on this "level".
e.g. the next field in a struct, the next value in an array. Returns FALSE at the end of the current container.
reader | the reader |
Definition at line 1036 of file dbus-marshal-recursive.c.
References _dbus_type_reader_get_current_type(), _dbus_type_to_string(), DBUS_TYPE_INVALID, FALSE, DBusTypeReader::klass, DBusTypeReaderClass::next, DBusTypeReader::type_pos, DBusTypeReader::type_str, and DBusTypeReader::value_pos.
Referenced by _dbus_header_load(), _dbus_message_iter_get_args_valist(), _dbus_type_reader_has_next(), and dbus_message_iter_next().
void _dbus_type_reader_read_basic | ( | const DBusTypeReader * | reader, | |
void * | value | |||
) |
Reads a basic-typed value, as with _dbus_marshal_read_basic().
reader | the reader | |
value | the address of the value |
Definition at line 854 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_marshal_read_basic(), _dbus_type_reader_get_current_type(), DBusTypeReader::byte_order, DBusTypeReader::klass, NULL, DBusTypeReader::type_pos, DBusTypeReader::type_str, DBusTypeReaderClass::types_only, DBusTypeReader::value_pos, and DBusTypeReader::value_str.
Referenced by _dbus_header_load(), _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_basic().
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 array.
Does not work for arrays of string or container types.
This function returns the array in-place; it does not make a copy, and it does not swap the bytes.
If you ask for DBUS_TYPE_DOUBLE you will get a "const double*" back and the "value" argument should be a "const double**" and so on.
reader | the reader to read from | |
value | place to return the array values | |
n_elements | place to return number of array elements |
Definition at line 908 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_first_type_in_signature(), _dbus_type_get_alignment(), DBusTypeReader::array, DBUS_TYPE_INVALID, dbus_type_is_fixed(), DBusTypeReader::klass, NULL, DBusTypeReader::type_pos, DBusTypeReader::type_str, DBusTypeReaderClass::types_only, DBusTypeReader::u, DBusTypeReader::value_pos, and DBusTypeReader::value_str.
Referenced by _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_fixed_array().
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.
The address may not be aligned; you have to align it to the type of the value you want to read. Most of the demarshal routines do this for you.
reader | the reader | |
value_location | the address of the marshaled value |
Definition at line 837 of file dbus-marshal-recursive.c.
References _dbus_assert, DBusTypeReader::klass, DBusTypeReaderClass::types_only, DBusTypeReader::value_pos, and DBusTypeReader::value_str.
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 current container.
It's an error to call this if the current type is a non-container.
Note that DBusTypeReader traverses values, not types. So if you have an empty array of array of int, you can't recurse into it. You can only recurse into each element.
reader | the reader | |
sub | a reader to init pointing to the first child |
Definition at line 973 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_first_type_in_signature(), _dbus_type_to_string(), _dbus_warn_check_failed(), DBUS_TYPE_ARRAY, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_INVALID, DBUS_TYPE_STRUCT, DBUS_TYPE_VARIANT, DBusTypeReaderClass::id, DBusTypeReader::klass, DBusTypeReaderClass::recurse, DBusTypeReader::type_pos, DBusTypeReader::type_str, DBusTypeReaderClass::types_only, and DBusTypeReader::value_pos.
Referenced by _dbus_header_load(), _dbus_message_iter_get_args_valist(), and dbus_message_iter_recurse().
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 continue reading.
Any other readers will be invalidated if you set a variable-length type such as a string.
The provided realign_root is the reader to start from when realigning the data that follows the newly-set value. The reader parameter must point to a value below the realign_root parameter. If the type being set is fixed-length, then realign_root may be NULL. Only values reachable from realign_root will be realigned, so if your string contains other values you will need to deal with those somehow yourself. It is OK if realign_root is the same reader as the reader parameter, though if you aren't setting the root it may not be such a good idea.
reader | reader indicating where to set a new value | |
value | address of the value to set | |
realign_root | realign from here |
Definition at line 1345 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_type_reader_get_current_type(), _dbus_type_to_string(), _dbus_verbose_bytes_of_string(), dbus_type_is_basic(), dbus_type_is_fixed(), DBusTypeReader::klass, NULL, TRUE, DBusTypeReader::type_pos, DBusTypeReader::type_str, DBusTypeReaderClass::types_only, DBusTypeReader::value_pos, and DBusTypeReader::value_str.
void _dbus_type_signature_next | ( | const char * | type_str, | |
int * | type_pos | |||
) |
Skips to the next "complete" type inside a type signature.
The signature is read starting at type_pos, and the next type position is stored in the same variable.
type_str | a type signature (must be valid) | |
type_pos | an integer position in the type signature (in and out) |
Definition at line 327 of file dbus-marshal-recursive.c.
References _dbus_assert, DBUS_DICT_ENTRY_BEGIN_CHAR, DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_BEGIN_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_ARRAY, DBUS_TYPE_INVALID, NULL, and TRUE.
Referenced by dbus_signature_iter_get_signature(), and dbus_signature_iter_next().
const char* _dbus_type_to_string | ( | int | typecode | ) |
Returns a string describing the given type.
typecode | the type to describe |
Definition at line 1257 of file dbus-marshal-basic.c.
References DBUS_DICT_ENTRY_BEGIN_CHAR, DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_BEGIN_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_INVALID, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_STRUCT, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, and DBUS_TYPE_VARIANT.
Referenced by _dbus_marshal_read_basic(), _dbus_marshal_skip_basic(), _dbus_marshal_write_fixed_multi(), _dbus_message_iter_get_args_valist(), _dbus_type_reader_get_current_type(), _dbus_type_reader_next(), _dbus_type_reader_recurse(), _dbus_type_reader_set_basic(), _dbus_type_writer_unrecurse(), and dbus_message_append_args_valist().
void _dbus_type_writer_add_types | ( | DBusTypeWriter * | writer, | |
DBusString * | type_str, | |||
int | type_pos | |||
) |
Adds type string to the writer, if it had none.
writer | the writer to init | |
type_str | type string to add | |
type_pos | type position |
Definition at line 1528 of file dbus-marshal-recursive.c.
References NULL, DBusTypeWriter::type_pos, and DBusTypeWriter::type_str.
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.
Essentially, the writer will read an existing length at the write location; jump over that length; and write new fields. On unrecurse(), the existing length will be updated.
writer | the writer | |
contained_type | element type | |
contained_type_start | position of element type | |
sub | the subwriter to init |
Definition at line 2108 of file dbus-marshal-recursive.c.
References DBUS_TYPE_ARRAY, and TRUE.
Referenced by _dbus_header_set_field_basic().
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.
The type_pos passed in is expected to be inside an already-valid, though potentially empty, type signature. This means that the byte after type_pos must be either DBUS_TYPE_INVALID (aka nul) or some other valid type. DBusTypeWriter won't enforce that the signature is already valid (you can append the nul byte at the end if you like), but just be aware that you need the nul byte eventually and DBusTypeWriter isn't going to write it for you.
writer | the writer to init | |
byte_order | the byte order to marshal into | |
type_str | the string to write typecodes into | |
type_pos | where to insert typecodes | |
value_str | the string to write values into | |
value_pos | where to insert values |
Definition at line 1475 of file dbus-marshal-recursive.c.
References DBusTypeWriter::byte_order, DBusTypeWriter::container_type, DBUS_TYPE_INVALID, DBusTypeWriter::enabled, FALSE, TRUE, DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, DBusTypeWriter::type_str, DBusTypeWriter::value_pos, and DBusTypeWriter::value_str.
Referenced by _dbus_type_writer_init_types_delayed(), and _dbus_type_writer_init_values_only().
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.
writer | the writer to init | |
byte_order | the byte order to marshal into | |
value_str | the string to write values into | |
value_pos | where to insert values |
Definition at line 1510 of file dbus-marshal-recursive.c.
References _dbus_type_writer_init(), and NULL.
Referenced by dbus_message_iter_init_append().
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 signature that matches what you're going to write out.
The writer will check what you write vs. this existing signature.
writer | the writer to init | |
byte_order | the byte order to marshal into | |
type_str | the string with signature | |
type_pos | start of signature | |
value_str | the string to write values into | |
value_pos | where to insert values |
Definition at line 1566 of file dbus-marshal-recursive.c.
References _dbus_type_writer_init(), TRUE, and DBusTypeWriter::type_pos_is_expectation.
Referenced by _dbus_header_create(), and _dbus_header_set_field_basic().
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.
writer | the writer | |
container_type | the type of the container to open | |
contained_type | the array element type or variant content type | |
contained_type_start | position to look for the type | |
sub | the new sub-writer to write container contents |
Definition at line 2074 of file dbus-marshal-recursive.c.
References FALSE.
Referenced by _dbus_header_create(), and dbus_message_iter_open_container().
void _dbus_type_writer_remove_types | ( | DBusTypeWriter * | writer | ) |
Removes type string from the writer.
writer | the writer to remove from |
Definition at line 1545 of file dbus-marshal-recursive.c.
References NULL, DBusTypeWriter::type_pos, and DBusTypeWriter::type_str.
void _dbus_type_writer_set_enabled | ( | DBusTypeWriter * | writer, | |
dbus_bool_t | enabled | |||
) |
If disabled, a writer can still be iterated forward and recursed/unrecursed but won't write any values.
Types will still be written unless the writer is a "values only" writer, because the writer needs access to a valid signature to be able to iterate.
writer | the type writer | |
enabled | TRUE if values should be written |
Definition at line 2712 of file dbus-marshal-recursive.c.
References DBusTypeWriter::enabled, and FALSE.
Referenced by _dbus_type_writer_write_reader_partial().
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 the values block.
writer | the writer | |
sub | the sub-writer created by _dbus_type_writer_recurse() |
Definition at line 2144 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_marshal_set_uint32(), _dbus_type_to_string(), DBusTypeWriter::array, DBusTypeWriter::byte_order, DBusTypeWriter::container_type, DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_ARRAY, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_INVALID, DBUS_TYPE_STRUCT, FALSE, NULL, TRUE, DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, DBusTypeWriter::type_str, DBusTypeWriter::u, DBusTypeWriter::value_pos, and DBusTypeWriter::value_str.
Referenced by _dbus_header_create(), _dbus_header_set_field_basic(), and dbus_message_iter_close_container().
dbus_bool_t _dbus_type_writer_write_basic | ( | DBusTypeWriter * | writer, | |
int | type, | |||
const void * | value | |||
) |
Writes out a basic type.
writer | the writer | |
type | the type to write | |
value | the address of the value to write |
Definition at line 2276 of file dbus-marshal-recursive.c.
References _dbus_assert_not_reached, _dbus_string_alloc_space(), FALSE, NULL, TRUE, DBusTypeWriter::type_pos_is_expectation, and DBusTypeWriter::type_str.
Referenced by _dbus_header_create(), and dbus_message_iter_append_basic().
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.
those that are both dbus_type_is_fixed() and _dbus_type_is_basic(). The block must be written inside an array.
The value parameter should be the address of said array of values, so e.g. if it's an array of double, pass in "const double**"
writer | the writer | |
element_type | type of stuff in the array | |
value | address of the array | |
n_elements | number of elements in the array |
Definition at line 2324 of file dbus-marshal-recursive.c.
References _dbus_assert, _dbus_assert_not_reached, _dbus_marshal_write_fixed_multi(), DBusTypeWriter::container_type, DBUS_TYPE_ARRAY, dbus_type_is_fixed(), FALSE, TRUE, DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, and DBusTypeWriter::value_pos.
Referenced by dbus_message_iter_append_fixed_array().
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.
The reader will be moved forward to its end position.
writer | the writer to copy to | |
reader | the reader to copy from |
Definition at line 2696 of file dbus-marshal-recursive.c.
References _dbus_type_writer_write_reader_partial(), and NULL.
dbus_bool_t _dbus_type_writer_write_reader_partial | ( | DBusTypeWriter * | writer, | |
DBusTypeReader * | reader, | |||
const DBusTypeReader * | start_after, | |||
int | start_after_new_pos, | |||
int | start_after_new_len, | |||
DBusList ** | fixups | |||
) |
Iterate through all values in the given reader, writing a copy of each value to the writer.
The reader will be moved forward to its end position.
If a reader start_after is provided, it should be a reader for the same data as the reader to be written. Only values occurring after the value pointed to by start_after will be written to the writer.
If start_after is provided, then the copy of the reader will be partial. This means that array lengths will not have been copied. The assumption is that you wrote a new version of the value at start_after to the writer. You have to pass in the start position and length of the new value. (If you are deleting the value at start_after, pass in 0 for the length.)
If the fixups parameter is non-NULL, then any array length that was read but not written due to start_after will be provided as a DBusArrayLenFixup. The fixup contains the position of the array length in the source data, and the correct array length assuming you combine the source data before start_after with the written data at start_after and beyond.
writer | the writer to copy to | |
reader | the reader to copy from | |
start_after | NULL or a reader showing where to start | |
start_after_new_pos | the position of start_after equivalent in the target data | |
start_after_new_len | the length of start_after equivalent in the target data | |
fixups | list to append DBusArrayLenFixup if the write was partial |
Definition at line 2642 of file dbus-marshal-recursive.c.
References _dbus_string_delete(), _dbus_type_writer_set_enabled(), DBusTypeWriter::enabled, FALSE, TRUE, DBusTypeWriter::type_pos, DBusTypeWriter::type_str, DBusTypeWriter::value_pos, and DBusTypeWriter::value_str.
Referenced by _dbus_type_writer_write_reader().
DBusValidity _dbus_validate_body_with_reason | ( | const DBusString * | expected_signature, | |
int | expected_signature_start, | |||
int | byte_order, | |||
int * | bytes_remaining, | |||
const DBusString * | value_str, | |||
int | value_pos, | |||
int | len | |||
) |
Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expected_signature.
If this function returns TRUE, it will be safe to iterate over the values with DBusTypeReader. The signature is assumed to be already valid.
If bytes_remaining is not NULL, then leftover bytes will be stored there and DBUS_VALID returned. If it is NULL, then DBUS_INVALID_TOO_MUCH_DATA will be returned if bytes are left over.
expected_signature | the expected types in the value_str | |
expected_signature_start | where in expected_signature is the signature | |
byte_order | the byte order | |
bytes_remaining | place to store leftover bytes | |
value_str | the string containing the body | |
value_pos | where the values start | |
len | length of values after value_pos |
Definition at line 629 of file dbus-marshal-validate.c.
References _dbus_assert, _dbus_type_reader_init_types_only(), DBUS_INVALID_TOO_MUCH_DATA, DBUS_VALID, and TRUE.
Referenced by _dbus_header_load().
dbus_bool_t _dbus_validate_bus_name | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid bus name in the D-Bus protocol.
This includes a length restriction, etc., see the specification.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 954 of file dbus-marshal-validate.c.
References _dbus_assert, DBUS_MAXIMUM_NAME_LENGTH, FALSE, NULL, TRUE, VALID_BUS_NAME_CHARACTER, and VALID_INITIAL_BUS_NAME_CHARACTER.
dbus_bool_t _dbus_validate_error_name | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid error name in the D-Bus protocol.
This includes a length restriction, etc., see the specification.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 913 of file dbus-marshal-validate.c.
References _dbus_validate_interface().
dbus_bool_t _dbus_validate_interface | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid interface name in the D-Bus protocol.
This includes a length restriction and an ASCII subset, see the specification.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 776 of file dbus-marshal-validate.c.
References _dbus_assert, DBUS_MAXIMUM_NAME_LENGTH, FALSE, NULL, TRUE, VALID_INITIAL_NAME_CHARACTER, and VALID_NAME_CHARACTER.
Referenced by _dbus_validate_error_name().
dbus_bool_t _dbus_validate_member | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid member name in the D-Bus protocol.
This includes a length restriction, etc., see the specification.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 852 of file dbus-marshal-validate.c.
References _dbus_assert, DBUS_MAXIMUM_NAME_LENGTH, FALSE, TRUE, VALID_INITIAL_NAME_CHARACTER, and VALID_NAME_CHARACTER.
dbus_bool_t _dbus_validate_path | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid object path name in the D-Bus protocol.
Part of the validation ensures that the object path contains only ASCII.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 711 of file dbus-marshal-validate.c.
References _dbus_assert, FALSE, TRUE, and VALID_NAME_CHARACTER.
dbus_bool_t _dbus_validate_signature | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Checks that the given range of the string is a valid message type signature in the D-Bus protocol.
str | the string | |
start | first byte index to check | |
len | number of bytes to check |
Definition at line 1053 of file dbus-marshal-validate.c.
References _dbus_assert, _dbus_validate_signature_with_reason(), DBUS_VALID, and FALSE.
Referenced by dbus_signature_validate().
DBusValidity _dbus_validate_signature_with_reason | ( | const DBusString * | type_str, | |
int | type_pos, | |||
int | len | |||
) |
Verifies that the range of type_str from type_pos to type_end is a valid signature.
If this function returns TRUE, it will be safe to iterate over the signature with a types-only DBusTypeReader. The range passed in should NOT include the terminating nul/DBUS_TYPE_INVALID.
type_str | the string | |
type_pos | where the typecodes start | |
len | length of typecodes |
Definition at line 50 of file dbus-marshal-validate.c.
References _dbus_assert, _DBUS_INT32_MAX, _DBUS_INT_TO_POINTER, _dbus_list_append(), _dbus_list_clear(), _dbus_list_pop_last(), _DBUS_POINTER_TO_INT, DBUS_DICT_ENTRY_BEGIN_CHAR, DBUS_DICT_ENTRY_END_CHAR, DBUS_MAXIMUM_SIGNATURE_LENGTH, DBUS_MAXIMUM_TYPE_RECURSION_DEPTH, DBUS_STRUCT_BEGIN_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_INVALID, dbus_type_is_basic(), DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_STRUCT, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, DBUS_TYPE_VARIANT, DBUS_VALID, DBUS_VALIDITY_UNKNOWN_OOM_ERROR, and NULL.
Referenced by _dbus_validate_signature().
void _dbus_verbose_bytes | ( | const unsigned char * | data, | |
int | len, | |||
int | offset | |||
) |
If in verbose mode, print a block of binary data.
data | the data | |
len | the length of the data | |
offset | where to start counting for byte indexes |
Definition at line 1316 of file dbus-marshal-basic.c.
References _dbus_assert, DBUS_BIG_ENDIAN, and DBUS_LITTLE_ENDIAN.
Referenced by _dbus_verbose_bytes_of_string().
void _dbus_verbose_bytes_of_string | ( | const DBusString * | str, | |
int | start, | |||
int | len | |||
) |
Dump the given part of the string to verbose log.
str | the string | |
start | the start of range to dump | |
len | length of range |
Definition at line 1402 of file dbus-marshal-basic.c.
References _dbus_assert, and _dbus_verbose_bytes().
Referenced by _dbus_read(), _dbus_type_reader_set_basic(), and _dbus_write().