Extracting fixed-type arrays using an iterator?

Friedemann Kleint (Fa. metis) kleint at bifab.de
Wed May 4 00:51:54 PDT 2005


what would be the    correct  code to extract a message containing fixed-type
arrays created by 

dbus_message_append_args (...DBUS_TYPE_ARRAY,DBUS_TYPE_BYTE,&arr,len...)

using a message iterator (eg for a function like print_message())?

When porting from dbus-0.2x to dbus-0.3x, I mistakenly replaced
dbus_message_iter_get_byte_array() by dbus_message_iter_get_fixed_array().
John pointed out to me, that I have to recurse down the iterator (resolved
Bug 2754). I then tried:

 if (  dbus_message_iter_get_arg_type () == DBUS_TYPE_ARRAY
dbus_message_iter_recurse (it,&subiter);
dbus_message_iter_get_fixed_array (&subiter,&array,&len);

This sometimes works, but sometimes (when appending several,
consecutive arrays) it leads  to:

15212: arguments to unknown function() were incorrect, assertion
"dbus_type_is_fixed (_dbus_type_reader_get_element_type (&real->u.reader))"
failed in file dbus-message.c line 1689. This is normally a bug in some
application using the D-BUS library.

The   correct      code      appears     to  be   in   the internal  function
_dbus_message_iter_get_args_valist(), but it has no public interface?

[A detour on strings:

I had to resort  to DBUS_TYPE_ARRAYs   of DBUS_TYPE_BYTE for  strings because
dbus checks for correct UTF8-strings and refuses eg ISO-Latin-umlauts.     At
the moment, we cannot  switch LANG from ISO-Latin  to  UTF8  (due   to legacy
files and projects);  I suppose this is a very common problem in Europe.  So,
on non GNU-Linux   systems,  dbus will very  likely encounter eg system error
messages in ISO-Latin, which raises   the question: should this cause a basic
communication  layer  to fail?  Maybe a new kind of 8bit-string type could be
introduced  to  work around this  (if  you want to  keep    the  Gnome-system
UTF8-clean)? ]

Thank your four your help.

Friedemann Kleint

More information about the dbus mailing list