toaruos/libc/getenv.c
2018-02-25 17:14:43 +09:00

20 lines
299 B
C

#include <string.h>
extern char ** environ;
extern int _environ_size;
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;
}