1*47944Sbostic /*-
2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic * All rights reserved.
42526Sdlw *
5*47944Sbostic * %sccs.include.proprietary.c%
623022Skre */
723022Skre
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)getenv_.c 5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic
1223022Skre /*
132526Sdlw * return environment variables
142526Sdlw *
152526Sdlw * calling sequence:
162526Sdlw * character*20 evar
172526Sdlw * call getenv (ENV_NAME, evar)
182526Sdlw * where:
192526Sdlw * ENV_NAME is the name of an environment variable
202526Sdlw * evar is a character variable which will receive
212526Sdlw * the current value of ENV_NAME,
222526Sdlw * or all blanks if ENV_NAME is not defined
232526Sdlw */
242526Sdlw
252526Sdlw extern char **environ;
262526Sdlw
getenv_(fname,value,flen,vlen)272526Sdlw getenv_(fname, value, flen, vlen)
282526Sdlw char *value, *fname;
292526Sdlw long int vlen, flen;
302526Sdlw {
312526Sdlw register char *ep, *fp;
322526Sdlw register char **env = environ;
332526Sdlw int i;
342526Sdlw
352526Sdlw while (ep = *env++) {
362526Sdlw for (fp=fname, i=0; i <= flen; i++) {
372526Sdlw if (i == flen || *fp == ' ') {
382526Sdlw if (*ep++ == '=') {
392526Sdlw b_char(ep, value, vlen);
402526Sdlw return(0);
412526Sdlw }
422526Sdlw else break;
432526Sdlw }
442526Sdlw else if (*ep++ != *fp++) break;
452526Sdlw }
462526Sdlw }
472526Sdlw b_char(" ", value, vlen);
482526Sdlw return(0);
492526Sdlw }
50