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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [rdos/] [getenv.c] - Blame information for rev 438

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

Line No. Rev Author Line
1 148 jeremybenn
/*#######################################################################
2
# RDOS operating system
3
# Copyright (C) 1988-2006, Leif Ekblad
4
#
5
# This library is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License as published
7
# by the Free Software Foundation; either version 2.1 of the License, or
8
# (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU Lesser General Public License for more details.
14
#
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
#
19
# The author of this program may be contacted at leif@rdos.net
20
#
21
# getenv.c
22
# getenv function implementation
23
#
24
##########################################################################*/
25
 
26
/*
27
FUNCTION
28
<<getenv>>---look up environment variable
29
 
30
INDEX
31
        getenv
32
INDEX
33
        environ
34
 
35
ANSI_SYNOPSIS
36
        #include <stdlib.h>
37
        char *getenv(const char *<[name]>);
38
 
39
TRAD_SYNOPSIS
40
        #include <stdlib.h>
41
        char *getenv(<[name]>)
42
        char *<[name]>;
43
 
44
DESCRIPTION
45
<<getenv>> searches the list of environment variable names and values
46
(using the global pointer ``<<char **environ>>'') for a variable whose
47
name matches the string at <[name]>.  If a variable name matches,
48
<<getenv>> returns a pointer to the associated value.
49
 
50
RETURNS
51
A pointer to the (string) value of the environment variable, or
52
<<NULL>> if there is no such environment variable.
53
 
54
PORTABILITY
55
<<getenv>> is ANSI, but the rules for properly forming names of environment
56
variables vary from one system to another.
57
 
58
This function is not thread-safe, but does it need to be??
59
There is an reentrant class that should be used if reentrance is required
60
 
61
*/
62
 
63
#include <stdlib.h>
64
#include <stddef.h>
65
#include <string.h>
66
#include <rdos.h>
67
 
68
static char envbuf[256];
69
 
70
char *getenv(const char *name)
71
{
72
    int handle;
73
    char *ptr = 0;
74
 
75
    handle = RdosOpenSysEnv();
76
    if (handle)
77
    {
78
        if (RdosFindEnvVar(handle, name, envbuf))
79
            ptr = envbuf;
80
    }
81
    RdosCloseEnv(handle);
82
    return ptr;
83
}

powered by: WebSVN 2.1.0

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