]> code.delx.au - pulseaudio/commitdiff
Use <pulsecore/socket.h> instead of <sys/socket.h>
authorMaarten Bosmans <mkbosmans@gmail.com>
Tue, 4 Jan 2011 16:03:13 +0000 (17:03 +0100)
committerMaarten Bosmans <mkbosmans@gmail.com>
Thu, 17 Feb 2011 10:58:21 +0000 (11:58 +0100)
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)

30 files changed:
src/Makefile.am
src/daemon/main.c
src/modules/module-esound-sink.c
src/modules/module-protocol-stub.c
src/pulse/context.c
src/pulse/mainloop.c
src/pulse/timeval.c
src/pulse/util.c
src/pulsecore/core-util.c
src/pulsecore/core-util.h
src/pulsecore/creds.h
src/pulsecore/inet_ntop.c
src/pulsecore/inet_ntop.h
src/pulsecore/inet_pton.c
src/pulsecore/inet_pton.h
src/pulsecore/iochannel.c
src/pulsecore/ioline.c
src/pulsecore/ipacl.c
src/pulsecore/parseaddr.c
src/pulsecore/pipe.c
src/pulsecore/poll.c
src/pulsecore/pstream.c
src/pulsecore/rtpoll.c
src/pulsecore/socket-client.c
src/pulsecore/socket-server.c
src/pulsecore/socket-util.c
src/pulsecore/socket-util.h
src/pulsecore/socket.h [moved from src/pulsecore/winsock.h with 77% similarity]
src/pulsecore/tagstruct.c
src/tests/ipacl-test.c

index 0687e40933283a526dd07aca1dae635ef79d4dc1..baba9c5e9073c31e889a269a94ab34e90eadd186 100644 (file)
@@ -617,7 +617,7 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
                pulsecore/tokenizer.c pulsecore/tokenizer.h \
                pulsecore/usergroup.c pulsecore/usergroup.h \
                pulsecore/sndfile-util.c pulsecore/sndfile-util.h \
-               pulsecore/winsock.h
+               pulsecore/socket.h
 
 libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
 libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
index 0db794bcfeccf4b1cca5e06b1a09614467d3c34d..de809b1b89786c2589520899e18fb18c164d4a93 100644 (file)
@@ -70,7 +70,7 @@
 #include <pulse/i18n.h>
 
 #include <pulsecore/lock-autospawn.h>
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-rtclock.h>
 #include <pulsecore/core.h>
index 0d04fff71c614c1d5ea7f89b47cdfbfc0cce7b78..9eba8ac3dc1544eaaef22b37937a306bfa3d2893 100644 (file)
@@ -31,7 +31,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <limits.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <sys/ioctl.h>
@@ -44,6 +43,7 @@
 #include <pulse/timeval.h>
 #include <pulse/xmalloc.h>
 
+#include <pulsecore/socket.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/iochannel.h>
 #include <pulsecore/sink.h>
index e21186bbc9611e4f5369855de3bb3beeffe56b03..7ba540543b41356671fe3229c75c233814b920fc 100644 (file)
@@ -30,9 +30,6 @@
 #include <unistd.h>
 #include <limits.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
@@ -42,9 +39,9 @@
 
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/module.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-server.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/core-util.h>
index 7a539b4d66b31ce19fd4dc484aa1cdd87b8a4199..ca816507ab7d592d10c6abd6e941ac2c9685ba48 100644 (file)
@@ -39,9 +39,6 @@
 #include <sys/wait.h>
 #endif
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
@@ -57,9 +54,7 @@
 #include <pulse/mainloop.h>
 #include <pulse/timeval.h>
 
-#include <pulsecore/winsock.h>
 #include <pulsecore/core-error.h>
-
 #include <pulsecore/native-common.h>
 #include <pulsecore/pdispatch.h>
 #include <pulsecore/pstream.h>
@@ -69,6 +64,7 @@
 #include <pulsecore/core-rtclock.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/creds.h>
 #include <pulsecore/macro.h>
index 8f743ec75aa63f1a0283295b531a1de30b1a51b8..8c261381b42ad9cb212ad87dfcd4bcf627b10059 100644 (file)
@@ -47,7 +47,7 @@
 #include <pulsecore/llist.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-error.h>
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/macro.h>
 
 #include "mainloop.h"
index cde4417caf646c0cfca29b3f4151fa0789030fef..c4a084192768e85048a5879c61a34d69a85dfcf1 100644 (file)
@@ -31,7 +31,6 @@
 #include <windows.h>
 #endif
 
-#include <pulsecore/winsock.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/core-util.h>
 
index ca766dab75dfc7966ba987d11fe411fda930083c..3206e94c6ff4da3e6511c1c84f1c21f9737af384 100644 (file)
 #include <pwd.h>
 #endif
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
@@ -56,7 +52,7 @@
 #include <pulse/xmalloc.h>
 #include <pulse/timeval.h>
 
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-util.h>
@@ -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
 
