2 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
4 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\" based on the description in glibc source and infopages
8 .\" Corrections and additions, aeb
9 .TH envz_add 3 (date) "Linux man-pages (unreleased)"
11 envz_add, envz_entry, envz_get, envz_merge,
12 envz_remove, envz_strip \- environment string support
15 .RI ( libc ", " \-lc )
20 .BI "error_t envz_add(char **restrict " envz ", size_t *restrict " envz_len ,
21 .BI " const char *restrict " name \
22 ", const char *restrict " value );
24 .BI "char *envz_entry(const char *restrict " envz ", size_t " envz_len ,
25 .BI " const char *restrict " name );
27 .BI "char *envz_get(const char *restrict " envz ", size_t " envz_len ,
28 .BI " const char *restrict " name );
30 .BI "error_t envz_merge(char **restrict " envz ", size_t *restrict " envz_len ,
31 .BI " const char *restrict " envz2 ", size_t " envz2_len ,
32 .BI " int " override );
34 .BI "void envz_remove(char **restrict " envz ", size_t *restrict " envz_len ,
35 .BI " const char *restrict " name );
37 .BI "void envz_strip(char **restrict " envz ", size_t *restrict " envz_len );
40 These functions are glibc-specific.
42 An argz vector is a pointer to a character buffer together with a length,
45 An envz vector is a special argz vector, namely one where the strings
46 have the form "name=value".
47 Everything after the first \[aq]=\[aq] is considered
49 If there is no \[aq]=\[aq], the value is taken to be NULL.
50 (While the value in case of a trailing \[aq]=\[aq] is the empty string "".)
52 These functions are for handling envz vectors.
56 .RI \&" name = value \&"
63 is NULL) to the envz vector
64 .RI ( *envz ,\ *envz_len )
69 If an entry with the same
71 existed, it is removed.
77 .RI ( envz ,\ envz_len )
78 and returns the entry if found, or NULL if not.
84 .RI ( envz ,\ envz_len )
85 and returns the value if found, or NULL if not.
86 (Note that the value can also be NULL, namely when there is
89 without \[aq]=\[aq] sign.)
100 is true, then values in
102 will supersede those with the same name in
107 removes the entry for
110 .RI ( *envz ,\ *envz_len )
114 removes all entries with value NULL.
116 All envz functions that do memory allocation have a return type of
119 and return 0 for success, and
121 if an allocation error occurs.
123 For an explanation of the terms used in this section, see
131 Interface Attribute Value
139 T} Thread safety MT-Safe
145 These functions are a GNU extension.
147 .\" SRC BEGIN (envz_add.c)
154 main(int argc, char *argv[], char *envp[])
159 for (size_t i = 0; envp[i] != NULL; i++)
160 e_len += strlen(envp[i]) + 1;
162 str = envz_entry(*envp, e_len, "HOME");
163 printf("%s\en", str);
164 str = envz_get(*envp, e_len, "HOME");
165 printf("%s\en", str);