Add setenv() to libroken

This commit is contained in:
Asanka Herath
2009-09-01 16:32:10 -04:00
committed by Love Hornquist Astrand
parent 649a929a54
commit 28023be15a
2 changed files with 13 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ libroken_la_OBJS = \
$(OBJ)\roken_gethostby.obj \
$(OBJ)\rtbl.obj \
$(OBJ)\sendmsg_w32.obj \
$(OBJ)\setenv.obj \
$(OBJ)\setprogname.obj \
$(OBJ)\simple_exec_w32.obj \
$(OBJ)\sleep.obj \

View File

@@ -47,6 +47,7 @@
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
setenv(const char *var, const char *val, int rewrite)
{
#ifndef _WIN32
char *t;
if (!rewrite && getenv(var) != 0)
@@ -60,4 +61,15 @@ setenv(const char *var, const char *val, int rewrite)
return 0;
else
return -1;
#else /* Win32 */
char dummy[8];
if (!rewrite && GetEnvironmentVariable(var, dummy, sizeof(dummy)/sizeof(char)) != 0)
return 0;
if (SetEnvironmentVariable(var, val) == 0)
return -1;
else
return 0;
#endif
}