OSDN Git Service

Initial revision
[uclinux-h8/uClibc.git] / libc / stdlib / getenv.c
1 /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
2  * This file is part of the Linux-8086 C library and is distributed
3  * under the GNU Library General Public License.
4  */
5 #include <string.h>
6 #include <stdlib.h>
7 #include <malloc.h>
8
9 extern char ** environ;
10
11 char *
12 getenv(var)
13 const char * var;
14 {
15    char **p;
16    int len;
17
18    len = strlen(var);
19    
20    if (!environ)
21       return 0;
22
23    for(p=environ; *p; p++)
24    {
25       if( memcmp(var, *p, len) == 0 && (*p)[len] == '=' )
26          return *p + len + 1;
27    }
28    return 0;
29 }
30
31