]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/argz_add.3
dlinfo.3: ATTRIBUTES: Note function that is thread-safe
[thirdparty/man-pages.git] / man3 / argz_add.3
CommitLineData
fea681da 1.\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2297bf0e 2.\"
38f20bb9 3.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
fea681da 4.\" Distributed under GPL
38f20bb9 5.\" %%%LICENSE_END
a781c7d0 6.\"
fea681da 7.\" based on the description in glibc source and infopages
c13182ef 8.\"
fea681da 9.\" Corrections and additions, aeb
fe0fefbf 10.TH ARGZ_ADD 3 2015-03-02 "" "Linux Programmer's Manual"
fea681da
MK
11.SH NAME
12argz_add, argz_add_sep, argz_append, argz_count, argz_create,
13argz_create_sep, argz_delete, argz_extract, argz_insert,
14argz_next, argz_replace, argz_stringify \- functions to handle an argz list
15.SH SYNOPSIS
16.nf
fea681da
MK
17.B "#include <argz.h>"
18.sp
2bbf2292
MK
19.BI "error_t argz_add(char **" argz ", size_t *" argz_len \
20", const char *" str );
fea681da 21.sp
2bbf2292 22.BI "error_t argz_add_sep(char **" argz ", size_t *" argz_len ,
04aa9282 23.BI " const char *" str ", int " delim );
fea681da 24.sp
2bbf2292 25.BI "error_t argz_append(char **" argz ", size_t *" argz_len ,
04aa9282 26.BI " const char *" buf ", size_t " buf_len );
fea681da 27.sp
2bbf2292 28.BI "size_t argz_count(const char *" argz ", size_t " argz_len );
fea681da 29.sp
2bbf2292 30.BI "error_t argz_create(char * const " argv "[], char **" argz ,
04aa9282 31.BI " size_t *" argz_len );
fea681da 32.sp
2bbf2292 33.BI "error_t argz_create_sep(const char *" str ", int " sep ", char **" argz ,
04aa9282 34.BI " size_t *" argz_len );
fea681da 35.sp
888904f4 36.BI "void argz_delete(char **" argz ", size_t *" argz_len ", char *" entry );
fea681da 37.sp
888904f4 38.BI "void argz_extract(const char *" argz ", size_t " argz_len ", char **" argv );
fea681da 39.sp
2bbf2292 40.BI "error_t argz_insert(char **" argz ", size_t *" argz_len ", char *" before ,
04aa9282 41.BI " const char *" entry );
fea681da 42.sp
888904f4 43.BI "char *argz_next(const char *" argz ", size_t " argz_len ", const char *" entry );
fea681da 44.sp
2bbf2292
MK
45.BI "error_t argz_replace(char **" argz ", size_t *" argz_len \
46", const char *" str ,
04aa9282 47.BI " const char *" with ", unsigned int *" replace_count );
fea681da 48.sp
2bbf2292 49.BI "void argz_stringify(char *" argz ", size_t " len ", int " sep );
c8250206 50.fi
fea681da 51.SH DESCRIPTION
8382f16d 52These functions are glibc-specific.
fea681da
MK
53.LP
54An argz vector is a pointer to a character buffer together with a length.
c3b8df70 55The intended interpretation of the character buffer is an array
f81fb444 56of strings, where the strings are separated by null bytes (\(aq\\0\(aq).
c7094399 57If the length is nonzero, the last byte of the buffer must be a null byte.
fea681da
MK
58.LP
59These functions are for handling argz vectors.
60The pair (NULL,0) is an argz vector, and, conversely,
b437fdd9 61argz vectors of length 0 must have null pointer.
aa796481 62Allocation of nonempty argz vectors is done using
fea681da
MK
63.BR malloc (3),
64so that
65.BR free (3)
66can be used to dispose of them again.
67.LP
63aa9df0 68.BR argz_add ()
fea681da
MK
69adds the string
70.I str
71at the end of the array
2bbf2292 72.IR *argz ,
fea681da 73and updates
2bbf2292 74.I *argz
fea681da 75and
2bbf2292 76.IR *argz_len .
fea681da 77.LP
63aa9df0 78.BR argz_add_sep ()
fea681da
MK
79is similar, but splits the string
80.I str
81into substrings separated by the delimiter
82.IR delim .
008f1ecc 83For example, one might use this on a UNIX search path with
f81fb444 84delimiter \(aq:\(aq.
fea681da 85.LP
63aa9df0 86.BR argz_append ()
fea681da 87appends the argz vector
ea01d886 88.RI ( buf ,\ buf_len )
fea681da 89after
ea01d886 90.RI ( *argz ,\ *argz_len )
fea681da 91and updates
2bbf2292 92.IR *argz
fea681da 93and
2bbf2292 94.IR *argz_len .
fea681da 95(Thus,
2bbf2292 96.I *argz_len
fea681da
MK
97will be increased by
98.IR buf_len .)
99.LP
63aa9df0 100.BR argz_count ()
c13182ef 101counts the number of strings, that is,
f81fb444 102the number of null bytes (\(aq\\0\(aq), in
ea01d886 103.RI ( argz ,\ argz_len ).
fea681da 104.LP
63aa9df0 105.BR argz_create ()
008f1ecc 106converts a UNIX-style argument vector
fea681da 107.IR argv ,
2bbf2292 108terminated by
5049da5b 109.IR "(char\ *)\ 0" ,
2bbf2292 110into an argz vector
ea01d886 111.RI ( *argz ,\ *argz_len ).
fea681da 112.LP
63aa9df0 113.BR argz_create_sep ()
28d88c17 114converts the null-terminated string
fea681da
MK
115.I str
116into an argz vector
ea01d886 117.RI ( *argz ,\ *argz_len )
fea681da
MK
118by breaking it up at every occurrence of the separator
119.IR sep .
120.LP
63aa9df0 121.BR argz_delete ()
fea681da
MK
122removes the substring pointed to by
123.I entry
124from the argz vector
ea01d886 125.RI ( *argz ,\ *argz_len )
fea681da 126and updates
2bbf2292 127.I *argz
fea681da 128and
2bbf2292 129.IR *argz_len .
fea681da 130.LP
63aa9df0 131.BR argz_extract ()
fea681da 132is the opposite of
63aa9df0 133.BR argz_create ().
fea681da 134It takes the argz vector
ea01d886 135.RI ( argz ,\ argz_len )
fea681da
MK
136and fills the array starting at
137.I argv
138with pointers to the substrings, and a final NULL,
008f1ecc 139making a UNIX-style argv vector.
fea681da
MK
140The array
141.I argv
142must have room for
97e91fec 143.IR argz_count ( argz ", " argz_len ") + 1"
fea681da
MK
144pointers.
145.LP
63aa9df0 146.BR argz_insert ()
fea681da 147is the opposite of
63aa9df0 148.BR argz_delete ().
fea681da
MK
149It inserts the argument
150.I entry
151at position
152.I before
153into the argz vector
ea01d886 154.RI ( *argz ,\ *argz_len )
fea681da 155and updates
2bbf2292 156.I *argz
fea681da 157and
2bbf2292 158.IR *argz_len .
fea681da
MK
159If
160.I before
161is NULL, then
162.I entry
163will inserted at the end.
164.LP
63aa9df0 165.BR argz_next ()
c13182ef
MK
166is a function to step trough the argz vector.
167If
fea681da 168.I entry
c13182ef
MK
169is NULL, the first entry is returned.
170Otherwise, the entry
171following is returned.
172It returns NULL if there is no following entry.
fea681da 173.LP
63aa9df0 174.BR argz_replace ()
fea681da
MK
175replaces each occurrence of
176.I str
177with
178.IR with ,
c13182ef
MK
179reallocating argz as necessary.
180If
fea681da
MK
181.I replace_count
182is non-NULL,
2bbf2292 183.I *replace_count
fea681da
MK
184will be incremented by the number of replacements.
185.LP
63aa9df0 186.BR argz_stringify ()
fea681da 187is the opposite of
63aa9df0 188.BR argz_create_sep ().
fea681da 189It transforms the argz vector into a normal string by replacing
f81fb444 190all null bytes (\(aq\\0\(aq) except the last by
fea681da 191.IR sep .
47297adb 192.SH RETURN VALUE
fea681da 193All argz functions that do memory allocation have a return type of
c6fa0841
MK
194.IR error_t ,
195and return 0 for success, and
196.B ENOMEM
fea681da 197if an allocation error occurs.
3cc3c5e6
MS
198.SH ATTRIBUTES
199For an explanation of the terms used in this section, see
200.BR attributes (7).
201.TS
202allbox;
203lbw33 lb lb
204l l l.
205Interface Attribute Value
206T{
207.BR argz_add (),
208.BR argz_add_sep (),
209.br
210.BR argz_append (),
211.BR argz_count (),
212.br
213.BR argz_create (),
214.BR argz_create_sep (),
215.br
216.BR argz_delete (),
217.BR argz_extract (),
218.br
219.BR argz_insert (),
220.BR argz_next (),
221.br
222.BR argz_replace (),
223.BR argz_stringify ()
224T} Thread safety MT-Safe
225.TE
226
db71f2e2 227.SH CONFORMING TO
c13182ef
MK
228These functions are a GNU extension.
229Handle with care.
2b2581ee
MK
230.SH BUGS
231Argz vectors without a terminating null byte may lead to
232Segmentation Faults.
47297adb 233.SH SEE ALSO
faade342 234.BR envz_add (3)