Use <pulsecore/socket.h> instead of <sys/socket.h>

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)
This commit is contained in:
Maarten Bosmans 2011-01-04 17:03:13 +01:00
parent d6d9fb295d
commit 4f1d4044f8
30 changed files with 52 additions and 108 deletions

View file

@ -617,7 +617,7 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/tokenizer.c pulsecore/tokenizer.h \ pulsecore/tokenizer.c pulsecore/tokenizer.h \
pulsecore/usergroup.c pulsecore/usergroup.h \ pulsecore/usergroup.c pulsecore/usergroup.h \
pulsecore/sndfile-util.c pulsecore/sndfile-util.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_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version

View file

@ -70,7 +70,7 @@
#include <pulse/i18n.h> #include <pulse/i18n.h>
#include <pulsecore/lock-autospawn.h> #include <pulsecore/lock-autospawn.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/core-rtclock.h> #include <pulsecore/core-rtclock.h>
#include <pulsecore/core.h> #include <pulsecore/core.h>

View file

@ -31,7 +31,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -44,6 +43,7 @@
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/socket.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/iochannel.h> #include <pulsecore/iochannel.h>
#include <pulsecore/sink.h> #include <pulsecore/sink.h>

View file

@ -30,9 +30,6 @@
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
@ -42,9 +39,9 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/module.h> #include <pulsecore/module.h>
#include <pulsecore/socket.h>
#include <pulsecore/socket-server.h> #include <pulsecore/socket-server.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>

View file

@ -39,9 +39,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
@ -57,9 +54,7 @@
#include <pulse/mainloop.h> #include <pulse/mainloop.h>
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/native-common.h> #include <pulsecore/native-common.h>
#include <pulsecore/pdispatch.h> #include <pulsecore/pdispatch.h>
#include <pulsecore/pstream.h> #include <pulsecore/pstream.h>
@ -69,6 +64,7 @@
#include <pulsecore/core-rtclock.h> #include <pulsecore/core-rtclock.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/socket.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>
#include <pulsecore/creds.h> #include <pulsecore/creds.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>

View file

@ -47,7 +47,7 @@
#include <pulsecore/llist.h> #include <pulsecore/llist.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include "mainloop.h" #include "mainloop.h"

View file

@ -31,7 +31,6 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <pulsecore/winsock.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>

View file

@ -37,10 +37,6 @@
#include <pwd.h> #include <pwd.h>
#endif #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H #ifdef HAVE_NETDB_H
#include <netdb.h> #include <netdb.h>
#endif #endif
@ -56,7 +52,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
@ -195,11 +191,11 @@ char *pa_get_binary_name(char *s, size_t l) {
{ {
char *rp; char *rp;
if ((rp = pa_readlink("/proc/curproc/file"))) { if ((rp = pa_readlink("/proc/curproc/file"))) {
pa_strlcpy(s, pa_path_get_filename(rp), l); pa_strlcpy(s, pa_path_get_filename(rp), l);
pa_xfree(rp); pa_xfree(rp);
return s; return s;
} }
} }
#endif #endif

View file

@ -43,7 +43,6 @@
#include <regex.h> #include <regex.h>
#include <langinfo.h> #include <langinfo.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/socket.h>
#ifdef HAVE_STRTOF_L #ifdef HAVE_STRTOF_L
#include <locale.h> #include <locale.h>
@ -110,7 +109,7 @@
#include <pulse/utf8.h> #include <pulse/utf8.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/thread.h> #include <pulsecore/thread.h>

View file

@ -28,7 +28,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_RESOURCE_H #ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> #include <sys/resource.h>
@ -36,6 +35,7 @@
#include <pulse/gccmacro.h> #include <pulse/gccmacro.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/socket.h>
#ifndef PACKAGE #ifndef PACKAGE
#error "Please include config.h before including this file!" #error "Please include config.h before including this file!"

View file

@ -28,9 +28,7 @@
#error "Please include config.h before including this file!" #error "Please include config.h before including this file!"
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>

View file

@ -28,11 +28,7 @@
#ifndef HAVE_INET_NTOP #ifndef HAVE_INET_NTOP
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#include "winsock.h"
#include "inet_ntop.h" #include "inet_ntop.h"

View file

@ -1,11 +1,7 @@
#ifndef fooinet_ntophfoo #ifndef fooinet_ntophfoo
#define fooinet_ntophfoo #define fooinet_ntophfoo
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#include "winsock.h"
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);

View file

@ -28,11 +28,7 @@
#ifndef HAVE_INET_PTON #ifndef HAVE_INET_PTON
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#include "winsock.h"
#include "inet_pton.h" #include "inet_pton.h"

View file

@ -1,11 +1,7 @@
#ifndef fooinet_ptonhfoo #ifndef fooinet_ptonhfoo
#define fooinet_ptonhfoo #define fooinet_ptonhfoo
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#include "winsock.h"
int inet_pton(int af, const char *src, void *dst); int inet_pton(int af, const char *src, void *dst);

View file

@ -28,19 +28,16 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
#include "winsock.h"
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/socket.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>

View file

@ -30,7 +30,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>

View file

