]>
Commit | Line | Data |
---|---|---|
faeb1b64 KZ |
1 | /* |
2 | * SPDX-License-Identifier: LGPL-2.1-or-later | |
3 | */ | |
548b9714 KZ |
4 | #ifndef UTIL_LINUX_STRV |
5 | #define UTIL_LINUX_STRV | |
6 | ||
7 | #include <stdarg.h> | |
8 | ||
9 | #include "c.h" | |
10 | ||
11 | char **strv_free(char **l); | |
12 | void strv_clear(char **l); | |
13 | char **strv_copy(char * const *l); | |
14 | unsigned strv_length(char * const *l); | |
15 | ||
16 | int strv_extend_strv(char ***a, char **b); | |
17 | int strv_extend_strv_concat(char ***a, char **b, const char *suffix); | |
18 | int strv_extend(char ***l, const char *value); | |
43554534 KZ |
19 | |
20 | int strv_extendv(char ***l, const char *format, va_list ap) | |
21 | __attribute__ ((__format__ (__printf__, 2, 0))); | |
548b9714 | 22 | int strv_extendf(char ***l, const char *format, ...) |
43554534 KZ |
23 | __attribute__ ((__format__ (__printf__, 2, 3))); |
24 | ||
548b9714 KZ |
25 | int strv_push(char ***l, char *value); |
26 | int strv_push_prepend(char ***l, char *value); | |
27 | int strv_consume(char ***l, char *value); | |
28 | int strv_consume_prepend(char ***l, char *value); | |
29 | ||
30 | char **strv_remove(char **l, const char *s); | |
31 | ||
32 | char **strv_new(const char *x, ...); | |
33 | char **strv_new_ap(const char *x, va_list ap); | |
34 | ||
35 | static inline const char* STRV_IFNOTNULL(const char *x) { | |
36 | return x ? x : (const char *) -1; | |
37 | } | |
38 | ||
39 | static inline int strv_isempty(char * const *l) { | |
40 | return !l || !*l; | |
41 | } | |
42 | ||
43 | char **strv_split(const char *s, const char *separator); | |
44 | char *strv_join(char **l, const char *separator); | |
45 | ||
46 | #define STRV_FOREACH(s, l) \ | |
47 | for ((s) = (l); (s) && *(s); (s)++) | |
48 | ||
49 | #define STRV_FOREACH_BACKWARDS(s, l) \ | |
50 | STRV_FOREACH(s, l) \ | |
51 | ; \ | |
52 | for ((s)--; (l) && ((s) >= (l)); (s)--) | |
53 | ||
54 | ||
55 | #define STRV_MAKE_EMPTY ((char*[1]) { NULL }) | |
56 | ||
57 | char **strv_reverse(char **l); | |
58 | ||
59 | #endif /* UTIL_LINUX_STRV */ | |
60 | ||
61 |