source: trunk/libs/newlib/src/newlib/libc/stdlib/getenv.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.4 KB
Line 
1/*
2FUNCTION
3<<getenv>>---look up environment variable
4
5INDEX
6        getenv
7INDEX
8        environ
9
10SYNOPSIS
11        #include <stdlib.h>
12        char *getenv(const char *<[name]>);
13
14DESCRIPTION
15<<getenv>> searches the list of environment variable names and values
16(using the global pointer ``<<char **environ>>'') for a variable whose
17name matches the string at <[name]>.  If a variable name matches,
18<<getenv>> returns a pointer to the associated value.
19
20RETURNS
21A pointer to the (string) value of the environment variable, or
22<<NULL>> if there is no such environment variable.
23
24PORTABILITY
25<<getenv>> is ANSI, but the rules for properly forming names of environment
26variables 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 * and in all advertising materials mentioning features or use of this
42 * software. Neither the name of the University nor the names of its
43 * contributors may be used to endorse or promote products derived
44 * from this software without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
47 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
48 */
49
50#ifndef _REENT_ONLY
51
52#include <stdlib.h>
53#include <stddef.h>
54#include <string.h>
55
56/*
57 * _findenv --
58 *      Returns pointer to value associated with name, if any, else NULL.
59 *      Sets offset to be the offset of the name/value combination in the
60 *      environmental array, for use by setenv(3) and unsetenv(3).
61 *      Explicitly removes '=' in argument name.
62 *
63 *      This routine *should* be a static; don't use it.
64 */
65
66char *
67_findenv (register const char *name,
68        int *offset)
69{
70  return _findenv_r (_REENT, name, offset);
71}
72
73/*
74 * getenv --
75 *      Returns ptr to value associated with name, if any, else NULL.
76 */
77
78char *
79getenv (const char *name)
80{
81  int offset;
82
83  return _findenv_r (_REENT, name, &offset);
84}
85
86#endif /* !_REENT_ONLY */
Note: See TracBrowser for help on using the repository browser.