@ -28,9 +28,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
@ -50,10 +47,10 @@
#include <pulsecore/llist.h> #include <pulsecore/llist.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#ifndef HAVE_INET_PTON #ifndef HAVE_INET_PTON
#include "inet_pton.h" #include <pulsecore/inet_pton.h>
#endif #endif
#include "ipacl.h" #include "ipacl.h"

View file

@ -25,8 +25,10 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #endif
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/util.h> #include <pulse/util.h>

View file

@ -29,11 +29,7 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H #include <pulsecore/socket.h>
#include <sys/socket.h>
#endif
#include "winsock.h"
#include "pipe.h" #include "pipe.h"

View file

@ -45,8 +45,7 @@
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include "winsock.h" #include <pulsecore/socket.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulse/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 * connected socket, a server socket, or something else using a
* 0-byte recv, and use ioctl(2) to detect POLLHUP. */ * 0-byte recv, and use ioctl(2) to detect POLLHUP. */
r = recv(f->fd, NULL, 0, MSG_PEEK); r = recv(f->fd, NULL, 0, MSG_PEEK);
if (r == 0 || (r < 0 && errno == ENOTSOCK)) if (r == 0 || (r < 0 && errno == ENOTSOCK))
ioctl(f->fd, FIONREAD, &r); ioctl(f->fd, FIONREAD, &r);
if (r == 0) if (r == 0)
f->revents |= POLLHUP; f->revents |= POLLHUP;
#else /* !OS_IS_DARWIN */ #else /* !OS_IS_DARWIN */
if (recv (f->fd, data, 64, MSG_PEEK) == -1) { if (recv (f->fd, data, 64, MSG_PEEK) == -1) {
if (errno == ESHUTDOWN || errno == ECONNRESET || if (errno == ESHUTDOWN || errno == ECONNRESET ||

View file

@ -28,9 +28,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
@ -38,10 +35,9 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/queue.h> #include <pulsecore/queue.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/core-scache.h> #include <pulsecore/core-scache.h>

View file

@ -40,7 +40,6 @@
#include <pulsecore/llist.h> #include <pulsecore/llist.h>
#include <pulsecore/flist.h> #include <pulsecore/flist.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/winsock.h>
#include <pulsecore/ratelimit.h> #include <pulsecore/ratelimit.h>
#include <pulse/rtclock.h> #include <pulse/rtclock.h>

View file

@ -32,9 +32,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
@ -56,9 +53,9 @@
#include <pulse/timeval.h> #include <pulse/timeval.h>
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/core-error.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core-rtclock.h> #include <pulsecore/core-rtclock.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>

View file

@ -32,9 +32,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#ifndef SUN_LEN #ifndef SUN_LEN
@ -54,18 +51,16 @@
#endif #endif
#ifndef HAVE_INET_NTOP #ifndef HAVE_INET_NTOP
#include "inet_ntop.h" #include <pulsecore/inet_ntop.h>
#endif #endif
#ifndef HAVE_INET_PTON #ifndef HAVE_INET_PTON
#include "inet_pton.h" #include <pulsecore/inet_pton.h>
#endif #endif
#include "winsock.h"
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulse/util.h> #include <pulse/util.h>
#include <pulsecore/socket.h>
#include <pulsecore/socket-util.h> #include <pulsecore/socket-util.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>

View file

@ -36,9 +36,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
@ -62,17 +59,16 @@
#endif #endif
#ifndef HAVE_INET_NTOP #ifndef HAVE_INET_NTOP
#include "inet_ntop.h" #include <pulsecore/inet_ntop.h>
#endif #endif
#include "winsock.h"
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/core-error.h> #include <pulsecore/core-error.h>
#include <pulsecore/core-util.h> #include <pulsecore/core-util.h>
#include <pulsecore/log.h> #include <pulsecore/log.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include <pulsecore/socket.h>
#include "socket-util.h" #include "socket-util.h"

View file

@ -24,8 +24,8 @@
***/ ***/
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
#include <pulsecore/socket.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
void pa_socket_peer_to_string(int fd, char *c, size_t l); void pa_socket_peer_to_string(int fd, char *c, size_t l);

View file

@ -1,5 +1,9 @@
#ifndef foowinsockhfoo #ifndef foopulsecoresockethfoo
#define foowinsockhfoo #define foopulsecoresockethfoo
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H #ifdef HAVE_WINSOCK2_H
#include <winsock2.h> #include <winsock2.h>
@ -14,6 +18,7 @@
#define ECONNREFUSED WSAECONNREFUSED #define ECONNREFUSED WSAECONNREFUSED
#define EHOSTUNREACH WSAEHOSTUNREACH #define EHOSTUNREACH WSAEHOSTUNREACH
#define EWOULDBLOCK WSAEWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK
#define EADDRINUSE WSAEADDRINUSE
typedef long suseconds_t; typedef long suseconds_t;

View file

@ -35,7 +35,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pulsecore/winsock.h> #include <pulsecore/socket.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
#include "tagstruct.h" #include "tagstruct.h"

View file

@ -8,9 +8,6 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
@ -24,9 +21,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "../pulsecore/winsock.h" #include <pulsecore/socket.h>
#include "../pulsecore/macro.h" #include <pulsecore/macro.h>
#include <pulsecore/ipacl.h> #include <pulsecore/ipacl.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {