]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/argz_add.3
time.1, _syscall.2, acct.2, getsockname.2, nanosleep.2, pciconfig_read.2, sched_get_p...
[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
e127c16a 10.TH ARGZ_ADD 3 2007-05-18 "" "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 ,
fea681da
MK
23.ti 20n
24.BI "const char *" str ", int " delim );
25.sp
2bbf2292 26.BI "error_t argz_append(char **" argz ", size_t *" argz_len ,
fea681da
MK
27.ti 20n
28.BI "const char *" buf ", size_t " buf_len );
29.sp
2bbf2292 30.BI "size_t argz_count(const char *" argz ", size_t " argz_len );
fea681da 31.sp
2bbf2292 32.BI "error_t argz_create(char * const " argv "[], char **" argz ,
fea681da
MK
33.ti 20n
34.BI "size_t *" argz_len );
35.sp
2bbf2292 36.BI "error_t argz_create_sep(const char *" str ", int " sep ", char **" argz ,
fea681da
MK
37.ti 20n
38.BI "size_t *" argz_len );
39.sp
2bbf2292 40.BI "error_t argz_delete(char **" argz ", size_t *" argz_len ", char *" entry );
fea681da 41.sp
2bbf2292 42.BI "void argz_extract(char *" argz ", size_t " argz_len ", char **" argv );
fea681da 43.sp
2bbf2292 44.BI "error_t argz_insert(char **" argz ", size_t *" argz_len ", char *" before ,
fea681da
MK
45.ti 20n
46.BI "const char *" entry );
47.sp
2bbf2292 48.BI "char *argz_next(char *" argz ", size_t " argz_len ", const char *" entry );
fea681da 49.sp
2bbf2292
MK
50.BI "error_t argz_replace(char **" argz ", size_t *" argz_len \
51", const char *" str ,
fea681da
MK
52.ti 20n
53.BI "const char *" with ", unsigned int *" replace_count );
54.sp
2bbf2292 55.BI "void argz_stringify(char *" argz ", size_t " len ", int " sep );
c8250206 56.fi
fea681da 57.SH DESCRIPTION
8382f16d 58These functions are glibc-specific.
fea681da
MK
59.LP
60An argz vector is a pointer to a character buffer together with a length.
c3b8df70 61The intended interpretation of the character buffer is an array
f81fb444 62of strings, where the strings are separated by null bytes (\(aq\\0\(aq).
c7094399 63If the length is nonzero, the last byte of the buffer must be a null byte.
fea681da
MK
64.LP
65These functions are for handling argz vectors.
66The pair (NULL,0) is an argz vector, and, conversely,
67argz vectors of length 0 must have NULL pointer.
aa796481 68Allocation of nonempty argz vectors is done using
fea681da
MK
69.BR malloc (3),
70so that
71.BR free (3)
72can be used to dispose of them again.
73.LP
63aa9df0 74.BR argz_add ()
fea681da
MK
75adds the string
76.I str
77at the end of the array
2bbf2292 78.IR *argz ,
fea681da 79and updates
2bbf2292 80.I *argz
fea681da 81and
2bbf2292 82.IR *argz_len .
fea681da 83.LP
63aa9df0 84.BR argz_add_sep ()
fea681da
MK
85is similar, but splits the string
86.I str
87into substrings separated by the delimiter
88.IR delim .
008f1ecc 89For example, one might use this on a UNIX search path with
f81fb444 90delimiter \(aq:\(aq.
fea681da 91.LP
63aa9df0 92.BR argz_append ()
fea681da 93appends the argz vector
e7c0f078 94.RI ( buf ,\ buf_len )
fea681da 95after
2bbf2292 96.RI ( *argz ,\ *argz_len )
fea681da 97and updates
2bbf2292 98.IR *argz
fea681da 99and
2bbf2292 100.IR *argz_len .
fea681da 101(Thus,
2bbf2292 102.I *argz_len
fea681da
MK
103will be increased by
104.IR buf_len .)
105.LP
63aa9df0 106.BR argz_count ()
c13182ef 107counts the number of strings, that is,
f81fb444 108the number of null bytes (\(aq\\0\(aq), in
57cfb7f3 109.RI ( argz ,\ argz_len ).
fea681da 110.LP
63aa9df0 111.BR argz_create ()
008f1ecc 112converts a UNIX-style argument vector
fea681da 113.IR argv ,
2bbf2292
MK
114terminated by
115.IR "(char *) 0" ,
116into an argz vector
117.RI ( *argz ,\ *argz_len ).
fea681da 118.LP
63aa9df0 119.BR argz_create_sep ()
28d88c17 120converts the null-terminated string
fea681da
MK
121.I str
122into an argz vector
57cfb7f3 123.RI ( *argz ,\ *argz_len )
fea681da
MK
124by breaking it up at every occurrence of the separator
125.IR sep .
126.LP
63aa9df0 127.BR argz_delete ()
fea681da
MK
128removes the substring pointed to by
129.I entry
130from the argz vector
57cfb7f3 131.RI ( *argz ,\ *argz_len )
fea681da 132and updates
2bbf2292 133.I *argz
fea681da 134and
2bbf2292 135.IR *argz_len .
fea681da 136.LP
63aa9df0 137.BR argz_extract ()
fea681da 138is the opposite of
63aa9df0 139.BR argz_create ().
fea681da 140It takes the argz vector
57cfb7f3 141.RI ( argz ,\ argz_len )
fea681da
MK
142and fills the array starting at
143.I argv
144with pointers to the substrings, and a final NULL,
008f1ecc 145making a UNIX-style argv vector.
fea681da
MK
146The array
147.I argv
148must have room for
149.IR argz_count ( argz , argz_len ") + 1"
150pointers.
151.LP
63aa9df0 152.BR argz_insert ()
fea681da 153is the opposite of
63aa9df0 154.BR argz_delete ().
fea681da
MK
155It inserts the argument
156.I entry
157at position
158.I before
159into the argz vector
e7c0f078 160.RI ( *argz ,\ *argz_len )
fea681da 161and updates
2bbf2292 162.I *argz
fea681da 163and
2bbf2292 164.IR *argz_len .
fea681da
MK
165If
166.I before
167is NULL, then
168.I entry
169will inserted at the end.
170.LP
63aa9df0 171.BR argz_next ()
c13182ef
MK
172is a function to step trough the argz vector.
173If
fea681da 174.I entry
c13182ef
MK
175is NULL, the first entry is returned.
176Otherwise, the entry
177following is returned.
178It returns NULL if there is no following entry.
fea681da 179.LP
63aa9df0 180.BR argz_replace ()
fea681da
MK
181replaces each occurrence of
182.I str
183with
184.IR with ,
c13182ef
MK
185reallocating argz as necessary.
186If
fea681da
MK
187.I replace_count
188is non-NULL,
2bbf2292 189.I *replace_count
fea681da
MK
190will be incremented by the number of replacements.
191.LP
63aa9df0 192.BR argz_stringify ()
fea681da 193is the opposite of
63aa9df0 194.BR argz_create_sep ().
fea681da 195It transforms the argz vector into a normal string by replacing
f81fb444 196all null bytes (\(aq\\0\(aq) except the last by
fea681da 197.IR sep .
47297adb 198.SH RETURN VALUE
fea681da 199All argz functions that do memory allocation have a return type of
c6fa0841
MK
200.IR error_t ,
201and return 0 for success, and
202.B ENOMEM
fea681da 203if an allocation error occurs.
db71f2e2 204.SH CONFORMING TO
c13182ef
MK
205These functions are a GNU extension.
206Handle with care.
2b2581ee
MK
207.SH BUGS
208Argz vectors without a terminating null byte may lead to
209Segmentation Faults.
47297adb 210.SH SEE ALSO
faade342 211.BR envz_add (3)