annotate osdep/setenv.c @ 23337:10a7279b8e56

get rid of -menu-utf8 and -menu-unicode once for all, patch by Guillaume Lecerf
author ben
date Sun, 20 May 2007 15:17:56 +0000
parents 936209c39ed1
children 5cfef41a1771
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
1 /* setenv implementation for systems lacking it. */
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
2
21853
d0d487227d60 consistent include path
diego
parents: 17245
diff changeset
3 #include "config.h"
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
4
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
5 #include <stdlib.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
6 #include <string.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
7 #ifndef MP_DEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
8 #define NDEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
9 #endif
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
10 #include <assert.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
11
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
12 int setenv(const char *name, const char *val, int overwrite)
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
13 {
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
14 int len = strlen(name) + strlen(val) + 2;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
15 char *env = malloc(len);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
16 if (!env) { return -1; }
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
17
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
18 assert(overwrite != 0);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
19
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
20 strcpy(env, name);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
21 strcat(env, "=");
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
22 strcat(env, val);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
23 putenv(env);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
24
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
25 return 0;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
26 }