X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fstrv.c;h=ea5e57acdb0430406f7d8c7b03652cbe207163c8;hb=059696ac014da265ee2d1b062cd0dc7bee3d2001;hp=31d83f3efd9a7e38e8a65ec3bab9f885c48efbc7;hpb=1cfc78c91965df340cdde100ad6cb3ed50b28927;p=elogind.git diff --git a/src/basic/strv.c b/src/basic/strv.c index 31d83f3ef..ea5e57acd 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -201,6 +201,8 @@ int strv_extend_strv(char ***a, char **b) { return 0; } +/// UNNEEDED by elogind +#if 0 int strv_extend_strv_concat(char ***a, char **b, const char *suffix) { int r; char **s; @@ -221,6 +223,7 @@ int strv_extend_strv_concat(char ***a, char **b, const char *suffix) { return 0; } +#endif // 0 char **strv_split(const char *s, const char *separator) { const char *word, *state; @@ -279,9 +282,8 @@ char **strv_split_newlines(const char *s) { return l; } -#endif // 0 -int strv_split_quoted(char ***t, const char *s, UnquoteFlags flags) { +int strv_split_extract(char ***t, const char *s, const char *separators, ExtractFlags flags) { size_t n = 0, allocated = 0; _cleanup_strv_free_ char **l = NULL; int r; @@ -292,11 +294,12 @@ int strv_split_quoted(char ***t, const char *s, UnquoteFlags flags) { for (;;) { _cleanup_free_ char *word = NULL; - r = unquote_first_word(&s, &word, flags); + r = extract_first_word(&s, &word, separators, flags); if (r < 0) return r; - if (r == 0) + if (r == 0) { break; + } if (!GREEDY_REALLOC(l, allocated, n + 2)) return -ENOMEM; @@ -315,6 +318,7 @@ int strv_split_quoted(char ***t, const char *s, UnquoteFlags flags) { return 0; } +#endif // 0 char *strv_join(char **l, const char *separator) { char *r, *e; @@ -350,6 +354,8 @@ char *strv_join(char **l, const char *separator) { return r; } +/// UNNEEDED by elogind +#if 0 char *strv_join_quoted(char **l) { char *buf = NULL; char **s; @@ -386,6 +392,7 @@ char *strv_join_quoted(char **l) { free(buf); return NULL; } +#endif // 0 int strv_push(char ***l, char *value) { char **c; @@ -706,6 +713,26 @@ char **strv_reverse(char **l) { return l; } + +char **strv_shell_escape(char **l, const char *bad) { + char **s; + + /* Escapes every character in every string in l that is in bad, + * edits in-place, does not roll-back on error. */ + + STRV_FOREACH(s, l) { + char *v; + + v = shell_escape(*s, bad); + if (!v) + return NULL; + + free(*s); + *s = v; + } + + return l; +} #endif // 0 bool strv_fnmatch(char* const* patterns, const char *s, int flags) {