]> git.ipfire.org Git - thirdparty/util-linux.git/blob - include/strv.h
libmount: fix comment referring to passno field
[thirdparty/util-linux.git] / include / strv.h
1 #ifndef UTIL_LINUX_STRV
2 #define UTIL_LINUX_STRV
3
4 #include <stdarg.h>
5
6 #include "c.h"
7
8 char **strv_free(char **l);
9 void strv_clear(char **l);
10 char **strv_copy(char * const *l);
11 unsigned strv_length(char * const *l);
12
13 int strv_extend_strv(char ***a, char **b);
14 int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
15 int strv_extend(char ***l, const char *value);
16 int strv_extendv(char ***l, const char *format, va_list ap);
17 int strv_extendf(char ***l, const char *format, ...)
18 __attribute__ ((__format__ (__printf__, 2, 0)));
19 int strv_push(char ***l, char *value);
20 int strv_push_prepend(char ***l, char *value);
21 int strv_consume(char ***l, char *value);
22 int strv_consume_prepend(char ***l, char *value);
23
24 char **strv_remove(char **l, const char *s);
25
26 char **strv_new(const char *x, ...);
27 char **strv_new_ap(const char *x, va_list ap);
28
29 static inline const char* STRV_IFNOTNULL(const char *x) {
30 return x ? x : (const char *) -1;
31 }
32
33 static inline int strv_isempty(char * const *l) {
34 return !l || !*l;
35 }
36
37 char **strv_split(const char *s, const char *separator);
38 char *strv_join(char **l, const char *separator);
39
40 #define STRV_FOREACH(s, l) \
41 for ((s) = (l); (s) && *(s); (s)++)
42
43 #define STRV_FOREACH_BACKWARDS(s, l) \
44 STRV_FOREACH(s, l) \
45 ; \
46 for ((s)--; (l) && ((s) >= (l)); (s)--)
47
48
49 #define STRV_MAKE_EMPTY ((char*[1]) { NULL })
50
51 char **strv_reverse(char **l);
52
53 #endif /* UTIL_LINUX_STRV */
54
55