]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/strv.h
include: add missing license lines
[thirdparty/util-linux.git] / include / strv.h
CommitLineData
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
11char **strv_free(char **l);
12void strv_clear(char **l);
13char **strv_copy(char * const *l);
14unsigned strv_length(char * const *l);
15
16int strv_extend_strv(char ***a, char **b);
17int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
18int strv_extend(char ***l, const char *value);
43554534
KZ
19
20int strv_extendv(char ***l, const char *format, va_list ap)
21 __attribute__ ((__format__ (__printf__, 2, 0)));
548b9714 22int strv_extendf(char ***l, const char *format, ...)
43554534
KZ
23 __attribute__ ((__format__ (__printf__, 2, 3)));
24
548b9714
KZ
25int strv_push(char ***l, char *value);
26int strv_push_prepend(char ***l, char *value);
27int strv_consume(char ***l, char *value);
28int strv_consume_prepend(char ***l, char *value);
29
30char **strv_remove(char **l, const char *s);
31
32char **strv_new(const char *x, ...);
33char **strv_new_ap(const char *x, va_list ap);
34
35static inline const char* STRV_IFNOTNULL(const char *x) {
36 return x ? x : (const char *) -1;
37}
38
39static inline int strv_isempty(char * const *l) {
40 return !l || !*l;
41}
42
43char **strv_split(const char *s, const char *separator);
44char *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
57char **strv_reverse(char **l);
58
59#endif /* UTIL_LINUX_STRV */
60
61