X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fstrv.h;h=2dc2bc6c492bf6139a679896cdbaea10e7268102;hb=4de33e7f3238a6fe616e61139ab87e221572e5e5;hp=737728a3c6bde296b262a9d0a09177b4227a9eed;hpb=250a918dc4c8a15d927deecc3b3f6a0604657ae4;p=elogind.git diff --git a/src/shared/strv.h b/src/shared/strv.h index 737728a3c..2dc2bc6c4 100644 --- a/src/shared/strv.h +++ b/src/shared/strv.h @@ -36,14 +36,14 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free); char **strv_copy(char * const *l); unsigned strv_length(char * const *l) _pure_; -char **strv_merge(char **a, char **b); -char **strv_merge_concat(char **a, char **b, const char *suffix); -char **strv_append(char **l, const char *s); +int strv_extend_strv(char ***a, char **b); +int strv_extend_strv_concat(char ***a, char **b, const char *suffix); int strv_extend(char ***l, const char *value); +int strv_extendf(char ***l, const char *format, ...); int strv_push(char ***l, char *value); +int strv_consume(char ***l, char *value); char **strv_remove(char **l, const char *s); -char **strv_remove_prefix(char **l, const char *s); char **strv_uniq(char **l); #define strv_contains(l, s) (!!strv_find((l), (s))) @@ -82,16 +82,19 @@ bool strv_overlap(char **a, char **b) _pure_; #define STRV_FOREACH_PAIR(x, y, l) \ for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1)) - char **strv_sort(char **l); void strv_print(char **l); +#define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL })) + +#define STRV_MAKE_EMPTY ((char*[1]) { NULL }) + #define strv_from_stdarg_alloca(first) \ ({ \ char **_l; \ \ if (!first) \ - _l = ((char*[1]) { NULL }); \ + _l = (char**) &first; \ else { \ unsigned _n; \ va_list _ap; \ @@ -114,3 +117,5 @@ void strv_print(char **l); } \ _l; \ }) + +#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x)