mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-12 19:51:54 +00:00
miracle: add few bus helpers
Two new bus helpers to deal with common sd-bus tasks. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
2e50d006ad
commit
27a74298e9
1 changed files with 29 additions and 0 deletions
|
@ -65,4 +65,33 @@ static inline int log_bus_parser(int r)
|
|||
return r;
|
||||
}
|
||||
|
||||
static inline int log_bus_create(int r)
|
||||
{
|
||||
log_error("cannot create dbus message: %s", strerror(r < 0 ? -r : r));
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int bus_message_read_basic_variant(sd_bus_message *m,
|
||||
const char *sig, void *ptr)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!sig || !*sig || sig[1] || !ptr)
|
||||
return -EINVAL;
|
||||
|
||||
r = sd_bus_message_enter_container(m, 'v', sig);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_read(m, sig, ptr);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_exit_container(m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* MIRACLE_H */
|
||||
|
|
Loading…
Reference in a new issue