OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [getenv.c] - Blame information for rev 56

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
FUNCTION
3
<<getenv>>---look up environment variable
4
 
5
INDEX
6
        getenv
7
INDEX
8
        environ
9
 
10
ANSI_SYNOPSIS
11
        #include <stdlib.h>
12
        char *getenv(const char *<[name]>);
13
 
14
TRAD_SYNOPSIS
15
        #include <stdlib.h>
16
        char *getenv(<[name]>)
17
        char *<[name]>;
18
 
19
DESCRIPTION
20
<<getenv>> searches the list of environment variable names and values
21
(using the global pointer `<<char **environ>>') for a variable whose
22
name matches the string at <[name]>.  If a variable name matches,
23
<<getenv>> returns a pointer to the associated value.
24
 
25
RETURNS
26
A pointer to the (string) value of the environment variable, or
27
<<NULL>> if there is no such environment variable.
28
 
29
PORTABILITY
30
<<getenv>> is ANSI, but the rules for properly forming names of environment
31
variables vary from one system to another.
32
 
33
<<getenv>> requires a global pointer <<environ>>.
34
*/
35
 
36
/* This file may have been modified by DJ Delorie (Jan 1991).  If so,
37
** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
38
** Rochester NH, 03867-2954, USA.
39
*/
40
 
41
/*
42
 * Copyright (c) 1987 Regents of the University of California.
43
 * All rights reserved.
44
 *
45
 * Redistribution and use in source and binary forms are permitted
46
 * provided that: (1) source distributions retain this entire copyright
47
 * notice and comment, and (2) distributions including binaries display
48
 * the following acknowledgement:  ``This product includes software
49
 * developed by the University of California, Berkeley and its contributors''
50
 * in the documentation or other materials provided with the distribution
51
 * and in all advertising materials mentioning features or use of this
52
 * software. Neither the name of the University nor the names of its
53
 * contributors may be used to endorse or promote products derived
54
 * from this software without specific prior written permission.
55
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
56
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
57
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
58
 */
59
 
60
#include <stdlib.h>
61
#include <stddef.h>
62
#include <string.h>
63
 
64
extern char **environ;
65
 
66
/*
67
 * _findenv --
68
 *      Returns pointer to value associated with name, if any, else NULL.
69
 *      Sets offset to be the offset of the name/value combination in the
70
 *      environmental array, for use by setenv(3) and unsetenv(3).
71
 *      Explicitly removes '=' in argument name.
72
 *
73
 *      This routine *should* be a static; don't use it.
74
 */
75
 
76
char *
77
_DEFUN (_findenv, (name, offset),
78
        register _CONST char *name _AND
79
        int *offset)
80
{
81 56 joel
  return _findenv_r (_REENT, name, offset);
82 39 lampret
}
83
 
84
/*
85
 * getenv --
86
 *      Returns ptr to value associated with name, if any, else NULL.
87
 */
88
 
89
char *
90
_DEFUN (getenv, (name),
91
        _CONST char *name)
92
{
93
  int offset;
94 56 joel
  char *_findenv_r ();
95 39 lampret
 
96 56 joel
  return _findenv_r (_REENT, name, &offset);
97 39 lampret
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.