File: strv.h

package info (click to toggle)
util-linux 2.41.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 92,868 kB
  • sloc: ansic: 179,124; sh: 22,714; yacc: 1,284; makefile: 525; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (59 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */
#ifndef UTIL_LINUX_STRV
#define UTIL_LINUX_STRV

#include <stdarg.h>

#include "c.h"

char **ul_strv_free(char **l);
char **ul_strv_copy(char * const *l);
unsigned ul_strv_length(char * const *l);

int ul_strv_extend_strv(char ***a, char **b);
int ul_strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int ul_strv_extend(char ***l, const char *value);

int ul_strv_extendv(char ***l, const char *format, va_list ap)
		__attribute__ ((__format__ (__printf__, 2, 0)));
int ul_strv_extendf(char ***l, const char *format, ...)
		__attribute__ ((__format__ (__printf__, 2, 3)));

int ul_strv_push(char ***l, char *value);
int ul_strv_push_prepend(char ***l, char *value);
int ul_strv_consume(char ***l, char *value);
int ul_strv_consume_prepend(char ***l, char *value);

char **ul_strv_remove(char **l, const char *s);

char **ul_strv_new(const char *x, ...);

static inline const char* UL_STRV_IFNOTNULL(const char *x) {
        return x ? x : (const char *) -1;
}

static inline int ul_strv_isempty(char * const *l) {
        return !l || !*l;
}

char **ul_strv_split(const char *s, const char *separator);
char *ul_strv_join(char **l, const char *separator);

#define UL_STRV_FOREACH(s, l)                      \
        for ((s) = (l); (s) && *(s); (s)++)

#define UL_STRV_FOREACH_BACKWARDS(s, l)            \
        UL_STRV_FOREACH(s, l)                      \
                ;                               \
        for ((s)--; (l) && ((s) >= (l)); (s)--)


#define UL_STRV_MAKE_EMPTY ((char*[1]) { NULL })

char **ul_strv_reverse(char **l);

#endif /* UTIL_LINUX_STRV */