summaryrefslogtreecommitdiff
path: root/Xtranssock.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2008-10-11 09:09:51 +0200
committerMatthieu Herrb <matthieu.herrb@laas.fr>2008-10-11 09:09:51 +0200
commit0f8ee37aa319a8eca6941da9f67ee516f595f74e (patch)
tree2d892d8e5007cdd6a9cc8e6a76a43a9c459344c1 /Xtranssock.c
parentf79638411463f81b35d984f249d0f339e28fb712 (diff)
parent005bd80a9eab736aea737869b8a1079c565e1cd6 (diff)
Merge branch 'master' into obsd
Conflicts: Xtransutil.c
Diffstat (limited to 'Xtranssock.c')
-rw-r--r--Xtranssock.c139
1 files changed, 13 insertions, 126 deletions
diff --git a/Xtranssock.c b/Xtranssock.c
index 6b90040..06f4556 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -69,21 +69,14 @@ from the copyright holders.
#ifdef UNIXCONN
#ifndef X_NO_SYS_UN
-#ifndef Lynx
#include <sys/un.h>
-#else
-#include <un.h>
-#endif
#endif
#include <sys/stat.h>
#endif
-#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV))
-#define NO_TCP_H
-#endif
#ifndef NO_TCP_H
-#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5)
+#if defined(linux) || defined(__GLIBC__)
#include <sys/param.h>
#endif /* osf */
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
@@ -94,7 +87,7 @@ from the copyright holders.
#endif /* !NO_TCP_H */
#include <sys/ioctl.h>
-#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_)
+#if defined(SVR4)
#include <sys/filio.h>
#endif
@@ -102,10 +95,12 @@ from the copyright holders.
#include <net/errno.h>
#endif
-#if (defined(__i386__) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_)
+#if defined(__i386__) && defined(SYSV)
#include <sys/stropts.h>
#endif
+#include <unistd.h>
+
#else /* !WIN32 */
#include <X11/Xwinsock.h>
@@ -130,33 +125,8 @@ from the copyright holders.
#undef SO_DONTLINGER
#endif
-#if defined(__UNIXOS2__)
-#if defined(NOT_EMX09A)
-static int IBMsockInit = 0;
-#define SocketInitOnce()\
- if (!IBMsockInit) {\
- sock_init();\
- IBMsockInit = 1;\
- }
-#undef EINTR
-#define EINTR SOCEINTR
-#undef EINVAL
-#define EINVAL SOCEINVAL
-#undef errno
-#define errno sock_errno()
-#undef close
-#define close soclose
-#undef ioctl
-#define ioctl sockioctl
-#else
-#define SocketInitOnce() /**/
-#endif
-/* this is still not there */
-#define SOCKET int
-#else
/* others don't need this */
#define SocketInitOnce() /**/
-#endif
#ifdef linux
#define HAVE_ABSTRACT_SOCKETS
@@ -215,36 +185,6 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#ifdef UNIXCONN
-#ifdef hpux
-
-#if defined(X11_t)
-#define UNIX_PATH "/usr/spool/sockets/X11/"
-#define UNIX_DIR "/usr/spool/sockets/X11"
-#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
-#endif /* X11_t */
-#if defined(XIM_t)
-#define UNIX_PATH "/usr/spool/sockets/XIM/"
-#define UNIX_DIR "/usr/spool/sockets/XIM"
-#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM"
-#endif /* XIM_t */
-#if defined(FS_t) || defined(FONT_t)
-#define UNIX_PATH "/usr/spool/sockets/fontserv/"
-#define UNIX_DIR "/usr/spool/sockets/fontserv"
-#endif /* FS_t || FONT_t */
-#if defined(ICE_t)
-#define UNIX_PATH "/usr/spool/sockets/ICE/"
-#define UNIX_DIR "/usr/spool/sockets/ICE"
-#endif /* ICE_t */
-#if defined(TEST_t)
-#define UNIX_PATH "/usr/spool/sockets/xtrans_test/"
-#define UNIX_DIR "/usr/spool/sockets/xtrans_test"
-#endif
-#if defined(LBXPROXY_t)
-#define UNIX_PATH "/usr/spool/sockets/X11/"
-#define UNIX_DIR "/usr/spool/sockets/X11"
-#endif
-
-#else /* !hpux */
#if defined(X11_t)
#define UNIX_PATH "/tmp/.X11-unix/X"
@@ -271,7 +211,6 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#define UNIX_DIR "/tmp/.X11-unix"
#endif
-#endif /* hpux */
#endif /* UNIXCONN */
@@ -481,7 +420,7 @@ TRANS(SocketOpen) (int i, int type)
Sockettrans2devtab[i].protocol)) < 0
#ifndef WIN32
#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
- || ciptr->fd >= TRANS_OPEN_MAX
+ || ciptr->fd >= sysconf(_SC_OPEN_MAX)
#endif
#endif
) {
@@ -560,10 +499,10 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
PRMSG (1, "SocketReopen: malloc(addr) failed\n", 0, 0, 0);
return NULL;
}
- ciptr->addr = addr;
+ ciptr->addr = (char *) addr;
ciptr->addrlen = portlen + 2;
- if ((ciptr->peeraddr = (struct sockaddr *) xcalloc (1, portlen + 2)) == NULL) {
+ if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) {
PRMSG (1, "SocketReopen: malloc(portaddr) failed\n", 0, 0, 0);
return NULL;
}
@@ -1162,7 +1101,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
return TRANS_CREATE_LISTENER_FAILED;
}
-#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))
sockname.sun_len = strlen(sockname.sun_path);
#endif
@@ -1716,25 +1655,11 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
return TRANS_CONNECT_FAILED;
}
-#if defined(CRAY) && defined(OLDTCP)
- /* Only Cray UNICOS3 and UNICOS4 will define this */
- {
- long t;
- memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
- sockname.sin_addr = t;
- }
-#else
memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
sizeof (sockname.sin_addr));
-#endif /* CRAY and OLDTCP */
} else {
-#if defined(CRAY) && defined(OLDTCP)
- /* Only Cray UNICOS3 and UNICOS4 will define this */
- sockname.sin_addr = tmpaddr;
-#else
sockname.sin_addr.s_addr = tmpaddr;
-#endif /* CRAY and OLDTCP */
}
/*
@@ -2018,10 +1943,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
struct sockaddr_un sockname;
SOCKLEN_T namelen;
-#if defined(hpux) && defined(X11_t)
- struct sockaddr_un old_sockname;
- SOCKLEN_T old_namelen;
-#endif
int abstract = 0;
#ifdef HAVE_ABSTRACT_SOCKETS
@@ -2069,7 +1990,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
return TRANS_CONNECT_FAILED;
}
-#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))
sockname.sun_len = strlen (sockname.sun_path);
#endif
@@ -2080,18 +2001,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
#endif
-#if defined(hpux) && defined(X11_t)
- /*
- * This is gross, but it was in Xlib
- */
- old_sockname.sun_family = AF_UNIX;
- if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path, abstract) != 0) {
- PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
- return TRANS_CONNECT_FAILED;
- }
- old_namelen = strlen (old_sockname.sun_path) +
- offsetof(struct sockaddr_un, sun_path);
-#endif
/*
* Adjust the socket path if using abstract sockets.
@@ -2100,9 +2009,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
if (abstract) {
sockname.sun_path[0] = '\0';
-#if defined(hpux) && defined(X11_t)
- old_sockname.sun_path[0] = '\0';
-#endif
}
/*
@@ -2114,18 +2020,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
int olderrno = errno;
int connected = 0;
-#if defined(hpux) && defined(X11_t)
- if (olderrno == ENOENT)
- {
- if (connect (ciptr->fd,
- (struct sockaddr *) &old_sockname, old_namelen) >= 0)
- {
- connected = 1;
- }
- else
- olderrno = errno;
- }
-#endif
if (!connected)
{
errno = olderrno;
@@ -2204,9 +2098,6 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
{
PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n",
ciptr, ciptr->fd, pend);
-#if defined(QNX4)
- *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
-#endif
#ifdef WIN32
{
int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
@@ -2214,14 +2105,10 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
return ret;
}
#else
-#if (defined(__i386__) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1)
+#if defined(__i386__) && defined(SYSV) && !defined(SCO325)
return ioctl (ciptr->fd, I_NREAD, (char *) pend);
#else
-#if defined(__UNIXOS2__)
- return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int));
-#else
return ioctl (ciptr->fd, FIONREAD, (char *) pend);
-#endif /* __UNIXOS2__ */
#endif /* __i386__ && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */
#endif /* WIN32 */
}
@@ -2233,7 +2120,7 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
{
PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
-#if defined(WIN32) || defined(__UNIXOS2__)
+#if defined(WIN32)
{
int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
#ifdef WIN32
@@ -2253,7 +2140,7 @@ TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
{
PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
-#if defined(WIN32) || defined(__UNIXOS2__)
+#if defined(WIN32)
{
int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
#ifdef WIN32