summaryrefslogtreecommitdiff
path: root/userland/libc/stdlib/getenv.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-12-15 01:30:24 +0100
committerAnton Kling <anton@kling.gg>2024-12-15 01:30:24 +0100
commit19482e5ef5b6710b4b9a52edcb1bb39692336d7a (patch)
tree4b36953acd4ba6975a16ec57643267ac5f05b8bf /userland/libc/stdlib/getenv.c
parentfd724fc40e527a87d4e521cd704283cdf10f51c4 (diff)
libc: Add setenv/getenv
Diffstat (limited to 'userland/libc/stdlib/getenv.c')
-rw-r--r--userland/libc/stdlib/getenv.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/userland/libc/stdlib/getenv.c b/userland/libc/stdlib/getenv.c
index 0240d66..487ac76 100644
--- a/userland/libc/stdlib/getenv.c
+++ b/userland/libc/stdlib/getenv.c
@@ -1,7 +1,19 @@
#include <stdlib.h>
+#include <string.h>
+
+// Defined in stdlib/setenv.c
+struct env {
+ char *name;
+ char *value;
+ struct env *next;
+};
+
+struct env *internal_getenv(const char *name);
char *getenv(const char *name) {
- (void)name;
- // FIXME
- return NULL;
+ struct env *p = internal_getenv(name);
+ if (!p) {
+ return NULL;
+ }
+ return p->value;
}