diff options
author | Luca Boccassi <bluca@debian.org> | 2023-06-01 20:32:29 +0200 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2023-06-09 01:49:19 +0200 |
commit | 1d6f1e2fa1820e66ce8fea44cbefbbf3389d1cdf (patch) | |
tree | 02340a232c6129e3ab9fb7fa993d90caff447e96 /src/shared | |
parent | test-execute: add unit tests for *DirectorySymlink= (diff) | |
download | systemd-1d6f1e2fa1820e66ce8fea44cbefbbf3389d1cdf.tar.xz systemd-1d6f1e2fa1820e66ce8fea44cbefbbf3389d1cdf.zip |
serialize: add deserialize_strv helper
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/serialize.c | 14 | ||||
-rw-r--r-- | src/shared/serialize.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/serialize.c b/src/shared/serialize.c index 9d1a21360f..5396062a8b 100644 --- a/src/shared/serialize.c +++ b/src/shared/serialize.c @@ -131,6 +131,20 @@ int serialize_strv(FILE *f, const char *key, char **l) { return ret; } +int deserialize_strv(char ***l, const char *value) { + ssize_t unescaped_len; + char *unescaped; + + assert(l); + assert(value); + + unescaped_len = cunescape(value, 0, &unescaped); + if (unescaped_len < 0) + return unescaped_len; + + return strv_consume(l, unescaped); +} + int deserialize_usec(const char *value, usec_t *ret) { int r; diff --git a/src/shared/serialize.h b/src/shared/serialize.h index 6d4f1ef418..8fdc6dc304 100644 --- a/src/shared/serialize.h +++ b/src/shared/serialize.h @@ -23,5 +23,6 @@ static inline int serialize_bool(FILE *f, const char *key, bool b) { int deserialize_usec(const char *value, usec_t *timestamp); int deserialize_dual_timestamp(const char *value, dual_timestamp *t); int deserialize_environment(const char *value, char ***environment); +int deserialize_strv(char ***l, const char *value); int open_serialization_fd(const char *ident); |