diff options
author | pommicket <pommicket@gmail.com> | 2022-02-15 16:36:52 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-02-15 16:36:52 -0500 |
commit | 23198d16f445e3596e6d309a5d36b144fb32e058 (patch) | |
tree | 20487184c9c0235493e7829665056a9e51a3039c /05/stdlib.h | |
parent | f973ff8cb898aafd95673cb632ac83ebbcf820c7 (diff) |
ctype.h, getenv
Diffstat (limited to '05/stdlib.h')
-rw-r--r-- | 05/stdlib.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/05/stdlib.h b/05/stdlib.h new file mode 100644 index 0000000..e98156b --- /dev/null +++ b/05/stdlib.h @@ -0,0 +1,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 |