1 /*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)getenv_.c 5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
11
12 /*
13 * return environment variables
14 *
15 * calling sequence:
16 * character*20 evar
17 * call getenv (ENV_NAME, evar)
18 * where:
19 * ENV_NAME is the name of an environment variable
20 * evar is a character variable which will receive
21 * the current value of ENV_NAME,
22 * or all blanks if ENV_NAME is not defined
23 */
24
25 extern char **environ;
26
getenv_(fname,value,flen,vlen)27 getenv_(fname, value, flen, vlen)
28 char *value, *fname;
29 long int vlen, flen;
30 {
31 register char *ep, *fp;
32 register char **env = environ;
33 int i;
34
35 while (ep = *env++) {
36 for (fp=fname, i=0; i <= flen; i++) {
37 if (i == flen || *fp == ' ') {
38 if (*ep++ == '=') {
39 b_char(ep, value, vlen);
40 return(0);
41 }
42 else break;
43 }
44 else if (*ep++ != *fp++) break;
45 }
46 }
47 b_char(" ", value, vlen);
48 return(0);
49 }
50