From 808c5e28c0e8bc7a397eb2ffd1e77ee7a53061a6 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 30 Sep 2009 00:36:47 +0000 Subject: * driver/Makefile.in (open-axiom): Link against core runtime. * driver/main.c (publish_systemdir): Rework. * include/cfuns.h (oa_setenv): Declare. * lib/cfuns-c.c (oa_setenv): Define. --- src/lib/cfuns-c.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/lib') diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index 63758092..7562874a 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -552,6 +552,25 @@ oa_getenv(const char* var) #endif } +/* Set the value of environment variable VAR to VAL. + Return 1 on success, and 0 otherwise. */ +OPENAXIOM_EXPORT int +oa_setenv(const char* var, const char* val) +{ +#ifdef __WIN32__ + return SetEnvironmentVariable(var, val); +#else + const int var_length = strlen(var); + const int val_length = strlen(val); + char* str = (char*) malloc(var_length + 1 + val_length + 1); + strcpy(str, var); + str[var_length] = '='; + strcpy(str + var_length + 1, val); + str[var_length + 1 + val_length] = '\0'; + return !putenv(str); +#endif +} + OPENAXIOM_EXPORT char* oa_getcwd(void) -- cgit v1.2.3