+2003-03-16 Anders Carlsson <andersca@codefactory.se>
+
+ * dbus/dbus-connection.c:
+ (dbus_connection_send_with_reply_and_block):
+ Decrease connection->n_incoming when removing an entry
+ from the list.
+ * dbus/dbus-dict.c: (dbus_dict_entry_free),
+ (dbus_dict_set_boolean_array), (dbus_dict_set_int32_array),
+ (dbus_dict_set_uint32_array), (dbus_dict_set_double_array),
+ (dbus_dict_set_byte_array), (dbus_dict_set_string_array),
+ (dbus_dict_get_boolean_array), (dbus_dict_get_double_array),
+ (dbus_dict_get_byte_array):
+ Handle NULL arrays and strings. Also add support for byte arrays.
+
+ * dbus/dbus-marshal.c: (_dbus_marshal_byte_array),
+ (_dbus_marshal_dict), (_dbus_demarshal_byte_array),
+ (_dbus_demarshal_int32_array), (_dbus_demarshal_uint32_array),
+ (_dbus_demarshal_double_array), (_dbus_demarshal_string_array),
+ (_dbus_demarshal_dict), (demarshal_and_validate_len),
+ (_dbus_marshal_validate_arg), (_dbus_marshal_test):
+ * dbus/dbus-marshal.h:
+ Add support for marshalling and demarshalling empty arrays and strings.
+
+ * dbus/dbus-message.c: (dbus_message_append_args_valist),
+ (dbus_message_append_string_array),
+ (dbus_message_iter_get_boolean),
+ (dbus_message_iter_get_boolean_array),
+ (dbus_message_iter_get_int32_array),
+ (dbus_message_iter_get_uint32_array),
+ (dbus_message_iter_get_double_array),
+ (dbus_message_iter_get_byte_array),
+ (dbus_message_iter_get_string_array), (dbus_message_iter_get_dict),
+ (check_message_handling):
+ Add support for getting empty arrays and dicts.
+
+ * dbus/dbus-string.c: (_dbus_string_validate_utf8):
+ Don't do any validation at all for now, that's better than just checking
+ for ASCII.
+
+ * test/data/valid-messages/emptiness.message:
+ New test message with lots of empty arrays.
+
2003-03-16 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c
if (dbus_message_get_reply_serial (reply) == client_serial)
{
_dbus_list_remove_link (&connection->incoming_messages, link);
+ connection->n_incoming -= 1;
dbus_message_ref (reply);
dbus_mutex_unlock (connection->mutex);
struct {
unsigned char *value;
int len;
- } boolean_array;
+ } byte_array;
struct {
dbus_int32_t *value;
int len;
case DBUS_TYPE_STRING:
dbus_free (entry->v.string_value);
break;
+ case DBUS_TYPE_BYTE_ARRAY:
case DBUS_TYPE_BOOLEAN_ARRAY:
- dbus_free (entry->v.boolean_array.value);
+ dbus_free (entry->v.byte_array.value);
break;
case DBUS_TYPE_INT32_ARRAY:
dbus_free (entry->v.int32_array.value);
DBusDictEntry *entry;
unsigned char *tmp;
- tmp = dbus_malloc (len);
-
- if (!tmp)
- return FALSE;
+ if (len == 0)
+ tmp = NULL;
+ else
+ {
+ tmp = dbus_malloc (len);
+
+ if (!tmp)
+ return FALSE;
- memcpy (tmp, value, len);
+ memcpy (tmp, value, len);
+ }
if (insert_entry (dict, key, &entry))
{
entry->type = DBUS_TYPE_BOOLEAN_ARRAY;
- entry->v.boolean_array.value = tmp;
- entry->v.boolean_array.len = len;
+ entry->v.byte_array.value = tmp;
+ entry->v.byte_array.len = len;
return TRUE;
}
DBusDictEntry *entry;
dbus_int32_t *tmp;
- tmp = dbus_new (dbus_int32_t, len);
-
- if (!tmp)
- return FALSE;
-
+ if (len == 0)
+ tmp = NULL;
+ else
+ {
+ tmp = dbus_new (dbus_int32_t, len);
+
+ if (!tmp)
+ return FALSE;
+ }
+
memcpy (tmp, value, len * sizeof (dbus_int32_t));
if (insert_entry (dict, key, &entry))
DBusDictEntry *entry;
dbus_uint32_t *tmp;
- tmp = dbus_new (dbus_uint32_t, len);
-
- if (!tmp)
- return FALSE;
-
- memcpy (tmp, value, len * sizeof (dbus_uint32_t));
+ if (len == 0)
+ tmp = NULL;
+ else
+ {
+ tmp = dbus_new (dbus_uint32_t, len);
+
+ if (!tmp)
+ return FALSE;
+
+ memcpy (tmp, value, len * sizeof (dbus_uint32_t));
+ }
if (insert_entry (dict, key, &entry))
{
DBusDictEntry *entry;
double *tmp;
- tmp = dbus_new (double, len);
+ if (len == 0)
+ tmp = NULL;
+ else
+ {
+ tmp = dbus_new (double, len);
- if (!tmp)
- return FALSE;
+ if (!tmp)
+ return FALSE;
- memcpy (tmp, value, len * sizeof (double));
+ memcpy (tmp, value, len * sizeof (double));
+ }
if (insert_entry (dict, key, &entry))
{
return FALSE;
}
+dbus_bool_t
+dbus_dict_set_byte_array (DBusDict *dict,
+ const char *key,
+ unsigned const char *value,
+ int len)
+{
+ DBusDictEntry *entry;
+ unsigned char *tmp;
+
+ if (len == 0)
+ tmp = NULL;
+ else
+ {
+ tmp = dbus_malloc (len);
+
+ if (!tmp)
+ return FALSE;
+
+ memcpy (tmp, value, len);
+ }
+
+ if (insert_entry (dict, key, &entry))
+ {
+ entry->type = DBUS_TYPE_BYTE_ARRAY;
+ entry->v.byte_array.value = tmp;
+ entry->v.byte_array.len = len;
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
/**
* Adds a string array to the dict. If a value with the same key
* already exists, then it will be replaced by the new value.
if (!tmp)
return FALSE;
+ tmp[len] = NULL;
+
for (i = 0; i < len; i++)
{
tmp[i] = _dbus_strdup (value[i]);
if (!entry || entry->type != DBUS_TYPE_BOOLEAN_ARRAY)
return FALSE;
- *value = entry->v.boolean_array.value;
- *len = entry->v.boolean_array.len;
+ *value = entry->v.byte_array.value;
+ *len = entry->v.byte_array.len;
return TRUE;
}
return TRUE;
}
+dbus_bool_t
+dbus_dict_get_byte_array (DBusDict *dict,
+ const char *key,
+ unsigned const char **value,
+ int *len)
+{
+ DBusDictEntry *entry;
+
+ entry = _dbus_hash_table_lookup_string (dict->table, key);
+
+ if (!entry || entry->type != DBUS_TYPE_BYTE_ARRAY)
+ return FALSE;
+
+ *value = entry->v.byte_array.value;
+ *len = entry->v.byte_array.len;
+
+ return TRUE;
+}
+
/**
* Gets a string array from a dict using a key.
*
return FALSE;
}
- return _dbus_string_append_len (str, value, len);
+ if (len == 0)
+ return TRUE;
+ else
+ return _dbus_string_append_len (str, value, len);
}
/**
return TRUE;
if (!_dbus_marshal_string_array (str, byte_order,
- keys, len))
+ (const char **)keys, len))
goto error;
for (i = 0; i < len; i++)
if (!dbus_dict_get_string_array (dict, keys[i], &value, &len))
goto error;
- if (!_dbus_marshal_string_array (str, byte_order, value, len))
+ if (!_dbus_marshal_string_array (str, byte_order, (const char **)value, len))
goto error;
break;
}
default:
- _dbus_warn ("unknwon value type %d\n", dbus_dict_get_value_type (dict, keys[i]));
+ _dbus_warn ("unkown value type %d\n", dbus_dict_get_value_type (dict, keys[i]));
_dbus_assert_not_reached ("unknown value type in dict");
}
}
* @param str the string containing the data
* @param byte_order the byte order
* @param pos the position in the string
- * @param new_pos the new position of the string
+ * @param array the array
* @param array_len length of the demarshaled data
- * @returns the demarshaled data.
+
+ * @returns #TRUE on success
*/
-unsigned char *
-_dbus_demarshal_byte_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len)
+dbus_bool_t
+_dbus_demarshal_byte_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ unsigned char **array,
+ int *array_len)
{
int len;
unsigned char *retval;
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
+ if (len == 0)
+ {
+ *array_len = len;
+ *array = NULL;
+
+ if (new_pos)
+ *new_pos = pos;
+
+ return TRUE;
+ }
+
retval = dbus_malloc (len);
if (!retval)
- return NULL;
+ return FALSE;
_dbus_string_get_const_data_len (str, &data, pos, len);
if (!data)
- return NULL;
+ {
+ dbus_free (retval);
+ return FALSE;
+ }
memcpy (retval, data, len);
if (new_pos)
*new_pos = pos + len;
- if (array_len)
- *array_len = len;
-
- return retval;
+ *array = retval;
+ *array_len = len;
+
+ return TRUE;
}
/**
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position of the string
+ * @param array the array
* @param array_len length of the demarshaled data
- * @returns the demarshaled data.
+ * @returns #TRUE on success
*/
-dbus_int32_t *
-_dbus_demarshal_int32_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len)
+dbus_bool_t
+_dbus_demarshal_int32_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ dbus_int32_t **array,
+ int *array_len)
{
int len, i;
dbus_int32_t *retval;
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
- retval = dbus_new (dbus_int32_t, len);
+ if (len == 0)
+ {
+ *array_len = 0;
+ *array = NULL;
+ if (new_pos)
+ *new_pos = pos;
+
+ return TRUE;
+ }
+
+ retval = dbus_new (dbus_int32_t, len);
+
if (!retval)
- return NULL;
+ return FALSE;
for (i = 0; i < len; i++)
retval[i] = _dbus_demarshal_int32 (str, byte_order, pos, &pos);
if (new_pos)
*new_pos = pos;
- if (array_len)
- *array_len = len;
+ *array_len = len;
+ *array = retval;
- return retval;
+ return TRUE;
}
/**
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position of the string
+ * @param array the array
* @param array_len length of the demarshaled data
- * @returns the demarshaled data.
+ * @returns #TRUE on success
*/
-dbus_uint32_t *
-_dbus_demarshal_uint32_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len)
+dbus_bool_t
+_dbus_demarshal_uint32_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ dbus_uint32_t **array,
+ int *array_len)
{
int len, i;
dbus_uint32_t *retval;
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
+ if (len == 0)
+ {
+ *array_len = 0;
+ *array = NULL;
+
+ if (new_pos)
+ *new_pos = pos;
+
+ return TRUE;
+ }
+
retval = dbus_new (dbus_uint32_t, len);
if (!retval)
- return NULL;
+ return FALSE;
for (i = 0; i < len; i++)
retval[i] = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
if (new_pos)
*new_pos = pos;
- if (array_len)
- *array_len = len;
+ *array_len = len;
+ *array = retval;
- return retval;
+ return TRUE;
}
/**
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position of the string
+ * @param array the array
* @param array_len length of the demarshaled data
- * @returns the demarshaled data.
+ * @returns #TRUE on success
*/
-double *
-_dbus_demarshal_double_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len)
+dbus_bool_t
+_dbus_demarshal_double_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ double **array,
+ int *array_len)
{
int len, i;
double *retval;
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
+ if (len == 0)
+ {
+ *array_len = 0;
+ *array = NULL;
+
+ if (new_pos)
+ *new_pos = pos;
+
+ return TRUE;
+ }
+
retval = dbus_new (double, len);
if (!retval)
- return NULL;
+ return FALSE;
for (i = 0; i < len; i++)
retval[i] = _dbus_demarshal_double (str, byte_order, pos, &pos);
if (new_pos)
*new_pos = pos;
- if (array_len)
- *array_len = len;
+ *array_len = len;
+ *array = retval;
- return retval;
+ return TRUE;
}
/**
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position of the string
+ * @param array the array
* @param array_len length of the demarshaled data
- * @returns the demarshaled data.
+ * @returns #TRUE on success
*/
-char **
-_dbus_demarshal_string_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len)
+dbus_bool_t
+_dbus_demarshal_string_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ char ***array,
+ int *array_len)
{
int len, i, j;
char **retval;
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
+ if (len == 0)
+ {
+ *array_len = 0;
+ *array = NULL;
+
+ if (new_pos)
+ *new_pos = pos;
+
+ return TRUE;
+ }
+
retval = dbus_new (char *, len + 1);
if (!retval)
- return NULL;
+ return FALSE;
retval[len] = NULL;
if (new_pos)
*new_pos = pos;
- if (array_len)
- *array_len = len;
+ *array = retval;
+ *array_len = len;
- return retval;
+ return TRUE;
error:
for (j = 0; j < i; j++)
dbus_free (retval[i]);
dbus_free (retval);
- return NULL;
+ return FALSE;
}
/**
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position in the string
- * @returns the demarshalled dict
+ * @param dict the dict
+ * @returns #TRUE on success.
*/
-DBusDict *
+dbus_bool_t
_dbus_demarshal_dict (const DBusString *str,
int byte_order,
int pos,
- int *new_pos)
+ int *new_pos,
+ DBusDict **dict)
{
char **keys;
int i, len;
- DBusDict *dict;
- dict = dbus_dict_new ();
- if (!dict)
- return NULL;
+ *dict = dbus_dict_new ();
+ if (!*dict)
+ return FALSE;
- keys = _dbus_demarshal_string_array (str, byte_order, pos, &pos, &len);
-
- if (!keys)
+ if (!_dbus_demarshal_string_array (str, byte_order, pos, &pos, &keys, &len))
goto error;
for (i = 0; i < len; i++)
value = _dbus_string_get_byte (str, pos ++);
- if (!dbus_dict_set_boolean (dict, keys[i], value))
+ if (!dbus_dict_set_boolean (*dict, keys[i], value))
goto error;
break;
}
value = _dbus_demarshal_int32 (str, byte_order, pos, &pos);
- if (!dbus_dict_set_int32 (dict, keys[i], value))
+ if (!dbus_dict_set_int32 (*dict, keys[i], value))
goto error;
break;
value = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
- if (!dbus_dict_set_uint32 (dict, keys[i], value))
+ if (!dbus_dict_set_uint32 (*dict, keys[i], value))
goto error;
break;
value = _dbus_demarshal_double (str, byte_order, pos, &pos);
- if (!dbus_dict_set_double (dict, keys[i], value))
+ if (!dbus_dict_set_double (*dict, keys[i], value))
goto error;
break;
if (!value)
goto error;
- if (!dbus_dict_set_string (dict, keys[i], value))
+ if (!dbus_dict_set_string (*dict, keys[i], value))
{
dbus_free (value);
goto error;
unsigned char *value;
int len;
- value = _dbus_demarshal_byte_array (str, byte_order, pos, &pos, &len);
-
- if (!value)
+ if (!_dbus_demarshal_byte_array (str, byte_order, pos, &pos, &value, &len))
goto error;
- if (!dbus_dict_set_boolean_array (dict, keys[i], value, len))
+ if (!dbus_dict_set_boolean_array (*dict, keys[i], value, len))
{
dbus_free (value);
goto error;
dbus_int32_t *value;
int len;
- value = _dbus_demarshal_int32_array (str, byte_order, pos, &pos, &len);
-
- if (!value)
+ if (!_dbus_demarshal_int32_array (str, byte_order, pos, &pos, &value, &len))
goto error;
- if (!dbus_dict_set_int32_array (dict, keys[i], value, len))
+ if (!dbus_dict_set_int32_array (*dict, keys[i], value, len))
{
dbus_free (value);
goto error;
dbus_uint32_t *value;
int len;
- value = _dbus_demarshal_uint32_array (str, byte_order, pos, &pos, &len);
-
- if (!value)
+ if (!_dbus_demarshal_uint32_array (str, byte_order, pos, &pos, &value, &len))
goto error;
- if (!dbus_dict_set_uint32_array (dict, keys[i], value, len))
+ if (!dbus_dict_set_uint32_array (*dict, keys[i], value, len))
{
dbus_free (value);
goto error;
double *value;
int len;
- value = _dbus_demarshal_double_array (str, byte_order, pos, &pos, &len);
+ if (!_dbus_demarshal_double_array (str, byte_order, pos, &pos, &value, &len))
+ goto error;
- if (!value)
+ if (!dbus_dict_set_double_array (*dict, keys[i], value, len))
+ {
+ dbus_free (value);
+ goto error;
+ }
+
+ dbus_free (value);
+ break;
+ }
+ case DBUS_TYPE_BYTE_ARRAY:
+ {
+ unsigned char *value;
+ int len;
+
+ if (!_dbus_demarshal_byte_array (str, byte_order, pos, &pos, &value, &len))
goto error;
- if (!dbus_dict_set_double_array (dict, keys[i], value, len))
+ if (!dbus_dict_set_byte_array (*dict, keys[i], value, len))
{
dbus_free (value);
goto error;
char **value;
int len;
- value = _dbus_demarshal_string_array (str, byte_order, pos, &pos, &len);
-
- if (!value)
+ if (!_dbus_demarshal_string_array (str, byte_order, pos, &pos, &value, &len))
goto error;
- if (!dbus_dict_set_string_array (dict, keys[i], value, len))
+ if (!dbus_dict_set_string_array (*dict, keys[i], (const char **)value, len))
{
dbus_free_string_array (value);
goto error;
}
dbus_free_string_array (keys);
- return dict;
+ return TRUE;
error:
dbus_free_string_array (keys);
- dbus_dict_unref (dict);
- return NULL;
+ dbus_dict_unref (*dict);
+
+ return FALSE;
}
/**
_dbus_assert (new_pos != NULL);
- if ((align_4 + 4) >= _dbus_string_get_length (str))
+ if ((align_4 + 4) > _dbus_string_get_length (str))
{
_dbus_verbose ("not enough room in message for array length\n");
return -1;
if (len < 0)
return FALSE;
- align_8 = _DBUS_ALIGN_VALUE (pos, 8);
- if (!_dbus_string_validate_nul (str, pos,
- align_8 - pos))
- {
- _dbus_verbose ("double array alignment padding not initialized to nul\n");
- return FALSE;
- }
-
- *end_pos = align_8 + len * 8;
+ if (len == 0)
+ *end_pos = pos;
+ else
+ {
+ align_8 = _DBUS_ALIGN_VALUE (pos, 8);
+ if (!_dbus_string_validate_nul (str, pos,
+ align_8 - pos))
+ {
+ _dbus_verbose ("double array alignment padding not initialized to nul\n");
+ return FALSE;
+ }
+
+ *end_pos = align_8 + len * 8;
+ }
}
break;
/* Marshal signed integer arrays */
if (!_dbus_marshal_int32_array (&str, DBUS_BIG_ENDIAN, array1, 3))
_dbus_assert_not_reached ("could not marshal integer array");
- array2 = _dbus_demarshal_int32_array (&str, DBUS_BIG_ENDIAN, pos, &pos, &len);
+ if (!_dbus_demarshal_int32_array (&str, DBUS_BIG_ENDIAN, pos, &pos, &array2, &len))
+ _dbus_assert_not_reached ("could not demarshal integer array");
if (len != 3)
_dbus_assert_not_reached ("Signed integer array lengths differ!\n");
dbus_dict_unref (dict);
- dict = _dbus_demarshal_dict (&str, DBUS_BIG_ENDIAN, pos, &pos);
+ if (!_dbus_demarshal_dict (&str, DBUS_BIG_ENDIAN, pos, &pos, &dict))
+ _dbus_assert_not_reached ("could not demarshal dict");
if (!dbus_dict_get_boolean (dict, "boolean", &our_bool) ||
!our_bool)
const DBusString *value,
int len);
+dbus_bool_t _dbus_marshal_int32 (DBusString *str,
+ int byte_order,
+ dbus_int32_t value);
+dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
+ int byte_order,
+ dbus_uint32_t value);
+dbus_bool_t _dbus_marshal_double (DBusString *str,
+ int byte_order,
+ double value);
+dbus_bool_t _dbus_marshal_string (DBusString *str,
+ int byte_order,
+ const char *value);
+dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
+ int byte_order,
+ const unsigned char *value,
+ int len);
+dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
+ int byte_order,
+ const dbus_int32_t *value,
+ int len);
+dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
+ int byte_order,
+ const dbus_uint32_t *value,
+ int len);
+dbus_bool_t _dbus_marshal_double_array (DBusString *str,
+ int byte_order,
+ const double *value,
+ int len);
+dbus_bool_t _dbus_marshal_string_array (DBusString *str,
+ int byte_order,
+ const char **value,
+ int len);
+dbus_bool_t _dbus_marshal_dict (DBusString *str,
+ int byte_order,
+ DBusDict *dict);
+double _dbus_demarshal_double (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos);
+dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos);
+dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos);
+char * _dbus_demarshal_string (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos);
+dbus_bool_t _dbus_demarshal_byte_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ unsigned char **array,
+ int *array_len);
+dbus_bool_t _dbus_demarshal_int32_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ dbus_int32_t **array,
+ int *array_len);
+dbus_bool_t _dbus_demarshal_uint32_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ dbus_uint32_t **array,
+ int *array_len);
+dbus_bool_t _dbus_demarshal_double_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ double **array,
+ int *array_len);
+dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ char ***array,
+ int *array_len);
+dbus_bool_t _dbus_demarshal_dict (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ DBusDict **dict);
-dbus_bool_t _dbus_marshal_int32 (DBusString *str,
- int byte_order,
- dbus_int32_t value);
-dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
- int byte_order,
- dbus_uint32_t value);
-dbus_bool_t _dbus_marshal_double (DBusString *str,
- int byte_order,
- double value);
-dbus_bool_t _dbus_marshal_string (DBusString *str,
- int byte_order,
- const char *value);
-dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
- int byte_order,
- const unsigned char *value,
- int len);
-dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
- int byte_order,
- const dbus_int32_t *value,
- int len);
-dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
- int byte_order,
- const dbus_uint32_t *value,
- int len);
-dbus_bool_t _dbus_marshal_double_array (DBusString *str,
- int byte_order,
- const double *value,
- int len);
-dbus_bool_t _dbus_marshal_string_array (DBusString *str,
- int byte_order,
- const char **value,
- int len);
-dbus_bool_t _dbus_marshal_dict (DBusString *str,
- int byte_order,
- DBusDict *dict);
-
-double _dbus_demarshal_double (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos);
-dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos);
-dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos);
-char * _dbus_demarshal_string (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos);
-unsigned char *_dbus_demarshal_byte_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len);
-dbus_int32_t * _dbus_demarshal_int32_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len);
-dbus_uint32_t *_dbus_demarshal_uint32_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len);
-double * _dbus_demarshal_double_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len);
-char ** _dbus_demarshal_string_array (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- int *array_len);
-DBusDict * _dbus_demarshal_dict (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos);
case DBUS_TYPE_STRING_ARRAY:
{
int len;
- const char **data;
+ char **data;
data = va_arg (var_args, const char **);
len = va_arg (var_args, int);
if (!dbus_message_append_dict (message, dict))
goto enomem;
+ break;
}
default:
_dbus_warn ("Unknown field type %d\n", type);
* @returns #TRUE on success
*/
dbus_bool_t
-dbus_message_append_string_array (DBusMessage *message,
- const char **value,
- int len)
+dbus_message_append_string_array (DBusMessage *message,
+ const char **value,
+ int len)
{
_dbus_assert (!message->locked);
return FALSE;
if (!_dbus_marshal_string_array (&message->body, message->byte_order,
- value, len))
+ (const char **)value, len))
{
_dbus_string_shorten (&message->body, 1);
return FALSE;
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BOOLEAN);
value = _dbus_string_get_byte (&iter->message->body, iter->pos + 1);
- iter->pos += 2;
return value;
}
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BOOLEAN_ARRAY);
- *value = _dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
-
- if (!*value)
+ if (!_dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_INT32_ARRAY);
- *value = _dbus_demarshal_int32_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
-
- if (!*value)
+ if (!_dbus_demarshal_int32_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_UINT32_ARRAY);
- *value = _dbus_demarshal_uint32_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
-
- if (!*value)
+ if (!_dbus_demarshal_uint32_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_DOUBLE_ARRAY);
- *value = _dbus_demarshal_double_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
-
- if (!*value)
+ if (!_dbus_demarshal_double_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
int *len)
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BYTE_ARRAY);
-
- *value = _dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
- if (!*value)
+ if (!_dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING_ARRAY);
- *value = _dbus_demarshal_string_array (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL, len);
-
- if (!*value)
+ if (!_dbus_demarshal_string_array (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, value, len))
return FALSE;
else
return TRUE;
{
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_DICT);
- *dict = _dbus_demarshal_dict (&iter->message->body, iter->message->byte_order,
- iter->pos + 1, NULL);
-
- if (!*dict)
+ if (!_dbus_demarshal_dict (&iter->message->body, iter->message->byte_order,
+ iter->pos + 1, NULL, dict))
return FALSE;
else
return TRUE;
dbus_free (str);
}
break;
+ case DBUS_TYPE_BOOLEAN_ARRAY:
+ {
+ unsigned char *values;
+ int len;
+
+ if (!dbus_message_iter_get_boolean_array (iter, &values, &len))
+ return FALSE;
+
+ dbus_free (values);
+ }
+ break;
case DBUS_TYPE_INT32_ARRAY:
{
dbus_int32_t *values;
if (!dbus_message_iter_get_dict (iter, &dict))
return FALSE;
-
dbus_dict_unref (dict);
}
break;
int len)
{
/* FIXME actually validate UTF-8 */
- return _dbus_string_validate_ascii (str, start, len);
+ return TRUE;
+
+ /*return _dbus_string_validate_ascii (str, start, len);*/
}
/**
--- /dev/null
+# Empty arrays and strings
+
+VALID_HEADER
+FIELD_NAME name
+TYPE STRING
+STRING 'org.freedesktop.Foo'
+END_LENGTH Header
+ALIGN 8
+START_LENGTH Body
+TYPE STRING
+INT32 0
+BYTE 0 # Strings need to be NULL-terminated
+TYPE BOOLEAN_ARRAY
+INT32 0
+TYPE INT32_ARRAY
+INT32 0
+TYPE UINT32_ARRAY
+INT32 0
+TYPE DOUBLE_ARRAY
+INT32 0
+TYPE BYTE_ARRAY
+INT32 0
+TYPE STRING_ARRAY
+INT32 0
+TYPE DICT
+INT32 0
+
+# A dict with empty arrays
+TYPE DICT
+STRING_ARRAY {'boolean_array', 'int32_array' , 'uint32_array', 'double_array', 'byte_array', 'string_array' }
+TYPE BOOLEAN_ARRAY
+INT32 0
+TYPE INT32_ARRAY
+INT32 0
+TYPE UINT32_ARRAY
+INT32 0
+TYPE DOUBLE_ARRAY
+INT32 0
+TYPE BYTE_ARRAY
+INT32 0
+TYPE STRING_ARRAY
+INT32 0
+END_LENGTH Body
+