Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / getenv.c
blob9ccb9038363fe271d6336b27047e263406c76820
1 /*
2 FUNCTION
3 <<getenv>>---look up environment variable
5 INDEX
6 getenv
7 INDEX
8 environ
10 SYNOPSIS
11 #include <stdlib.h>
12 char *getenv(const char *<[name]>);
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.
20 RETURNS
21 A pointer to the (string) value of the environment variable, or
22 <<NULL>> if there is no such environment variable.
24 PORTABILITY
25 <<getenv>> is ANSI, but the rules for properly forming names of environment
26 variables vary from one system to another.
28 <<getenv>> requires a global pointer <<environ>>.
32 * Copyright (c) 1987, 2000 Regents of the University of California.
33 * All rights reserved.
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.
49 #ifndef _REENT_ONLY
51 #include <stdlib.h>
52 #include <stddef.h>
53 #include <string.h>
56 * _findenv --
57 * Returns pointer to value associated with name, if any, else NULL.
58 * Sets offset to be the offset of the name/value combination in the
59 * environmental array, for use by setenv(3) and unsetenv(3).
60 * Explicitly removes '=' in argument name.
62 * This routine *should* be a static; don't use it.
65 char *
66 _findenv (register const char *name,
67 int *offset)
69 return _findenv_r (_REENT, name, offset);
73 * getenv --
74 * Returns ptr to value associated with name, if any, else NULL.
77 char *
78 getenv (const char *name)
80 int offset;
82 return _findenv_r (_REENT, name, &offset);
85 #endif /* !_REENT_ONLY */