summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authoral <al@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-12-26 03:16:48 +0000
committeral <al@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-12-26 03:16:48 +0000
commitfa2d1c9a69ced48a070320857df2298b795ae0c4 (patch)
tree611d3d52b025fed8ac05a6c9c311931637e594d0 /osdep
parent74f1ad8a0ab3bf05805a2f83ca271c29a33c45cc (diff)
downloadmpv-fa2d1c9a69ced48a070320857df2298b795ae0c4.tar.bz2
mpv-fa2d1c9a69ced48a070320857df2298b795ae0c4.tar.xz
- move our setenv() fallback implementation to osdep
- assert that the override param is nonzero (zero is not implemented) - correct return value type to int based on a patch by Diego fixes bugzilla bug #342 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17246 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep')
-rw-r--r--osdep/Makefile2
-rw-r--r--osdep/setenv.c29
2 files changed, 30 insertions, 1 deletions
diff --git a/osdep/Makefile b/osdep/Makefile
index 0cc5c2bbda..341da0d9eb 100644
--- a/osdep/Makefile
+++ b/osdep/Makefile
@@ -4,7 +4,7 @@ include ../config.mak
LIBNAME = libosdep.a
SRCS= shmem.c strsep.c strl.c vsscanf.c scandir.c gettimeofday.c fseeko.c \
- swab.c
+ swab.c setenv.c
# timer.c
getch = getch2.c
diff --git a/osdep/setenv.c b/osdep/setenv.c
new file mode 100644
index 0000000000..e0ef9a35bc
--- /dev/null
+++ b/osdep/setenv.c
@@ -0,0 +1,29 @@
+/* setenv implementation for systems lacking it. */
+
+#include "../config.h"
+
+#ifndef HAVE_SETENV
+
+#include <stdlib.h>
+#include <string.h>
+#ifndef MP_DEBUG
+ #define NDEBUG
+#endif
+#include <assert.h>
+
+int setenv(const char *name, const char *val, int overwrite)
+{
+ int len = strlen(name) + strlen(val) + 2;
+ char *env = malloc(len);
+ if (!env) { return -1; }
+
+ assert(overwrite != 0);
+
+ strcpy(env, name);
+ strcat(env, "=");
+ strcat(env, val);
+ putenv(env);
+
+ return 0;
+}
+#endif