NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ATTRIBUTES |STANDARDS |BUGS |SEE ALSO |COLOPHON | |
argz_add(3) Library Functions Manualargz_add(3)argz_add, argz_add_sep, argz_append, argz_count, argz_create, argz_create_sep, argz_delete, argz_extract, argz_insert, argz_next, argz_replace, argz_stringify - functions to handle an argz list
Standard C library (libc,-lc)
#include <argz.h>error_t argz_add(char **restrictargz, size_t *restrictargz_len,const char *restrictstr);error_t argz_add_sep(char **restrictargz, size_t *restrictargz_len,const char *restrictstr, intdelim);error_t argz_append(char **restrictargz, size_t *restrictargz_len,const char *restrictbuf, size_tbuf_len);size_t argz_count(const char *argz, size_targz_len);error_t argz_create(char *constargv[], char **restrictargz,size_t *restrictargz_len);error_t argz_create_sep(const char *restrictstr, intsep,char **restrictargz, size_t *restrictargz_len);void argz_delete(char **restrictargz, size_t *restrictargz_len,char *restrictentry);void argz_extract(const char *restrictargz, size_targz_len,char **restrictargv);error_t argz_insert(char **restrictargz, size_t *restrictargz_len,char *restrictbefore, const char *restrictentry);char *argz_next(const char *restrictargz, size_targz_len,const char *restrictentry);error_t argz_replace(char **restrictargz, size_t *restrictargz_len,const char *restrictstr, const char *restrictwith,unsigned int *restrictreplace_count);void argz_stringify(char *argz, size_tlen, intsep);
These functions are glibc-specific. An argz vector is a pointer to a character buffer together with a length. The intended interpretation of the character buffer is an array of strings, where the strings are separated by null bytes ('\0'). If the length is nonzero, the last byte of the buffer must be a null byte. These functions are for handling argz vectors. The pair (NULL,0) is an argz vector, and, conversely, argz vectors of length 0 must have null pointer. Allocation of nonempty argz vectors is done usingmalloc(3), so thatfree(3) can be used to dispose of them again.argz_add() adds the stringstr at the end of the array*argz, and updates*argz and*argz_len.argz_add_sep() is similar, but splits the stringstr into substrings separated by the delimiterdelim. For example, one might use this on a UNIX search path with delimiter ':'.argz_append() appends the argz vector (buf,buf_len) after (*argz,*argz_len) and updates*argz and*argz_len. (Thus,*argz_len will be increased bybuf_len.)argz_count() counts the number of strings, that is, the number of null bytes ('\0'), in (argz,argz_len).argz_create() converts a UNIX-style argument vectorargv, terminated by(char *) 0, into an argz vector (*argz,*argz_len).argz_create_sep() converts the null-terminated stringstr into an argz vector (*argz,*argz_len) by breaking it up at every occurrence of the separatorsep.argz_delete() removes the substring pointed to byentry from the argz vector (*argz,*argz_len) and updates*argz and*argz_len.argz_extract() is the opposite ofargz_create(). It takes the argz vector (argz,argz_len) and fills the array starting atargv with pointers to the substrings, and a final NULL, making a UNIX- style argv vector. The arrayargv must have room forargz_count(argz,argz_len) + 1 pointers.argz_insert() is the opposite ofargz_delete(). It inserts the argumententry at positionbefore into the argz vector (*argz,*argz_len) and updates*argz and*argz_len. Ifbefore is NULL, thenentry will inserted at the end.argz_next() is a function to step through the argz vector. Ifentry is NULL, the first entry is returned. Otherwise, the entry following is returned. It returns NULL if there is no following entry.argz_replace() replaces each occurrence ofstr withwith, reallocating argz as necessary. Ifreplace_count is non-NULL,*replace_count will be incremented by the number of replacements.argz_stringify() is the opposite ofargz_create_sep(). It transforms the argz vector into a normal string by replacing all null bytes ('\0') except the last bysep.All argz functions that do memory allocation have a return type oferror_t (an integer type), and return 0 for success, andENOMEMif an allocation error occurs.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├──────────────────────────────────────┼───────────────┼─────────┤ │argz_add(),argz_add_sep(), │ Thread safety │ MT-Safe │ │argz_append(),argz_count(), │ │ │ │argz_create(),argz_create_sep(), │ │ │ │argz_delete(),argz_extract(), │ │ │ │argz_insert(),argz_next(), │ │ │ │argz_replace(),argz_stringify() │ │ │ └──────────────────────────────────────┴───────────────┴─────────┘
GNU.
Argz vectors without a terminating null byte may lead to Segmentation Faults.
envz_add(3)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17argz_add(3)Pages that refer to this page:envz_add(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |