[systemd-devel] Reading an "ao" signature message with the sdbus c library?

Lennart Poettering lennart at poettering.net
Thu Aug 31 13:53:45 UTC 2017


On Do, 17.08.17 13:43, James Johnson (jjjwallyhome at gmail.com) wrote:

> Hello,
> 
> Can someone please point me to the correct method for reading an "ao"
> signature dbus message using the sd_bus C api?
> 
> I am trying to read all the network devices with the following call:
> 
>   result = sd_bus_get_property(m_bus, "org.freedesktop.NetworkManager",
>                                  "/org/freedesktop/NetworkManager",
>                                  "org.freedesktop.NetworkManager",
>                                  "AllDevices", &error,
>                                  &msgCall, "ao");
> I have tried:
> 
> char * ptr;
> size_t size;
> 
> result = sd_bus_message_read_array(msgCall, 'o', &ptr, &size);

_read_array() only works for trivial types, not for strings and
other variable length types. If you have such complex types you need
to enter the array with _enter_container() and then _read() each item
individually...

But I see you already figure that out...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list