1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\" based on the description in glibc source and infopages
5 .\" Corrections and additions, aeb
6 .TH ENVZ_ADD 3 2007-05-18 "" "Linux Programmer's Manual"
8 envz_add, envz_entry, envz_get, envz_merge,
9 envz_remove, envz_strip \- environment string support
12 .B "#include <envz.h>"
14 .BI "error_t envz_add(char **" envz ", size_t *" envz_len ,
16 .BI "const char *" name ", const char *" value );
18 .BI "char *envz_entry(const char *" envz ", size_t *" envz_len \
19 ", const char *" name );
21 .BI "char *envz_get(const char *" envz ", size_t *" envz_len \
22 ", const char *" name );
24 .BI "error_t envz_merge(char **" envz ", size_t *" envz_len ,
26 .BI "const char *" envz2 ", size_t " envz2_len ", int " override );
28 .BI "void envz_remove(char **" envz ", size_t *" envz_len \
29 ", const char *" name );
31 .BI "void envz_strip(char **" envz ", size_t *" envz_len );
34 These functions are glibc-specific.
36 An argz vector is a pointer to a character buffer together with a length,
39 An envz vector is a special argz vector, namely one where the strings
40 have the form "name=value".
41 Everything after the first \(aq=\(aq is considered
43 If there is no \(aq=\(aq, the value is taken to be NULL.
44 (While the value in case of a trailing \(aq=\(aq is the empty string "".)
46 These functions are for handling envz vectors.
50 .RI \&" name = value \&"
57 is NULL) to the envz vector
58 .RI ( *envz ,\ *envz_len )
63 If an entry with the same
65 existed, it is removed.
71 .RI ( envz ,\ envz_len )
72 and returns the entry if found, or NULL if not.
78 .RI ( envz ,\ envz_len )
79 and returns the value if found, or NULL if not.
80 (Note that the value can also be NULL, namely when there is
83 without \(aq=\(aq sign.)
94 is true, then values in
96 will supersede those with the same name in
101 removes the entry for
104 .RI ( *envz ,\ *envz_len )
108 removes all entries with value NULL.
110 All envz functions that do memory allocation have a return type of
111 \fIerror_t\fP, and return 0 for success, and \fBENOMEM\fP
112 if an allocation error occurs.
114 These functions are a GNU extension.
123 main(int argc, char *argv[], char *envp[])
128 for (i = 0; envp[i] != NULL; i++)
129 e_len += strlen(envp[i]) + 1;
131 str = envz_entry(*envp, e_len, "HOME");
132 printf("%s\en", str);
133 str = envz_get(*envp, e_len, "HOME");
134 printf("%s\en", str);