tholm@uvicctr.UUCP (Terrence W. Holm) (08/26/88)
EFTH MINIX report #32 - August 1988 - getenv(3) There has been a different implementation of getenv(3) for each release of MINIX, as well as a couple variations posted to comp.os.minix, none of them has worked for me. Thus, I hereby distribute my coding of getenv(3). ---------------------------------------------------------- echo x - getenv.3 gres '^X' '' > getenv.3 << '/' XSUBROUTINES X getenv(3) - get an environment entry X XINVOCATION X char *getenv( name ) X char *name; X XEXPLANATION X If the entry "name=value" exists in the user environment, then X a pointer to "value" is returned. Otherwise NULL is returned. X XREFERENCES X execve(2), putenv(3), environ(4) / echo x - getenv.c gres '^X' '' > getenv.c << '/' X/* getenv(3) X * X * Author: Terrence W. Holm Aug. 1988 X */ X X#define NULL (char *) 0 X Xextern char **environ; X X Xchar *getenv( name ) X char *name; X { X char **v; X register char *n; X register char *p; X X if ( environ == (char **) NULL || name == NULL ) X return(NULL); X X for ( v = environ; *v != NULL; ++v ) X { X n = name; X p = *v; X X while ( *n == *p && *n != '\0' ) X ++n, ++p; X X if ( *n == '\0' && *p == '=' ) X return( p + 1 ); X } X X return(NULL); X } / ---------------------------------------------------------- Edwin L. Froese uw-beaver!ubc-cs!mprg!handel!froese Terrence W. Holm uw-beaver!uvicctr!tholm