[systemd-devel] Returning arrays from sd-bus methods
Lennart Poettering
lennart at poettering.net
Sat Jun 24 07:55:04 UTC 2017
On Fri, 23.06.17 20:45, guhan balasubramanian (guhan.sac at gmail.com) wrote:
> Hi,
>
> I'm currently trying out sd-bus methods for my application. I am in a
> situation where I must accept an input and return a byte array based on the
> input.
>
> In the vtable. the following declaration is present:
> SD_BUS_METHOD("method_id", "x", "ay", method_1, 0)
>
> And inside the definition for method_1, for returning:
> uint8_t b[2] = {0x01, 0x02};
> sd_bus_reply_method_return(m, "ay", b);
if you use sd_bus_reply_method_return() (or sd_bus_append()) the
arguments to pass for an array is the array's size followed by the
members. Hence, the following should do what you want:
sd_bus_reply_method_return(m, "ay", 2, 0x01, 0x02);
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list