+2003-01-14 Anders Carlsson <andersca@codefactory.se>
+
+ * bus/connection.c: (connection_error_handler),
+ (bus_connection_setup):
+ * bus/main.c: (main):
+ Make sure that the DBusConnectionData struct is NULLed
+ out to prevent a segfault.
+
+ * dbus/dbus-errors.c: (dbus_result_to_string):
+ * dbus/dbus-errors.h:
+ * dbus/dbus-message.c: (dbus_message_get_fields),
+ (dbus_message_get_fields_valist), (_dbus_message_test):
+ * dbus/dbus-message.h:
+ Make dbus_message_get_fields return a result code so we can
+ track invalid fields as well as oom.
+
2003-01-11 Havoc Pennington <hp@pobox.com>
* configure.in: change --enable-test/--enable-ansi action-if-given
* @param message the message
* @param first_field_type the first field type
* @param ... location for first field value, then list of type-location pairs
- * @returns #TRUE on success
+ * @returns result code
*/
-dbus_bool_t
+DBusResultCode
dbus_message_get_fields (DBusMessage *message,
int first_field_type,
...)
{
- dbus_bool_t retval;
+ DBusResultCode retval;
va_list var_args;
va_start (var_args, first_field_type);
* to the arg that's bad, as that would be a security hole
* (allow one app to force another to leak memory)
*
+ * @todo We need to free the field data when an error occurs.
+ *
* @see dbus_message_get_fields
* @param message the message
* @param first_field_type type of the first field
* @param var_args return location for first field, followed by list of type/location pairs
- * @returns #TRUE on success
+ * @returns result code
*/
-dbus_bool_t
+DBusResultCode
dbus_message_get_fields_valist (DBusMessage *message,
int first_field_type,
va_list var_args)
if (msg_type != spec_type)
{
- _dbus_warn ("Field %d is specified to be of type \"%s\", but "
- "is actually of type \"%s\"\n", i,
- _dbus_type_to_string (spec_type),
- _dbus_type_to_string (msg_type));
+ _dbus_verbose ("Field %d is specified to be of type \"%s\", but "
+ "is actually of type \"%s\"\n", i,
+ _dbus_type_to_string (spec_type),
+ _dbus_type_to_string (msg_type));
dbus_message_iter_unref (iter);
- return FALSE;
+ return DBUS_RESULT_INVALID_FIELDS;
}
switch (spec_type)
ptr = va_arg (var_args, char **);
*ptr = dbus_message_iter_get_string (iter);
+
+ if (!*ptr)
+ return DBUS_RESULT_NO_MEMORY;
+
break;
}
len = va_arg (var_args, int *);
*ptr = dbus_message_iter_get_byte_array (iter, len);
+
+ if (!*ptr)
+ return DBUS_RESULT_NO_MEMORY;
+
break;
}
default:
spec_type = va_arg (var_args, int);
if (spec_type != 0 && !dbus_message_iter_next (iter))
{
- _dbus_warn ("More fields than exist in the message were specified\n");
+ _dbus_verbose ("More fields than exist in the message were specified\n");
dbus_message_iter_unref (iter);
- return FALSE;
+ return DBUS_RESULT_INVALID_FIELDS;
}
i++;
}
dbus_message_iter_unref (iter);
- return TRUE;
+ return DBUS_RESULT_SUCCESS;
}
/**
DBUS_TYPE_DOUBLE, 3.14159,
0);
- if (!dbus_message_get_fields (message,
- DBUS_TYPE_INT32, &our_int,
- DBUS_TYPE_STRING, &our_str,
- DBUS_TYPE_DOUBLE, &our_double,
- 0))
+ if (dbus_message_get_fields (message,
+ DBUS_TYPE_INT32, &our_int,
+ DBUS_TYPE_STRING, &our_str,
+ DBUS_TYPE_DOUBLE, &our_double,
+ 0) != DBUS_RESULT_SUCCESS)
_dbus_assert_not_reached ("Could not get fields");
if (our_int != -0x12345678)
DBusMessageIter *dbus_message_get_fields_iter (DBusMessage *message);
+DBusResultCode dbus_message_get_fields (DBusMessage *message,
+ int first_field_type,
+ ...);
+DBusResultCode dbus_message_get_fields_valist (DBusMessage *message,
+ int first_field_type,
+ va_list var_args);
+
+void dbus_message_iter_ref (DBusMessageIter *iter);
+void dbus_message_iter_unref (DBusMessageIter *iter);
+
+dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter);
+dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter);
+int dbus_message_iter_get_field_type (DBusMessageIter *iter);
+int dbus_message_iter_get_int32 (DBusMessageIter *iter);
+int dbus_message_iter_get_uint32 (DBusMessageIter *iter);
+double dbus_message_iter_get_double (DBusMessageIter *iter);
+char * dbus_message_iter_get_string (DBusMessageIter *iter);
+unsigned char * dbus_message_iter_get_byte_array (DBusMessageIter *iter,
+ int *len);
-dbus_bool_t dbus_message_get_fields (DBusMessage *message,
- int first_field_type,
- ...);
-dbus_bool_t dbus_message_get_fields_valist (DBusMessage *message,
- int first_field_type,
- va_list var_args);
-
-void dbus_message_iter_ref (DBusMessageIter *iter);
-void dbus_message_iter_unref (DBusMessageIter *iter);
-
-dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter);
-dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter);
-int dbus_message_iter_get_field_type (DBusMessageIter *iter);
-int dbus_message_iter_get_int32 (DBusMessageIter *iter);
-int dbus_message_iter_get_uint32 (DBusMessageIter *iter);
-double dbus_message_iter_get_double (DBusMessageIter *iter);
-char * dbus_message_iter_get_string (DBusMessageIter *iter);
-unsigned char *dbus_message_iter_get_byte_array (DBusMessageIter *iter, int *len);