Files
heimdal/lib/roken/setenv.c
Unknown User d91-jda 89af9ddeda Add libbroken.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@417 ec53bebd-3082-4978-b11e-865c3cabbd6b
1996-04-23 07:15:17 +00:00

32 lines
538 B
C

#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;
}