]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/strv.h
1 #ifndef UTIL_LINUX_STRV
2 #define UTIL_LINUX_STRV
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
);
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
);
24 char **strv_remove(char **l
, const char *s
);
26 char **strv_new(const char *x
, ...);
27 char **strv_new_ap(const char *x
, va_list ap
);
29 static inline const char* STRV_IFNOTNULL(const char *x
) {
30 return x
? x
: (const char *) -1;
33 static inline int strv_isempty(char * const *l
) {
37 char **strv_split(const char *s
, const char *separator
);
38 char *strv_join(char **l
, const char *separator
);
40 #define STRV_FOREACH(s, l) \
41 for ((s) = (l); (s) && *(s); (s)++)
43 #define STRV_FOREACH_BACKWARDS(s, l) \
46 for ((s)--; (l) && ((s) >= (l)); (s)--)
49 #define STRV_MAKE_EMPTY ((char*[1]) { NULL })
51 char **strv_reverse(char **l
);
53 #endif /* UTIL_LINUX_STRV */