getenv.c 564 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Header$ */
  6. #include <stdlib.h>
  7. extern char **environ;
  8. char *
  9. getenv(const char *name)
  10. {
  11. register char **v = environ;
  12. register char *p, *q;
  13. if (v == (char **)NULL || name == (char *)NULL)
  14. return (char *)NULL;
  15. while ((p = *v++) != (char *)NULL) {
  16. q = name;
  17. while (*q && (*q++ == *p++))
  18. /* EMPTY */ ;
  19. if (*q || (*p != '='))
  20. continue;
  21. return(p+1);
  22. }
  23. return((char *)NULL);
  24. }