372 lines
7.8 KiB
HTML
372 lines
7.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of ARGZ_ADD</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>ARGZ_ADD</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
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
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/argz.h">argz.h</A>></B>
|
|
|
|
<B>error_t argz_add(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>, const char *</B><I>str</I><B>);</B>
|
|
|
|
<B>error_t argz_add_sep(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>,</B>
|
|
<B> const char *</B><I>str</I><B>, int </B><I>delim</I><B>);</B>
|
|
|
|
<B>error_t argz_append(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>,</B>
|
|
<B> const char *</B><I>buf</I><B>, size_t </B><I>buf_len</I><B>);</B>
|
|
|
|
<B>size_t argz_count(const char *</B><I>argz</I><B>, size_t </B><I>argz_len</I><B>);</B>
|
|
|
|
<B>error_t argz_create(char * const </B><I>argv</I><B>[], char **</B><I>argz</I><B>,</B>
|
|
<B> size_t *</B><I>argz_len</I><B>);</B>
|
|
|
|
<B>error_t argz_create_sep(const char *</B><I>str</I><B>, int </B><I>sep</I><B>, char **</B><I>argz</I><B>,</B>
|
|
<B> size_t *</B><I>argz_len</I><B>);</B>
|
|
|
|
<B>void argz_delete(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>, char *</B><I>entry</I><B>);</B>
|
|
|
|
<B>void argz_extract(const char *</B><I>argz</I><B>, size_t </B><I>argz_len</I><B>, char **</B><I>argv</I><B>);</B>
|
|
|
|
<B>error_t argz_insert(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>, char *</B><I>before</I><B>,</B>
|
|
<B> const char *</B><I>entry</I><B>);</B>
|
|
|
|
<B>char *argz_next(const char *</B><I>argz</I><B>, size_t </B><I>argz_len</I><B>, const char *</B><I>entry</I><B>);</B>
|
|
|
|
<B>error_t argz_replace(char **</B><I>argz</I><B>, size_t *</B><I>argz_len</I><B>, const char *</B><I>str</I><B>,</B>
|
|
<B> const char *</B><I>with</I><B>, unsigned int *</B><I>replace_count</I><B>);</B>
|
|
|
|
<B>void argz_stringify(char *</B><I>argz</I><B>, size_t </B><I>len</I><B>, int </B><I>sep</I><B>);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
These functions are glibc-specific.
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3),
|
|
|
|
so that
|
|
<B><A HREF="/cgi-bin/man/man2html?3+free">free</A></B>(3)
|
|
|
|
can be used to dispose of them again.
|
|
<P>
|
|
|
|
<B>argz_add</B>()
|
|
|
|
adds the string
|
|
<I>str</I>
|
|
|
|
at the end of the array
|
|
<I>*argz</I>,
|
|
|
|
and updates
|
|
<I>*argz</I>
|
|
|
|
and
|
|
<I>*argz_len</I>.
|
|
|
|
<P>
|
|
|
|
<B>argz_add_sep</B>()
|
|
|
|
is similar, but splits the string
|
|
<I>str</I>
|
|
|
|
into substrings separated by the delimiter
|
|
<I>delim</I>.
|
|
|
|
For example, one might use this on a UNIX search path with
|
|
delimiter ':'.
|
|
<P>
|
|
|
|
<B>argz_append</B>()
|
|
|
|
appends the argz vector
|
|
(<I>buf</I>, <I>buf_len</I>)
|
|
|
|
after
|
|
(<I>*argz</I>, <I>*argz_len</I>)
|
|
|
|
and updates
|
|
<I>*argz</I>
|
|
|
|
and
|
|
<I>*argz_len</I>.
|
|
|
|
(Thus,
|
|
<I>*argz_len</I>
|
|
|
|
will be increased by
|
|
<I>buf_len</I>.)
|
|
|
|
<P>
|
|
|
|
<B>argz_count</B>()
|
|
|
|
counts the number of strings, that is,
|
|
the number of null bytes ('\0'), in
|
|
(<I>argz</I>, <I>argz_len</I>).
|
|
|
|
<P>
|
|
|
|
<B>argz_create</B>()
|
|
|
|
converts a UNIX-style argument vector
|
|
<I>argv</I>,
|
|
|
|
terminated by
|
|
<I>(char *) 0</I>,
|
|
|
|
into an argz vector
|
|
(<I>*argz</I>, <I>*argz_len</I>).
|
|
|
|
<P>
|
|
|
|
<B>argz_create_sep</B>()
|
|
|
|
converts the null-terminated string
|
|
<I>str</I>
|
|
|
|
into an argz vector
|
|
(<I>*argz</I>, <I>*argz_len</I>)
|
|
|
|
by breaking it up at every occurrence of the separator
|
|
<I>sep</I>.
|
|
|
|
<P>
|
|
|
|
<B>argz_delete</B>()
|
|
|
|
removes the substring pointed to by
|
|
<I>entry</I>
|
|
|
|
from the argz vector
|
|
(<I>*argz</I>, <I>*argz_len</I>)
|
|
|
|
and updates
|
|
<I>*argz</I>
|
|
|
|
and
|
|
<I>*argz_len</I>.
|
|
|
|
<P>
|
|
|
|
<B>argz_extract</B>()
|
|
|
|
is the opposite of
|
|
<B>argz_create</B>().
|
|
|
|
It takes the argz vector
|
|
(<I>argz</I>, <I>argz_len</I>)
|
|
|
|
and fills the array starting at
|
|
<I>argv</I>
|
|
|
|
with pointers to the substrings, and a final NULL,
|
|
making a UNIX-style argv vector.
|
|
The array
|
|
<I>argv</I>
|
|
|
|
must have room for
|
|
<I>argz_count</I>(<I>argz</I>, <I>argz_len</I>) + 1
|
|
|
|
pointers.
|
|
<P>
|
|
|
|
<B>argz_insert</B>()
|
|
|
|
is the opposite of
|
|
<B>argz_delete</B>().
|
|
|
|
It inserts the argument
|
|
<I>entry</I>
|
|
|
|
at position
|
|
<I>before</I>
|
|
|
|
into the argz vector
|
|
(<I>*argz</I>, <I>*argz_len</I>)
|
|
|
|
and updates
|
|
<I>*argz</I>
|
|
|
|
and
|
|
<I>*argz_len</I>.
|
|
|
|
If
|
|
<I>before</I>
|
|
|
|
is NULL, then
|
|
<I>entry</I>
|
|
|
|
will inserted at the end.
|
|
<P>
|
|
|
|
<B>argz_next</B>()
|
|
|
|
is a function to step trough the argz vector.
|
|
If
|
|
<I>entry</I>
|
|
|
|
is NULL, the first entry is returned.
|
|
Otherwise, the entry
|
|
following is returned.
|
|
It returns NULL if there is no following entry.
|
|
<P>
|
|
|
|
<B>argz_replace</B>()
|
|
|
|
replaces each occurrence of
|
|
<I>str</I>
|
|
|
|
with
|
|
<I>with</I>,
|
|
|
|
reallocating argz as necessary.
|
|
If
|
|
<I>replace_count</I>
|
|
|
|
is non-NULL,
|
|
<I>*replace_count</I>
|
|
|
|
will be incremented by the number of replacements.
|
|
<P>
|
|
|
|
<B>argz_stringify</B>()
|
|
|
|
is the opposite of
|
|
<B>argz_create_sep</B>().
|
|
|
|
It transforms the argz vector into a normal string by replacing
|
|
all null bytes ('\0') except the last by
|
|
<I>sep</I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
All argz functions that do memory allocation have a return type of
|
|
<I>error_t</I>,
|
|
|
|
and return 0 for success, and
|
|
<B>ENOMEM</B>
|
|
|
|
if an allocation error occurs.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>argz_add</B>(),
|
|
|
|
<B>argz_add_sep</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>argz_append</B>(),
|
|
|
|
<B>argz_count</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>argz_create</B>(),
|
|
|
|
<B>argz_create_sep</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>argz_delete</B>(),
|
|
|
|
<B>argz_extract</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>argz_insert</B>(),
|
|
|
|
<B>argz_next</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>argz_replace</B>(),
|
|
|
|
<B>argz_stringify</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These functions are a GNU extension.
|
|
Handle with care.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
Argz vectors without a terminating null byte may lead to
|
|
Segmentation Faults.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+envz_add">envz_add</A></B>(3)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ATTRIBUTES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">BUGS</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|