1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * d_winsock.h
|
---|
4 | * Copyright (C) 1996
|
---|
5 | *
|
---|
6 | * A component of the fnord webserver written by [email protected].
|
---|
7 | *
|
---|
8 | * Altered for use with the Greenstone digital library software by the
|
---|
9 | * New Zealand Digital Library Project at the University of Waikato,
|
---|
10 | * New Zealand.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | #ifndef D_WINSOCK_H
|
---|
29 | #define D_WINSOCK_H
|
---|
30 |
|
---|
31 | /* get most definitions from the real winsock */
|
---|
32 | #include <winsock.h>
|
---|
33 |
|
---|
34 | #define D_NOERROR 0
|
---|
35 | #define D_ERR_UNEXPECTED 1
|
---|
36 | #define D_ERR_LOADFAILED 2
|
---|
37 | #define D_ERR_FREELIBFAILED 3
|
---|
38 |
|
---|
39 | // d_LoadWinsock must be called before an normal winsock
|
---|
40 | // functions
|
---|
41 |
|
---|
42 | // expects path to be NULL, a empty string, or a path which ends in a slash
|
---|
43 | // returns D_NOERROR on success,
|
---|
44 | // D_ERR_UNEXPECTED or D_ERR_LOADFAILED on failure
|
---|
45 | int d_LoadWinsock (char *path);
|
---|
46 |
|
---|
47 | // returns D_NOERROR on success,
|
---|
48 | // D_ERR_FREELIBFAILED on failure
|
---|
49 | int d_UnloadWinsock ();
|
---|
50 |
|
---|
51 | // dynamically loaded versions of the winsock functions
|
---|
52 |
|
---|
53 | SOCKET d_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
|
---|
54 | int d_bind (SOCKET s, const struct sockaddr *addr, int namelen);
|
---|
55 | int d_closesocket (SOCKET s);
|
---|
56 | int d_connect (SOCKET s, const struct sockaddr *name, int namelen);
|
---|
57 | int d_ioctlsocket (SOCKET s, long cmd, u_long *argp);
|
---|
58 | int d_getpeername (SOCKET s, struct sockaddr *name, int *namelen);
|
---|
59 | int d_getsockname (SOCKET s, struct sockaddr *name, int *namelen);
|
---|
60 | int d_getsockopt (SOCKET s, int level, int optname, char *optval, int *optlen);
|
---|
61 | u_long d_htonl (u_long hostlong);
|
---|
62 | u_short d_htons (u_short hostshort);
|
---|
63 | unsigned long d_inet_addr (const char *cp);
|
---|
64 | char *d_inet_ntoa (struct in_addr in);
|
---|
65 | int d_listen (SOCKET s, int backlog);
|
---|
66 | u_long d_ntohl (u_long netlong);
|
---|
67 | u_short d_ntohs (u_short netshort);
|
---|
68 | int d_recv (SOCKET s, char *buf, int len, int flags);
|
---|
69 | int d_recvfrom (SOCKET s, char *buf, int len, int flags,
|
---|
70 | struct sockaddr *from, int *fromlen);
|
---|
71 | int d_select (int nfds, fd_set *readfds, fd_set *writefds,
|
---|
72 | fd_set *exceptfds, const struct timeval *timeout);
|
---|
73 | int d_send (SOCKET s, const char *buf, int len, int flags);
|
---|
74 | int d_sendto (SOCKET s, const char *buf, int len, int flags,
|
---|
75 | const struct sockaddr *to, int tolen);
|
---|
76 | int d_setsockopt (SOCKET s, int level, int optname,
|
---|
77 | const char *optval, int optlen);
|
---|
78 | int d_shutdown (SOCKET s, int how);
|
---|
79 | SOCKET d_socket (int af, int type, int protocol);
|
---|
80 |
|
---|
81 | hostent *d_gethostbyaddr(const char *addr, int len, int type);
|
---|
82 | hostent *d_gethostbyname(const char *name);
|
---|
83 | int d_gethostname (char *name, int namelen);
|
---|
84 | servent *d_getservbyport(int port, const char *proto);
|
---|
85 | servent *d_getservbyname(const char *name, const char *proto);
|
---|
86 | protoent *d_getprotobynumber(int proto);
|
---|
87 | protoent *d_getprotobyname(const char *name);
|
---|
88 |
|
---|
89 | int d_WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
|
---|
90 | int d_WSACleanup(void);
|
---|
91 | void d_WSASetLastError(int iError);
|
---|
92 | int d_WSAGetLastError(void);
|
---|
93 | BOOL d_WSAIsBlocking(void);
|
---|
94 | int d_WSAUnhookBlockingHook(void);
|
---|
95 | FARPROC d_WSASetBlockingHook(FARPROC lpBlockFunc);
|
---|
96 | int d_WSACancelBlockingCall(void);
|
---|
97 | HANDLE d_WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
|
---|
98 | const char *name,
|
---|
99 | const char *proto,
|
---|
100 | char *buf, int buflen);
|
---|
101 | HANDLE d_WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
|
---|
102 | const char *proto, char *buf,
|
---|
103 | int buflen);
|
---|
104 | HANDLE d_WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
|
---|
105 | const char *name, char *buf,
|
---|
106 | int buflen);
|
---|
107 | HANDLE d_WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
|
---|
108 | int number, char *buf,
|
---|
109 | int buflen);
|
---|
110 | HANDLE d_WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
|
---|
111 | const char *name, char *buf,
|
---|
112 | int buflen);
|
---|
113 | HANDLE d_WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
|
---|
114 | const char *addr, int len, int type,
|
---|
115 | char *buf, int buflen);
|
---|
116 | int d_WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
|
---|
117 | int d_WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
|
---|
118 | long lEvent);
|
---|
119 |
|
---|
120 | #endif
|
---|