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 **restrict argz, size_t *restrict argz_len,
14                       const char *restrict str);
15
16       error_t argz_add_sep(char **restrict argz, size_t *restrict argz_len,
17                       const char *restrict str, int delim);
18
19       error_t argz_append(char **restrict argz, size_t *restrict argz_len,
20                       const char *restrict buf, size_t buf_len);
21
22       size_t argz_count(const char *argz, size_t argz_len);
23
24       error_t argz_create(char *const argv[], char **restrict argz,
25                       size_t *restrict argz_len);
26
27       error_t argz_create_sep(const char *restrict str, int sep,
28                       char **restrict argz, size_t *restrict argz_len);
29
30       void argz_delete(char **restrict argz, size_t *restrict argz_len,
31                       char *restrict entry);
32
33       void argz_extract(const char *restrict argz, size_t argz_len,
34                       char **restrict argv);
35
36       error_t argz_insert(char **restrict argz, size_t *restrict argz_len,
37                       char *restrict before, const char *restrict entry);
38
39       char *argz_next(const char *restrict argz, size_t argz_len,
40                       const char *restrict entry);
41
42       error_t argz_replace(char **restrict argz, size_t *restrict argz_len,
43                       const char *restrict str, const char *restrict with,
44                       unsigned int *restrict replace_count);
45
46       void argz_stringify(char *argz, size_t len, int sep);
47

DESCRIPTION

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

RETURN VALUE

110       All  argz functions that do memory allocation have a return type of er‐
111       ror_t (an integer type), and return 0 for success, and ENOMEM if an al‐
112       location error occurs.
113

ATTRIBUTES

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

CONFORMING TO

129       These functions are a GNU extension.
130

BUGS

132       Argz vectors without a terminating null byte may lead  to  Segmentation
133       Faults.
134

SEE ALSO

136       envz_add(3)
137

COLOPHON

139       This  page  is  part of release 5.13 of the Linux man-pages project.  A
140       description of the project, information about reporting bugs,  and  the
141       latest     version     of     this    page,    can    be    found    at
142       https://www.kernel.org/doc/man-pages/.
143
144
145
146                                  2021-03-22                       ARGZ_ADD(3)
Impressum