[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r8329: Try to fix eventdns.c build on windows. (in tor/trunk: . src/or)
Author: nickm
Date: 2006-09-06 16:33:28 -0400 (Wed, 06 Sep 2006)
New Revision: 8329
Modified:
tor/trunk/
tor/trunk/src/or/eventdns.c
Log:
r8731@Kushana: nickm | 2006-09-06 16:33:19 -0400
Try to fix eventdns.c build on windows.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r8731] on c95137ef-5f19-0410-b913-86e773d04f59
Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c 2006-09-06 20:22:05 UTC (rev 8328)
+++ tor/trunk/src/or/eventdns.c 2006-09-06 20:33:28 UTC (rev 8329)
@@ -261,15 +261,12 @@
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <unistd.h>
#include <limits.h>
#include <sys/stat.h>
@@ -277,6 +274,16 @@
#include <stdio.h>
#include <stdarg.h>
+#ifdef WIN32
+#include <windows.h>
+#include <winsock2.h>
+#include <iphlpapi.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
#define EVENTDNS_LOG_DEBUG 0
#define EVENTDNS_LOG_WARN 1
@@ -436,6 +443,19 @@
{
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 @@
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 @@
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,