X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fstrv.h;h=e26ab828d2598922a1a2b2148d5d8624ea142988;hb=981e4cd325410384cdadd837f34c002699d2d750;hp=13a4bb6cf16d90af5acb429cc99363237bcf715a;hpb=6e18964d3a365567954fe10ddcfad74babdc427c;p=elogind.git diff --git a/src/shared/strv.h b/src/shared/strv.h index 13a4bb6cf..e26ab828d 100644 --- a/src/shared/strv.h +++ b/src/shared/strv.h @@ -39,6 +39,7 @@ unsigned strv_length(char * const *l) _pure_; 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, ...) _printf_(2,0); int strv_push(char ***l, char *value); int strv_consume(char ***l, char *value); @@ -116,3 +117,17 @@ void strv_print(char **l); } \ _l; \ }) + +#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x) + +#define FOREACH_STRING(x, ...) \ + for (char **_l = ({ \ + char **_ll = STRV_MAKE(__VA_ARGS__); \ + x = _ll ? _ll[0] : NULL; \ + _ll; \ + }); \ + _l && *_l; \ + x = ({ \ + _l ++; \ + _l[0]; \ + }))