1 /*
2 FUNCTION
3 <<getenv>>---look up environment variable
4
5 INDEX
6 getenv
7 INDEX
8 environ
9
10 SYNOPSIS
11 #include <stdlib.h>
12 char *getenv(const char *<[name]>);
13
14 DESCRIPTION
15 <<getenv>> searches the list of environment variable names and values
16 (using the global pointer ``<<char **environ>>'') for a variable whose
17 name matches the string at <[name]>. If a variable name matches,
18 <<getenv>> returns a pointer to the associated value.
19
20 RETURNS
21 A pointer to the (string) value of the environment variable, or
22 <<NULL>> if there is no such environment variable.
23
24 PORTABILITY
25 <<getenv>> is ANSI, but the rules for properly forming names of environment
26 variables vary from one system to another.
27
28 <<getenv>> requires a global pointer <<environ>>.
29 */
30
31 /*
32 * Copyright (c) 1987, 2000 Regents of the University of California.
33 * All rights reserved.
34 *
35 * Redistribution and use in source and binary forms are permitted
36 * provided that: (1) source distributions retain this entire copyright
37 * notice and comment, and (2) distributions including binaries display
38 * the following acknowledgement: ``This product includes software
39 * developed by the University of California, Berkeley and its contributors''
40 * in the documentation or other materials provided with the distribution.
41 * Neither the name of the University nor the names of its
42 * contributors may be used to endorse or promote products derived
43 * from this software without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
45 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
46 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
47 */
48
49 #ifndef _REENT_ONLY
50
51 #include <stdlib.h>
52 #include <stddef.h>
53 #include <string.h>
54
55 /*
56 * getenv --
57 * Returns ptr to value associated with name, if any, else NULL.
58 */
59
60 char *
getenv(const char * name)61 getenv (const char *name)
62 {
63 int offset;
64
65 return _findenv (name, &offset);
66 }
67
68 #endif /* !_REENT_ONLY */
69