X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fstrv.h;h=3034073d3288e5a28871769b4561b4d53d70837c;hb=6294aa76d818e831de4592b41a37e225fd0871f9;hp=2dc2bc6c492bf6139a679896cdbaea10e7268102;hpb=4de33e7f3238a6fe616e61139ab87e221572e5e5;p=elogind.git diff --git a/src/shared/strv.h b/src/shared/strv.h index 2dc2bc6c4..3034073d3 100644 --- a/src/shared/strv.h +++ b/src/shared/strv.h @@ -39,9 +39,11 @@ 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, ...); +int strv_extendf(char ***l, const char *format, ...) _printf_(2,0); int strv_push(char ***l, char *value); +int strv_push_prepend(char ***l, char *value); int strv_consume(char ***l, char *value); +int strv_consume_prepend(char ***l, char *value); char **strv_remove(char **l, const char *s); char **strv_uniq(char **l); @@ -119,3 +121,15 @@ void strv_print(char **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]; \ + }))