diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-04-30 15:07:45 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-05-04 10:11:19 +0200 |
commit | ddd6a22a0fb034c763495fa1f3b6ebdd6a669e27 (patch) | |
tree | ac7bfb9eec91128813c0c9a54522f3983d411a36 /src/basic/strv.h | |
parent | 2d4f8cf467b6825c91276808250823a29ab461fe (diff) | |
download | systemd-ddd6a22a0fb034c763495fa1f3b6ebdd6a669e27.tar.gz |
basic: add STRCASE_IN_SET() which is to STR_IN_SET() what strcaseeq() is to streq()
Diffstat (limited to 'src/basic/strv.h')
-rw-r--r-- | src/basic/strv.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/basic/strv.h b/src/basic/strv.h index d7166ce5f3..0837e65a18 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -14,9 +14,13 @@ #include "string-util.h" char *strv_find(char * const *l, const char *name) _pure_; +char *strv_find_case(char * const *l, const char *name) _pure_; char *strv_find_prefix(char * const *l, const char *name) _pure_; char *strv_find_startswith(char * const *l, const char *name) _pure_; +#define strv_contains(l, s) (!!strv_find((l), (s))) +#define strv_contains_case(l, s) (!!strv_find_case((l), (s))) + char **strv_free(char **l); DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free); #define _cleanup_strv_free_ _cleanup_(strv_freep) @@ -54,8 +58,6 @@ static inline bool strv_equal(char * const *a, char * const *b) { return strv_compare(a, b) == 0; } -#define strv_contains(l, s) (!!strv_find((l), (s))) - char **strv_new_internal(const char *x, ...) _sentinel_; char **strv_new_ap(const char *x, va_list ap); #define strv_new(...) strv_new_internal(__VA_ARGS__, NULL) @@ -156,6 +158,13 @@ void strv_print(char * const *l); _x && strv_contains(STRV_MAKE(__VA_ARGS__), _x); \ }) +#define STRCASE_IN_SET(x, ...) strv_contains_case(STRV_MAKE(__VA_ARGS__), x) +#define STRCASEPTR_IN_SET(x, ...) \ + ({ \ + const char* _x = (x); \ + _x && strv_contains_case(STRV_MAKE(__VA_ARGS__), _x); \ + }) + #define STARTSWITH_SET(p, ...) \ ({ \ const char *_p = (p); \ |