]> granicus.if.org Git - libevent/commitdiff
Various MSVC cleanups from Brodie Thiesfield.
authorNick Mathewson <nickm@torproject.org>
Tue, 28 Jul 2009 19:41:39 +0000 (19:41 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 28 Jul 2009 19:41:39 +0000 (19:41 +0000)
svn:r1385

16 files changed:
WIN32-Code/event-config.h
WIN32-Code/win32.c
buffer_iocp.c
evdns.c
event.h
event_iocp.c
evmap.c
include/event2/event_struct.h
log.c
sample/event-test.c
sample/signal-test.c
test/regress_dns.c
test/regress_et.c
test/regress_http.c
test/regress_main.c
test/tinytest.c

index be1e4c564deeb852b94248797fb995568a59d14f..6c85329b15a3f2e09ebe64eb06e64a057f26aa2a 100644 (file)
 /* Define to `int' if <sys/types.h> does not define. */
 #define _EVENT_ssize_t intptr_t
 
+#define ssize_t SSIZE_T
+
 #endif
index d809bf2e10c2146589d610cf314965baa3931723..6c8ba2171139b698a22e04d333cfe01aba1426df 100644 (file)
@@ -334,11 +334,12 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
                }
        }
        if (win32op->writeset_out->fd_count) {
+        SOCKET s;
                i = rand() % win32op->writeset_out->fd_count;
                for (j=0; j<win32op->writeset_out->fd_count; ++j) {
                        if (++i >= win32op->writeset_out->fd_count)
                                i = 0;
-                       SOCKET s = win32op->writeset_out->fd_array[i];
+                       s = win32op->writeset_out->fd_array[i];
                        evmap_io_active(base, s, EV_WRITE);
                }
        }
index 565f232fb524ba4521a0ad5e692e942ae0f99724..eb7635f66c9748d5e24492032f377a01822fb4f1 100644 (file)
@@ -42,6 +42,7 @@
 #include "iocp-internal.h"
 #include "mm-internal.h"
 
+#include <winsock2.h>
 #include <windows.h>
 #include <assert.h>
 #include <stdio.h>
diff --git a/evdns.c b/evdns.c
index ffada0eba78dee75ebbcc2c4731c183746543d6c..9b255002f94264241989bd348a292e2b6ff3cf42 100644 (file)
--- a/evdns.c
+++ b/evdns.c
 #include "evthread-internal.h"
 #ifdef WIN32
 #include <ctype.h>
+#include <winsock2.h>
 #include <windows.h>
 #include <iphlpapi.h>
 #include <io.h>
