]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/strv.h
scriptreplay: add --summary
[thirdparty/util-linux.git] / include / strv.h
CommitLineData
548b9714
KZ
1#ifndef UTIL_LINUX_STRV
2#define UTIL_LINUX_STRV
3
4#include <stdarg.h>
5
6#include "c.h"
7
8char **strv_free(char **l);
9void strv_clear(char **l);
10char **strv_copy(char * const *l);
11unsigned strv_length(char * const *l);
12
13int strv_extend_strv(char ***a, char **b);
14int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
15int strv_extend(char ***l, const char *value);
de8d3863 16int strv_extendv(char ***l, const char *format, va_list ap);
548b9714
KZ
17int strv_extendf(char ***l, const char *format, ...)
18 __attribute__ ((__format__ (__printf__, 2, 0)));
19int strv_push(char ***l, char *value);
20int strv_push_prepend(char ***l, char *value);
21int strv_consume(char ***l, char *value);
22int strv_consume_prepend(char ***l, char *value);
23
24char **strv_remove(char **l, const char *s);
25
26char **strv_new(const char *x, ...);
27char **strv_new_ap(const char *x, va_list ap);
28
29static inline const char* STRV_IFNOTNULL(const char *x) {
30 return x ? x : (const char *) -1;
31}
32
33static inline int strv_isempty(char * const *l) {
34 return !l || !*l;
35}
36
37char **strv_split(const char *s, const char *separator);
38char *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
51char **strv_reverse(char **l);
52
53#endif /* UTIL_LINUX_STRV */
54
55