Back to index

wims  3.65+svn20090927
setenv.c
Go to the documentation of this file.
00001 #include "../config.h"
00002 
00003 #ifndef HAVE_SETENV
00004 #include <stdlib.h>
00005 #include <stdio.h>
00006 extern void *xmalloc(size_t n);
00007 int setenv(const char *name, const char *value, int overwrite)
00008 {
00009   char *s;
00010   if (!overwrite && getenv(name)) return 0;
00011   s = xmalloc(2 + strlen(name) + strlen(value));
00012   sprintf(s, "%s=%s", name,value);
00013   return putenv(s);
00014 }
00015 
00016 /* putenv("FOO=") should remove FOO from environment */
00017 void unsetenv(const char *name) { setenv(name,"",1); }
00018 #endif