From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/compat/win32.cpp | 134 +++++++++++++++++++++++++-------------------------- src/compat/win32.h | 104 +++++++++++++++++++-------------------- 2 files changed, 119 insertions(+), 119 deletions(-) (limited to 'src/compat') diff --git a/src/compat/win32.cpp b/src/compat/win32.cpp index e1151b0..38b9ad7 100644 --- a/src/compat/win32.cpp +++ b/src/compat/win32.cpp @@ -10,7 +10,7 @@ #ifdef WIN32 #define deffunc( name ) \ - Bu::Winsock2::FNDEF_DYN_ ##name Bu::Winsock2::_fnptr_ ##name = NULL + Bu::Winsock2::FNDEF_DYN_ ##name Bu::Winsock2::_fnptr_ ##name = NULL char Bu::Winsock2::scode[32]; @@ -33,133 +33,133 @@ deffunc( getpeername ); deffunc( setsockopt ); deffunc( bind ); deffunc( listen ); -deffunc( accept ); +deffunc( accept ); deffunc( recv ); deffunc( send ); deffunc( __WSAFDIsSet ); // Safely get a function from the library #define getfunc( name ) \ - Bu::Winsock2::_fnptr_ ##name = (FNDEF_DYN_ ##name) \ - GetProcAddress( Ws2_32, #name ); \ - if( Bu::Winsock2::_fnptr_ ##name == NULL ) { \ - throw Bu::ExceptionBase("Error loading function " #name " from dll.");\ - } (void)0 + Bu::Winsock2::_fnptr_ ##name = (FNDEF_DYN_ ##name) \ + GetProcAddress( Ws2_32, #name ); \ + if( Bu::Winsock2::_fnptr_ ##name == NULL ) { \ + throw Bu::ExceptionBase("Error loading function " #name " from dll.");\ + } (void)0 Bu::Winsock2::Winsock2() { - Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); - - getfunc( WSAStartup ); - getfunc( WSACleanup ); - getfunc( WSAGetLastError ); - getfunc( inet_ntoa ); - getfunc( inet_addr ); - getfunc( select ); - getfunc( socket ); - getfunc( shutdown ); - getfunc( ioctlsocket ); - getfunc( htons ); - getfunc( htonl ); - getfunc( gethostbyname ); - getfunc( freeaddrinfo ); - getfunc( getaddrinfo ); - getfunc( connect ); - getfunc( getpeername ); - getfunc( setsockopt ); - getfunc( bind ); - getfunc( listen ); - getfunc( accept ); - getfunc( recv ); - getfunc( send ); - getfunc( __WSAFDIsSet ); - - Bu::Winsock2::WSAStartup( MAKEWORD(2, 2), &wsaData ); + Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); + + getfunc( WSAStartup ); + getfunc( WSACleanup ); + getfunc( WSAGetLastError ); + getfunc( inet_ntoa ); + getfunc( inet_addr ); + getfunc( select ); + getfunc( socket ); + getfunc( shutdown ); + getfunc( ioctlsocket ); + getfunc( htons ); + getfunc( htonl ); + getfunc( gethostbyname ); + getfunc( freeaddrinfo ); + getfunc( getaddrinfo ); + getfunc( connect ); + getfunc( getpeername ); + getfunc( setsockopt ); + getfunc( bind ); + getfunc( listen ); + getfunc( accept ); + getfunc( recv ); + getfunc( send ); + getfunc( __WSAFDIsSet ); + + Bu::Winsock2::WSAStartup( MAKEWORD(2, 2), &wsaData ); } Bu::Winsock2::~Winsock2() { - Bu::Winsock2::WSACleanup(); - FreeLibrary( Ws2_32 ); + Bu::Winsock2::WSACleanup(); + FreeLibrary( Ws2_32 ); } char *Bu::Winsock2::gai_strerror( int iCode ) { - sprintf( scode, "%d (%d)", iCode, Bu::Winsock2::WSAGetLastError() ); - return scode; + sprintf( scode, "%d (%d)", iCode, Bu::Winsock2::WSAGetLastError() ); + return scode; } int Bu::Winsock2::WSAStartup( WORD a, LPWSADATA b ) { - return (*Bu::Winsock2::_fnptr_WSAStartup)( a, b ); + return (*Bu::Winsock2::_fnptr_WSAStartup)( a, b ); } int Bu::Winsock2::WSACleanup( ) { - return (*Bu::Winsock2::_fnptr_WSACleanup)(); + return (*Bu::Winsock2::_fnptr_WSACleanup)(); } int Bu::Winsock2::WSAGetLastError( ) { - return (*Bu::Winsock2::_fnptr_WSAGetLastError)(); + return (*Bu::Winsock2::_fnptr_WSAGetLastError)(); } char * Bu::Winsock2::inet_ntoa( struct in_addr a ) { - return (*Bu::Winsock2::_fnptr_inet_ntoa)( a ); + return (*Bu::Winsock2::_fnptr_inet_ntoa)( a ); } unsigned long Bu::Winsock2::inet_addr( const char *s_in ) { - return (*Bu::Winsock2::_fnptr_inet_addr)( s_in ); + return (*Bu::Winsock2::_fnptr_inet_addr)( s_in ); } int Bu::Winsock2::select( int a, fd_set *b, fd_set *c, fd_set *d, - const struct timeval *e ) { - return (*Bu::Winsock2::_fnptr_select)( a, b, c, d, e ); + const struct timeval *e ) { + return (*Bu::Winsock2::_fnptr_select)( a, b, c, d, e ); } SOCKET Bu::Winsock2::socket( int domain, int type, int protocol ) { - return (*Bu::Winsock2::_fnptr_socket)( domain, type, protocol ); + return (*Bu::Winsock2::_fnptr_socket)( domain, type, protocol ); } int Bu::Winsock2::shutdown( SOCKET s, int how ) { - return (*Bu::Winsock2::_fnptr_shutdown)( s, how ); + return (*Bu::Winsock2::_fnptr_shutdown)( s, how ); } int Bu::Winsock2::ioctlsocket( SOCKET s, long cmd, u_long *argp ) { - return (*Bu::Winsock2::_fnptr_ioctlsocket)( s, cmd, argp ); + return (*Bu::Winsock2::_fnptr_ioctlsocket)( s, cmd, argp ); } u_short Bu::Winsock2::htons( u_short in ) { - return (*Bu::Winsock2::_fnptr_htons)( in ); + return (*Bu::Winsock2::_fnptr_htons)( in ); } u_long Bu::Winsock2::htonl( u_long in ) { - return (*Bu::Winsock2::_fnptr_htonl)( in ); + return (*Bu::Winsock2::_fnptr_htonl)( in ); } struct hostent * Bu::Winsock2::gethostbyname( const char *name ) { - return (*Bu::Winsock2::_fnptr_gethostbyname)( name ); + return (*Bu::Winsock2::_fnptr_gethostbyname)( name ); } void Bu::Winsock2::freeaddrinfo( struct addrinfo *ai ) { - return (*Bu::Winsock2::_fnptr_freeaddrinfo)( ai ); + return (*Bu::Winsock2::_fnptr_freeaddrinfo)( ai ); } int Bu::Winsock2::getaddrinfo( const char *a, const char *b, - const struct addrinfo *c, struct addrinfo **d ) { - return (*Bu::Winsock2::_fnptr_getaddrinfo)( a, b, c, d ); + const struct addrinfo *c, struct addrinfo **d ) { + return (*Bu::Winsock2::_fnptr_getaddrinfo)( a, b, c, d ); } int Bu::Winsock2::connect( SOCKET s, const struct sockaddr *a, int b ) { - return (*Bu::Winsock2::_fnptr_connect)( s, a, b ); + return (*Bu::Winsock2::_fnptr_connect)( s, a, b ); } int Bu::Winsock2::getpeername( SOCKET s, struct sockaddr *a, int *b ) { - return (*Bu::Winsock2::_fnptr_getpeername)( s, a, b); + return (*Bu::Winsock2::_fnptr_getpeername)( s, a, b); } int Bu::Winsock2::setsockopt( SOCKET s, int a, int b, - const char *c, int d ) { - return (*Bu::Winsock2::_fnptr_setsockopt)( s, a, b, c, d ); + const char *c, int d ) { + return (*Bu::Winsock2::_fnptr_setsockopt)( s, a, b, c, d ); } int Bu::Winsock2::bind( SOCKET s, const struct sockaddr *a, int b ) { - return (*Bu::Winsock2::_fnptr_bind)( s, a, b ); + return (*Bu::Winsock2::_fnptr_bind)( s, a, b ); } int Bu::Winsock2::listen( SOCKET s, int backlog ) { - return (*Bu::Winsock2::_fnptr_listen)( s, backlog ); + return (*Bu::Winsock2::_fnptr_listen)( s, backlog ); } -SOCKET Bu::Winsock2::accept( SOCKET s, struct sockaddr *a, int *b ) { - return (*Bu::Winsock2::_fnptr_accept)( s, a, b ); +SOCKET Bu::Winsock2::accept( SOCKET s, struct sockaddr *a, int *b ) { + return (*Bu::Winsock2::_fnptr_accept)( s, a, b ); } int Bu::Winsock2::recv( SOCKET s, char *buf, int len, int flags ) { - return (*Bu::Winsock2::_fnptr_recv)( s, buf, len, flags ); + return (*Bu::Winsock2::_fnptr_recv)( s, buf, len, flags ); } int Bu::Winsock2::send( SOCKET s, const char *buf, int len, int flags ) { - return (*Bu::Winsock2::_fnptr_send)( s, buf, len, flags ); + return (*Bu::Winsock2::_fnptr_send)( s, buf, len, flags ); } int Bu::Winsock2::__WSAFDIsSet( SOCKET s, fd_set *set ) { - return (*Bu::Winsock2::_fnptr___WSAFDIsSet)( s, set ); + return (*Bu::Winsock2::_fnptr___WSAFDIsSet)( s, set ); } Bu::String Bu::getLastWinError() @@ -177,11 +177,11 @@ Bu::String Bu::getLastWinError() (LPSTR) &lpMsgBuf, 0, NULL ); - Bu::String sRet( (char *)lpMsgBuf ); + Bu::String sRet( (char *)lpMsgBuf ); LocalFree(lpMsgBuf); - return sRet; + return sRet; } #endif diff --git a/src/compat/win32.h b/src/compat/win32.h index 7e44c13..0cc42b6 100644 --- a/src/compat/win32.h +++ b/src/compat/win32.h @@ -32,9 +32,9 @@ extern "C" #endif #define decltype( ret, name, ... ) \ - typedef ret (__cdecl *FNDEF_DYN_ ##name)( __VA_ARGS__ ); \ - static FNDEF_DYN_ ##name _fnptr_ ##name; \ - static ret name( __VA_ARGS__ ) + typedef ret (__cdecl *FNDEF_DYN_ ##name)( __VA_ARGS__ ); \ + static FNDEF_DYN_ ##name _fnptr_ ##name; \ + static ret name( __VA_ARGS__ ) __extension__ typedef int socklen_t; @@ -44,54 +44,54 @@ __extension__ typedef int socklen_t; namespace Bu { - class Winsock2 : public Bu::Singleton - { - friend class Bu::Singleton; - private: - Winsock2(); - virtual ~Winsock2(); - - WSADATA wsaData; - HINSTANCE Ws2_32; - - public: - // decltype( return type, function name<, optional parameters> ) - decltype( int, WSAStartup, WORD, LPWSADATA ); - decltype( int, WSACleanup ); - decltype( int, WSAGetLastError ); - decltype( char *, inet_ntoa, struct in_addr ); - decltype( unsigned long, inet_addr, const char *s_in ); - decltype( int, select, int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, const struct timeval *timeout ); - decltype( SOCKET, socket, int domain, int type, int protocol ); - decltype( int, shutdown, SOCKET s, int how ); - decltype( int, ioctlsocket, SOCKET s, long cmd, u_long *argp ); - decltype( u_short, htons, u_short in ); - decltype( u_long, htonl, u_long in ); - decltype( struct hostent *, gethostbyname, const char *name ); - decltype( void, freeaddrinfo, struct addrinfo *ai ); - decltype( int, getaddrinfo, const char *nodename, const char *servname, - const struct addrinfo *hints, struct addrinfo **res ); - decltype( int, connect, SOCKET s, const struct sockaddr *serv_addr, - int addrlen ); - decltype( int, getpeername, SOCKET s, struct sockaddr *name, - int *namelen ); - decltype( int, setsockopt, SOCKET s, int level, int optname, - const char *optval, int optlen ); - decltype( int, bind, SOCKET s, const struct sockaddr *my_addr, - int addrlen ); - decltype( int, listen, SOCKET s, int backlog ); - decltype( SOCKET, accept, SOCKET s, struct sockaddr *addr, - int *addrlen); - decltype( int, recv, SOCKET s, char *buf, int len, int flags ); - decltype( int, send, SOCKET s, const char *buf, int len, int flags ); - decltype( int, __WSAFDIsSet, SOCKET s, fd_set *set ); - - static char scode[32]; - static char *gai_strerror( int iCode ); - }; - - Bu::String getLastWinError(); + class Winsock2 : public Bu::Singleton + { + friend class Bu::Singleton; + private: + Winsock2(); + virtual ~Winsock2(); + + WSADATA wsaData; + HINSTANCE Ws2_32; + + public: + // decltype( return type, function name<, optional parameters> ) + decltype( int, WSAStartup, WORD, LPWSADATA ); + decltype( int, WSACleanup ); + decltype( int, WSAGetLastError ); + decltype( char *, inet_ntoa, struct in_addr ); + decltype( unsigned long, inet_addr, const char *s_in ); + decltype( int, select, int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timeval *timeout ); + decltype( SOCKET, socket, int domain, int type, int protocol ); + decltype( int, shutdown, SOCKET s, int how ); + decltype( int, ioctlsocket, SOCKET s, long cmd, u_long *argp ); + decltype( u_short, htons, u_short in ); + decltype( u_long, htonl, u_long in ); + decltype( struct hostent *, gethostbyname, const char *name ); + decltype( void, freeaddrinfo, struct addrinfo *ai ); + decltype( int, getaddrinfo, const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res ); + decltype( int, connect, SOCKET s, const struct sockaddr *serv_addr, + int addrlen ); + decltype( int, getpeername, SOCKET s, struct sockaddr *name, + int *namelen ); + decltype( int, setsockopt, SOCKET s, int level, int optname, + const char *optval, int optlen ); + decltype( int, bind, SOCKET s, const struct sockaddr *my_addr, + int addrlen ); + decltype( int, listen, SOCKET s, int backlog ); + decltype( SOCKET, accept, SOCKET s, struct sockaddr *addr, + int *addrlen); + decltype( int, recv, SOCKET s, char *buf, int len, int flags ); + decltype( int, send, SOCKET s, const char *buf, int len, int flags ); + decltype( int, __WSAFDIsSet, SOCKET s, fd_set *set ); + + static char scode[32]; + static char *gai_strerror( int iCode ); + }; + + Bu::String getLastWinError(); }; #ifdef FD_ISSET @@ -117,7 +117,7 @@ namespace Bu #define bu_setsockopt (*Bu::Winsock2::setsockopt) #define bu_bind (*Bu::Winsock2::bind) #define bu_listen (*Bu::Winsock2::listen) -#define bu_accept (*Bu::Winsock2::accept) +#define bu_accept (*Bu::Winsock2::accept) #define bu_recv (*Bu::Winsock2::recv) #define bu_send (*Bu::Winsock2::send) #define bu___WSAFDIsSet (*Bu::Winsock2::__WSAFDIsSet) -- cgit v1.2.3