1ENVZ_ADD(3)                Linux Programmer's Manual               ENVZ_ADD(3)
2
3
4

NAME

6       envz_add,  envz_entry,  envz_get, envz_merge, envz_remove, envz_strip -
7       environment string support
8

SYNOPSIS

10       #include <envz.h>
11
12       error_t envz_add(char **envz, size_t *envz_len,
13                        const char *name, const char *value);
14
15       char *envz_entry(const char *envz, size_t envz_len, const char *name);
16
17       char *envz_get(const char *envz, size_t envz_len, const char *name);
18
19       error_t envz_merge(char **envz, size_t *envz_len,
20                          const char *envz2, size_t envz2_len, int override);
21
22       void envz_remove(char **envz, size_t *envz_len, const char *name);
23
24       void envz_strip(char **envz, size_t *envz_len);
25

DESCRIPTION

27       These functions are glibc-specific.
28
29       An argz vector is a pointer to  a  character  buffer  together  with  a
30       length,  see  argz_add(3).   An  envz  vector is a special argz vector,
31       namely one where the strings have the  form  "name=value".   Everything
32       after the first '=' is considered to be the value.  If there is no '=',
33       the value is taken to be NULL.  (While the value in case of a  trailing
34       '=' is the empty string "".)
35
36       These functions are for handling envz vectors.
37
38       envz_add()  adds the string "name=value" (in case value is non-NULL) or
39       "name" (in case value is NULL) to the  envz  vector  (*envz, *envz_len)
40       and  updates  *envz  and  *envz_len.   If  an  entry with the same name
41       existed, it is removed.
42
43       envz_entry() looks for name in the  envz  vector  (envz, envz_len)  and
44       returns the entry if found, or NULL if not.
45
46       envz_get()  looks  for  name  in  the  envz vector (envz, envz_len) and
47       returns the value if found, or NULL if not.  (Note that the  value  can
48       also be NULL, namely when there is an entry for name without '=' sign.)
49
50       envz_merge()  adds each entry in envz2 to *envz, as if with envz_add().
51       If override is true, then values in envz2 will supersede those with the
52       same name in *envz, otherwise not.
53
54       envz_remove()  removes  the  entry  for name from (*envz, *envz_len) if
55       there was one.
56
57       envz_strip() removes all entries with value NULL.
58

RETURN VALUE

60       All envz functions that do memory allocation  have  a  return  type  of
61       error_t,  and  return  0 for success, and ENOMEM if an allocation error
62       occurs.
63

ATTRIBUTES

65       For  an  explanation  of  the  terms  used   in   this   section,   see
66       attributes(7).
67
68       ┌────────────────────────────┬───────────────┬─────────┐
69Interface                   Attribute     Value   
70       ├────────────────────────────┼───────────────┼─────────┤
71envz_add(), envz_entry(),   │ Thread safety │ MT-Safe │
72envz_get(), envz_merge(),   │               │         │
73envz_remove(), envz_strip() │               │         │
74       └────────────────────────────┴───────────────┴─────────┘
75

CONFORMING TO

77       These functions are a GNU extension.  Handle with care.
78

EXAMPLE

80       #include <stdio.h>
81       #include <stdlib.h>
82       #include <envz.h>
83
84       int
85       main(int argc, char *argv[], char *envp[])
86       {
87           int i, e_len = 0;
88           char *str;
89
90           for (i = 0; envp[i] != NULL; i++)
91               e_len += strlen(envp[i]) + 1;
92
93           str = envz_entry(*envp, e_len, "HOME");
94           printf("%s\n", str);
95           str = envz_get(*envp, e_len, "HOME");
96           printf("%s\n", str);
97           exit(EXIT_SUCCESS);
98       }
99

SEE ALSO

101       argz_add(3)
102

COLOPHON

104       This  page  is  part of release 5.02 of the Linux man-pages project.  A
105       description of the project, information about reporting bugs,  and  the
106       latest     version     of     this    page,    can    be    found    at
107       https://www.kernel.org/doc/man-pages/.
108
109
110
111                                  2017-09-15                       ENVZ_ADD(3)
Impressum