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

James Johnson jjjwallyhome at gmail.com
Thu Aug 17 20:58:02 UTC 2017


Hello,


It looks like I figured out my problem, I have to use:

result = sd_bus_message_enter_container(msgCall, 'a', "o");

before I try reading the array with :

result = sd_bus_message_read(msgCall, "o", &ptr);

Thanks,
Jimmy

On Thu, Aug 17, 2017 at 1:43 PM, 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);
>
> as well as:
>
> result = sd_bus_message_read(msgCall, "ao", ptr);
>
> but these both return an error. I am not sure what method to use to parse
> the returned message when it is an array of path objects.
>
> Please note this interface gives me the following when executed via the
> busctl command:
>
> [jjohnson at macbookpro]$ busctl --verbose get-property
> org.freedesktop.NetworkManager /org/freedesktop/NetworkManager
> org.freedesktop.NetworkManager AllDevices
> ARRAY "o" {
>         OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/1";
>         OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/3";
>         OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/11";
>         OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/12";
> };
>
>
> Thanks!
> Jimmy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20170817/94012a01/attachment.html>


More information about the systemd-devel mailing list