index ec0b338de23582645430527d0478044eaeed095d..3ce5edbf0401e3fc12975b7234da089cb4287888 100644 (file)
@@ -43,7 +43,6 @@
 #include <regex.h>
 #include <langinfo.h>
 #include <sys/utsname.h>
-#include <sys/socket.h>
 
 #ifdef HAVE_STRTOF_L
 #include <locale.h>
 #include <pulse/utf8.h>
 
 #include <pulsecore/core-error.h>
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/thread.h>
index 0d63cfcba1172f1c5e9fea15b5537959a6fc66e4..8619330de6fb4f99d1b823e5f84bf8208bdf6b72 100644 (file)
@@ -28,7 +28,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/socket.h>
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
@@ -36,6 +35,7 @@
 
 #include <pulse/gccmacro.h>
 #include <pulsecore/macro.h>
+#include <pulsecore/socket.h>
 
 #ifndef PACKAGE
 #error "Please include config.h before including this file!"
index c15c469b7785c24ec3adbe2c0e3057b3d419c15e..9e6fb124b8f40a516fa463ad4ccf329c70387662 100644 (file)
@@ -28,9 +28,7 @@
 #error "Please include config.h before including this file!"
 #endif
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
+#include <pulsecore/socket.h>
 
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
index 012a1a05bebd91907f18f5faa5a961918ea3f92f..e283a6707a4d770c0bdac419a391d736a98f19c3 100644 (file)
 
 #ifndef HAVE_INET_NTOP
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#include "winsock.h"
+#include <pulsecore/socket.h>
 
 #include "inet_ntop.h"
 
index 7fb67b4422267275d45f5fcb017ac4b3bebb18dc..7e1b20378383047606c8012afe351a593b87facf 100644 (file)
@@ -1,11 +1,7 @@
 #ifndef fooinet_ntophfoo
 #define fooinet_ntophfoo
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#include "winsock.h"
+#include <pulsecore/socket.h>
 
 const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
 
index abdfa46731ce6c9203fbaa7706417119054fafc0..198d1a0d830695db61867bcfee55cc732061f6a8 100644 (file)
 
 #ifndef HAVE_INET_PTON
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#include "winsock.h"
+#include <pulsecore/socket.h>
 
 #include "inet_pton.h"
 
index 111b4a07feb4a26e63e99d634a644459d4bc8f65..9d9c476a7364348b0489f7ed4024009448d0f3e0 100644 (file)
@@ -1,11 +1,7 @@
 #ifndef fooinet_ptonhfoo
 #define fooinet_ptonhfoo
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#include "winsock.h"
+#include <pulsecore/socket.h>
 
 int inet_pton(int af, const char *src, void *dst);
 
index f85c989662a8b0a466036dd5f4c0c96fb2ab7b7f..f89b06703b5417ae86ff41db57ca8816310e2367 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
+
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
index 7afdb08cc719b7cad9de599c9943ea82af187e03..963f7d22cd410a569d1456314ba9eb983e0feb2d 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
index 312e04037c1d8e346a0205c4ffd26656f9f01981..0cbe34af0fe892162164cf8e0712c6f55c9c635f 100644 (file)
@@ -28,9 +28,6 @@
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
 #include <pulsecore/llist.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 
 #ifndef HAVE_INET_PTON
-#include "inet_pton.h"
+#include <pulsecore/inet_pton.h>
 #endif
 
 #include "ipacl.h"
index 44cd9a0508e3a4ebe45ff182821a401d9289ce33..7f6cd9039f739dc739a8672c1ccb35388d583083 100644 (file)
 
 #include <string.h>
 #include <stdlib.h>
+
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
-#include <sys/socket.h>
+#endif
 
 #include <pulse/xmalloc.h>
 #include <pulse/util.h>
index c21e4b1fa582c64f561fbc22a74faa2b99a25f9f..db8e16f88123e94a7bdd857d3ca23dcfbc77fd68 100644 (file)
 
 #include <sys/types.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#include "winsock.h"
+#include <pulsecore/socket.h>
 
 #include "pipe.h"
 
index b98fb1697af405d57c8906a763488f62caae6a21..b993c478143a8a695a988f4b07c0c2194edc5fe3 100644 (file)
@@ -45,8 +45,7 @@
 #include <sys/select.h>
 #endif
 
-#include "winsock.h"
-
+#include <pulsecore/socket.h>
 #include <pulsecore/core-util.h>
 #include <pulse/util.h>
 
