]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/envz_add.3
fuse.4: fuse_entry_out: rework discussion of uniqueness of nodeid + generation
[thirdparty/man-pages.git] / man3 / envz_add.3
CommitLineData
fea681da 1.\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2297bf0e 2.\"
38f20bb9 3.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
fea681da 4.\" Distributed under GPL
38f20bb9 5.\" %%%LICENSE_END
0389adc9 6.\"
fea681da 7.\" based on the description in glibc source and infopages
c13182ef 8.\"
fea681da 9.\" Corrections and additions, aeb
fe0fefbf 10.TH ENVZ_ADD 3 2015-03-02 "" "Linux Programmer's Manual"
fea681da
MK
11.SH NAME
12envz_add, envz_entry, envz_get, envz_merge,
13envz_remove, envz_strip \- environment string support
14.SH SYNOPSIS
15.nf
fea681da 16.B "#include <envz.h>"
98488604 17
e7c0f078 18.BI "error_t envz_add(char **" envz ", size_t *" envz_len ,
dcf163b9 19.BI " const char *" name ", const char *" value );
98488604 20
5c1d7bca 21.BI "char *envz_entry(const char *" envz ", size_t " envz_len \
e7c0f078 22", const char *" name );
98488604 23
5c1d7bca 24.BI "char *envz_get(const char *" envz ", size_t " envz_len \
e7c0f078 25", const char *" name );
98488604 26
e7c0f078 27.BI "error_t envz_merge(char **" envz ", size_t *" envz_len ,
dcf163b9
MK
28.BI " const char *" envz2 ", size_t " envz2_len \
29", int " override );
98488604 30
e7c0f078
MK
31.BI "void envz_remove(char **" envz ", size_t *" envz_len \
32", const char *" name );
98488604 33
e7c0f078 34.BI "void envz_strip(char **" envz ", size_t *" envz_len );
c8250206 35.fi
fea681da 36.SH DESCRIPTION
8382f16d 37These functions are glibc-specific.
fea681da
MK
38.LP
39An argz vector is a pointer to a character buffer together with a length,
40see
41.BR argz_add (3).
42An envz vector is a special argz vector, namely one where the strings
c13182ef 43have the form "name=value".
f81fb444 44Everything after the first \(aq=\(aq is considered
c13182ef 45to be the value.
f81fb444
MK
46If there is no \(aq=\(aq, the value is taken to be NULL.
47(While the value in case of a trailing \(aq=\(aq is the empty string "".)
fea681da
MK
48.LP
49These functions are for handling envz vectors.
50.LP
63aa9df0 51.BR envz_add ()
fea681da
MK
52adds the string
53.RI \&" name = value \&"
54(in case
55.I value
56is non-NULL) or
57.RI \&" name \&"
58(in case
59.I value
60is NULL) to the envz vector
e7c0f078 61.RI ( *envz ,\ *envz_len )
fea681da 62and updates
e7c0f078 63.I *envz
fea681da 64and
e7c0f078 65.IR *envz_len .
fea681da
MK
66If an entry with the same
67.I name
68existed, it is removed.
69.LP
63aa9df0 70.BR envz_entry ()
fea681da
MK
71looks for
72.I name
73in the envz vector
e7c0f078 74.RI ( envz ,\ envz_len )
fea681da
MK
75and returns the entry if found, or NULL if not.
76.LP
63aa9df0 77.BR envz_get ()
fea681da
MK
78looks for
79.I name
80in the envz vector
e7c0f078 81.RI ( envz ,\ envz_len )
fea681da
MK
82and returns the value if found, or NULL if not.
83(Note that the value can also be NULL, namely when there is
84an entry for
85.I name
f81fb444 86without \(aq=\(aq sign.)
fea681da 87.LP
63aa9df0 88.BR envz_merge ()
fea681da
MK
89adds each entry in
90.I envz2
91to
e7c0f078 92.IR *envz ,
fea681da 93as if with
63aa9df0 94.BR envz_add ().
fea681da
MK
95If
96.I override
97is true, then values in
98.I envz2
99will supersede those with the same name in
e7c0f078 100.IR *envz ,
fea681da
MK
101otherwise not.
102.LP
63aa9df0 103.BR envz_remove ()
fea681da
MK
104removes the entry for
105.I name
106from
e7c0f078 107.RI ( *envz ,\ *envz_len )
fea681da
MK
108if there was one.
109.LP
e511ffb6 110.BR envz_strip ()
fea681da 111removes all entries with value NULL.
47297adb 112.SH RETURN VALUE
fea681da 113All envz functions that do memory allocation have a return type of
c6fa0841
MK
114.IR error_t ,
115and return 0 for success, and
116.B ENOMEM
fea681da 117if an allocation error occurs.
29a663f7
MS
118.SH ATTRIBUTES
119For an explanation of the terms used in this section, see
120.BR attributes (7).
121.TS
122allbox;
123lbw27 lb lb
124l l l.
125Interface Attribute Value
126T{
127.BR envz_add (),
128.BR envz_entry (),
129.br
130.BR envz_get (),
131.BR envz_merge (),
132.br
133.BR envz_remove (),
134.BR envz_strip ()
135T} Thread safety MT-Safe
136.TE
137
47297adb 138.SH CONFORMING TO
2b2581ee
MK
139These functions are a GNU extension.
140Handle with care.
fea681da 141.SH EXAMPLE
fea681da
MK
142.nf
143#include <stdio.h>
af9c7ff2 144#include <stdlib.h>
fea681da 145#include <envz.h>
cf0a9ace 146
fea681da 147int
cf0a9ace
MK
148main(int argc, char *argv[], char *envp[])
149{
150 int i, e_len = 0;
151 char *str;
fea681da 152
22a33e86 153 for (i = 0; envp[i] != NULL; i++)
cf0a9ace 154 e_len += strlen(envp[i]) + 1;
fea681da 155
cf0a9ace 156 str = envz_entry(*envp, e_len, "HOME");
31a6818e 157 printf("%s\en", str);
cf0a9ace 158 str = envz_get(*envp, e_len, "HOME");
31a6818e 159 printf("%s\en", str);
5bc8c34c 160 exit(EXIT_SUCCESS);
fea681da
MK
161}
162.fi
47297adb 163.SH SEE ALSO
d122bd56 164.BR argz_add (3)