From 26d04f86a36595e3565c74d67863e076c3e3c773 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 27 Feb 2013 18:50:41 +0100 Subject: unit: rework resource management API This introduces a new static list of known attributes and their special semantics. This means that cgroup attribute values can now be automatically translated from user to kernel notation for command line set settings, too. This also adds proper support for multi-line attributes. --- src/shared/strv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/shared/strv.c') diff --git a/src/shared/strv.c b/src/shared/strv.c index ec25755289..60c4762572 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -305,6 +305,31 @@ char **strv_split_quoted(const char *s) { return r; } +char **strv_split_newlines(const char *s) { + char **l; + unsigned n; + + assert(s); + + /* Special version of strv_split() that splits on newlines and + * suppresses an empty string at the end */ + + l = strv_split(s, NEWLINE); + if (!l) + return NULL; + + n = strv_length(l); + if (n <= 0) + return l; + + if (isempty(l[n-1])) { + free(l[n-1]); + l[n-1] = NULL; + } + + return l; +} + char *strv_join(char **l, const char *separator) { char *r, *e; char **s; -- cgit v1.2.3-54-g00ecf