@@ -187,11 +186,11 @@ int pa_poll (struct pollfd *fds, unsigned long int nfds, int timeout) {
                      * connected socket, a server socket, or something else using a
                      * 0-byte recv, and use ioctl(2) to detect POLLHUP.  */
                     r = recv(f->fd, NULL, 0, MSG_PEEK);
-                   if (r == 0 || (r < 0 && errno == ENOTSOCK))
-                       ioctl(f->fd, FIONREAD, &r);
+                    if (r == 0 || (r < 0 && errno == ENOTSOCK))
+                        ioctl(f->fd, FIONREAD, &r);
 
-                   if (r == 0)
-                       f->revents |= POLLHUP;
+                    if (r == 0)
+                        f->revents |= POLLHUP;
 #else /* !OS_IS_DARWIN */
                     if (recv (f->fd, data, 64, MSG_PEEK) == -1) {
                         if (errno == ESHUTDOWN || errno == ECONNRESET ||
index 3e0bfa3beb58da9b6277f0d1867a93615296b418..369e22ca82eb1943c9ea3da50785dbfcb43478de 100644 (file)
@@ -28,9 +28,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
 #include <netinet/in.h>
 #endif
 
-
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/queue.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-scache.h>
index 2ef78736de2c50561d541cfe13e358eea192aa07..98d7d6258a1741d6ad42b7ea354f8b419eabe9d7 100644 (file)
@@ -40,7 +40,6 @@
 #include <pulsecore/llist.h>
 #include <pulsecore/flist.h>
 #include <pulsecore/core-util.h>
-#include <pulsecore/winsock.h>
 #include <pulsecore/ratelimit.h>
 #include <pulse/rtclock.h>
 
index 7c449bee2f5f0d9904de6f670e435e513772b0e0..31acfd2dd0d6f968f02894c3d4961c8c7013fd19 100644 (file)
@@ -32,9 +32,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
@@ -56,9 +53,9 @@
 #include <pulse/timeval.h>
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
-#include <pulsecore/core-error.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-util.h>
+#include <pulsecore/core-error.h>
 #include <pulsecore/core-rtclock.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/socket-util.h>
index 3b7c697338dd058fb2ee0cacd50e9fcbb4f7b712..e45ded04dcee93a7e4fb468475ec16fa877a33cd 100644 (file)
@@ -32,9 +32,6 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #ifndef SUN_LEN
 #endif
 
 #ifndef HAVE_INET_NTOP
-#include "inet_ntop.h"
+#include <pulsecore/inet_ntop.h>
 #endif
-
 #ifndef HAVE_INET_PTON
-#include "inet_pton.h"
+#include <pulsecore/inet_pton.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/xmalloc.h>
 #include <pulse/util.h>
 
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
index 2cc9882a1c63301a4a900f25afd7fff31509da42..0b16e0f95ec5d916f652003c7315c19b8673ba7b 100644 (file)
@@ -36,9 +36,6 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
 #endif
 
 #ifndef HAVE_INET_NTOP
-#include "inet_ntop.h"
+#include <pulsecore/inet_ntop.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
+#include <pulsecore/socket.h>
 
 #include "socket-util.h"
 
index f6d163766ff7b93038eb4b29a33236e30f95628d..154afd4a211460a93d19255af24c8d0059e87722 100644 (file)
@@ -24,8 +24,8 @@
 ***/
 
 #include <sys/types.h>
-#include <sys/socket.h>
 
+#include <pulsecore/socket.h>
 #include <pulsecore/macro.h>
 
 void pa_socket_peer_to_string(int fd, char *c, size_t l);
similarity index 77%
rename from src/pulsecore/winsock.h
rename to src/pulsecore/socket.h
index 0352bf4d42d7162a9795ca86c96740ac3a726ab1..0d38bee66a45ca138d1ac4b3781f6595b470d037 100644 (file)
@@ -1,5 +1,9 @@
-#ifndef foowinsockhfoo
-#define foowinsockhfoo
+#ifndef foopulsecoresockethfoo
+#define foopulsecoresockethfoo
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
 
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
@@ -14,6 +18,7 @@
 #define ECONNREFUSED    WSAECONNREFUSED
 #define EHOSTUNREACH    WSAEHOSTUNREACH
 #define EWOULDBLOCK     WSAEWOULDBLOCK
+#define EADDRINUSE      WSAEADDRINUSE
 
 typedef long suseconds_t;
 
index 330b7596884b00483fb9c18a58a0fe0ba27cdff9..804b9f90fed7eb2e3ec939f9fda3b1a6e827fd5e 100644 (file)
@@ -35,7 +35,7 @@
 
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/macro.h>
 
 #include "tagstruct.h"
index 57b7068560febbffa0965ad51650494da0d3f9d5..88bd6c6f6c6ac4acb25013df2aea96155b813ccf 100644 (file)
@@ -8,9 +8,6 @@
 #include <assert.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
@@ -24,9 +21,8 @@
 #include <arpa/inet.h>
 #endif
 
-#include "../pulsecore/winsock.h"
-#include "../pulsecore/macro.h"
-
+#include <pulsecore/socket.h>
+#include <pulsecore/macro.h>
 #include <pulsecore/ipacl.h>
 
 int main(int argc, char *argv[]) {