[pulseaudio-discuss] [PATCH 09/10] Implement some functions for win32

Maarten Bosmans mkbosmans at gmail.com
Wed Jan 5 17:39:56 PST 2011


And disable building binaries for win32 that make no sense
---
 src/Makefile.am           |   22 ++++++++++++++++------
 src/pulsecore/authkey.c   |    2 +-
 src/pulsecore/core-util.c |   26 ++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 4c4c09a..e80b4b0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -196,8 +196,11 @@ endif
 
 bin_PROGRAMS += \
 		pacat \
-		pactl \
-		pasuspender
+		pactl
+
+if !OS_IS_WIN32
+bin_PROGRAMS += pasuspender
+endif
 
 if HAVE_AF_UNIX
 bin_PROGRAMS += pacmd
@@ -275,9 +278,7 @@ TESTS = \
 		envelope-test \
 		proplist-test \
 		lock-autospawn-test \
-		prioq-test \
-		sigbus-test \
-		usergroup-test
+		prioq-test
 
 TESTS_BINARIES = \
 		mainloop-test \
@@ -314,9 +315,16 @@ TESTS_BINARIES = \
 		rtstutter \
 		stripnul \
 		lock-autospawn-test \
-		prioq-test \
+		prioq-test
+
+if !OS_IS_WIN32
+TESTS += \
+		sigbus-test \
+		usergroup-test
+TESTS_BINARIES += \
 		sigbus-test \
 		usergroup-test
+endif
 
 if HAVE_SIGXCPU
 #TESTS += \
@@ -345,9 +353,11 @@ TESTS_BINARIES += \
 endif
 
 if !OS_IS_DARWIN
+if !OS_IS_WIN32
 TESTS_BINARIES += \
 		once-test
 endif
+endif
 
 if BUILD_TESTS_DEFAULT
 noinst_PROGRAMS = $(TESTS_BINARIES)
diff --git a/src/pulsecore/authkey.c b/src/pulsecore/authkey.c
index d671e36..684bc01 100644
--- a/src/pulsecore/authkey.c
+++ b/src/pulsecore/authkey.c
@@ -151,7 +151,7 @@ static char *normalize_path(const char *fn) {
 #ifndef OS_IS_WIN32
     if (fn[0] != '/') {
 #else
-    if (strlen(fn) < 3 || !isalpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
+    if (strlen(fn) < 3 || !IsCharAlpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
 #endif
         char *homedir, *s;
 
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 1659d3a..f8e471d 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -91,6 +91,10 @@
 #include <windows.h>
 #endif
 
+#ifndef ENOTSUP
+#define ENOTSUP   135
+#endif
+
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
@@ -2565,7 +2569,11 @@ void pa_unset_env_recorded(void) {
         if (!s)
             break;
 
+#ifdef OS_IS_WIN32
+        putenv(pa_sprintf_malloc("%s=", s));
+#else
         unsetenv(s);
+#endif
         pa_xfree(s);
     }
 }
@@ -2683,11 +2691,22 @@ char *pa_session_id(void) {
 }
 
 char *pa_uname_string(void) {
+#ifdef HAVE_UNAME
     struct utsname u;
 
     pa_assert_se(uname(&u) >= 0);
 
     return pa_sprintf_malloc("%s %s %s %s", u.sysname, u.machine, u.release, u.version);
+#endif
+#ifdef OS_IS_WIN32
+    OSVERSIONINFO i;
+
+    pa_zero(i);
+    i.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    pa_assert_se(GetVersionEx(&i));
+
+    return pa_sprintf_malloc("Windows %d.%d (%d) %s", i.dwMajorVersion, i.dwMinorVersion, i.dwBuildNumber, i.szCSDVersion);
+#endif
 }
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
@@ -2836,10 +2855,17 @@ char *pa_realpath(const char *path) {
         char *path_buf;
         path_buf = pa_xmalloc(PATH_MAX);
 
+#if defined(OS_IS_WIN32)
+        if (!(t = _fullpath(path_buf, path, _MAX_PATH))) {
+            pa_xfree(path_buf);
+            return NULL;
+        }
+#else
         if (!(t = realpath(path, path_buf))) {
             pa_xfree(path_buf);
             return NULL;
         }
+#endif
     }
 #else
 #error "It's not clear whether this system supports realpath(..., NULL) like GNU libc does. If it doesn't we need a private version of realpath() here."
-- 
1.7.1




More information about the pulseaudio-discuss mailing list