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