aboutsummaryrefslogtreecommitdiff
path: root/src/win32_compatibility.cpp
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2009-01-14 20:05:02 +0000
committerDavid <david@xagasoft.com>2009-01-14 20:05:02 +0000
commit3ee5204eb254e914d695a37fede11c8599415fa9 (patch)
tree26b92fba438d16a0d2e896f92f106125e04abf94 /src/win32_compatibility.cpp
parente771f7c48d38d1c1481b9904d17ed7989d6cd579 (diff)
downloadlibbu++-3ee5204eb254e914d695a37fede11c8599415fa9.tar.gz
libbu++-3ee5204eb254e914d695a37fede11c8599415fa9.tar.bz2
libbu++-3ee5204eb254e914d695a37fede11c8599415fa9.tar.xz
libbu++-3ee5204eb254e914d695a37fede11c8599415fa9.zip
david - added getaddrinfo and freeaddrinfo
Diffstat (limited to '')
-rw-r--r--src/win32_compatibility.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/win32_compatibility.cpp b/src/win32_compatibility.cpp
index 372dd6c..0ef3abc 100644
--- a/src/win32_compatibility.cpp
+++ b/src/win32_compatibility.cpp
@@ -53,15 +53,19 @@ int DynamicWinsock2::select(int nfds, fd_set *readfds, fd_set *writefds,
53typedef SOCKET (__cdecl *FNDEF_DYN_socket)(int,int,int); 53typedef SOCKET (__cdecl *FNDEF_DYN_socket)(int,int,int);
54SOCKET DynamicWinsock2::socket(int domain, int type, int protocol) 54SOCKET DynamicWinsock2::socket(int domain, int type, int protocol)
55{ 55{
56 printf("in win32::socket\n");
56 SOCKET out = 0; 57 SOCKET out = 0;
57 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32")); 58 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32"));
59 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
58 if( Ws2_32 != NULL ) 60 if( Ws2_32 != NULL )
59 { 61 {
60 FNDEF_DYN_socket fn = (FNDEF_DYN_socket) 62 FNDEF_DYN_socket fn = (FNDEF_DYN_socket)
61 GetProcAddress( Ws2_32, "socket" ); 63 GetProcAddress( Ws2_32, "socket" );
64 printf("socket function pointer: %08x\n", (int)fn);
62 if( fn != NULL ) 65 if( fn != NULL )
63 out = (fn)( domain, type, protocol ); 66 out = (fn)( domain, type, protocol );
64 } 67 }
68 printf("win32::socket complete.\n");
65 return out; 69 return out;
66} 70}
67 71
@@ -125,6 +129,37 @@ struct hostent *DynamicWinsock2::gethostbyname(const char *name)
125 return out; 129 return out;
126} 130}
127 131
132typedef void (__cdecl *FNDEF_DYN_freeaddrinfo)(struct addrinfo *);
133void DynamicWinsock2::freeaddrinfo(struct addrinfo *ai)
134{
135 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32"));
136 if( Ws2_32 != NULL )
137 {
138 FNDEF_DYN_freeaddrinfo fn = (FNDEF_DYN_freeaddrinfo)
139 GetProcAddress( Ws2_32, "freeaddrinfo" );
140 if( fn != NULL )
141 (fn)( ai );
142 }
143}
144
145typedef int (__cdecl *FNDEF_DYN_getaddrinfo)(
146 const char*,const char*,const struct addrinfo*,struct addrinfo**);
147int DynamicWinsock2::getaddrinfo(
148 const char *nodename, const char *servname,
149 const struct addrinfo *hints, struct addrinfo **res )
150{
151 int out = 0;
152 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32"));
153 if( Ws2_32 != NULL )
154 {
155 FNDEF_DYN_getaddrinfo fn = (FNDEF_DYN_getaddrinfo)
156 GetProcAddress( Ws2_32, "getaddrinfo" );
157 if( fn != NULL )
158 out = (fn)( nodename, servname, hints, res );
159 }
160 return out;
161}
162
128typedef int (__cdecl *FNDEF_DYN_connect)(SOCKET,const struct sockaddr*,int); 163typedef int (__cdecl *FNDEF_DYN_connect)(SOCKET,const struct sockaddr*,int);
129int DynamicWinsock2::connect( 164int DynamicWinsock2::connect(
130 SOCKET s, const struct sockaddr *serv_addr, int addrlen) 165 SOCKET s, const struct sockaddr *serv_addr, int addrlen)