1 .\" $NetBSD: getenv.3,v 1.18 2005/09/25 20:08:01 christos Exp $
3 .\" Copyright (c) 1988, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the American National Standards Committee X3, on Information
8 .\" Processing Systems.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" from: @(#)getenv.3 8.2 (Berkeley) 12/11/93
36 .Dd September 25, 2005
45 .Nd environment variable functions
51 .Fn getenv "const char *name"
53 .Fn getenv_r "const char *name" "char *buf" "size_t len"
55 .Fn setenv "const char *name" "const char *value" "int overwrite"
57 .Fn putenv "const char *string"
59 .Fn unsetenv "const char *name"
61 These functions set, unset and fetch environment variables from the
63 .Em environment list .
64 For compatibility with differing environment conventions,
69 may be appended and prepended,
78 function obtains the current value of the environment variable
82 is not in the current environment, a
88 function obtains the current value of the environment variable
94 is not in the current environment, or the string length of the value of
98 characters, then \-1 is returned and
100 is set to indicate the error.
104 function inserts or resets the environment variable
106 in the current environment list.
109 does not exist in the list,
110 it is inserted with the given
112 If the variable does exist, the argument
117 variable is not reset, otherwise it is reset
123 function takes an argument of the form ``name=value'' and is
125 .Bd -literal -offset indent
126 setenv(name, value, 1);
132 deletes all instances of the variable name pointed to by
142 return zero if successful; otherwise the global variable
144 is set to indicate the error and a
149 is successful, the string returned should be considered read-only.
157 is a null pointer, points to an empty string, or points to a string
166 failed because they were unable to allocate memory for the environment.
170 can return the following errors:
175 was not found in the environment.
177 The value of the named variable is too long to fit in the supplied buffer.