From 315259ae9f48228c8a40b7be08f8d290d96e9fdc Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Sat, 20 Oct 2001 05:57:28 +0000 Subject: [PATCH] Win32 updates. Mostly header fixes and defines for windows. Apparently interface is a reserved word, so we've renamed one variable. There's also no sethostent on win32, and Oddsock seems to think we need DeleteCriticalSection instead of DestroyCriticalSection. I was unable to figure out from msdn.microsoft.com why this was, but I'll trust Oddsock's judgement. svn path=/trunk/net/; revision=2194 --- net/resolver.c | 11 +++++++---- net/sock.c | 13 +++++++------ net/sock.h | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/net/resolver.c b/net/resolver.c index e2d865d..a554b04 100644 --- a/net/resolver.c +++ b/net/resolver.c @@ -7,15 +7,18 @@ #include #include -#include #include -#include -#include #include #include #ifndef _WIN32 +#include #include +#include +#include +#else +#include +#define sethostent(x) #endif #include "resolver.h" @@ -156,7 +159,7 @@ void resolver_shutdown(void) #ifndef _WIN32 pthread_mutex_destroy(&_resolver_mutex); #else - DestroyCriticalSection(&_resolver_mutex); + DeleteCriticalSection(&_resolver_mutex); #endif _initialized = 0; diff --git a/net/sock.c b/net/sock.c index e629243..854dd6c 100644 --- a/net/sock.c +++ b/net/sock.c @@ -23,24 +23,25 @@ #include #include #include -#include #include #include #include +#include #ifndef _WIN32 -#include #include #include #include #include #include #include +#include #else -#include +#include #define vsnprintf _vsnprintf #define EINPROGRESS WSAEINPROGRESS #define ENOTSOCK WSAENOTSOCK +#define EWOULDBLOCK WSAEWOULDBLOCK #endif #include "sock.h" @@ -415,7 +416,7 @@ sock_t sock_connect_wto(const char *hostname, const int port, const int timeout) ** interface. if interface is null, listen on all interfaces. ** returns the socket, or SOCK_ERROR on failure */ -sock_t sock_get_server_socket(const int port, char *interface) +sock_t sock_get_server_socket(const int port, char *sinterface) { #ifdef HAVE_IPV6 struct sockaddr_storage sa; @@ -435,8 +436,8 @@ sock_t sock_get_server_socket(const int port, char *interface) sa_len = sizeof (struct sockaddr_in); /* set the interface to bind to if specified */ - if (interface != NULL) { - if (!resolver_getip(interface, ip, sizeof (ip))) + if (sinterface != NULL) { + if (!resolver_getip(sinterface, ip, sizeof (ip))) return SOCK_ERROR; #ifdef HAVE_IPV6 diff --git a/net/sock.h b/net/sock.h index 8e458dc..ddb5425 100644 --- a/net/sock.h +++ b/net/sock.h @@ -23,7 +23,7 @@ #define __SOCK_H #ifdef _WIN32 -#include +#include typedef SOCKET sock_t #else typedef int sock_t; @@ -59,7 +59,7 @@ int sock_read_bytes(sock_t sock, char *buff, const int len); int sock_read_line(sock_t sock, char *string, const int len); /* server socket functions */ -sock_t sock_get_server_socket(const int port, char *interface); +sock_t sock_get_server_socket(const int port, char *sinterface); int sock_listen(sock_t serversock, int backlog); int sock_accept(sock_t serversock, char *ip, int len);