17245
|
1 /* setenv implementation for systems lacking it. */
|
|
2
|
21853
|
3 #include "config.h"
|
17245
|
4
|
|
5 #include <stdlib.h>
|
|
6 #include <string.h>
|
|
7 #ifndef MP_DEBUG
|
|
8 #define NDEBUG
|
|
9 #endif
|
|
10 #include <assert.h>
|
|
11
|
|
12 int setenv(const char *name, const char *val, int overwrite)
|
|
13 {
|
|
14 int len = strlen(name) + strlen(val) + 2;
|
|
15 char *env = malloc(len);
|
|
16 if (!env) { return -1; }
|
|
17
|
|
18 assert(overwrite != 0);
|
|
19
|
|
20 strcpy(env, name);
|
|
21 strcat(env, "=");
|
|
22 strcat(env, val);
|
|
23 putenv(env);
|
|
24
|
|
25 return 0;
|
|
26 }
|