[D-BUS] How append array of struct

Havoc Pennington hp at redhat.com
Wed Aug 3 02:49:53 EST 2005


On Tue, 2005-08-02 at 10:36 -0300, Claudio Takahasi wrote:
> dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &cnf);
> dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &dev_num);

I think cnf and dev_num here should be "unsigned char" rather than "int"
btw

> dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, array_sig,
> &array_iter);
> for ( i = 0; i < dev_num; i++) {
> 	dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, struct_sig,
> 			&struct_iter);
> 	dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &ptr_name);
> 	dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &ptr_addr);
> 	dbus_message_iter_close_container(&array_iter, &struct_iter);
> 	ptr_name = name1;
> 	ptr_addr = addr1;
> }
> dbus_message_iter_close_container(&iter, &array_iter);

When this fails do you get some kind of error message?

The open_container() for the struct can just have NULL instead of
struct_sig for the contained type, though in theory the code would
silently ignore that arg if you specify it.

Havoc




More information about the dbus mailing list