aboutsummaryrefslogtreecommitdiff
path: root/X11/xtrans
diff options
context:
space:
mode:
Diffstat (limited to 'X11/xtrans')
-rw-r--r--X11/xtrans/Xtrans.c11
-rw-r--r--X11/xtrans/Xtransint.h7
-rw-r--r--X11/xtrans/Xtranslcl.c6
-rwxr-xr-x[-rw-r--r--]X11/xtrans/Xtranssock.c71
4 files changed, 60 insertions, 35 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c
index 735d7b87f..13adf59ef 100644
--- a/X11/xtrans/Xtrans.c
+++ b/X11/xtrans/Xtrans.c
@@ -48,7 +48,11 @@ from The Open Group.
*/
#include <ctype.h>
+#include <unistd.h>
+#ifdef _MSC_VER
+#include <X11\Xwinsock.h>
+#endif
/*
* The transport table contains a definition for every transport (protocol)
* family. All operations that can be made on the transport go through this
@@ -108,9 +112,10 @@ Xtransport_table Xtransports[] = {
{ &TRANS(SCOFuncs), TRANS_LOCAL_SCO_INDEX },
#endif /* __SCO__ || __UNIXWARE__ */
#endif /* LOCALCONN */
+ { NULL, 0}
};
-#define NUMTRANS (sizeof(Xtransports)/sizeof(Xtransport_table))
+#define NUMTRANS (sizeof(Xtransports)/sizeof(Xtransport_table)-1)
#ifdef WIN32
@@ -695,7 +700,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg)
#if defined(WIN32)
{
#ifdef WIN32
- u_long arg;
+ unsigned long arg;
#else
int arg;
#endif
@@ -879,7 +884,6 @@ TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
return ciptr->transptr->Writev (ciptr, buf, size);
}
-#if XTRANS_SEND_FDS
int
TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close)
{
@@ -891,7 +895,6 @@ TRANS(RecvFd) (XtransConnInfo ciptr)
{
return ciptr->transptr->RecvFd(ciptr);
}
-#endif
int
TRANS(Disconnect) (XtransConnInfo ciptr)
diff --git a/X11/xtrans/Xtransint.h b/X11/xtrans/Xtransint.h
index 1f32f0cae..b2b6821d3 100644
--- a/X11/xtrans/Xtransint.h
+++ b/X11/xtrans/Xtransint.h
@@ -291,7 +291,6 @@ typedef struct _Xtransport {
int /* size */
);
-#if XTRANS_SEND_FDS
int (*SendFd)(
XtransConnInfo, /* connection */
int, /* fd */
@@ -301,7 +300,6 @@ typedef struct _Xtransport {
int (*RecvFd)(
XtransConnInfo /* connection */
);
-#endif
int (*Disconnect)(
XtransConnInfo /* connection */
@@ -416,6 +414,11 @@ static int trans_mkdir (
# if defined(XSERV_t) && defined(TRANS_SERVER)
# include "os.h"
# else
+
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
static inline void _X_ATTRIBUTE_PRINTF(1, 0)
VErrorF(const char *f, va_list args)
{
diff --git a/X11/xtrans/Xtranslcl.c b/X11/xtrans/Xtranslcl.c
index 4deb86c40..65f1957b9 100644
--- a/X11/xtrans/Xtranslcl.c
+++ b/X11/xtrans/Xtranslcl.c
@@ -72,17 +72,23 @@ from The Open Group.
#include <errno.h>
#include <ctype.h>
+#ifdef _MSC_VER
+#include <signal.h>
+#else
#include <sys/signal.h>
#include <sys/ioctl.h>
+#endif
#include <sys/stat.h>
#if defined(SVR4) || defined(__SVR4)
#include <sys/filio.h>
#endif
+#ifndef _MSC_VER
#ifdef sun
# include <stropts.h>
#else
# include <sys/stropts.h>
#endif
+#endif
#include <sys/wait.h>
#include <sys/types.h>
diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c
index c9d103352..bbc08f4e0 100644..100755
--- a/X11/xtrans/Xtranssock.c
+++ b/X11/xtrans/Xtranssock.c
@@ -129,11 +129,15 @@ from the copyright holders.
#include <X11/Xw32defs.h>
#undef close
#define close closesocket
+#undef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
+#undef EADDRINUSE
#define EADDRINUSE WSAEADDRINUSE
+#undef EPROTOTYPE
#define EPROTOTYPE WSAEPROTOTYPE
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
+#undef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#undef EINTR
#define EINTR WSAEINTR
@@ -242,13 +246,20 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#endif
#if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6))
+#ifdef _MSC_VER
+# define SOCKLEN_T int
+#else
# define SOCKLEN_T socklen_t
+#endif
#elif defined(SVR4) || defined(__SVR4) || defined(__SCO__)
# define SOCKLEN_T size_t
#else
# define SOCKLEN_T int
#endif
+static int TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr);
+static int TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close);
+
/*
* These are some utility function used by the real interface function below.
*/
@@ -640,7 +651,7 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol,
if (Sockettrans2devtab[i].family == AF_INET6)
{
int one = 1;
- setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&one, sizeof(int));
}
#endif
/* Save the index for later use */
@@ -725,7 +736,7 @@ TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol,
if (Sockettrans2devtab[i].family == AF_INET6)
{
int one = 1;
- setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&one, sizeof(int));
}
#endif
/* Save the index for later use */
@@ -850,6 +861,10 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract)
#ifdef TRANS_SERVER
+#ifndef SO_BINDRETRYCOUNT
+#define SO_BINDRETRYCOUNT 20
+#endif
+
static int
TRANS(SocketCreateListener) (XtransConnInfo ciptr,
struct sockaddr *sockname,
@@ -867,7 +882,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr,
|| Sockettrans2devtab[ciptr->index].family == AF_INET6
#endif
)
- retry = 20;
+ retry = SO_BINDRETRYCOUNT;
else
retry = 0;
@@ -1247,7 +1262,11 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
{
XtransConnInfo newciptr;
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage sockname;
+#else
struct sockaddr_in sockname;
+#endif
SOCKLEN_T namelen = sizeof(sockname);
prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd);
@@ -2181,20 +2200,6 @@ TRANS(SocketSendFd) (XtransConnInfo ciptr, int fd, int do_close)
return 0;
}
-static int
-TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr)
-{
- errno = EINVAL;
- return -1;
-}
-
-static int
-TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close)
-{
- errno = EINVAL;
- return -1;
-}
-
#define MAX_FDS 128
struct fd_pass {
@@ -2221,6 +2226,20 @@ static inline void init_msg_send(struct msghdr *msg, struct iovec *iov, int niov
#endif /* XTRANS_SEND_FDS */
static int
+TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr)
+{
+ errno = EINVAL;
+ return -1;
+}
+
+static int
+TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close)
+{
+ errno = EINVAL;
+ return -1;
+}
+
+static int
TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
{
@@ -2530,10 +2549,8 @@ Xtransport TRANS(SocketTCPFuncs) = {
TRANS(SocketWrite),
TRANS(SocketReadv),
TRANS(SocketWritev),
-#if XTRANS_SEND_FDS
- TRANS(SocketSendFdInvalid),
- TRANS(SocketRecvFdInvalid),
-#endif
+ TRANS(SocketSendFdInvalid),
+ TRANS(SocketRecvFdInvalid),
TRANS(SocketDisconnect),
TRANS(SocketINETClose),
TRANS(SocketINETClose),
@@ -2574,10 +2591,8 @@ Xtransport TRANS(SocketINETFuncs) = {
TRANS(SocketWrite),
TRANS(SocketReadv),
TRANS(SocketWritev),
-#if XTRANS_SEND_FDS
- TRANS(SocketSendFdInvalid),
- TRANS(SocketRecvFdInvalid),
-#endif
+ TRANS(SocketSendFdInvalid),
+ TRANS(SocketRecvFdInvalid),
TRANS(SocketDisconnect),
TRANS(SocketINETClose),
TRANS(SocketINETClose),
@@ -2619,10 +2634,8 @@ Xtransport TRANS(SocketINET6Funcs) = {
TRANS(SocketWrite),
TRANS(SocketReadv),
TRANS(SocketWritev),
-#if XTRANS_SEND_FDS
- TRANS(SocketSendFdInvalid),
- TRANS(SocketRecvFdInvalid),
-#endif
+ TRANS(SocketSendFdInvalid),
+ TRANS(SocketRecvFdInvalid),
TRANS(SocketDisconnect),
TRANS(SocketINETClose),
TRANS(SocketINETClose),