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

Defined functions

getenv defined in line 10; used 105 times
nvmatch defined in line 30; used 2 times
  • in line 8, 18

Defined macros

NULL defined in line 6; used 4 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 840
Valid CSS Valid XHTML 1.0 Strict