diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-02-23 01:12:07 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-02-23 01:12:07 +0100 |
commit | 21bc923aa35d455cdef1607eb7022608c705c9f3 (patch) | |
tree | dd3258fedfadbd93b1ba9d7534cc43f128c4c052 /src/strv.c | |
parent | 80758717a6359cbe6048f43a17c2b53a3ca8c2fa (diff) |
ask-password: supported plymouth cached passwords
Diffstat (limited to 'src/strv.c')
-rw-r--r-- | src/strv.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/strv.c b/src/strv.c index d1c7b2c32d..b1643b357f 100644 --- a/src/strv.c +++ b/src/strv.c @@ -577,3 +577,45 @@ char **strv_env_clean(char **l) { return ret; } + +char **strv_parse_nulstr(const char *s, size_t l) { + const char *p; + unsigned c = 0, i = 0; + char **v; + + assert(s || l <= 0); + + if (l <= 0) + return strv_new(NULL, NULL); + + for (p = s; p < s + l; p++) + if (*p == 0) + c++; + + if (s[l-1] != 0) + c++; + + if (!(v = new0(char*, c+1))) + return NULL; + + p = s; + while (p < s + l) { + const char *e; + + e = memchr(p, 0, s + l - p); + + if (!(v[i++] = strndup(p, e ? e - p : s + l - p))) { + strv_free(v); + return NULL; + } + + if (!e) + break; + + p = e + 1; + } + + assert(i == c); + + return v; +} |