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
13 .B "#include <envz.h>"
15 .BI "error_t envz_add(char **" envz ", size_t *" envz_len ,
17 .BI "const char *" name ", const char *" value );
19 .BI "char *envz_entry(const char *" envz ", size_t *" envz_len \
20 ", const char *" name );
22 .BI "char *envz_get(const char *" envz ", size_t *" envz_len \
23 ", const char *" name );
25 .BI "error_t envz_merge(char **" envz ", size_t *" envz_len ,
27 .BI "const char *" envz2 ", size_t " envz2_len ", int " override );
29 .BI "void envz_remove(char **" envz ", size_t *" envz_len \
30 ", const char *" name );
32 .BI "void envz_strip(char **" envz ", size_t *" envz_len );
35 These functions are glibc-specific.
37 An argz vector is a pointer to a character buffer together with a length,
40 An envz vector is a special argz vector, namely one where the strings
41 have the form "name=value".
42 Everything after the first '=' is considered
44 If there is no '=', the value is taken to be NULL.
45 (While the value in case of a trailing '=' is the empty string "".)
47 These functions are for handling envz vectors.
51 .RI \&" name = value \&"
58 is NULL) to the envz vector
59 .RI ( *envz ,\ *envz_len )
64 If an entry with the same
66 existed, it is removed.
72 .RI ( envz ,\ envz_len )
73 and returns the entry if found, or NULL if not.
79 .RI ( envz ,\ envz_len )
80 and returns the value if found, or NULL if not.
81 (Note that the value can also be NULL, namely when there is
95 is true, then values in
97 will supersede those with the same name in
102 removes the entry for
105 .RI ( *envz ,\ *envz_len )
109 removes all entries with value NULL.
111 All envz functions that do memory allocation have a return type of
112 \fIerror_t\fP, and return 0 for success, and \fBENOMEM\fP
113 if an allocation error occurs.
115 These functions are a GNU extension.
125 main(int argc, char *argv[], char *envp[])
130 for (i=0; envp[i] != NULL; i++)
131 e_len += strlen(envp[i]) + 1;
133 str = envz_entry(*envp, e_len, "HOME");
134 printf("%s\en", str);
135 str = envz_get(*envp, e_len, "HOME");
136 printf("%s\en", str);