]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/strv.h
2 * SPDX-License-Identifier: LGPL-2.1-or-later
4 #ifndef UTIL_LINUX_STRV
5 #define UTIL_LINUX_STRV
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
);
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
);
20 int strv_extendv(char ***l
, const char *format
, va_list ap
)
21 __attribute__ ((__format__ (__printf__
, 2, 0)));
22 int strv_extendf(char ***l
, const char *format
, ...)
23 __attribute__ ((__format__ (__printf__
, 2, 3)));
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
);
30 char **strv_remove(char **l
, const char *s
);
32 char **strv_new(const char *x
, ...);
33 char **strv_new_ap(const char *x
, va_list ap
);
35 static inline const char* STRV_IFNOTNULL(const char *x
) {
36 return x
? x
: (const char *) -1;
39 static inline int strv_isempty(char * const *l
) {
43 char **strv_split(const char *s
, const char *separator
);
44 char *strv_join(char **l
, const char *separator
);
46 #define STRV_FOREACH(s, l) \
47 for ((s) = (l); (s) && *(s); (s)++)
49 #define STRV_FOREACH_BACKWARDS(s, l) \
52 for ((s)--; (l) && ((s) >= (l)); (s)--)
55 #define STRV_MAKE_EMPTY ((char*[1]) { NULL })
57 char **strv_reverse(char **l
);
59 #endif /* UTIL_LINUX_STRV */