Manpage of ARGZ_ADD

ARGZ_ADD

Section: Linux Programmer's Manual (3)
Updated: 2015-03-02
Index
 

NAME

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  

SYNOPSIS

#include <argz.h>error_t argz_add(char **argz, size_t *argz_len, const char *str);error_t argz_add_sep(char **argz, size_t *argz_len,                     const char *str, int delim);error_t argz_append(char **argz, size_t *argz_len,                     const char *buf, size_t buf_len);size_t argz_count(const char *argz, size_t argz_len);error_t argz_create(char * const argv[], char **argz,                     size_t *argz_len);error_t argz_create_sep(const char *str, int sep, char **argz,                     size_t *argz_len);void argz_delete(char **argz, size_t *argz_len, char *entry);void argz_extract(const char *argz, size_t argz_len, char  **argv);error_t argz_insert(char **argz, size_t *argz_len, char *before,                     const char *entry);char *argz_next(const char *argz, size_t argz_len, const char *entry);error_t argz_replace(char **argz, size_t *argz_len, const char *str,                     const char *with, unsigned int *replace_count);void argz_stringify(char *argz, size_t len, int sep);
 

DESCRIPTION

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 (aq\0aq). 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 using malloc(3), so that free(3) can be used to dispose of them again.

argz_add() adds the string strat the end of the array *argz, and updates *argzand *argz_len.

argz_add_sep() is similar, but splits the string strinto substrings separated by the delimiter delim. For example, one might use this on a UNIX search path with delimiter aq:aq.

argz_append() appends the argz vector (bufbuf_len) after (*argz*argz_len) and updates *argzand *argz_len. (Thus, *argz_lenwill be increased by buf_len.)

argz_count() counts the number of strings, that is, the number of null bytes (aq\0aq), in (argzargz_len).

argz_create() converts a UNIX-style argument vector argv, terminated by (char *) 0, into an argz vector (*argz*argz_len).

argz_create_sep() converts the null-terminated string strinto an argz vector (*argz*argz_len) by breaking it up at every occurrence of the separator sep.

argz_delete() removes the substring pointed to by entryfrom the argz vector (*argz*argz_len) and updates *argzand *argz_len.

argz_extract() is the opposite of argz_create(). It takes the argz vector (argzargz_len) and fills the array starting at argvwith pointers to the substrings, and a final NULL, making a UNIX-style argv vector. The array argvmust have room for argz_count(argz, argz_len) + 1 pointers.

argz_insert() is the opposite of argz_delete(). It inserts the argument entryat position beforeinto the argz vector (*argz*argz_len) and updates *argzand *argz_len. If beforeis NULL, then entrywill inserted at the end.

argz_next() is a function to step trough the argz vector. If entryis 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 of strwith with, reallocating argz as necessary. If replace_countis non-NULL, *replace_countwill be incremented by the number of replacements.

argz_stringify() is the opposite of argz_create_sep(). It transforms the argz vector into a normal string by replacing all null bytes (aq\0aq) except the last by sep.  

RETURN VALUE

All argz functions that do memory allocation have a return type of error_t, and return 0 for success, and ENOMEMif an allocation error occurs.  

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).
InterfaceAttributeValue
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()
Thread safetyMT-Safe

 

CONFORMING TO

These functions are a GNU extension. Handle with care.  

BUGS

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

SEE ALSO

envz_add(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ATTRIBUTES
CONFORMING TO
BUGS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 22:27:48 GMT, June 20, 2016