getenv.c 546 B

12345678910111213141516171819202122232425262728293031
  1. /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
  2. * This file is part of the Linux-8086 C library and is distributed
  3. * under the GNU Library General Public License.
  4. */
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <malloc.h>
  8. extern char ** environ;
  9. char *
  10. getenv(var)
  11. const char * var;
  12. {
  13. char **p;
  14. int len;
  15. len = strlen(var);
  16. if (!environ)
  17. return 0;
  18. for(p=environ; *p; p++)
  19. {
  20. if( memcmp(var, *p, len) == 0 && (*p)[len] == '=' )
  21. return *p + len + 1;
  22. }
  23. return 0;
  24. }