aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2009-01-14 21:06:20 +0000
committerDavid <david@xagasoft.com>2009-01-14 21:06:20 +0000
commitb49973db8489f02e10e3475b6a8a199d919a6efa (patch)
tree3aff4a0ea51c91445f236cd75b52a716a87625e2
parent13de3079105d65f130db04adc9d3004f4651cd69 (diff)
downloadlibbu++-b49973db8489f02e10e3475b6a8a199d919a6efa.tar.gz
libbu++-b49973db8489f02e10e3475b6a8a199d919a6efa.tar.bz2
libbu++-b49973db8489f02e10e3475b6a8a199d919a6efa.tar.xz
libbu++-b49973db8489f02e10e3475b6a8a199d919a6efa.zip
david - WSA functions
-rw-r--r--src/win32_compatibility.cpp53
-rw-r--r--src/win32_compatibility.h9
2 files changed, 62 insertions, 0 deletions
diff --git a/src/win32_compatibility.cpp b/src/win32_compatibility.cpp
index 0ef3abc..083925b 100644
--- a/src/win32_compatibility.cpp
+++ b/src/win32_compatibility.cpp
@@ -2,6 +2,59 @@
2 2
3#ifdef WIN32 3#ifdef WIN32
4 4
5typedef int (__cdecl *FNDEF_DYN_WSAStartup)(WORD,LPWSADATA);
6int DynamicWinsock2::WSAStartup(
7 WORD wVersionRequested,LPWSADATA lpWSAData)
8{
9 int out=0;
10 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
11 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
12 if( Ws2_32 != NULL )
13 {
14 FNDEF_DYN_WSAStartup fn = (FNDEF_DYN_WSAStartup)
15 GetProcAddress( Ws2_32, "WSAStartup" );
16 printf("WSAStartup function pointer: %08x\n", (int)fn);
17 if( fn != NULL )
18 out = (fn)(wVersionRequested,lpWSAData);
19 }
20 return out;
21}
22
23typedef int (__cdecl *FNDEF_DYN_WSACleanup)();
24int DynamicWinsock2::WSACleanup()
25{
26 int out=0;
27 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
28 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
29 if( Ws2_32 != NULL )
30 {
31 FNDEF_DYN_WSACleanup fn = (FNDEF_DYN_WSACleanup)
32 GetProcAddress( Ws2_32, "WSACleanup" );
33 printf("WSACleanup function pointer: %08x\n", (int)fn);
34 if( fn != NULL )
35 out = (fn)();
36 }
37 return out;
38}
39
40//typedef char * (__cdecl *FNDEF_DYN_gai_strerrorA)( int ecode );
41typedef int (__cdecl *FNDEF_DYN_WSAGetLastError)(void);
42int DynamicWinsock2::WSAGetLastError()
43{
44 int out=0;
45 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
46 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
47 if( Ws2_32 != NULL )
48 {
49 FNDEF_DYN_WSAGetLastError fn = (FNDEF_DYN_WSAGetLastError)
50 GetProcAddress( Ws2_32, "WSAGetLastError" );
51 printf("WSAGetLastError function pointer: %08x\n", (int)fn);
52 if( fn != NULL )
53 out = (fn)();
54 }
55 return out;
56}
57
5typedef char * (__cdecl *FNDEF_DYN_inet_ntoa)( struct in_addr ); 58typedef char * (__cdecl *FNDEF_DYN_inet_ntoa)( struct in_addr );
6void DynamicWinsock2::inet_ntoa( Bu::FString &out, struct in_addr addr_in ) 59void DynamicWinsock2::inet_ntoa( Bu::FString &out, struct in_addr addr_in )
7{ 60{
diff --git a/src/win32_compatibility.h b/src/win32_compatibility.h
index 8bf3a00..72cb4f7 100644
--- a/src/win32_compatibility.h
+++ b/src/win32_compatibility.h
@@ -16,8 +16,14 @@
16 16
17#ifdef WIN32 17#ifdef WIN32
18 18
19#ifdef __cplusplus
20extern "C"
21{
19#include <Winsock2.h> 22#include <Winsock2.h>
20#include <ws2tcpip.h> 23#include <ws2tcpip.h>
24}
25#endif
26
21#include "fstring.h" 27#include "fstring.h"
22 28
23#ifndef TEMP_FAILURE_RETRY 29#ifndef TEMP_FAILURE_RETRY
@@ -33,6 +39,9 @@ __extension__ typedef int socklen_t;
33 39
34namespace DynamicWinsock2 40namespace DynamicWinsock2
35{ 41{
42 int WSAStartup(WORD wVersionRequested,LPWSADATA lpWSAData);
43 int WSACleanup(void);
44 int WSAGetLastError();
36 void inet_ntoa( Bu::FString &out, struct in_addr addr_in ); 45 void inet_ntoa( Bu::FString &out, struct in_addr addr_in );
37 unsigned long inet_addr( const char *s_in ); 46 unsigned long inet_addr( const char *s_in );
38 int select(int nfds, fd_set *readfds, fd_set *writefds, 47 int select(int nfds, fd_set *readfds, fd_set *writefds,