1ARGZ_ADD(3)                Library Functions 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,
8       argz_replace, argz_stringify - functions to handle an argz list
9

SYNOPSIS

11       #include <argz.h>
12
13       error_t
14       argz_add(char **argz, size_t *argz_len, const char *str);
15
16       error_t
17       argz_add_sep(char **argz, size_t *argz_len,
18                    const char *str, int delim);
19
20       error_t
21       argz_append(char **argz, size_t *argz_len,
22                    const char *buf, size_t buf_len);
23
24       size_t
25       argz_count(const char *argz, size_t argz_len);
26
27       error_t
28       argz_create(char * const argv[], char **argz,
29                    size_t *argz_len);
30
31       error_t
32       argz_create_sep(const char *str, int sep, char **argz,
33                    size_t *argz_len);
34
35       error_t
36       argz_delete(char **argz, size_t *argz_len, char *entry);
37
38       void
39       argz_extract(char *argz, size_t argz_len, char  **argv);
40
41       error_t
42       argz_insert (char **argz, size_t *argz_len, char *before,
43                    const char *entry);
44
45       char *
46       argz_next(char *argz, size_t argz_len, const char *entry);
47
48       error_t
49       argz_replace(char **argz, size_t *argz_len, const char *str,
50                    const char *with, unsigned int *replace_count);
51
52       void
53       argz_stringify(char *argz, size_t len, int sep);
54
55

DESCRIPTION

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

RETURN VALUE

118       All  argz  functions  that  do  memory allocation have a return type of
119       error_t, and return 0 for success, and ENOMEM if  an  allocation  error
120       occurs.
121

BUGS

123       Argz  vectors  without a terminating null byte may lead to Segmentation
124       Faults.
125

CONFORMING TO

127       These functions are a GNU extension. Handle with care.
128

SEE ALSO

130       envz(3)
131
132
133
134                                                                   ARGZ_ADD(3)
Impressum