diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-08-26 19:20:02 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-05 08:50:53 +0200 |
commit | d93949b9ea71babdcccbe98d33a9b9472ab2d08f (patch) | |
tree | 57fc0af1232063a5e8d67cb8442e7b91da08e5f8 /src/shared | |
parent | 706da8f4c21d582eb3334aa01ecd75a9db5c481c (diff) |
bus-util: generalize helper for ID128 prpoerties
This way, we can make use of this in other code, too.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bus-util.c | 17 | ||||
-rw-r--r-- | src/shared/bus-util.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index c8b070b53..fde3c3119 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -1334,6 +1334,23 @@ int bus_property_get_bool( return sd_bus_message_append_basic(reply, 'b', &b); } +int bus_property_get_id128( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + sd_id128_t *id = userdata; + + if (sd_id128_is_null(*id)) /* Add an empty array if the ID is zero */ + return sd_bus_message_append(reply, "ay", 0); + else + return sd_bus_message_append_array(reply, 'b', id->bytes, 16); +} + #if __SIZEOF_SIZE_T__ != 8 int bus_property_get_size( sd_bus *bus, diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index 88c2804d6..802983766 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -91,6 +91,7 @@ int bus_print_property(const char *name, sd_bus_message *property, bool value, b int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all); int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); +int bus_property_get_id128(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); #define bus_property_get_usec ((sd_bus_property_get_t) NULL) #define bus_property_set_usec ((sd_bus_property_set_t) NULL) |