From 4f1d4044f8409ff29eeb7f97324daba496e40714 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 4 Jan 2011 17:03:13 +0100 Subject: Use instead of The check whether POSIX socket.h or WIN32 winsock2.h must be included can be made centrally. The downside is that some functionality of e.g. arpa/inet.h is also implemented in winsock.h, so that some files that don't use socket functions, but do use inet.h functions, must also include pulsecore/socket.h. (as well as arpa/inet.h) --- src/pulse/util.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/pulse/util.c') diff --git a/src/pulse/util.c b/src/pulse/util.c index ca766dab..3206e94c 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -37,10 +37,6 @@ #include #endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - #ifdef HAVE_NETDB_H #include #endif @@ -56,7 +52,7 @@ #include #include -#include +#include #include #include #include @@ -195,11 +191,11 @@ char *pa_get_binary_name(char *s, size_t l) { { char *rp; - if ((rp = pa_readlink("/proc/curproc/file"))) { - pa_strlcpy(s, pa_path_get_filename(rp), l); - pa_xfree(rp); - return s; - } + if ((rp = pa_readlink("/proc/curproc/file"))) { + pa_strlcpy(s, pa_path_get_filename(rp), l); + pa_xfree(rp); + return s; + } } #endif -- cgit From bb12ff83564d43566089dd979639c6993ba76665 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Thu, 6 Jan 2011 00:51:33 +0100 Subject: Apply #ifdefs around functionality not available on win32 And also the reverse: around some win32 specific functionality --- src/pulse/util.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/pulse/util.c') diff --git a/src/pulse/util.c b/src/pulse/util.c index 3206e94c..c5cfc8ca 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -75,11 +75,15 @@ char *pa_get_user_name(char *s, size_t l) { pa_assert(s); pa_assert(l > 0); - if ((p = (getuid() == 0 ? "root" : NULL)) || - (p = getenv("USER")) || - (p = getenv("LOGNAME")) || - (p = getenv("USERNAME"))) - { + p = NULL; +#ifdef HAVE_GETUID + p = getuid() == 0 ? "root" : NULL; +#endif + if (!p) p = getenv("USER"); + if (!p) p = getenv("LOGNAME"); + if (!p) p = getenv("USERNAME"); + + if (p) { name = pa_strlcpy(s, p, l); } else { #ifdef HAVE_PWD_H -- cgit