summaryrefslogtreecommitdiff
path: root/05/stdlib.h
blob: e98156ba764092348f9c8def252b5bae124869c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _STDLIB_H
#define _STDLIB_H

#include <stdc_common.h>

char *getenv(const char *name) {
	int i, j;
	for (i = 0; _envp[i]; ++i) {
		char *key = _envp[i];
		for (j = 0; key[j] != '=' && name[j]; ++j)
			if (name[j] != key[j])
				break;
		if (key[j] == '=' && !name[j])
			return key + (j+1);
	}
	return NULL;
}

#endif // _STDLIB_H