diff options
-rw-r--r-- | Xtrans.c | 6 | ||||
-rw-r--r-- | Xtransdnet.c | 34 | ||||
-rw-r--r-- | Xtranssock.c | 54 | ||||
-rw-r--r-- | Xtransutil.c | 11 |
4 files changed, 95 insertions, 10 deletions
@@ -1,4 +1,4 @@ -/* $XdotOrg: xc/lib/xtrans/Xtrans.c,v 1.2 2004/04/23 18:44:27 eich Exp $ */ +/* $XdotOrg: xc/lib/xtrans/Xtrans.c,v 1.3 2004/07/17 01:13:31 alanc Exp $ */ /* $Xorg: Xtrans.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */ /* @@ -726,7 +726,11 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) #else #if (defined(AIXV3) || defined(uniosu) || defined(WIN32) || defined(__UNIXOS2__) || defined(__QNX__)) && defined(FIONBIO) { +#ifdef WIN32 + u_long arg; +#else int arg; +#endif arg = 1; /* IBM TCP/IP understands this option too well: it causes TRANS(Read) to fail * eventually with EWOULDBLOCK */ diff --git a/Xtransdnet.c b/Xtransdnet.c index 9bc3e17..ac91695 100644 --- a/Xtransdnet.c +++ b/Xtransdnet.c @@ -525,7 +525,11 @@ TRANS(DNETBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) PRMSG (2,"DNETBytesReadable(%x,%d,%x)\n", ciptr, ciptr->fd, pend); #ifdef WIN32 - return ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); + { + int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); + errno = WSAGetLastError(); + return ret; + } #else return ioctl(ciptr->fd, FIONREAD, (char *)pend); #endif /* WIN32 */ @@ -539,7 +543,11 @@ TRANS(DNETRead) (XtransConnInfo ciptr, char *buf, int size) PRMSG (2,"DNETRead(%d,%x,%d)\n", ciptr->fd, buf, size); #ifdef WIN32 - return recv ((SOCKET)ciptr->fd, buf, size, 0); + { + int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); + errno = WSAGetLastError(); + return ret; + } #else return read (ciptr->fd, buf, size); #endif /* WIN32 */ @@ -553,7 +561,11 @@ TRANS(DNETWrite) (XtransConnInfo ciptr, char *buf, int size) PRMSG (2,"DNETWrite(%d,%x,%d)\n", ciptr->fd, buf, size); #ifdef WIN32 - return send ((SOCKET)ciptr->fd, buf, size, 0); + { + int ret = send ((SOCKET)ciptr->fd, buf, size, 0); + errno = WSAGetLastError(); + return ret; + } #else return write (ciptr->fd, buf, size); #endif /* WIN32 */ @@ -586,7 +598,15 @@ TRANS(DNETDisconnect) (XtransConnInfo ciptr) { PRMSG (2,"DNETDisconnect(%x,%d)\n", ciptr, ciptr->fd, 0); +#ifdef WIN32 + { + int ret = shutdown (ciptr->fd, 2); + errno = WSAGetLastError(); + return ret; + } +#else return shutdown (ciptr->fd, 2); /* disallow further sends and receives */ +#endif } @@ -596,7 +616,15 @@ TRANS(DNETClose) (XtransConnInfo ciptr) { PRMSG (2,"DNETClose(%x,%d)\n", ciptr, ciptr->fd, 0); +#ifdef WIN32 + { + int ret = close (ciptr->fd); + errno = WSAGetLastError(); + return ret; + } +#else return close (ciptr->fd); +#endif } diff --git a/Xtranssock.c b/Xtranssock.c index 0609c90..f413016 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -1,4 +1,4 @@ -/* $XdotOrg$ */ +/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.2 2004/04/23 18:44:27 eich Exp $ */ /* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */ /* @@ -114,6 +114,7 @@ from the copyright holders. #else /* !WIN32 */ #include <X11/Xwinsock.h> +#include <X11/Xwindows.h> #include <X11/Xw32defs.h> #undef close #define close closesocket @@ -122,6 +123,7 @@ from the copyright holders. #define EPROTOTYPE WSAEPROTOTYPE #undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK +#define EINPROGRESS WSAEINPROGRESS #undef EINTR #define EINTR WSAEINTR #define X_INCLUDE_NETDB_H @@ -348,6 +350,9 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr, (void *)&namelen) < 0) { +#ifdef WIN32 + errno = WSAGetLastError(); +#endif PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n", EGET(),0, 0); return -1; @@ -420,6 +425,9 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr, (void *)&namelen) < 0) { +#ifdef WIN32 + errno = WSAGetLastError(); +#endif PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n", EGET(), 0, 0); return -1; @@ -475,6 +483,9 @@ TRANS(SocketOpen) (int i, int type) #endif #endif ) { +#ifdef WIN32 + errno = WSAGetLastError(); +#endif PRMSG (2, "SocketOpen: socket() failed for %s\n", Sockettrans2devtab[i].transname, 0, 0); @@ -1233,6 +1244,9 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) if ((newciptr->fd = accept (ciptr->fd, (struct sockaddr *) &sockname, (void *)&namelen)) < 0) { +#ifdef WIN32 + errno = WSAGetLastError(); +#endif PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0); xfree (newciptr); *status = TRANS_ACCEPT_FAILED; @@ -2081,7 +2095,11 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */ #endif #ifdef WIN32 - return ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); + { + int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); + errno = WSAGetLastError(); + return ret; + } #else #if (defined(i386) && defined(SYSV) && !defined(sco)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1) return ioctl (ciptr->fd, I_NREAD, (char *) pend); @@ -2103,7 +2121,13 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); #if defined(WIN32) || defined(__UNIXOS2__) - return recv ((SOCKET)ciptr->fd, buf, size, 0); + { + int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); +#ifdef WIN32 + errno = WSAGetLastError(); +#endif + return ret; + } #else return read (ciptr->fd, buf, size); #endif /* WIN32 */ @@ -2117,7 +2141,13 @@ TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); #if defined(WIN32) || defined(__UNIXOS2__) - return send ((SOCKET)ciptr->fd, buf, size, 0); + { + int ret = send ((SOCKET)ciptr->fd, buf, size, 0); +#ifdef WIN32 + errno = WSAGetLastError(); +#endif + return ret; + } #else return write (ciptr->fd, buf, size); #endif /* WIN32 */ @@ -2150,7 +2180,15 @@ TRANS(SocketDisconnect) (XtransConnInfo ciptr) { PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0); +#ifdef WIN32 + { + int ret = shutdown (ciptr->fd, 2); + errno = WSAGetLastError(); + return ret; + } +#else return shutdown (ciptr->fd, 2); /* disallow further sends and receives */ +#endif } @@ -2161,7 +2199,15 @@ TRANS(SocketINETClose) (XtransConnInfo ciptr) { PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0); +#ifdef WIN32 + { + int ret = close (ciptr->fd); + errno = WSAGetLastError(); + return ret; + } +#else return close (ciptr->fd); +#endif } #endif /* TCPCONN */ diff --git a/Xtransutil.c b/Xtransutil.c index 2432ba7..cd22b68 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -472,7 +472,7 @@ TRANS(WSAStartup) (void) PRMSG (2,"WSAStartup()\n", 0, 0, 0); - if (!wsadata.wVersion && WSAStartup(MAKEWORD(1,1), &wsadata)) + if (!wsadata.wVersion && WSAStartup(0x0101, &wsadata)) return 1; return 0; } @@ -498,6 +498,7 @@ is_numeric (char *str) #include <errno.h> #if !defined(S_IFLNK) && !defined(S_ISLNK) +#undef lstat #define lstat(a,b) stat(a,b) #endif @@ -523,6 +524,7 @@ trans_mkdir(char *path, int mode) } /* Dir doesn't exist. Try to create it */ +#ifndef WIN32 /* * 'sticky' bit requested: assume application makes * certain security implications. If effective user ID @@ -541,7 +543,9 @@ trans_mkdir(char *path, int mode) path, 0, 0); } } - +#endif + +#ifndef WIN32 if (mkdir(path, mode) == 0) { if (chmod(path, mode)) { PRMSG(1, "mkdir: ERROR: Mode of %s should be set to %04o\n", @@ -550,6 +554,9 @@ trans_mkdir(char *path, int mode) return -1; #endif } +#else + if (mkdir(path) == 0) { +#endif } else { PRMSG(1, "mkdir: ERROR: Cannot create %s\n", path, 0, 0); |