summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dbus/dbus-marshal-basic.c127
-rw-r--r--dbus/dbus-marshal-basic.h97
-rw-r--r--dbus/dbus-marshal-recursive.c77
3 files changed, 149 insertions, 152 deletions
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c
index 92517c9f..bad7d117 100644
--- a/dbus/dbus-marshal-basic.c
+++ b/dbus/dbus-marshal-basic.c
@@ -283,7 +283,7 @@ set_string (DBusString *str,
_dbus_string_init_const (&dstr, value);
- old_len = _dbus_demarshal_uint32 (str, pos, byte_order, NULL);
+ old_len = _dbus_marshal_read_uint32 (str, pos, byte_order, NULL);
new_len = _dbus_string_get_length (&dstr);
@@ -358,13 +358,13 @@ set_signature (DBusString *str,
* @returns #FALSE if no memory
*/
dbus_bool_t
-_dbus_marshal_set_basic_type (DBusString *str,
- int pos,
- int type,
- const void *value,
- int byte_order,
- int *old_end_pos,
- int *new_end_pos)
+_dbus_marshal_set_basic (DBusString *str,
+ int pos,
+ int type,
+ const void *value,
+ int byte_order,
+ int *old_end_pos,
+ int *new_end_pos)
{
const DBusBasicValue *vp;
@@ -419,10 +419,10 @@ _dbus_marshal_set_basic_type (DBusString *str,
}
static dbus_uint32_t
-demarshal_4_octets (const DBusString *str,
- int pos,
- int byte_order,
- int *new_pos)
+read_4_octets (const DBusString *str,
+ int pos,
+ int byte_order,
+ int *new_pos)
{
pos = _DBUS_ALIGN_VALUE (pos, 4);
@@ -443,16 +443,16 @@ demarshal_4_octets (const DBusString *str,
* @returns the demarshaled integer.
*/
dbus_uint32_t
-_dbus_demarshal_uint32 (const DBusString *str,
- int pos,
- int byte_order,
- int *new_pos)
+_dbus_marshal_read_uint32 (const DBusString *str,
+ int pos,
+ int byte_order,
+ int *new_pos)
{
- return demarshal_4_octets (str, pos, byte_order, new_pos);
+ return read_4_octets (str, pos, byte_order, new_pos);
}
/**
- * Demarshals a basic type. The "value" pointer is always
+ * 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
@@ -473,12 +473,12 @@ _dbus_demarshal_uint32 (const DBusString *str,
* @param new_pos pointer to update with new position, or #NULL
**/
void
-_dbus_demarshal_basic_type (const DBusString *str,
- int pos,
- int type,
- void *value,
- int byte_order,
- int *new_pos)
+_dbus_marshal_read_basic (const DBusString *str,
+ int pos,
+ int type,
+ void *value,
+ int byte_order,
+ int *new_pos)
{
const char *str_data;
DBusBasicValue *vp;
@@ -523,7 +523,7 @@ _dbus_demarshal_basic_type (const DBusString *str,
{
int len;
- len = _dbus_demarshal_uint32 (str, pos, byte_order, &pos);
+ len = _dbus_marshal_read_uint32 (str, pos, byte_order, &pos);
vp->str = (char*) str_data + pos;
@@ -711,11 +711,11 @@ marshal_signature (DBusString *str,
}
/**
- * Marshals a basic type. The "value" pointer is always the
+ * 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_demarshal_basic_type() and to have a simple
+ * with _dbus_marshal_read_basic() and to have a simple
* consistent rule.
*
* @param str string to marshal to
@@ -727,12 +727,12 @@ marshal_signature (DBusString *str,
* @returns #TRUE on success
**/
dbus_bool_t
-_dbus_marshal_basic_type (DBusString *str,
- int insert_at,
- int type,
- const void *value,
- int byte_order,
- int *pos_after)
+_dbus_marshal_write_basic (DBusString *str,
+ int insert_at,
+ int type,
+ const void *value,
+ int byte_order,
+ int *pos_after)
{
const DBusBasicValue *vp;
@@ -909,13 +909,13 @@ marshal_8_octets_array (DBusString *str,
* @returns #TRUE on success
**/
dbus_bool_t
-_dbus_marshal_basic_type_array (DBusString *str,
- int insert_at,
- int element_type,
- const void *value,
- int len,
- int byte_order,
- int *pos_after)
+_dbus_marshal_write_basic_array (DBusString *str,
+ int insert_at,
+ int element_type,
+ const void *value,
+ int len,
+ int byte_order,
+ int *pos_after)
{
/* FIXME use the insert_at arg and fill in pos_after */
@@ -956,19 +956,19 @@ _dbus_marshal_basic_type_array (DBusString *str,
/**
- * Skips over a basic type, reporting the following position.
+ * Skips over a basic-typed value, reporting the following position.
*
* @param str the string containing the data
- * @param type type of value to demarshal
+ * @param type type of value to read
* @param byte_order the byte order
* @param pos pointer to position in the string,
* updated on return to new position
**/
void
-_dbus_marshal_skip_basic_type (const DBusString *str,
- int type,
- int byte_order,
- int *pos)
+_dbus_marshal_skip_basic (const DBusString *str,
+ int type,
+ int byte_order,
+ int *pos)
{
switch (type)
{
@@ -992,7 +992,7 @@ _dbus_marshal_skip_basic_type (const DBusString *str,
{
int len;
- len = _dbus_demarshal_uint32 (str, *pos, byte_order, pos);
+ len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos);
*pos += len + 1; /* length plus nul */
}
@@ -1035,12 +1035,7 @@ _dbus_marshal_skip_array (const DBusString *str,
i = _DBUS_ALIGN_VALUE (*pos, 4);
- _dbus_demarshal_basic_type (str,
- i,
- DBUS_TYPE_UINT32,
- &array_len,
- byte_order,
- &i);
+ array_len = _dbus_marshal_read_uint32 (str, i, byte_order, &i);
alignment = _dbus_type_get_alignment (element_type);
@@ -1155,7 +1150,7 @@ _dbus_type_is_container (int typecode)
*
* This function is defined to return #TRUE for exactly those
* types that can be written with _dbus_marshal_basic_type()
- * and read with _dbus_demarshal_basic_type().
+ * and read with _dbus_marshal_read_basic().
*
* This function will crash if passed a typecode that isn't
* in dbus-protocol.h
@@ -1320,7 +1315,7 @@ _dbus_verbose_bytes_of_string (const DBusString *str,
#define MARSHAL_BASIC(typename, byte_order, literal) \
do { \
v_##typename = literal; \
- if (!_dbus_marshal_basic_type (&str, pos, DBUS_TYPE_##typename, \
+ if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename, \
&v_##typename, \
byte_order, NULL)) \
_dbus_assert_not_reached ("no memory"); \
@@ -1328,7 +1323,7 @@ _dbus_verbose_bytes_of_string (const DBusString *str,
#define DEMARSHAL_BASIC(typename, byte_order) \
do { \
- _dbus_demarshal_basic_type (&str, pos, DBUS_TYPE_##typename, &v_##typename, \
+ _dbus_marshal_read_basic (&str, pos, DBUS_TYPE_##typename, &v_##typename, \
byte_order, &pos); \
} while (0)
@@ -1621,23 +1616,23 @@ _dbus_marshal_test (void)
_dbus_string_init_const (&t, "Hello world foo");
v_STRING = _dbus_string_get_const_data (&t);
- _dbus_marshal_set_basic_type (&str, 0, DBUS_TYPE_STRING,
- &v_STRING, byte_order, NULL, NULL);
+ _dbus_marshal_set_basic (&str, 0, DBUS_TYPE_STRING,
+ &v_STRING, byte_order, NULL, NULL);
- _dbus_demarshal_basic_type (&str, 0, DBUS_TYPE_STRING,
- &v_STRING, byte_order,
- NULL);
+ _dbus_marshal_read_basic (&str, 0, DBUS_TYPE_STRING,
+ &v_STRING, byte_order,
+ NULL);
_dbus_assert (strcmp (v_STRING, "Hello world foo") == 0);
/* Set it to something shorter */
_dbus_string_init_const (&t, "Hello");
v_STRING = _dbus_string_get_const_data (&t);
- _dbus_marshal_set_basic_type (&str, 0, DBUS_TYPE_STRING,
- &v_STRING, byte_order, NULL, NULL);
- _dbus_demarshal_basic_type (&str, 0, DBUS_TYPE_STRING,
- &v_STRING, byte_order,
- NULL);
+ _dbus_marshal_set_basic (&str, 0, DBUS_TYPE_STRING,
+ &v_STRING, byte_order, NULL, NULL);
+ _dbus_marshal_read_basic (&str, 0, DBUS_TYPE_STRING,
+ &v_STRING, byte_order,
+ NULL);
_dbus_assert (strcmp (v_STRING, "Hello") == 0);
/* Do the other byte order */
diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h
index 89565079..529ada5d 100644
--- a/dbus/dbus-marshal-basic.h
+++ b/dbus/dbus-marshal-basic.h
@@ -2,7 +2,7 @@
/* dbus-marshal-basic.h Marshalling routines for basic (primitive) types
*
* Copyright (C) 2002 CodeFactory AB
- * Copyright (C) 2004 Red Hat, Inc.
+ * Copyright (C) 2004, 2005 Red Hat, Inc.
*
* Licensed under the Academic Free License version 2.1
*
@@ -262,53 +262,54 @@ dbus_uint32_t _dbus_unpack_uint32 (int byte_order,
const unsigned char *data);
-dbus_bool_t _dbus_marshal_set_basic_type (DBusString *str,
- int pos,
- int type,
- const void *value,
- int byte_order,
- int *old_end_pos,
- int *new_end_pos);
-dbus_bool_t _dbus_marshal_basic_type (DBusString *str,
- int insert_at,
- int type,
- const void *value,
- int byte_order,
- int *pos_after);
-dbus_bool_t _dbus_marshal_basic_type_array (DBusString *str,
- int insert_at,
- int element_type,
- const void *value,
- int len,
- int byte_order,
- int *pos_after);
-void _dbus_demarshal_basic_type (const DBusString *str,
- int pos,
- int type,
- void *value,
- int byte_order,
- int *new_pos);
-void _dbus_marshal_skip_basic_type (const DBusString *str,
- int type,
- int byte_order,
- int *pos);
-void _dbus_marshal_skip_array (const DBusString *str,
- int element_type,
- int byte_order,
- int *pos);
-void _dbus_marshal_set_uint32 (DBusString *str,
- int pos,
- dbus_uint32_t value,
- int byte_order);
-dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
- int pos,
- int byte_order,
- int *new_pos);
-dbus_bool_t _dbus_type_is_valid (int typecode);
-int _dbus_type_get_alignment (int typecode);
-dbus_bool_t _dbus_type_is_basic (int typecode);
-dbus_bool_t _dbus_type_is_container (int typecode);
-dbus_bool_t _dbus_type_length_varies (int typecode);
+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);
+dbus_bool_t _dbus_marshal_write_basic (DBusString *str,
+ int insert_at,
+ int type,
+ const void *value,
+ int byte_order,
+ int *pos_after);
+dbus_bool_t _dbus_marshal_write_basic_array (DBusString *str,
+ int insert_at,
+ int element_type,
+ const void *value,
+ int len,
+ int byte_order,
+ int *pos_after);
+void _dbus_marshal_read_basic (const DBusString *str,
+ int pos,
+ int type,
+ void *value,
+ int byte_order,
+ int *new_pos);
+void _dbus_marshal_skip_basic (const DBusString *str,
+ int type,
+ int byte_order,
+ int *pos);
+void _dbus_marshal_skip_array (const DBusString *str,
+ int element_type,
+ int byte_order,
+ int *pos);
+void _dbus_marshal_set_uint32 (DBusString *str,
+ int pos,
+ dbus_uint32_t value,
+ int byte_order);
+dbus_uint32_t _dbus_marshal_read_uint32 (const DBusString *str,
+ int pos,
+ int byte_order,
+ int *new_pos);
+dbus_bool_t _dbus_type_is_valid (int typecode);
+int _dbus_type_get_alignment (int typecode);
+dbus_bool_t _dbus_type_is_basic (int typecode);
+dbus_bool_t _dbus_type_is_container (int typecode);
+dbus_bool_t _dbus_type_length_varies (int typecode);
+
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c
index 21f922fa..5902fe3b 100644
--- a/dbus/dbus-marshal-recursive.c
+++ b/dbus/dbus-marshal-recursive.c
@@ -140,12 +140,12 @@ array_reader_get_array_len (const DBusTypeReader *reader)
/* array_len_offset is the offset back from start_pos to end of the len */
len_pos = reader->u.array.start_pos - ((int)reader->array_len_offset) - 4;
- _dbus_demarshal_basic_type (reader->value_str,
- len_pos,
- DBUS_TYPE_UINT32,
- &array_len,
- reader->byte_order,
- NULL);
+ _dbus_marshal_read_basic (reader->value_str,
+ len_pos,
+ DBUS_TYPE_UINT32,
+ &array_len,
+ reader->byte_order,
+ NULL);
_dbus_verbose (" reader %p len_pos %d array len %u len_offset %d\n",
reader, len_pos, array_len, reader->array_len_offset);
@@ -333,9 +333,9 @@ base_reader_next (DBusTypeReader *reader,
default:
if (!reader->klass->types_only)
- _dbus_marshal_skip_basic_type (reader->value_str,
- current_type, reader->byte_order,
- &reader->value_pos);
+ _dbus_marshal_skip_basic (reader->value_str,
+ current_type, reader->byte_order,
+ &reader->value_pos);
reader->type_pos += 1;
break;
@@ -421,9 +421,9 @@ array_reader_next (DBusTypeReader *reader,
default:
{
- _dbus_marshal_skip_basic_type (reader->value_str,
- current_type, reader->byte_order,
- &reader->value_pos);
+ _dbus_marshal_skip_basic (reader->value_str,
+ current_type, reader->byte_order,
+ &reader->value_pos);
}
break;
}
@@ -660,12 +660,12 @@ _dbus_type_reader_array_is_empty (const DBusTypeReader *reader)
_dbus_verbose ("checking array len at %d\n", reader->value_pos);
#endif
- _dbus_demarshal_basic_type (reader->value_str,
- reader->value_pos,
- DBUS_TYPE_UINT32,
- &array_len,
- reader->byte_order,
- NULL);
+ _dbus_marshal_read_basic (reader->value_str,
+ reader->value_pos,
+ DBUS_TYPE_UINT32,
+ &array_len,
+ reader->byte_order,
+ NULL);
#if RECURSIVE_MARSHAL_TRACE
_dbus_verbose (" ... array len = %d\n", array_len);
#endif
@@ -683,11 +683,11 @@ _dbus_type_reader_read_basic (const DBusTypeReader *reader,
t = _dbus_type_reader_get_current_type (reader);
- _dbus_demarshal_basic_type (reader->value_str,
- reader->value_pos,
- t, value,
- reader->byte_order,
- NULL);
+ _dbus_marshal_read_basic (reader->value_str,
+ reader->value_pos,
+ t, value,
+ reader->byte_order,
+ NULL);
#if RECURSIVE_MARSHAL_TRACE
@@ -859,16 +859,16 @@ _dbus_type_reader_get_signature (const DBusTypeReader *reader,
}
static void
-reader_fixed_length_set_basic (DBusTypeReader *reader,
+reader_set_basic_fixed_length (DBusTypeReader *reader,
int current_type,
const void *value)
{
- _dbus_marshal_set_basic_type ((DBusString*) reader->value_str,
- reader->value_pos,
- current_type,
- value,
- reader->byte_order,
- NULL, NULL);
+ _dbus_marshal_set_basic ((DBusString*) reader->value_str,
+ reader->value_pos,
+ current_type,
+ value,
+ reader->byte_order,
+ NULL, NULL);
}
/**
@@ -905,11 +905,12 @@ _dbus_type_reader_set_basic (DBusTypeReader *reader,
if (!_dbus_type_length_varies (current_type))
{
- reader_fixed_length_set_basic (reader, current_type, value);
+ reader_set_basic_fixed_length (reader, current_type, value);
return TRUE;
}
- /* FIXME */
+ /* In the harder case, we have to fix alignment after we insert. */
+
retval = TRUE;
@@ -975,12 +976,12 @@ _dbus_type_writer_write_basic_no_typecode (DBusTypeWriter *writer,
int type,
const void *value)
{
- return _dbus_marshal_basic_type (writer->value_str,
- writer->value_pos,
- type,
- value,
- writer->byte_order,
- &writer->value_pos);
+ return _dbus_marshal_write_basic (writer->value_str,
+ writer->value_pos,
+ type,
+ value,
+ writer->byte_order,
+ &writer->value_pos);
}
/* If our parent is an array, things are a little bit complicated.