1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
7 .\" based on the description in glibc source and infopages
9 .\" Corrections and additions, aeb
10 .TH ENVZ_ADD 3 2021-03-22 "" "Linux Programmer's Manual"
12 envz_add, envz_entry, envz_get, envz_merge,
13 envz_remove, envz_strip \- environment string support
16 .B "#include <envz.h>"
18 .BI "error_t envz_add(char **restrict " envz ", size_t *restrict " envz_len ,
19 .BI " const char *restrict " name \
20 ", const char *restrict " value );
22 .BI "char *envz_entry(const char *restrict " envz ", size_t " envz_len ,
23 .BI " const char *restrict " name );
25 .BI "char *envz_get(const char *restrict " envz ", size_t " envz_len ,
26 .BI " const char *restrict " name );
28 .BI "error_t envz_merge(char **restrict " envz ", size_t *restrict " envz_len ,
29 .BI " const char *restrict " envz2 ", size_t " envz2_len ,
30 .BI " int " override );
32 .BI "void envz_remove(char **restrict " envz ", size_t *restrict " envz_len ,
33 .BI " const char *restrict " name );
35 .BI "void envz_strip(char **restrict " envz ", size_t *restrict " envz_len );
38 These functions are glibc-specific.
40 An argz vector is a pointer to a character buffer together with a length,
43 An envz vector is a special argz vector, namely one where the strings
44 have the form "name=value".
45 Everything after the first \(aq=\(aq is considered
47 If there is no \(aq=\(aq, the value is taken to be NULL.
48 (While the value in case of a trailing \(aq=\(aq is the empty string "".)
50 These functions are for handling envz vectors.
54 .RI \&" name = value \&"
61 is NULL) to the envz vector
62 .RI ( *envz ,\ *envz_len )
67 If an entry with the same
69 existed, it is removed.
75 .RI ( envz ,\ envz_len )
76 and returns the entry if found, or NULL if not.
82 .RI ( envz ,\ envz_len )
83 and returns the value if found, or NULL if not.
84 (Note that the value can also be NULL, namely when there is
87 without \(aq=\(aq sign.)
98 is true, then values in
100 will supersede those with the same name in
105 removes the entry for
108 .RI ( *envz ,\ *envz_len )
112 removes all entries with value NULL.
114 All envz functions that do memory allocation have a return type of
117 and return 0 for success, and
119 if an allocation error occurs.
121 For an explanation of the terms used in this section, see
129 Interface Attribute Value
137 T} Thread safety MT-Safe
143 These functions are a GNU extension.
151 main(int argc, char *argv[], char *envp[])
156 for (int i = 0; envp[i] != NULL; i++)
157 e_len += strlen(envp[i]) + 1;
159 str = envz_entry(*envp, e_len, "HOME");
160 printf("%s\en", str);
161 str = envz_get(*envp, e_len, "HOME");
162 printf("%s\en", str);