From 9935d5b01e4345829a7ea5c06e86d45156ea8944 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 13 Jan 2009 21:39:32 +0000 Subject: [PATCH] Fix win32 compilation. Surprisingly, unit tests pass too. svn:r1002 --- WIN32-Code/win32.c | 13 +++++-------- evdns.c | 17 +---------------- evmap.c | 1 - evutil.c | 9 +++++---- http.c | 2 +- ipv6-internal.h | 2 +- test/regress_util.c | 1 + util-internal.h | 2 +- 8 files changed, 15 insertions(+), 32 deletions(-) diff --git a/WIN32-Code/win32.c b/WIN32-Code/win32.c index 863f4e30..d7b94ac7 100644 --- a/WIN32-Code/win32.c +++ b/WIN32-Code/win32.c @@ -48,7 +48,7 @@ #include "log-internal.h" #include "event.h" #include "event-internal.h" -#include "evmap-inernal.h" +#include "evmap-internal.h" #define XFREE(ptr) do { if (ptr) mm_free(ptr); } while(0) @@ -95,7 +95,7 @@ RB_PROTOTYPE(event_map, event_entry, node, compare); RB_GENERATE(event_map, event_entry, node, compare); void *win32_init (struct event_base *); -int win32_insert(struct event_base *, evutil_socket_t, short old short events); +int win32_insert(struct event_base *, evutil_socket_t, short old, short events); int win32_del(struct event_base *, evutil_socket_t, short old, short events); int win32_dispatch (struct event_base *base, struct timeval *); void win32_dealloc (struct event_base *); @@ -292,7 +292,7 @@ win32_del(struct event_base *base, evutil_socket_t fd, short old, short events) do_fd_clear(win32op, ent, 1); if (events & EV_WRITE) do_fd_clear(win32op, ent, 0); - if ((events & (EV_WRITE|EV_READ) == (EV_WRITE|EV_READ)) { + if ((events & (EV_WRITE|EV_READ)) == (EV_WRITE|EV_READ)) { RB_REMOVE(event_map, &win32op->event_root, ent); mm_free(ent); } @@ -356,19 +356,16 @@ win32_dispatch(struct event_base *base, struct timeval *tv) } for (i=0; ireadset_out->fd_count; ++i) { - struct event_entry *ent; SOCKET s = win32op->readset_out->fd_array[i]; evmap_io_active(base, s, EV_READ); } for (i=0; iexset_out->fd_count; ++i) { - struct event_entry *ent; SOCKET s = win32op->exset_out->fd_array[i]; - evmap_io_active(base, s, EV_READ, 1); + evmap_io_active(base, s, EV_READ); } for (i=0; iwriteset_out->fd_count; ++i) { - struct event_entry *ent; SOCKET s = win32op->writeset_out->fd_array[i]; - evmap_io_active(base, s, EV_WRITE, 1); + evmap_io_active(base, s, EV_WRITE); } return (0); diff --git a/evdns.c b/evdns.c index a62fa0b4..51cf0d7c 100644 --- a/evdns.c +++ b/evdns.c @@ -109,6 +109,7 @@ #ifdef WIN32 #include #include +#include #include #include #else @@ -360,22 +361,6 @@ static void server_port_ready_callback(evutil_socket_t fd, short events, void *a static int strtoint(const char *const str); -#ifdef WIN32 -static int -inet_aton(const char *c, struct in_addr *addr) -{ - ev_uint32_t r; - if (strcmp(c, "255.255.255.255") == 0) { - addr->s_addr = 0xffffffffu; - } else { - r = inet_addr(c); - if (r == INADDR_NONE) - return 0; - addr->s_addr = r; - } - return 1; -} -#endif #define CLOSE_SOCKET(s) EVUTIL_CLOSESOCKET(s) #define ISSPACE(c) isspace((int)(unsigned char)(c)) diff --git a/evmap.c b/evmap.c index f88c81a4..250411f2 100644 --- a/evmap.c +++ b/evmap.c @@ -32,7 +32,6 @@ #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -#include "misc.h" #endif #include #ifdef HAVE_SYS_TIME_H diff --git a/evutil.c b/evutil.c index 8f8f09ad..68503ebc 100644 --- a/evutil.c +++ b/evutil.c @@ -30,6 +30,7 @@ #ifdef WIN32 #include +#include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN @@ -465,14 +466,14 @@ evutil_inet_pton(int af, const char *src, void *dst) #else ev_uint32_t r; struct in_addr *out = dst; - if (strcmp(c, "255.255.255.255") == 0) { + if (strcmp(src, "255.255.255.255") == 0) { out->s_addr = 0xffffffffu; } else { - r = inet_addr(c); + r = inet_addr(src); if (r == INADDR_NONE) return 0; - addr->s_addr = r; - } + out->s_addr = r; + } return 1; #endif #ifdef AF_INET6 diff --git a/http.c b/http.c index 9c1a2ae3..6b70b3ef 100644 --- a/http.c +++ b/http.c @@ -108,7 +108,7 @@ #define NI_NUMERICHOST 1 #define NI_NUMERICSERV 2 -int +static int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { diff --git a/ipv6-internal.h b/ipv6-internal.h index 0cb40e00..bb3704d6 100644 --- a/ipv6-internal.h +++ b/ipv6-internal.h @@ -19,7 +19,7 @@ struct in6_addr { #endif #ifndef _EVENT_HAVE_SA_FAMILY_T -typedef int sa_family_t +typedef int sa_family_t; #endif #ifndef _EVENT_HAVE_STRUCT_SOCKADDR_IN6 diff --git a/test/regress_util.c b/test/regress_util.c index a1373170..ab32ecb4 100644 --- a/test/regress_util.c +++ b/test/regress_util.c @@ -27,6 +27,7 @@ #ifdef WIN32 #include #include +#include #endif #ifdef HAVE_CONFIG_H diff --git a/util-internal.h b/util-internal.h index 0ba7162a..536f0c35 100644 --- a/util-internal.h +++ b/util-internal.h @@ -39,7 +39,7 @@ extern "C" { ((e) == WSAEWOULDBLOCK || \ (e) == WSAEINTR || \ (e) == WSAEINPROGRESS || \ - (e) == WSAEINVAL)) + (e) == WSAEINVAL) #define EVUTIL_ERR_ACCEPT_RETRIABLE(e) \ EVUTIL_ERR_RW_RETRIABLE(e)