Commit 92f7d50b authored by Anders Carlsson's avatar Anders Carlsson

2003-02-21 Anders Carlsson <andersca@codefactory.se>

	* dbus/dbus-marshal.c: (_dbus_demarshal_string_array):
	Make string arrays NULL-terminated.

	* dbus/dbus-memory.c: (dbus_free_string_array):
	* dbus/dbus-memory.h:
	New function for freeing NULL-terminated string arrays.

	* dbus/dbus-message-builder.c: (append_quoted_string),
	(_dbus_message_data_load):
	Add support for array types.

	* dbus/dbus-message.c: (check_message_handling):
	Add more types as test cases.

	* dbus/dbus-sysdeps.c: (_dbus_string_parse_int),
	(_dbus_string_parse_double):
	Add the start offset to the end offset.

	* test/data/valid-messages/lots-of-arguments.message:
	New test message with lots of arguments.
parent fdb3ecc3
2003-02-21 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-marshal.c: (_dbus_demarshal_string_array):
Make string arrays NULL-terminated.
* dbus/dbus-memory.c: (dbus_free_string_array):
* dbus/dbus-memory.h:
New function for freeing NULL-terminated string arrays.
* dbus/dbus-message-builder.c: (append_quoted_string),
(_dbus_message_data_load):
Add support for array types.
* dbus/dbus-message.c: (check_message_handling):
Add more types as test cases.
* dbus/dbus-sysdeps.c: (_dbus_string_parse_int),
(_dbus_string_parse_double):
Add the start offset to the end offset.
* test/data/valid-messages/lots-of-arguments.message:
New test message with lots of arguments.
2003-02-21 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-message.c: (dbus_message_append_nil),
......
......@@ -813,11 +813,13 @@ _dbus_demarshal_string_array (const DBusString *str,
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
retval = dbus_new (char *, len);
retval = dbus_new (char *, len + 1);
if (!retval)
return NULL;
retval[len] = NULL;
for (i = 0; i < len; i++)
{
retval[i] = _dbus_demarshal_string (str, byte_order, pos, &pos);
......
......@@ -220,4 +220,28 @@ dbus_free (void *memory)
free (memory);
}
/**
* Frees a #NULL-terminated array of strings.
* If passed #NULL, does nothing.
*
* @param str_array the array to be freed
*/
void
dbus_free_string_array (char **str_array)
{
if (str_array)
{
int i;
i = 0;
while (str_array[i])
{
dbus_free (str_array[i]);
i++;
}
dbus_free (str_array);
}
}
/** @} */
......@@ -41,6 +41,8 @@ void dbus_free (void *memory);
#define dbus_new(type, count) ((type*)dbus_malloc (sizeof (type) * (count)));
#define dbus_new0(type, count) ((type*)dbus_malloc0 (sizeof (type) * (count)));
void dbus_free_string_array (char **str_array);
typedef void (* DBusFreeFunction) (void *memory);
DBUS_END_DECLS;
......
This diff is collapsed.
......@@ -1909,9 +1909,6 @@ dbus_message_iter_get_byte_array (DBusMessageIter *iter,
* Note that you need to check that the iterator points
* to a byte array prior to using this function.
*
* @todo this function should probably take "char **" as
* an out param argument, and return boolean or result code.
*
* @param iter the iterator
* @param len return location for length of byte array
* @returns the byte array
......@@ -2715,6 +2712,17 @@ check_message_handling (DBusMessage *message)
{
switch (type)
{
case DBUS_TYPE_NIL:
break;
case DBUS_TYPE_INT32:
dbus_message_iter_get_int32 (iter);
break;
case DBUS_TYPE_UINT32:
dbus_message_iter_get_uint32 (iter);
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_double (iter);
break;
case DBUS_TYPE_STRING:
{
char *str;
......@@ -2722,6 +2730,53 @@ check_message_handling (DBusMessage *message)
dbus_free (str);
}
break;
case DBUS_TYPE_INT32_ARRAY:
{
dbus_int32_t *values;
int len;
if (!dbus_message_iter_get_int32_array (iter, &values, &len))
return FALSE;
dbus_free (values);
}
break;
case DBUS_TYPE_UINT32_ARRAY:
{
dbus_uint32_t *values;
int len;
if (!dbus_message_iter_get_uint32_array (iter, &values, &len))
return FALSE;
dbus_free (values);
}
break;
case DBUS_TYPE_DOUBLE_ARRAY:
{
double *values;
int len;
if (!dbus_message_iter_get_double_array (iter, &values, &len))
return FALSE;
dbus_free (values);
}
break;
case DBUS_TYPE_STRING_ARRAY:
{
char **values;
int len;
if (!dbus_message_iter_get_string_array (iter, &values, &len))
return FALSE;
dbus_free_string_array (values);
}
break;
default:
break;
}
if (!dbus_message_iter_next (iter))
......
......@@ -925,7 +925,7 @@ _dbus_string_parse_int (const DBusString *str,
if (value_return)
*value_return = v;
if (end_return)
*end_return = (end - p);
*end_return = start + (end - p);
return TRUE;
}
......@@ -970,7 +970,7 @@ _dbus_string_parse_double (const DBusString *str,
if (value_return)
*value_return = v;
if (end_return)
*end_return = (end - p);
*end_return = start + (end - p);
return TRUE;
}
......
# Message with lots of different argument types
VALID_HEADER
END_LENGTH Header
ALIGN 8
START_LENGTH Body
TYPE NIL
TYPE INT32
INT32 0x12345678
TYPE UINT32
UINT32 0x8765432
TYPE DOUBLE
DOUBLE 3.141592653589
TYPE STRING
STRING 'This is a string'
TYPE INT32_ARRAY
INT32_ARRAY { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10 }
TYPE UINT32_ARRAY
UINT32_ARRAY { 11, 12, 314, 1911, 57692, 1237, 2834 }
TYPE DOUBLE_ARRAY
DOUBLE_ARRAY { 0.1, 0.2, 3.1415926, 2.7183, 10.0, 9.99 }
TYPE STRING_ARRAY
STRING_ARRAY { 'Hello', 'This', 'Is', 'A', 'String', 'Array!' }
END_LENGTH Body
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment