toaruos/libc/stdlib/getenv.c
2018-05-02 19:25:03 +09:00

20 lines
293 B
C

#include <string.h>
#include <stdlib.h>
extern char ** environ;
char * getenv(const char *name) {
char ** e = environ;
size_t len = strlen(name);
while (*e) {
char * t = *e;
if (strstr(t, name) == *e) {
if (t[len] == '=') {
return &t[len+1];
}
}
e++;
}
return NULL;
}