Commit | Line | Data |
0a753a76 |
1 | // sys/socket.h |
2 | |
3 | // djl |
4 | // Provide UNIX compatibility |
5 | |
0a753a76 |
6 | #ifndef _INC_SYS_SOCKET |
7 | #define _INC_SYS_SOCKET |
8 | |
7bac28a0 |
9 | #ifdef __cplusplus |
10 | extern "C" { |
11 | #endif |
0a753a76 |
12 | |
13 | #ifndef _WINDOWS_ |
14 | #define _WINDOWS_ |
15 | |
16 | #define FAR |
17 | #define PASCAL __stdcall |
18 | #define WINAPI __stdcall |
19 | |
20 | #undef WORD |
21 | typedef int BOOL; |
22 | typedef unsigned short WORD; |
23 | typedef void* HANDLE; |
24 | typedef void* HWND; |
25 | typedef int (FAR WINAPI *FARPROC)(); |
26 | |
27 | typedef unsigned long DWORD; |
28 | typedef void *PVOID; |
29 | |
30 | #define IN |
31 | #define OUT |
32 | |
33 | typedef struct _OVERLAPPED { |
34 | DWORD Internal; |
35 | DWORD InternalHigh; |
36 | DWORD Offset; |
37 | DWORD OffsetHigh; |
38 | HANDLE hEvent; |
39 | } OVERLAPPED, *LPOVERLAPPED; |
40 | |
41 | #endif //_WINDOWS_ |
42 | #include <winsock.h> |
43 | |
44 | #define ENOTSOCK WSAENOTSOCK |
45 | #undef HOST_NOT_FOUND |
46 | |
47 | |
48 | SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen); |
49 | int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen); |
50 | int win32_closesocket (SOCKET s); |
51 | int win32_connect (SOCKET s, const struct sockaddr *name, int namelen); |
52 | int win32_ioctlsocket (SOCKET s, long cmd, u_long *argp); |
53 | int win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen); |
54 | int win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen); |
55 | int win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen); |
56 | u_long win32_htonl (u_long hostlong); |
57 | u_short win32_htons (u_short hostshort); |
58 | unsigned long win32_inet_addr (const char * cp); |
59 | char * win32_inet_ntoa (struct in_addr in); |
60 | int win32_listen (SOCKET s, int backlog); |
61 | u_long win32_ntohl (u_long netlong); |
62 | u_short win32_ntohs (u_short netshort); |
63 | int win32_recv (SOCKET s, char * buf, int len, int flags); |
64 | int win32_recvfrom (SOCKET s, char * buf, int len, int flags, |
65 | struct sockaddr *from, int * fromlen); |
66 | int win32_select (int nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout); |
67 | int win32_send (SOCKET s, const char * buf, int len, int flags); |
68 | int win32_sendto (SOCKET s, const char * buf, int len, int flags, |
69 | const struct sockaddr *to, int tolen); |
70 | int win32_setsockopt (SOCKET s, int level, int optname, |
71 | const char * optval, int optlen); |
72 | SOCKET win32_socket (int af, int type, int protocol); |
73 | int win32_shutdown (SOCKET s, int how); |
74 | |
75 | /* Database function prototypes */ |
76 | |
77 | struct hostent * win32_gethostbyaddr(const char * addr, int len, int type); |
78 | struct hostent * win32_gethostbyname(const char * name); |
79 | int win32_gethostname (char * name, int namelen); |
80 | struct servent * win32_getservbyport(int port, const char * proto); |
81 | struct servent * win32_getservbyname(const char * name, const char * proto); |
82 | struct protoent * win32_getprotobynumber(int proto); |
83 | struct protoent * win32_getprotobyname(const char * name); |
84 | struct protoent *win32_getprotoent(void); |
85 | struct servent *win32_getservent(void); |
86 | void win32_sethostent(int stayopen); |
87 | void win32_setnetent(int stayopen); |
3e3baf6d |
88 | struct netent * win32_getnetent(void); |
89 | struct netent * win32_getnetbyname(char *name); |
90 | struct netent * win32_getnetbyaddr(long net, int type); |
0a753a76 |
91 | void win32_setprotoent(int stayopen); |
92 | void win32_setservent(int stayopen); |
3e3baf6d |
93 | void win32_endhostent(void); |
94 | void win32_endnetent(void); |
95 | void win32_endprotoent(void); |
96 | void win32_endservent(void); |
0a753a76 |
97 | |
98 | // |
99 | // direct to our version |
100 | // |
101 | #define htonl win32_htonl |
102 | #define htons win32_htons |
103 | #define ntohl win32_ntohl |
104 | #define ntohs win32_ntohs |
105 | #define inet_addr win32_inet_addr |
106 | #define inet_ntoa win32_inet_ntoa |
107 | |
108 | #define socket win32_socket |
109 | #define bind win32_bind |
110 | #define listen win32_listen |
111 | #define accept win32_accept |
112 | #define connect win32_connect |
113 | #define send win32_send |
114 | #define sendto win32_sendto |
115 | #define recv win32_recv |
116 | #define recvfrom win32_recvfrom |
117 | #define shutdown win32_shutdown |
118 | #define ioctlsocket win32_ioctlsocket |
119 | #define setsockopt win32_setsockopt |
120 | #define getsockopt win32_getsockopt |
121 | #define getpeername win32_getpeername |
122 | #define getsockname win32_getsockname |
123 | #define gethostname win32_gethostname |
124 | #define gethostbyname win32_gethostbyname |
125 | #define gethostbyaddr win32_gethostbyaddr |
126 | #define getprotobyname win32_getprotobyname |
127 | #define getprotobynumber win32_getprotobynumber |
128 | #define getservbyname win32_getservbyname |
129 | #define getservbyport win32_getservbyport |
130 | #define select win32_select |
131 | #define endhostent win32_endhostent |
132 | #define endnetent win32_endnetent |
133 | #define endprotoent win32_endprotoent |
134 | #define endservent win32_endservent |
135 | #define getnetent win32_getnetent |
136 | #define getnetbyname win32_getnetbyname |
137 | #define getnetbyaddr win32_getnetbyaddr |
138 | #define getprotoent win32_getprotoent |
139 | #define getservent win32_getservent |
140 | #define sethostent win32_sethostent |
141 | #define setnetent win32_setnetent |
142 | #define setprotoent win32_setprotoent |
143 | #define setservent win32_setservent |
144 | |
145 | #ifdef __cplusplus |
146 | } |
147 | #endif |
148 | |
149 | #endif // _INC_SYS_SOCKET |