util: add new FOREACH_STRING() macro as syntactic sugar to iterate through a number of fixed strings

This commit is contained in:
Lennart Poettering
2014-03-19 00:54:41 +01:00
parent cb9da7f24f
commit c4a7b2c56e
2 changed files with 32 additions and 0 deletions
+12
View File
@@ -119,3 +119,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]; \
}))