string-util: Add startswith_strv()

This is the function version of STARTSWITH_SET(). We also move
STARTSWITH_SET() to string-util.h as it fits more there than in
strv.h and reimplement it using startswith_strv().
This commit is contained in:
Daan De Meyer
2023-04-20 13:43:37 +02:00
parent 85003d1296
commit 70cc7ed97e
3 changed files with 17 additions and 12 deletions
-12
View File
@@ -200,18 +200,6 @@ static inline void strv_print(char * const *l) {
_x && strv_contains_case(STRV_MAKE(__VA_ARGS__), _x); \
})
#define STARTSWITH_SET(p, ...) \
({ \
const char *_p = (p); \
char *_found = NULL; \
STRV_FOREACH(_i, STRV_MAKE(__VA_ARGS__)) { \
_found = startswith(_p, *_i); \
if (_found) \
break; \
} \
_found; \
})
#define ENDSWITH_SET(p, ...) \
({ \
const char *_p = (p); \