1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
7 .\" based on the description in glibc source and infopages
9 .\" Corrections and additions, aeb
10 .TH ARGZ_ADD 3 2021-03-22 "" "Linux Programmer's Manual"
12 argz_add, argz_add_sep, argz_append, argz_count, argz_create,
13 argz_create_sep, argz_delete, argz_extract, argz_insert,
14 argz_next, argz_replace, argz_stringify \- functions to handle an argz list
17 .B "#include <argz.h>"
19 .BI "error_t argz_add(char **restrict " argz ", size_t *restrict " argz_len ",
20 .BI " const char *restrict " str );
22 .BI "error_t argz_add_sep(char **restrict " argz \
23 ", size_t *restrict " argz_len ,
24 .BI " const char *restrict " str ", int " delim );
26 .BI "error_t argz_append(char **restrict " argz ", size_t *restrict " argz_len ,
27 .BI " const char *restrict " buf ", size_t " buf_len );
29 .BI "size_t argz_count(const char *" argz ", size_t " argz_len );
31 .BI "error_t argz_create(char *const " argv "[], char **restrict " argz ,
32 .BI " size_t *restrict " argz_len );
34 .BI "error_t argz_create_sep(const char *restrict " str ", int " sep ,
35 .BI " char **restrict " argz ", size_t *restrict " argz_len );
37 .BI "void argz_delete(char **restrict " argz ", size_t *restrict " argz_len ,
38 .BI " char *restrict " entry );
40 .BI "void argz_extract(const char *restrict " argz ", size_t " argz_len ,
41 .BI " char **restrict " argv );
43 .BI "error_t argz_insert(char **restrict " argz ", size_t *restrict " argz_len ,
44 .BI " char *restrict " before ", const char *restrict " entry );
46 .BI "char *argz_next(const char *restrict " argz ", size_t " argz_len ,
47 .BI " const char *restrict " entry );
49 .BI "error_t argz_replace(char **restrict " argz \
50 ", size_t *restrict " argz_len ,
51 .BI " const char *restrict " str ", const char *restrict " with ,
52 .BI " unsigned int *restrict " replace_count );
54 .BI "void argz_stringify(char *" argz ", size_t " len ", int " sep );
57 These functions are glibc-specific.
59 An argz vector is a pointer to a character buffer together with a length.
60 The intended interpretation of the character buffer is an array
61 of strings, where the strings are separated by null bytes (\(aq\e0\(aq).
62 If the length is nonzero, the last byte of the buffer must be a null byte.
64 These functions are for handling argz vectors.
65 The pair (NULL,0) is an argz vector, and, conversely,
66 argz vectors of length 0 must have null pointer.
67 Allocation of nonempty argz vectors is done using
71 can be used to dispose of them again.
76 at the end of the array
84 is similar, but splits the string
86 into substrings separated by the delimiter
88 For example, one might use this on a UNIX search path with
92 appends the argz vector
93 .RI ( buf ,\ buf_len )
95 .RI ( *argz ,\ *argz_len )
106 counts the number of strings, that is,
107 the number of null bytes (\(aq\e0\(aq), in
108 .RI ( argz ,\ argz_len ).
111 converts a UNIX-style argument vector
116 .RI ( *argz ,\ *argz_len ).
118 .BR argz_create_sep ()
119 converts the null-terminated string
122 .RI ( *argz ,\ *argz_len )
123 by breaking it up at every occurrence of the separator
127 removes the substring pointed to by
130 .RI ( *argz ,\ *argz_len )
139 It takes the argz vector
140 .RI ( argz ,\ argz_len )
141 and fills the array starting at
143 with pointers to the substrings, and a final NULL,
144 making a UNIX-style argv vector.
148 .IR argz_count ( argz ", " argz_len ") + 1"
154 It inserts the argument
159 .RI ( *argz ,\ *argz_len )
168 will inserted at the end.
171 is a function to step through the argz vector.
174 is NULL, the first entry is returned.
176 following is returned.
177 It returns NULL if there is no following entry.
180 replaces each occurrence of
184 reallocating argz as necessary.
189 will be incremented by the number of replacements.
191 .BR argz_stringify ()
193 .BR argz_create_sep ().
194 It transforms the argz vector into a normal string by replacing
195 all null bytes (\(aq\e0\(aq) except the last by
198 All argz functions that do memory allocation have a return type of
201 and return 0 for success, and
203 if an allocation error occurs.
205 For an explanation of the terms used in this section, see
213 Interface Attribute Value
220 .BR argz_create_sep (),
226 .BR argz_stringify ()
227 T} Thread safety MT-Safe
233 These functions are a GNU extension.
235 Argz vectors without a terminating null byte may lead to