diff options
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/stdlib.c | 11 | ||||
| -rw-r--r-- | src/stdlib/stdlib.h | 2 |
2 files changed, 13 insertions, 0 deletions
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 diff --git a/src/stdlib/stdlib.h b/src/stdlib/stdlib.h index a452a04b..c4bf83e0 100644 --- a/src/stdlib/stdlib.h +++ b/src/stdlib/stdlib.h @@ -93,5 +93,7 @@ _Noreturn void tomo_exit(Text_t text, int32_t status); Closure_t spawn(Closure_t fn); bool pop_flag(char **argv, int *i, const char *flag, Text_t *result); void sleep_num(double seconds); +OptionalText_t getenv_text(Text_t name); +void setenv_text(Text_t name, Text_t value); // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
