Wed May 1 09:10:04 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[platform/upstream/glibc.git] / string / envz.h
1 /* Routines for dealing with '\0' separated environment vectors
2
3    Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4
5    Written by Miles Bader <miles@gnu.ai.mit.edu>
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #ifndef __ENVZ_H__
22 #define __ENVZ_H__
23
24 #include <errno.h>
25
26 /* Envz's are argz's too, and should be created etc., using the same
27    routines.  */
28 #include <argz.h>
29
30 /* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none.  */
31 char *envz_entry (const char *envz, size_t envz_len, const char *name);
32
33 /* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0
34    if there is none.  */
35 char *envz_get (const char *envz, size_t envz_len, const char *name);
36
37 /* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN.  If an entry
38    with the same name already exists in ENVZ, it is removed.  If VALUE is
39    NULL, then the new entry will a special null one, for which envz_get will
40    return NULL, although envz_entry will still return an entry; this is handy
41    because when merging with another envz, the null entry can override an
42    entry in the other one.  Null entries can be removed with envz_strip ().  */
43 error_t envz_add (char **envz, size_t *envz_len,
44                   const char *name, const char *value);
45
46 /* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add().  If
47    OVERRIDE is true, then values in ENVZ2 will supercede those with the same
48    name in ENV, otherwise not.  */
49 error_t envz_merge (char **envz, size_t *envz_len,
50                     const char *envz2, size_t envz2_len,
51                     int override);
52
53 /* Remove null entries.  */
54 void envz_strip (char **envz, size_t *envz_len);
55
56 #endif /* __ENVZ_H__ */