diff --git a/event.h b/event.h
index 9139296c6f394ec8560ea2aab0d863aff493ecc9..03c1394fe13dd3be2fb00471cbc4656b135e08af 100644 (file)
--- a/event.h
+++ b/event.h
@@ -179,6 +179,7 @@ extern "C" {
 
 #ifdef WIN32
 #define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 typedef unsigned char u_char;
index 9aca3b89077ea2f09bd23cd39d584b24754e38bc..4c144af687133a44b205db3f16f554d41205c742 100644 (file)
@@ -24,6 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <winsock2.h>
 #include <windows.h>
 #include <process.h>
 #include <stdio.h>
diff --git a/evmap.c b/evmap.c
index 9648892b19570a5ae8465d52a5215599d6cbda87..47bea3cee296ef6797e799b4f3bdcbb1cadda41d 100644 (file)
--- a/evmap.c
+++ b/evmap.c
@@ -28,6 +28,7 @@
 #endif
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
@@ -35,7 +36,7 @@
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
+#elif !defined(WIN32)
 #include <sys/_time.h>
 #endif
 #include <sys/queue.h>
index 2f0ff7a511262b41abd7afed0758d2aea866b40b..dd7042f476875c31d1c80750d888aaccc17f2730 100644 (file)
@@ -50,6 +50,7 @@ extern "C" {
 #include <event2/util.h>
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
diff --git a/log.c b/log.c
index 67e24beff0f1515430f4dc7bf2b794e581af744a..db6209908e229b964b5a2d7a7453e6ce7f4594fd 100644 (file)
--- a/log.c
+++ b/log.c
@@ -42,6 +42,7 @@
 #endif
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
@@ -49,7 +50,7 @@
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
+#elif !defined(WIN32)
 #include <sys/_time.h>
 #endif
 #include <stdio.h>
index 848cbc879cd9bfdcf2eb740f4bfec59d5d1ca622..3a06d3bfe83727efcd2c6622682f56f43b4e7ccb 100644 (file)
@@ -14,6 +14,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #else
+#include <winsock2.h>
 #include <windows.h>
 #endif
 #include <fcntl.h>
index 165883fb5aa483eecd1b5237abdec09d975cd4c7..4a3a738ea16eada1066d62a6eb905cdfa5474aa4 100644 (file)
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #else
+#include <winsock2.h>
 #include <windows.h>
 #endif
 #include <signal.h>
index 2ee544bffad7375b07d1a5ccbe19eb18bc2d5045..5b74fc4ad6476cc844dbd40873d2b0a2d62455f8 100644 (file)
@@ -61,6 +61,7 @@
 
 #include "event2/event.h"
 #include "event2/event_compat.h"
+#include <event2/util.h>
 #include "evdns.h"
 #include "log-internal.h"
 #include "regress.h"
@@ -222,7 +223,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
                ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */
                if (req->questions[i]->type == EVDNS_TYPE_A &&
                        req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-                       !strcasecmp(req->questions[i]->name, "zz.example.com")) {
+                       !evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
                        r = evdns_server_request_add_a_reply(req,
                                                                                                 req->questions[i]->name,
                                                                                                 1, &ans.s_addr, 12345);
@@ -230,7 +231,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
                                dns_ok = 0;
                } else if (req->questions[i]->type == EVDNS_TYPE_AAAA &&
                                   req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-                                  !strcasecmp(req->questions[i]->name, "zz.example.com")) {
+                                  !evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
                        char addr6[17] = "abcdefghijklmnop";
                        r = evdns_server_request_add_aaaa_reply(req,
                                                                                                        req->questions[i]->name,
@@ -239,7 +240,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
                                dns_ok = 0;
                } else if (req->questions[i]->type == EVDNS_TYPE_PTR &&
                                   req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-                                  !strcasecmp(req->questions[i]->name, TEST_ARPA)) {
+                                  !evutil_strcasecmp(req->questions[i]->name, TEST_ARPA)) {
                        r = evdns_server_request_add_ptr_reply(req, NULL,
                                                                                                   req->questions[i]->name,
                                                                                                   "ZZ.EXAMPLE.COM", 54321);
@@ -247,7 +248,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
                                dns_ok = 0;
                 } else if (req->questions[i]->type == EVDNS_TYPE_A &&
                    req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-                   !strcasecmp(req->questions[i]->name, "drop.example.com")) {
+                   !evutil_strcasecmp(req->questions[i]->name, "drop.example.com")) {
                        if (evdns_server_request_drop(req)<0)
                                dns_ok = 0;
                        return;
index f4762d9abd05fef64ebc6cf4b6971a439a4eaecb..925209dd9d82bf7b9395785e97d61e68bf1db88c 100644 (file)
@@ -31,7 +31,6 @@
 #endif
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #ifdef _EVENT_HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
+#include <sys/time.h>
 #include <unistd.h>
+#endif
 #include <errno.h>
 
 #include <event2/event.h>
index adcb2b57f3e2f2ef83d2c97da79c9bf2799bf3a0..1fb20aec00c971e9a92b894ab9e1d8c7c735834e 100644 (file)
@@ -2102,7 +2102,7 @@ static void
 http_multi_line_header_test(void)
 {
        struct bufferevent *bev= NULL;
-       int fd = -1;
+       evutil_socket_t fd = -1;
        const char *http_start_request;
        short port = -1;
 
@@ -2135,7 +2135,7 @@ http_multi_line_header_test(void)
        if (bev)
                bufferevent_free(bev);
        if (fd >= 0)
-               close(fd);
+               EVUTIL_CLOSESOCKET(fd);
        if (http)
                evhttp_free(http);
 }
index 68dcdc4d6c9f66e15e44cd1abaf9e80f45a41e97..3f2a23916d3e02c6ed95299b5677a18d4c6793ee 100644 (file)
@@ -28,6 +28,7 @@
 #ifdef WIN32
 #include <winsock2.h>
 #include <windows.h>
+#define __func__    __FUNCTION__
 #endif
 
 #ifdef HAVE_CONFIG_H
index 19d75dd124a29f1c7269d37d458b34fa712b6c91..20f04933544c44cb94f6fd916fbb4cf3cc996bce 100644 (file)
@@ -29,6 +29,7 @@
 #include <assert.h>
 
 #ifdef WIN32
+#include <winsock2.h>
 #include <windows.h>
 #else
 #include <sys/types.h>
@@ -36,6 +37,8 @@
 #include <unistd.h>
 #endif
 
+#include <event2/util.h>
+
 #include "tinytest.h"
 #include "tinytest_macros.h"
 
@@ -116,7 +119,7 @@ _testcase_run_forked(const struct testgroup_t *group,
        if (opt_verbosity>0)
                printf("[forking] ");
 
-       snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s",
+       evutil_snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s",
                 commandname, verbosity_flag, group->prefix, testcase->name);
 
        memset(&si, 0, sizeof(si));
@@ -245,7 +248,7 @@ _tinytest_set_flag(struct testgroup_t *groups, const char *arg, unsigned long fl
                length = strstr(arg,"..")-arg;
        for (i=0; groups[i].prefix; ++i) {
                for (j=0; groups[i].cases[j].name; ++j) {
-                       snprintf(fullname, sizeof(fullname), "%s%s",
+                       evutil_snprintf(fullname, sizeof(fullname), "%s%s",
                                 groups[i].prefix, groups[i].cases[j].name);
                        if (!flag) /* Hack! */
                                printf("    %s\n", fullname);