annotate osdep/setenv.c @ 37174:6c941fe7fc3e

Align backslashes followed by a newline (line continuation). Do so when the statement spans over multiple lines.
author ib
date Sun, 07 Sep 2014 22:22:50 +0000
parents 0bce77ccae9a
children
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
34645
0bce77ccae9a Fix compiling with osdep setenv
al
parents: 28744
diff changeset
30 #include "setenv.h"
0bce77ccae9a Fix compiling with osdep setenv
al
parents: 28744
diff changeset
31
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
32 int setenv(const char *name, const char *val, int overwrite)
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
33 {
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
34 int len = strlen(name) + strlen(val) + 2;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
35 char *env = malloc(len);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
36 if (!env) { return -1; }
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 assert(overwrite != 0);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
39
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
40 strcpy(env, name);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
41 strcat(env, "=");
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
42 strcat(env, val);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
43 putenv(env);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
44
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
45 return 0;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
46 }