From d612c814d8ea943c2f85fc1f3a2291afc86d120d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kl=C3=B6tzke?= Date: Thu, 11 Jan 2018 10:42:27 +0100 Subject: [PATCH] bus-util: add bool property setter --- src/shared/bus-util.c | 19 +++++++++++++++++++ src/shared/bus-util.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index f301ab185..375dbfb48 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -1348,6 +1348,25 @@ int bus_property_get_bool( return sd_bus_message_append_basic(reply, 'b', &b); } +int bus_property_set_bool( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *value, + void *userdata, + sd_bus_error *error) { + + int b, r; + + r = sd_bus_message_read(value, "b", &b); + if (r < 0) + return r; + + *(bool *) userdata = !!b; + return 0; +} + #if 0 /// UNNEEDED by elogind int bus_property_get_id128( sd_bus *bus, diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index e0addd71c..608345130 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -92,6 +92,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_set_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *error); #if 0 /// UNNEEDED by elogind 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); #endif // 0 -- 2.30.2