From 1e26233957be82fdc7eba8f6a6b526e11f0106b2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 6 Sep 2006 20:33:28 +0000 Subject: [PATCH] r8731@Kushana: nickm | 2006-09-06 16:33:19 -0400 Try to fix eventdns.c build on windows. svn:r8329 --- src/or/eventdns.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/or/eventdns.c b/src/or/eventdns.c index f7489d968b..8ab378c082 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -261,15 +261,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include #include #include #include @@ -277,6 +274,16 @@ #include #include +#ifdef WIN32 +#include +#include +#include +#else +#include +#include +#include +#endif + #define EVENTDNS_LOG_DEBUG 0 #define EVENTDNS_LOG_WARN 1 @@ -436,6 +443,19 @@ error_is_eagain(int err) { return err == EAGAIN || err == WSAEWOULDBLOCK; } +static int +inet_aton(const char *c, struct in_addr *addr) +{ + uint32_t r; + if (strcmp(c, "255.255.255.255") == 0) { + addr->s_addr = 0xffffffffu; + } else { + uint32_t r = inet_addr(c); + if (r == INADDR_NONE) + return 0; + addr->a_addr = r; + } +} #define CLOSE_SOCKET(x) closesocket(x) #else #define last_error(sock) (errno) @@ -1052,7 +1072,7 @@ nameserver_read(struct nameserver *ns) { for (;;) { const int r = recv(ns->socket, packet, sizeof(packet), 0); if (r < 0) { - int err = last_error(ns_socket); + int err = last_error(ns->socket); if (error_is_eagain(err)) return; nameserver_failed(ns, strerror(err)); return; @@ -2115,7 +2135,7 @@ load_nameservers_from_registry(void) found = 1; \ } - if (IS_NT()) { + if (((int)GetVersion()) > 0) { /* NT */ HKEY nt_key = 0, interfaces_key = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,