1: #if defined(LIBC_SCCS) && !defined(lint)
   2: static char sccsid[] = "@(#)getenv.c	5.2 (Berkeley) 3/9/86";
   3: #endif LIBC_SCCS and not lint
   4: 
   5: /*
   6:  *	getenv(name)
   7:  *	returns ptr to value associated with name, if any, else NULL
   8:  */
   9: #define NULL    0
  10: extern  char **environ;
  11: char    *nvmatch();
  12: 
  13: char *
  14: getenv(name)
  15: register char *name;
  16: {
  17:     register char **p = environ;
  18:     register char *v;
  19: 
  20:     while (*p != NULL)
  21:         if ((v = nvmatch(name, *p++)) != NULL)
  22:             return(v);
  23:     return(NULL);
  24: }
  25: 
  26: /*
  27:  *	s1 is either name, or name=value
  28:  *	s2 is name=value
  29:  *	if names match, return value of s2, else NULL
  30:  *	used for environment searching: see getenv
  31:  */
  32: 
  33: static char *
  34: nvmatch(s1, s2)
  35: register char *s1, *s2;
  36: {
  37: 
  38:     while (*s1 == *s2++)
  39:         if (*s1++ == '=')
  40:             return(s2);
  41:     if (*s1 == '\0' && *(s2-1) == '=')
  42:         return(s2);
  43:     return(NULL);
  44: }

Defined functions

getenv defined in line 13; used 469 times
nvmatch defined in line 33; used 2 times

Defined variables

sccsid defined in line 2; never used

Defined macros

NULL defined in line 9; used 4 times
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 766
Valid CSS Valid XHTML 1.0 Strict