]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-util: add bool property setter
authorJan Klötzke <Jan.Kloetzke@preh.de>
Thu, 11 Jan 2018 09:42:27 +0000 (10:42 +0100)
committerJan Klötzke <jan@kloetzke.net>
Mon, 22 Jan 2018 17:06:56 +0000 (18:06 +0100)
src/shared/bus-util.c
src/shared/bus-util.h

index b6677e27f609d20af1b3c2e394180d1513a11986..6b177afb8cc5535302a04bbe12842f1fba14c2e2 100644 (file)
@@ -1338,6 +1338,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;
+}
+
 int bus_property_get_id128(
                 sd_bus *bus,
                 const char *path,
index cbd22a6cd6b8d46415fc8cbcf33708d37c52ed75..969a444d838cacdb2d03deb3ca9e4ac577ac2e46 100644 (file)
@@ -80,6 +80,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);
 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)