From: Yu Watanabe Date: Fri, 17 Feb 2023 06:32:39 +0000 (+0900) Subject: bus-util: introduce bus_property_get_tristate() X-Git-Tag: v254-rc1~1179^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec1b4be82e8ec10cc5b092a74b80627f7624c257;p=thirdparty%2Fsystemd.git bus-util: introduce bus_property_get_tristate() This will be used in later commits. --- diff --git a/src/shared/bus-get-properties.c b/src/shared/bus-get-properties.c index 8b4f66b22e9..3d0887e6df7 100644 --- a/src/shared/bus-get-properties.c +++ b/src/shared/bus-get-properties.c @@ -38,6 +38,22 @@ int bus_property_set_bool( return 0; } +int bus_property_get_tristate( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + /* Defaults to false. */ + + int b = (*(int*) userdata) > 0; + + return sd_bus_message_append_basic(reply, 'b', &b); +} + int bus_property_get_id128( sd_bus *bus, const char *path, diff --git a/src/shared/bus-get-properties.h b/src/shared/bus-get-properties.h index d048913877c..44cd584bdcb 100644 --- a/src/shared/bus-get-properties.h +++ b/src/shared/bus-get-properties.h @@ -7,6 +7,7 @@ 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_tristate(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)