1argz_add(3) Library Functions Manual argz_add(3)
2
3
4
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, argz_re‐
8 place, argz_stringify - functions to handle an argz list
9
11 Standard C library (libc, -lc)
12
14 #include <argz.h>
15
16 error_t argz_add(char **restrict argz, size_t *restrict argz_len,
17 const char *restrict str);
18
19 error_t argz_add_sep(char **restrict argz, size_t *restrict argz_len,
20 const char *restrict str, int delim);
21
22 error_t argz_append(char **restrict argz, size_t *restrict argz_len,
23 const char *restrict buf, size_t buf_len);
24
25 size_t argz_count(const char *argz, size_t argz_len);
26
27 error_t argz_create(char *const argv[], char **restrict argz,
28 size_t *restrict argz_len);
29
30 error_t argz_create_sep(const char *restrict str, int sep,
31 char **restrict argz, size_t *restrict argz_len);
32
33 void argz_delete(char **restrict argz, size_t *restrict argz_len,
34 char *restrict entry);
35
36 void argz_extract(const char *restrict argz, size_t argz_len,
37 char **restrict argv);
38
39 error_t argz_insert(char **restrict argz, size_t *restrict argz_len,
40 char *restrict before, const char *restrict entry);
41
42 char *argz_next(const char *restrict argz, size_t argz_len,
43 const char *restrict entry);
44
45 error_t argz_replace(char **restrict argz, size_t *restrict argz_len,
46 const char *restrict str, const char *restrict with,
47 unsigned int *restrict replace_count);
48
49 void argz_stringify(char *argz, size_t len, int sep);
50
52 These functions are glibc-specific.
53
54 An argz vector is a pointer to a character buffer together with a
55 length. The intended interpretation of the character buffer is an ar‐
56 ray of strings, where the strings are separated by null bytes ('\0').
57 If the length is nonzero, the last byte of the buffer must be a null
58 byte.
59
60 These functions are for handling argz vectors. The pair (NULL,0) is an
61 argz vector, and, conversely, argz vectors of length 0 must have null
62 pointer. Allocation of nonempty argz vectors is done using malloc(3),
63 so that free(3) can be used to dispose of them again.
64
65 argz_add() adds the string str at the end of the array *argz, and up‐
66 dates *argz and *argz_len.
67
68 argz_add_sep() is similar, but splits the string str into substrings
69 separated by the delimiter delim. For example, one might use this on a
70 UNIX search path with delimiter ':'.
71
72 argz_append() appends the argz vector (buf, buf_len) after
73 (*argz, *argz_len) and updates *argz and *argz_len. (Thus, *argz_len
74 will be increased by buf_len.)
75
76 argz_count() counts the number of strings, that is, the number of null
77 bytes ('\0'), in (argz, argz_len).
78
79 argz_create() converts a UNIX-style argument vector argv, terminated by
80 (char *) 0, into an argz vector (*argz, *argz_len).
81
82 argz_create_sep() converts the null-terminated string str into an argz
83 vector (*argz, *argz_len) by breaking it up at every occurrence of the
84 separator sep.
85
86 argz_delete() removes the substring pointed to by entry from the argz
87 vector (*argz, *argz_len) and updates *argz and *argz_len.
88
89 argz_extract() is the opposite of argz_create(). It takes the argz
90 vector (argz, argz_len) and fills the array starting at argv with
91 pointers to the substrings, and a final NULL, making a UNIX-style argv
92 vector. The array argv must have room for argz_count(argz, argz_len) +
93 1 pointers.
94
95 argz_insert() is the opposite of argz_delete(). It inserts the argu‐
96 ment entry at position before into the argz vector (*argz, *argz_len)
97 and updates *argz and *argz_len. If before is NULL, then entry will
98 inserted at the end.
99
100 argz_next() is a function to step through the argz vector. If entry is
101 NULL, the first entry is returned. Otherwise, the entry following is
102 returned. It returns NULL if there is no following entry.
103
104 argz_replace() replaces each occurrence of str with with, reallocating
105 argz as necessary. If replace_count is non-NULL, *replace_count will
106 be incremented by the number of replacements.
107
108 argz_stringify() is the opposite of argz_create_sep(). It transforms
109 the argz vector into a normal string by replacing all null bytes ('\0')
110 except the last by sep.
111
113 All argz functions that do memory allocation have a return type of er‐
114 ror_t (an integer type), and return 0 for success, and ENOMEM if an al‐
115 location error occurs.
116
118 For an explanation of the terms used in this section, see at‐
119 tributes(7).
120
121 ┌────────────────────────────────────────────┬───────────────┬─────────┐
122 │Interface │ Attribute │ Value │
123 ├────────────────────────────────────────────┼───────────────┼─────────┤
124 │argz_add(), argz_add_sep(), argz_append(), │ Thread safety │ MT-Safe │
125 │argz_count(), argz_create(), │ │ │
126 │argz_create_sep(), argz_delete(), │ │ │
127 │argz_extract(), argz_insert(), argz_next(), │ │ │
128 │argz_replace(), argz_stringify() │ │ │
129 └────────────────────────────────────────────┴───────────────┴─────────┘
130
132 GNU.
133
135 Argz vectors without a terminating null byte may lead to Segmentation
136 Faults.
137
139 envz_add(3)
140
141
142
143Linux man-pages 6.05 2023-07-20 argz_add(3)