| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifndef __xport_h |
| 11 |
#define __xport_h |
| 12 |
|
| 13 |
#if HAVE_CONFIG_H |
| 14 |
#include <conf.h> |
| 15 |
#endif |
| 16 |
|
| 17 |
#if HAVE_MINGW32 |
| 18 |
|
| 19 |
#define FD_SETSIZE 8192 |
| 20 |
#include <winsock2.h> |
| 21 |
#include <process.h> |
| 22 |
#include <io.h> |
| 23 |
|
| 24 |
#ifdef EINPROGRESS |
| 25 |
#undef EINPROGRESS |
| 26 |
#endif |
| 27 |
#define EINPROGRESS WSAEINPROGRESS |
| 28 |
#ifdef EINTR |
| 29 |
#undef EINTR |
| 30 |
#endif |
| 31 |
#define EINTR WSAEINTR |
| 32 |
#ifdef ETIMEDOUT |
| 33 |
#undef ETIMEDOUT |
| 34 |
#endif |
| 35 |
#define ETIMEDOUT WSAETIMEDOUT |
| 36 |
#ifdef ECONNREFUSED |
| 37 |
#undef ECONNREFUSED |
| 38 |
#endif |
| 39 |
#define ECONNREFUSED WSAECONNREFUSED |
| 40 |
#ifdef EWOULDBLOCK |
| 41 |
#undef EWOULDBLOCK |
| 42 |
#endif |
| 43 |
#define EWOULDBLOCK WSAEWOULDBLOCK |
| 44 |
#ifdef EAGAIN |
| 45 |
#undef EAGAIN |
| 46 |
#endif |
| 47 |
#define EAGAIN WSAEWOULDBLOCK |
| 48 |
|
| 49 |
#else |
| 50 |
|
| 51 |
#include <sys/types.h> |
| 52 |
#include <sys/wait.h> |
| 53 |
#include <sys/socket.h> |
| 54 |
#include <netinet/in.h> |
| 55 |
#include <netdb.h> |
| 56 |
#include <arpa/inet.h> |
| 57 |
#if HAVE_SYS_UN_H |
| 58 |
#include <sys/un.h> |
| 59 |
#endif |
| 60 |
#if HAVE_CYGWIN |
| 61 |
#include <process.h> |
| 62 |
#endif |
| 63 |
|
| 64 |
#endif |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
#define xsocket(a,b,c) socket(a,b,c) |
| 69 |
#define xbind(a,b,c) bind(a,b,c) |
| 70 |
#define xaccept(a,b,c) accept(a,b,c) |
| 71 |
#define xselect(a,b,c,d,e) select(a,b,c,d,e) |
| 72 |
|
| 73 |
|
| 74 |
#if HAVE_MINGW32==0 |
| 75 |
|
| 76 |
#define xclose(a) close(a) |
| 77 |
|
| 78 |
#define xfcntl(a,b,c) fcntl(a,b,c) |
| 79 |
|
| 80 |
#define xfcntl_nonblock(a,b) \ |
| 81 |
b = fcntl(a, F_GETFL, 0); \ |
| 82 |
fcntl(a, F_SETFL, b|O_NONBLOCK) |
| 83 |
|
| 84 |
#define xfcntl_restore(a,b) fcntl(a, F_SETFL, b) |
| 85 |
|
| 86 |
#define xsocketstartup() |
| 87 |
|
| 88 |
#define xsocketcleanup() |
| 89 |
|
| 90 |
#define xfd_set_stdin(a,b) FD_SET(a,b) |
| 91 |
#define xfd_isset_stdin(a,b) (a >= 0) && FD_ISSET(a,b) |
| 92 |
#define xfd_clr_stdin(a,b) FD_CLR(a,b) |
| 93 |
|
| 94 |
#define xsignal_sigpipe() signal(SIGPIPE, SIG_IGN) |
| 95 |
|
| 96 |
#define xerrno errno |
| 97 |
|
| 98 |
#define xmkdir(a,b) mkdir(a,b) |
| 99 |
#define xchmod(a,b) chmod(a,b) |
| 100 |
|
| 101 |
|
| 102 |
#else |
| 103 |
|
| 104 |
#define xclose(a) closesocket(a) |
| 105 |
|
| 106 |
#define xfcntl(a,b,c) |
| 107 |
|
| 108 |
#define xfcntl_nonblock(a,b) \ |
| 109 |
{ \ |
| 110 |
int iomode=1; \ |
| 111 |
ioctlsocket(a, FIONBIO, (u_long FAR *) &iomode); \ |
| 112 |
} |
| 113 |
|
| 114 |
#define xfcntl_restore(a,b) \ |
| 115 |
{ \ |
| 116 |
int iomode=0; \ |
| 117 |
ioctlsocket(a, FIONBIO, (u_long FAR *) &iomode); \ |
| 118 |
} |
| 119 |
|
| 120 |
#define xsocketstartup() \ |
| 121 |
{ \ |
| 122 |
WSADATA wsaData; \ |
| 123 |
WSAStartup(MAKEWORD(2,0), &wsaData); \ |
| 124 |
} |
| 125 |
|
| 126 |
#define xsocketcleanup() WSACleanup() |
| 127 |
|
| 128 |
#define xfd_set_stdin(a,b) setmode(a, O_BINARY) |
| 129 |
|
| 130 |
#define xfd_isset_stdin(a,b) (a >= 0) |
| 131 |
#define xfd_clr_stdin(a,b) |
| 132 |
|
| 133 |
#define xsignal_sigpipe() |
| 134 |
|
| 135 |
#define xerrno WSAGetLastError() |
| 136 |
|
| 137 |
#define xmkdir(a,b) mkdir(a) |
| 138 |
#define xchmod(a,b) chmod(a,b) |
| 139 |
|
| 140 |
#endif |
| 141 |
|
| 142 |
#endif |