diff options
author | Luca Boccassi <bluca@debian.org> | 2023-09-18 22:26:12 +0200 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2023-10-12 14:37:22 +0200 |
commit | 5612426d7b827c1cfc12e1546c2e7eb256b06966 (patch) | |
tree | 94be2dc16f7a3bd1e3177463679b664ae34c96d4 /src/shared/serialize.h | |
parent | serialize: add serialize_item_base64mem() (diff) | |
download | systemd-5612426d7b827c1cfc12e1546c2e7eb256b06966.tar.xz systemd-5612426d7b827c1cfc12e1546c2e7eb256b06966.zip |
serialize: add serialize_item_tristate()
Diffstat (limited to 'src/shared/serialize.h')
-rw-r--r-- | src/shared/serialize.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/shared/serialize.h b/src/shared/serialize.h index 5eb9be2584..a4c67d8fb8 100644 --- a/src/shared/serialize.h +++ b/src/shared/serialize.h @@ -27,6 +27,10 @@ static inline int serialize_bool_elide(FILE *f, const char *key, bool b) { return b ? serialize_item(f, key, yes_no(b)) : 0; } +static inline int serialize_item_tristate(FILE *f, const char *key, int value) { + return value >= 0 ? serialize_item_format(f, key, "%i", value) : 0; +} + int deserialize_read_line(FILE *f, char **ret); int deserialize_usec(const char *value, usec_t *timestamp); |