getenv.c (282B)
1 #include <stdlib.h> 2 #include <string.h> 3 #undef getenv 4 5 extern char **_environ; 6 7 char * 8 getenv(const char *name) 9 { 10 char **p, *s; 11 size_t len = strlen(name); 12 13 for (p = _environ; s = *p; ++p) { 14 if (!strncmp(name, s, len) && s[len] == '=') 15 return s + len + 1; 16 } 17 return NULL; 18 }