Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / libcc.ansi / stdlib / getenv.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 /* $Id: getenv.c,v 1.5 1994/06/24 11:53:40 ceriel Exp $ */
6
7 #include        <stdlib.h>
8
9 extern const char **_penvp;
10
11 char *
12 getenv(const char *name)
13 {
14         register const char **v = _penvp;
15         register const char *p, *q;
16
17         if (v == NULL || name == NULL)
18                 return (char *)NULL;
19         while ((p = *v++) != NULL) {
20                 q = name;
21                 while (*q && (*q == *p++))
22                         q++;
23                 if (*q || (*p != '='))
24                         continue;
25                 return (char *)p + 1;
26         }
27         return (char *)NULL;
28 }