annotate osdep/setenv.c @ 18043:97aa495df9dd

segfault fix: assign param->apid (that is the audio id found) when inexistent audio language is specified; patch by Erik Auerswald auerswal a unix-ag d uni-kl d de
author nicodvb
date Wed, 05 Apr 2006 18:50:24 +0000
parents 44c24de55f9d
children d0d487227d60
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
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
3 #include "../config.h"
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 #ifndef HAVE_SETENV
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
6
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
7 #include <stdlib.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
8 #include <string.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
9 #ifndef MP_DEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
10 #define NDEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
11 #endif
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
12 #include <assert.h>
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 setenv(const char *name, const char *val, int overwrite)
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
15 {
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
16 int len = strlen(name) + strlen(val) + 2;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
17 char *env = malloc(len);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
18 if (!env) { return -1; }
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 assert(overwrite != 0);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
21
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
22 strcpy(env, name);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
23 strcat(env, "=");
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
24 strcat(env, val);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
25 putenv(env);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
26
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
27 return 0;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
28 }
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
29 #endif