| 1 |
/* |
| 2 |
* Copyright (C) 1994-1998 T. Teranishi |
| 3 |
* (C) 2007- TeraTerm Project |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
| 7 |
* modification, are permitted provided that the following conditions |
| 8 |
* are met: |
| 9 |
* |
| 10 |
* 1. Redistributions of source code must retain the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer. |
| 12 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
* documentation and/or other materials provided with the distribution. |
| 15 |
* 3. The name of the author may not be used to endorse or promote products |
| 16 |
* derived from this software without specific prior written permission. |
| 17 |
* |
| 18 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| 19 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 |
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
*/ |
| 29 |
/* IPv6 modification is Copyright(C) 2000 Jun-ya Kato <kato@win6.jp> */ |
| 30 |
|
| 31 |
/* TERATERM.EXE, Winsock interface */ |
| 32 |
#include <winsock2.h> |
| 33 |
#include <ws2tcpip.h> |
| 34 |
|
| 35 |
#ifdef __cplusplus |
| 36 |
extern "C" { |
| 37 |
#endif |
| 38 |
|
| 39 |
typedef int (PASCAL *Tclosesocket) (SOCKET s); |
| 40 |
typedef int (PASCAL *Tconnect) |
| 41 |
(SOCKET s, const struct sockaddr *name, int namelen); |
| 42 |
typedef u_long (PASCAL *Thtonl) |
| 43 |
(u_long hostlong); |
| 44 |
typedef u_short (PASCAL *Thtons) |
| 45 |
(u_short hostshort); |
| 46 |
typedef unsigned long (PASCAL *Tinet_addr) |
| 47 |
(const char * cp); |
| 48 |
typedef int (PASCAL *Tioctlsocket) |
| 49 |
(SOCKET s, long cmd, u_long *argp); |
| 50 |
typedef int (PASCAL *Trecv) |
| 51 |
(SOCKET s, char * buf, int len, int flags); |
| 52 |
typedef int (PASCAL *Tselect) |
| 53 |
(int nfds, fd_set *readfds, fd_set *writefds, |
| 54 |
fd_set *exceptfds, const struct timeval *timeout); |
| 55 |
typedef int (PASCAL *Tsend) |
| 56 |
(SOCKET s, const char * buf, int len, int flags); |
| 57 |
typedef int (PASCAL *Tsetsockopt) |
| 58 |
(SOCKET s, int level, int optname, |
| 59 |
const char * optval, int optlen); |
| 60 |
typedef SOCKET (PASCAL *Tsocket) |
| 61 |
(int af, int type, int protocol); |
| 62 |
//typedef struct hostent * (PASCAL *Tgethostbyname) |
| 63 |
// (const char * name); |
| 64 |
typedef int (PASCAL *TWSAStartup) |
| 65 |
(WORD wVersionRequired, LPWSADATA lpWSAData); |
| 66 |
typedef int (PASCAL *TWSACleanup)(void); |
| 67 |
typedef int (PASCAL *TWSAAsyncSelect) |
| 68 |
(SOCKET s, HWND hWnd, u_int wMsg,long lEvent); |
| 69 |
typedef HANDLE (PASCAL *TWSAAsyncGetHostByName) |
| 70 |
(HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen); |
| 71 |
typedef int (PASCAL *TWSACancelAsyncRequest)(HANDLE hAsyncTaskHandle); |
| 72 |
typedef int (PASCAL *TWSAGetLastError)(void); |
| 73 |
typedef HANDLE (PASCAL *TWSAAsyncGetAddrInfo) |
| 74 |
(HWND hWnd, unsigned int wMsg, const char * hostname, |
| 75 |
const char * portname, struct addrinfo * hints, |
| 76 |
struct addrinfo * * res); |
| 77 |
// typedef int (PASCAL *Tgetaddrinfo)(const char *name, const char *port, const struct addrinfo *hints, struct addrinfo **res); |
| 78 |
typedef void (PASCAL *Tfreeaddrinfo)(struct addrinfo *ai); |
| 79 |
|
| 80 |
BOOL LoadWinsock(); |
| 81 |
void FreeWinsock(); |
| 82 |
|
| 83 |
extern Tclosesocket Pclosesocket; |
| 84 |
extern Tconnect Pconnect; |
| 85 |
extern Thtonl Phtonl; |
| 86 |
extern Thtons Phtons; |
| 87 |
extern Tinet_addr Pinet_addr; |
| 88 |
extern Tioctlsocket Pioctlsocket; |
| 89 |
extern Trecv Precv; |
| 90 |
extern Tselect Pselect; |
| 91 |
extern Tsend Psend; |
| 92 |
extern Tsetsockopt Psetsockopt; |
| 93 |
extern Tsocket Psocket; |
| 94 |
// extern Tgethostbyname Pgethostbyname; |
| 95 |
extern TWSAAsyncSelect PWSAAsyncSelect; |
| 96 |
extern TWSAAsyncGetHostByName PWSAAsyncGetHostByName; |
| 97 |
extern TWSACancelAsyncRequest PWSACancelAsyncRequest; |
| 98 |
extern TWSAGetLastError PWSAGetLastError; |
| 99 |
extern TWSAStartup PWSAStartup; |
| 100 |
extern TWSACleanup PWSACleanup; |
| 101 |
extern TWSAAsyncGetAddrInfo PWSAAsyncGetAddrInfo; |
| 102 |
// extern Tgetaddrinfo Pgetaddrinfo; |
| 103 |
extern Tfreeaddrinfo Pfreeaddrinfo; |
| 104 |
|
| 105 |
#ifdef __cplusplus |
| 106 |
} |
| 107 |
#endif |
| 108 |
|