bus-util: add bool property setter

This commit is contained in:
Jan Klötzke
2018-01-22 18:06:56 +01:00
committed by Jan Klötzke
parent 204d140c4d
commit 43ce15ac30
2 changed files with 20 additions and 0 deletions
+19
View 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,
+1
View 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)