From 000d29a283b06517f0cfb599516a390e3afbf25c Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 7 Jan 2003 23:08:41 +0000 Subject: 2003-01-08 Anders Carlsson * dbus/dbus-internals.c: (_dbus_type_to_string): New function that returns a string describing a type. * dbus/dbus-marshal.c: (_dbus_demarshal_byte_array): * dbus/dbus-marshal.h: * dbus/dbus-message.c: (dbus_message_get_fields_valist), (dbus_message_iter_get_field_type), (dbus_message_iter_get_double), (dbus_message_iter_get_byte_array): * dbus/dbus-message.h: Add new convenience functions for appending and getting message fields. Also add demarshalling routines for byte arrays. --- dbus/dbus-marshal.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'dbus/dbus-marshal.c') diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c index 7c85ded0..14629362 100644 --- a/dbus/dbus-marshal.c +++ b/dbus/dbus-marshal.c @@ -396,6 +396,40 @@ _dbus_demarshal_string (DBusString *str, return retval; } +unsigned char * +_dbus_demarshal_byte_array (DBusString *str, + int byte_order, + int pos, + int *new_pos, + int *array_len) +{ + int len; + unsigned char *retval; + const char *data; + + len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos); + + retval = dbus_malloc (len); + + if (!retval) + return NULL; + + _dbus_string_get_const_data_len (str, &data, pos, len); + + if (!data) + return NULL; + + memcpy (retval, data, len); + + if (new_pos) + *new_pos = pos + len; + + if (array_len) + *array_len = len; + + return retval; +} + /** * Returns the position right after the end position * end position of a field -- cgit