Add libbroken.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@417 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
31
lib/roken/setenv.c
Normal file
31
lib/roken/setenv.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
/*
|
||||
* This is the easy way out, use putenv to implement setenv. We might
|
||||
* leak some memory but that is ok since we are usally about to exec
|
||||
* anyway.
|
||||
*/
|
||||
|
||||
int
|
||||
setenv(const char *var, const char *val, int rewrite)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (!rewrite && getenv(var) != 0)
|
||||
return 0;
|
||||
|
||||
if ((t = malloc(strlen(var) + strlen(val) + 2)) == 0)
|
||||
return -1;
|
||||
|
||||
strcpy(t, var);
|
||||
strcat(t, "=");
|
||||
strcat(t, val);
|
||||
if (putenv(t) == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
Reference in New Issue
Block a user