aboutsummaryrefslogtreecommitdiff
path: root/src/env/getenv.c
blob: 076a3c3f229f79f6681a0072af217071a0bd0080 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

char *getenv(const char *name)
{
	size_t l = __strchrnul(name, '=') - name;
	if (l && !name[l] && __environ)
		for (char **e = __environ; *e; e++)
			if (!strncmp(name, *e, l) && l[*e] == '=')
				return *e + l+1;
	return 0;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif