Commit | Line | Data |
---|---|---|
82492b51 KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
d1b03754 | 4 | * |
ad787160 C |
5 | * This module is believed to contain source code proprietary to AT&T. |
6 | * Use and redistribution is subject to the Berkeley Software License | |
7 | * Agreement and your Software Agreement with AT&T (Western Electric). | |
161423a6 RE |
8 | */ |
9 | ||
82492b51 | 10 | #ifndef lint |
ad787160 | 11 | static char sccsid[] = "@(#)getenv_.c 5.2 (Berkeley) 4/12/91"; |
82492b51 KB |
12 | #endif /* not lint */ |
13 | ||
161423a6 | 14 | /* |
d1b03754 DW |
15 | * return environment variables |
16 | * | |
17 | * calling sequence: | |
18 | * character*20 evar | |
19 | * call getenv (ENV_NAME, evar) | |
20 | * where: | |
21 | * ENV_NAME is the name of an environment variable | |
22 | * evar is a character variable which will receive | |
23 | * the current value of ENV_NAME, | |
24 | * or all blanks if ENV_NAME is not defined | |
25 | */ | |
26 | ||
27 | extern char **environ; | |
28 | ||
29 | getenv_(fname, value, flen, vlen) | |
30 | char *value, *fname; | |
31 | long int vlen, flen; | |
32 | { | |
33 | register char *ep, *fp; | |
34 | register char **env = environ; | |
35 | int i; | |
36 | ||
37 | while (ep = *env++) { | |
38 | for (fp=fname, i=0; i <= flen; i++) { | |
39 | if (i == flen || *fp == ' ') { | |
40 | if (*ep++ == '=') { | |
41 | b_char(ep, value, vlen); | |
42 | return(0); | |
43 | } | |
44 | else break; | |
45 | } | |
46 | else if (*ep++ != *fp++) break; | |
47 | } | |
48 | } | |
49 | b_char(" ", value, vlen); | |
50 | return(0); | |
51 | } |