annotate osdep/setenv.c @ 32926:7c205a5c2a9b

Remove parameter from appInitStruct() function. Since there is only one listItems structure variable (the global appMPlayer), there is no need to pass it to the function.
author ib
date Thu, 03 Mar 2011 13:13:20 +0000
parents 5cfef41a1771
children 0bce77ccae9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28744
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
1 /*
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
2 * setenv implementation for systems lacking it.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
3 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
4 * This file is part of MPlayer.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
5 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
7 * it under the terms of the GNU General Public License as published by
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
9 * (at your option) any later version.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
10 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
14 * GNU General Public License for more details.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
15 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
16 * You should have received a copy of the GNU General Public License along
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
19 */
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
20
21853
d0d487227d60 consistent include path
diego
parents: 17245
diff changeset
21 #include "config.h"
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
22
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
23 #include <stdlib.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
24 #include <string.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
25 #ifndef MP_DEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
26 #define NDEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
27 #endif
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
28 #include <assert.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
29
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
30 int setenv(const char *name, const char *val, int overwrite)
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
31 {
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
32 int len = strlen(name) + strlen(val) + 2;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
33 char *env = malloc(len);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
34 if (!env) { return -1; }
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
35
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
36 assert(overwrite != 0);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
37
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
38 strcpy(env, name);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
39 strcat(env, "=");
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
40 strcat(env, val);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
41 putenv(env);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
42
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
43 return 0;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
44 }