From 8c97575c8fb93671e4ac51fa8232a1a2cfb7ad22 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 17 Apr 2025 14:57:09 -0400 Subject: Add getenv()/setenv() --- src/stdlib/stdlib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/stdlib/stdlib.c') diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c index 88553f54..a7eeb745 100644 --- a/src/stdlib/stdlib.c +++ b/src/stdlib/stdlib.c @@ -634,4 +634,15 @@ public void sleep_num(double seconds) nanosleep(&ts, NULL); } +public OptionalText_t getenv_text(Text_t name) +{ + const char *val = getenv(Text$as_c_string(name)); + return val ? Text$from_str(val) : NONE_TEXT; +} + +public void setenv_text(Text_t name, Text_t value) +{ + setenv(Text$as_c_string(name), Text$as_c_string(value), 1); +} + // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 -- cgit v1.2.3