1ARGZ_ADD(3)                Linux Programmer's Manual               ARGZ_ADD(3)
2
3
4

NAME

6       argz_add, argz_add_sep, argz_append, argz_count, argz_create, argz_cre‐
7       ate_sep, argz_delete, argz_extract,  argz_insert,  argz_next,  argz_re‐
8       place, argz_stringify - functions to handle an argz list
9

SYNOPSIS

11       #include <argz.h>
12
13       error_t argz_add(char **argz, size_t *argz_len, const char *str);
14
15       error_t argz_add_sep(char **argz, size_t *argz_len,
16                            const char *str, int delim);
17
18       error_t argz_append(char **argz, size_t *argz_len,
19                            const char *buf, size_t buf_len);
20
21       size_t argz_count(const char *argz, size_t argz_len);
22
23       error_t argz_create(char * const argv[], char **argz,
24                            size_t *argz_len);
25
26       error_t argz_create_sep(const char *str, int sep, char **argz,
27                            size_t *argz_len);
28
29       void argz_delete(char **argz, size_t *argz_len, char *entry);
30
31       void argz_extract(const char *argz, size_t argz_len, char **argv);
32
33       error_t argz_insert(char **argz, size_t *argz_len, char *before,
34                            const char *entry);
35
36       char *argz_next(const char *argz, size_t argz_len, const char *entry);
37
38       error_t argz_replace(char **argz, size_t *argz_len, const char *str,
39                            const char *with, unsigned int *replace_count);
40
41       void argz_stringify(char *argz, size_t len, int sep);
42

DESCRIPTION

44       These functions are glibc-specific.
45
46       An  argz  vector  is  a  pointer  to a character buffer together with a
47       length.  The intended interpretation of the character buffer is an  ar‐
48       ray  of  strings, where the strings are separated by null bytes ('\0').
49       If the length is nonzero, the last byte of the buffer must  be  a  null
50       byte.
51
52       These functions are for handling argz vectors.  The pair (NULL,0) is an
53       argz vector, and, conversely, argz vectors of length 0 must  have  null
54       pointer.   Allocation of nonempty argz vectors is done using malloc(3),
55       so that free(3) can be used to dispose of them again.
56
57       argz_add() adds the string str at the end of the array *argz,  and  up‐
58       dates *argz and *argz_len.
59
60       argz_add_sep()  is  similar,  but splits the string str into substrings
61       separated by the delimiter delim.  For example, one might use this on a
62       UNIX search path with delimiter ':'.
63
64       argz_append()    appends   the   argz   vector   (buf, buf_len)   after
65       (*argz, *argz_len) and updates *argz and *argz_len.   (Thus,  *argz_len
66       will be increased by buf_len.)
67
68       argz_count()  counts the number of strings, that is, the number of null
69       bytes ('\0'), in (argz, argz_len).
70
71       argz_create() converts a UNIX-style argument vector argv, terminated by
72       (char *) 0, into an argz vector (*argz, *argz_len).
73
74       argz_create_sep()  converts the null-terminated string str into an argz
75       vector (*argz, *argz_len) by breaking it up at every occurrence of  the
76       separator sep.
77
78       argz_delete()  removes  the substring pointed to by entry from the argz
79       vector (*argz, *argz_len) and updates *argz and *argz_len.
80
81       argz_extract() is the opposite of argz_create().   It  takes  the  argz
82       vector  (argz, argz_len)  and  fills  the  array  starting at argv with
83       pointers to the substrings, and a final NULL, making a UNIX-style  argv
84       vector.  The array argv must have room for argz_count(argz, argz_len) +
85       1 pointers.
86
87       argz_insert() is the opposite of argz_delete().  It inserts  the  argu‐
88       ment  entry  at position before into the argz vector (*argz, *argz_len)
89       and updates *argz and *argz_len.  If before is NULL,  then  entry  will
90       inserted at the end.
91
92       argz_next() is a function to step through the argz vector.  If entry is
93       NULL, the first entry is returned.  Otherwise, the entry  following  is
94       returned.  It returns NULL if there is no following entry.
95
96       argz_replace()  replaces each occurrence of str with with, reallocating
97       argz as necessary.  If replace_count is non-NULL,  *replace_count  will
98       be incremented by the number of replacements.
99
100       argz_stringify()  is  the opposite of argz_create_sep().  It transforms
101       the argz vector into a normal string by replacing all null bytes ('\0')
102       except the last by sep.
103

RETURN VALUE

105       All  argz functions that do memory allocation have a return type of er‐
106       ror_t (an integer type), and return 0 for success, and ENOMEM if an al‐
107       location error occurs.
108

ATTRIBUTES

110       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
111       tributes(7).
112
113       ┌──────────────────────────────────┬───────────────┬─────────┐
114Interface                         Attribute     Value   
115       ├──────────────────────────────────┼───────────────┼─────────┤
116argz_add(), argz_add_sep(),       │ Thread safety │ MT-Safe │
117argz_append(), argz_count(),      │               │         │
118argz_create(), argz_create_sep(), │               │         │
119argz_delete(), argz_extract(),    │               │         │
120argz_insert(), argz_next(),       │               │         │
121argz_replace(), argz_stringify()  │               │         │
122       └──────────────────────────────────┴───────────────┴─────────┘
123

CONFORMING TO

125       These functions are a GNU extension.
126

BUGS

128       Argz vectors without a terminating null byte may lead  to  Segmentation
129       Faults.
130

SEE ALSO

132       envz_add(3)
133

COLOPHON

135       This  page  is  part of release 5.10 of the Linux man-pages project.  A
136       description of the project, information about reporting bugs,  and  the
137       latest     version     of     this    page,    can    be    found    at
138       https://www.kernel.org/doc/man-pages/.
139
140
141
142                                  2020-11-01                       ARGZ_ADD(3)
Impressum