Re: [systemd-devel] Returning a struct from an sd-bus method

2018-08-23 Thread Niall Murphy
Hi, thanks! You are correct about the signature, I was trying various things and pasted in some half complete code, sorry. After changing to pass the fields of the struct as individual parameters it does work correctly. I guess I would prefer to pass the struct so that you can share a single

Re: [systemd-devel] Returning a struct from an sd-bus method

2018-08-23 Thread Simon McVittie
On Thu, 23 Aug 2018 at 17:34:14 +0100, Simon McVittie wrote: > Finally, I think the message-building API expects struct members as > individual arguments, like > > sd_bus_reply_method_return(m, "xx", (int64_t) s->x, (int64_t) s->y); Sorry, obviously that's correct when not using a struct.

Re: [systemd-devel] Returning a struct from an sd-bus method

2018-08-23 Thread Simon McVittie
On Thu, 23 Aug 2018 at 16:52:38 +0200, Niall Murphy wrote: > struct pack { >     int x; >     int y; > }; ... >     return sd_bus_reply_method_return(m, "(xx)", s); Is there a reason why you're returning a struct/tuple? D-Bus methods can return as many things as you want[1], unlike C functions,

[systemd-devel] Returning a struct from an sd-bus method

2018-08-23 Thread Niall Murphy
Hi, I'm trying to return a struct from an sdbus method. I followed the simple example of a service at http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html. I then created a simple method as follows: struct pack { int x; int y; }; static int foo(sd_bus_message *m, void *userdata,