1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\" based on the description in glibc source and infopages
5 .\" Corrections and additions, aeb
6 .TH ARGZ_ADD 3 2007-05-18 "" "Linux Programmer's Manual"
8 argz_add, argz_add_sep, argz_append, argz_count, argz_create,
9 argz_create_sep, argz_delete, argz_extract, argz_insert,
10 argz_next, argz_replace, argz_stringify \- functions to handle an argz list
13 .B "#include <argz.h>"
15 .BI "error_t argz_add(char **" argz ", size_t *" argz_len \
16 ", const char *" str );
18 .BI "error_t argz_add_sep(char **" argz ", size_t *" argz_len ,
20 .BI "const char *" str ", int " delim );
22 .BI "error_t argz_append(char **" argz ", size_t *" argz_len ,
24 .BI "const char *" buf ", size_t " buf_len );
26 .BI "size_t argz_count(const char *" argz ", size_t " argz_len );
28 .BI "error_t argz_create(char * const " argv "[], char **" argz ,
30 .BI "size_t *" argz_len );
32 .BI "error_t argz_create_sep(const char *" str ", int " sep ", char **" argz ,
34 .BI "size_t *" argz_len );
36 .BI "error_t argz_delete(char **" argz ", size_t *" argz_len ", char *" entry );
38 .BI "void argz_extract(char *" argz ", size_t " argz_len ", char **" argv );
40 .BI "error_t argz_insert(char **" argz ", size_t *" argz_len ", char *" before ,
42 .BI "const char *" entry );
44 .BI "char *argz_next(char *" argz ", size_t " argz_len ", const char *" entry );
46 .BI "error_t argz_replace(char **" argz ", size_t *" argz_len \
47 ", const char *" str ,
49 .BI "const char *" with ", unsigned int *" replace_count );
51 .BI "void argz_stringify(char *" argz ", size_t " len ", int " sep );
54 These functions are glibc-specific.
56 An argz vector is a pointer to a character buffer together with a length.
57 The intended interpretation of the character buffer is an array
58 of strings, where the strings are separated by null bytes (\(aq\\0\(aq).
59 If the length is nonzero, the last byte of the buffer must be a null byte.
61 These functions are for handling argz vectors.
62 The pair (NULL,0) is an argz vector, and, conversely,
63 argz vectors of length 0 must have NULL pointer.
64 Allocation of nonempty argz vectors is done using
68 can be used to dispose of them again.
73 at the end of the array
81 is similar, but splits the string
83 into substrings separated by the delimiter
85 For example, one might use this on a Unix search path with
89 appends the argz vector
90 .RI ( buf ,\ buf_len )
92 .RI ( *argz ,\ *argz_len )
103 counts the number of strings, that is,
104 the number of null bytes (\(aq\\0\(aq), in
105 .RI ( argz ,\ argz_len ).
108 converts a Unix-style argument vector
113 .RI ( *argz ,\ *argz_len ).
115 .BR argz_create_sep ()
116 converts the null-terminated string
119 .RI ( *argz ,\ *argz_len )
120 by breaking it up at every occurrence of the separator
124 removes the substring pointed to by
127 .RI ( *argz ,\ *argz_len )
136 It takes the argz vector
137 .RI ( argz ,\ argz_len )
138 and fills the array starting at
140 with pointers to the substrings, and a final NULL,
141 making a Unix-style argv vector.
145 .IR argz_count ( argz , argz_len ") + 1"
151 It inserts the argument
156 .RI ( *argz ,\ *argz_len )
165 will inserted at the end.
168 is a function to step trough the argz vector.
171 is NULL, the first entry is returned.
173 following is returned.
174 It returns NULL if there is no following entry.
177 replaces each occurrence of
181 reallocating argz as necessary.
186 will be incremented by the number of replacements.
188 .BR argz_stringify ()
190 .BR argz_create_sep ().
191 It transforms the argz vector into a normal string by replacing
192 all null bytes (\(aq\\0\(aq) except the last by
195 All argz functions that do memory allocation have a return type of
196 \fIerror_t\fP, and return 0 for success, and \fBENOMEM\fP
197 if an allocation error occurs.
199 These functions are a GNU extension.
202 Argz vectors without a terminating null byte may lead to