2005-12-26 03:16:48 +00:00
|
|
|
/* setenv implementation for systems lacking it. */
|
|
|
|
|
2007-01-10 17:22:52 +00:00
|
|
|
#include "config.h"
|
2005-12-26 03:16:48 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifndef MP_DEBUG
|
|
|
|
#define NDEBUG
|
|
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
int setenv(const char *name, const char *val, int overwrite)
|
|
|
|
{
|
|
|
|
int len = strlen(name) + strlen(val) + 2;
|
|
|
|
char *env = malloc(len);
|
|
|
|
if (!env) { return -1; }
|
|
|
|
|
|
|
|
assert(overwrite != 0);
|
|
|
|
|
|
|
|
strcpy(env, name);
|
|
|
|
strcat(env, "=");
|
|
|
|
strcat(env, val);
|
|
|
|
putenv(env);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|