toaruos/libc/getenv.c

20 lines
299 B
C
Raw Normal View History

2018-02-25 08:13:54 +03:00
#include <string.h>
extern char ** environ;
2018-02-25 11:14:43 +03:00
extern int _environ_size;
2018-02-25 08:13:54 +03:00
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;
}