From 4e1ec3e05e39699025e087929b84f3634929ae4c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Nov 2007 21:01:26 +0000 Subject: [PATCH] Make all the C files in the libraries compile under MSVC 2005 Express. There are still a few warnings, and probably some subtle issues, but it's better than nothing. svn:r499 --- WIN32-Code/config.h | 314 ++++++++++++++++---------------- WIN32-Code/event-config.h | 244 +++++++++++++++++++++++++ WIN32-Code/misc.c | 4 +- WIN32-Code/win32.c | 4 +- WIN32-Prj/libevent.vcproj | 365 ++++++++++++++++++++++++++++++++++++++ buffer.c | 3 +- configure.in | 2 +- evbuffer.c | 4 + evdns.c | 39 +++- evdns.h | 7 +- event.h | 37 ++-- event_tagging.c | 13 +- evrpc.c | 2 - evutil.h | 13 ++ http.c | 25 ++- min_heap.h | 2 +- signal.c | 8 +- 17 files changed, 891 insertions(+), 195 deletions(-) create mode 100644 WIN32-Code/event-config.h create mode 100644 WIN32-Prj/libevent.vcproj diff --git a/WIN32-Code/config.h b/WIN32-Code/config.h index aed9774d..88b2a513 100644 --- a/WIN32-Code/config.h +++ b/WIN32-Code/config.h @@ -1,231 +1,239 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ -/* Define if kqueue works correctly with pipes */ -#undef HAVE_WORKING_KQUEUE +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ -/* Define to `unsigned long long' if doesn't define. */ -#undef u_int64_t +/* Define if clock_gettime is available in libc */ +/* #undef DNS_USE_CPU_CLOCK_FOR_ID */ -/* Define to `unsigned int' if doesn't define. */ -#undef u_int32_t +/* Define if no secure id variant is available */ +#define DNS_USE_FTIME_FOR_ID 1 -/* Define to `unsigned short' if doesn't define. */ -#undef u_int16_t +/* Define if no secure id variant is available */ +/* #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 */ -/* Define to `unsigned char' if doesn't define. */ -#undef u_int8_t +/* Define to 1 if you have the `clock_gettime' function. */ +/* #undef HAVE_CLOCK_GETTIME */ -/* Define if timeradd is defined in */ -#undef HAVE_TIMERADD -#ifndef HAVE_TIMERADD -#undef timersub -#define timeradd(tvp, uvp, vvp) \ - do { \ - (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ - if ((vvp)->tv_usec >= 1000000) { \ - (vvp)->tv_sec++; \ - (vvp)->tv_usec -= 1000000; \ - } \ - } while (0) -#define timersub(tvp, uvp, vvp) \ - do { \ - (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ - if ((vvp)->tv_usec < 0) { \ - (vvp)->tv_sec--; \ - (vvp)->tv_usec += 1000000; \ - } \ - } while (0) -#endif /* !HAVE_TIMERADD */ - -#undef HAVE_TIMERCLEAR -#ifndef HAVE_TIMERCLEAR -#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 -#endif +/* Define if /dev/poll is available */ +/* #undef HAVE_DEVPOLL */ -#define HAVE_TIMERCMP -#ifndef HAVE_TIMERCMP -#undef timercmp -#define timercmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#endif +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ -#undef HAVE_TIMERISSET -#ifndef HAVE_TIMERISSET -#undef timerisset -#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) -#endif +/* Define if your system supports the epoll system calls */ +/* #undef HAVE_EPOLL */ -/* Define if TAILQ_FOREACH is defined in */ -#define HAVE_TAILQFOREACH -#ifndef HAVE_TAILQFOREACH -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_END(head) NULL -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_FOREACH(var, head, field) \ - for((var) = TAILQ_FIRST(head); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_NEXT(var, field)) -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (0) -#endif /* TAILQ_FOREACH */ +/* Define to 1 if you have the `epoll_ctl' function. */ +/* #undef HAVE_EPOLL_CTL */ -/* Define if /dev/poll is available */ -#undef HAVE_DEVPOLL +/* Define if your system supports event ports */ +/* #undef HAVE_EVENT_PORTS */ -/* Define if your system supports the epoll system calls */ -#undef HAVE_EPOLL +/* Define to 1 if you have the `fcntl' function. */ +/* #undef HAVE_FCNTL */ -/* Define if you have the `epoll_ctl' function. */ -#undef HAVE_EPOLL_CTL +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 -/* Define if you have the `err' function. */ -#undef HAVE_ERR +/* Define to 1 if you have the `getaddrinfo' function. */ +/* #undef HAVE_GETADDRINFO */ -/* Define if you have the `fcntl' function. */ -#undef HAVE_FCNTL +/* Define to 1 if you have the `getnameinfo' function. */ +/* #undef HAVE_GETNAMEINFO */ -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H +/* Define to 1 if you have the `gettimeofday' function. */ +/* #define HAVE_GETTIMEOFDAY 1 */ -/* Define if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 +/* Define to 1 if you have the `inet_ntop' function. */ +/* #undef HAVE_INET_NTOP */ -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 -/* Define if you have the `kqueue' function. */ -#undef HAVE_KQUEUE +/* Define to 1 if you have the `kqueue' function. */ +/* #undef HAVE_KQUEUE */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ -/* Define if you have the `socket' library (-lsocket). */ -#undef HAVE_LIBSOCKET +/* Define to 1 if you have the `rt' library (-lrt). */ +/* #undef HAVE_LIBRT */ -/* Define if you have the header file. */ +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 -/* Define if you have the `poll' function. */ -#undef HAVE_POLL +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_IN6_H */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef HAVE_POLL */ -/* Define if you have the header file. */ -#undef HAVE_POLL_H +/* Define to 1 if you have the header file. */ +/* #undef HAVE_POLL_H */ -/* Define if your system supports POSIX realtime signals */ -#undef HAVE_RTSIG +/* Define to 1 if you have the `port_create' function. */ +/* #undef HAVE_PORT_CREATE */ -/* Define if you have the `select' function. */ -#undef HAVE_SELECT +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PORT_H */ + +/* Define to 1 if you have the `select' function. */ +/* #undef HAVE_SELECT */ /* Define if F_SETFD is defined in */ -#undef HAVE_SETFD +/* #undef HAVE_SETFD */ + +/* Define to 1 if you have the `sigaction' function. */ +/* #undef HAVE_SIGACTION */ -/* Define if you have the header file. */ -#undef HAVE_SIGNAL_H +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 -/* Define if you have the `sigtimedwait' function. */ -#undef HAVE_SIGTIMEDWAIT +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #define HAVE_STDARG_H 1 -/* Define if you have the header file. */ -#undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +/* #define HAVE_STDINT_H 1 */ -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 -/* Define if you have the header file. */ -#undef HAVE_STRINGS_H +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 -/* Define if you have the header file. */ -#undef HAVE_SYS_DEVPOLL_H +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef HAVE_STRLCPY */ + +/* Define to 1 if you have the `strsep' function. */ +/* #undef HAVE_STRSEP */ + +/* Define to 1 if you have the `strtok_r' function. */ +/* #undef HAVE_STRTOK_R */ -/* Define if you have the header file. */ -#undef HAVE_SYS_EPOLL_H +/* Define to 1 if the system has the type `struct in6_addr'. */ +#define HAVE_STRUCT_IN6_ADDR 1 -/* Define if you have the header file. */ -#undef HAVE_SYS_EVENT_H +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ -/* Define if you have the header file. */ -#undef HAVE_SYS_IOCTL_H +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EPOLL_H */ -/* Define if you have the header file. */ -#undef HAVE_SYS_QUEUE_H +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EVENT_H */ -/* Define if you have the header file. */ -#define HAVE_SYS_STAT_H 1 +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ -/* Define if you have the header file. */ -#undef HAVE_SYS_TIME_H +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_QUEUE_H */ -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_STAT_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_TYPES_H 1 */ /* Define if TAILQ_FOREACH is defined in */ -#undef HAVE_TAILQFOREACH +/* #undef HAVE_TAILQFOREACH */ /* Define if timeradd is defined in */ -#undef HAVE_TIMERADD +/* #undef HAVE_TIMERADD */ -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H +/* Define if timerclear is defined in */ +/* #define HAVE_TIMERCLEAR 1 */ -/* Define if you have the `vasprintf' function. */ -#undef HAVE_VASPRINTF +/* Define if timercmp is defined in */ +#define HAVE_TIMERCMP 1 -/* Define if kqueue works correctly with pipes */ -#undef HAVE_WORKING_KQUEUE +/* Define if timerisset is defined in */ +#define HAVE_TIMERISSET 1 -/* Define if realtime signals work on pipes */ -#undef HAVE_WORKING_RTSIG +/* Define to 1 if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef HAVE_VASPRINTF */ + +/* Define if kqueue works correctly with pipes */ +/* #undef HAVE_WORKING_KQUEUE */ /* Name of package */ #define PACKAGE "libevent" -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" -/* Define if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define VERSION "1.0b" +#define VERSION "1.3.99-trunk" + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +#define __func__ __FUNCTION__ /* Define to empty if `const' does not conform to ANSI C. */ -#undef const +/* #undef const */ -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus #define inline __inline +#endif /* Define to `int' if does not define. */ -#undef pid_t +/* #undef pid_t */ /* Define to `unsigned' if does not define. */ -#undef size_t +/* #undef size_t */ /* Define to unsigned int if you dont have it */ -#undef socklen_t +#define socklen_t unsigned int /* Define to `unsigned short' if does not define. */ -#undef u_int16_t +#define uint16_t unsigned short /* Define to `unsigned int' if does not define. */ -#undef u_int32_t +#define uint32_t unsigned int /* Define to `unsigned long long' if does not define. */ -/* #undef u_int64_t */ +#define uint64_t __uint64_t /* Define to `unsigned char' if does not define. */ -/* #undef u_int8_t */ - -/* Define to __FUNCTION__ or __file__ if your compiler doesn't have __func__ */ -#define __func__ __FUNCTION__ +#define uint8_t unsigned char diff --git a/WIN32-Code/event-config.h b/WIN32-Code/event-config.h new file mode 100644 index 00000000..a0cf8ef5 --- /dev/null +++ b/WIN32-Code/event-config.h @@ -0,0 +1,244 @@ +/* event-config.h + * Generated by autoconf; post-processed by libevent. + * Do not edit this file. + * Do not rely on macros in this file existing in later versions. + */ +#ifndef _EVENT_CONFIG_H_ +#define _EVENT_CONFIG_H_ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if clock_gettime is available in libc */ +/* #undef _EVENT_DNS_USE_CPU_CLOCK_FOR_ID */ + +/* Define is no secure id variant is available */ +#define _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +/* #undef _EVENT_HAVE_CLOCK_GETTIME */ + +/* Define if /dev/poll is available */ +/* #undef _EVENT_HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_DLFCN_H */ + +/* Define if your system supports the epoll system calls */ +/* #undef _EVENT_HAVE_EPOLL */ + +/* Define to 1 if you have the `epoll_ctl' function. */ +/* #undef _EVENT_HAVE_EPOLL_CTL */ + +/* Define if your system supports event ports */ +/* #undef _EVENT_HAVE_EVENT_PORTS */ + +/* Define to 1 if you have the `fcntl' function. */ +/* #undef _EVENT_HAVE_FCNTL */ + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +/* #undef _EVENT_HAVE_GETADDRINFO */ + +/* Define to 1 if you have the `getnameinfo' function. */ +/* #undef _EVENT_HAVE_GETNAMEINFO */ + +/* Define to 1 if you have the `gettimeofday' function. */ +/* #define _EVENT_HAVE_GETTIMEOFDAY 1 */ + +/* Define to 1 if you have the `inet_ntop' function. */ +/* #undef _EVENT_HAVE_INET_NTOP */ + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `kqueue' function. */ +/* #undef _EVENT_HAVE_KQUEUE */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef _EVENT_HAVE_LIBNSL */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef _EVENT_HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `rt' library (-lrt). */ +/* #undef _EVENT_HAVE_LIBRT */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef _EVENT_HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_NETINET_IN6_H */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef _EVENT_HAVE_POLL */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_POLL_H */ + +/* Define to 1 if you have the `port_create' function. */ +/* #undef _EVENT_HAVE_PORT_CREATE */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_PORT_H */ + +/* Define to 1 if you have the `select' function. */ +/* #undef _EVENT_HAVE_SELECT */ + +/* Define if F_SETFD is defined in */ +/* #undef _EVENT_HAVE_SETFD */ + +/* Define to 1 if you have the `sigaction' function. */ +/* #undef _EVENT_HAVE_SIGACTION */ + +/* Define to 1 if you have the `signal' function. */ +#define _EVENT_HAVE_SIGNAL 1 + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +/* #define _EVENT_HAVE_STDINT_H 1 */ + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef _EVENT_HAVE_STRLCPY */ + +/* Define to 1 if you have the `strsep' function. */ +/* #undef _EVENT_HAVE_STRSEP */ + +/* Define to 1 if you have the `strtok_r' function. */ +/* #undef _EVENT_HAVE_STRTOK_R */ + +/* Define to 1 if the system has the type `struct in6_addr'. */ +#define _EVENT_HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_EPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_QUEUE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _EVENT_HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +#define _EVENT_HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #define _EVENT_HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define _EVENT_HAVE_SYS_TYPES_H 1 */ + +/* Define if TAILQ_FOREACH is defined in */ +/* #undef _EVENT_HAVE_TAILQFOREACH */ + +/* Define if timeradd is defined in */ +/* #undef _EVENT_HAVE_TIMERADD */ + +/* Define if timerclear is defined in */ +/* #define _EVENT_HAVE_TIMERCLEAR 1 */ + +/* Define if timercmp is defined in */ +#define _EVENT_HAVE_TIMERCMP 1 + +/* Define if timerisset is defined in */ +#define _EVENT_HAVE_TIMERISSET 1 + +/* Define to 1 if you have the header file. */ +/* #define _EVENT_HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef _EVENT_HAVE_VASPRINTF */ + +/* Define if kqueue works correctly with pipes */ +/* #undef _EVENT_HAVE_WORKING_KQUEUE */ + +/* Name of package */ +#define _EVENT_PACKAGE "libevent" + +/* Define to the address where bug reports for this package should be sent. */ +#define _EVENT_PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define _EVENT_PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define _EVENT_PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define _EVENT_PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define _EVENT_PACKAGE_VERSION "" + +/* Define to 1 if you have the ANSI C header files. */ +#define _EVENT_STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define _EVENT_TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define _EVENT_VERSION "1.3.99-trunk" + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +/* #undef _EVENT___func__ */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef _EVENT_const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef _EVENT___cplusplus +#define _EVENT_inline __inline +#endif + +/* Define to `int' if does not define. */ +/* #undef _EVENT_pid_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef _EVENT_size_t */ + +/* Define to unsigned int if you dont have it */ +#define _EVENT_socklen_t unsigned int + +/* Define to `unsigned short' if does not define. */ +/* #undef _EVENT_uint16_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef _EVENT_uint32_t */ + +/* Define to `unsigned long long' if does not define. */ +/* #undef _EVENT_uint64_t */ + +/* Define to `unsigned char' if does not define. */ +/* #undef _EVENT_uint8_t */ +#endif diff --git a/WIN32-Code/misc.c b/WIN32-Code/misc.c index 4de0f429..9619ee33 100644 --- a/WIN32-Code/misc.c +++ b/WIN32-Code/misc.c @@ -25,13 +25,13 @@ #ifndef HAVE_GETTIMEOFDAY int gettimeofday(struct timeval *tv, struct timezone *tz) { - struct _timeb tb; + struct _timeb tb; if(tv == NULL) return -1; _ftime(&tb); - tv->tv_sec = tb.time; + tv->tv_sec = (long) tb.time; tv->tv_usec = ((int) tb.millitm) * 1000; return 0; } diff --git a/WIN32-Code/win32.c b/WIN32-Code/win32.c index 44240991..135a7f3e 100644 --- a/WIN32-Code/win32.c +++ b/WIN32-Code/win32.c @@ -26,14 +26,14 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef _MSC_VER -#include "config.h" +#include "./config.h" #else /* Avoid the windows/msvc thing. */ #include "../config.h" #endif -#include #include +#include #include #include #include diff --git a/WIN32-Prj/libevent.vcproj b/WIN32-Prj/libevent.vcproj new file mode 100644 index 00000000..f69730cc --- /dev/null +++ b/WIN32-Prj/libevent.vcproj @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/buffer.c b/buffer.c index 5b0208a4..5443263c 100644 --- a/buffer.c +++ b/buffer.c @@ -30,8 +30,8 @@ #endif #ifdef WIN32 -#include #include +#include #endif #ifdef HAVE_VASPRINTF @@ -62,6 +62,7 @@ #endif #include "event.h" +#include "config.h" struct evbuffer * evbuffer_new(void) diff --git a/configure.in b/configure.in index 0cbf0296..9e031aa2 100644 --- a/configure.in +++ b/configure.in @@ -37,7 +37,7 @@ AC_CHECK_LIB(nsl, inet_ntoa) dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in6.h sys/socket.h) +AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in6.h sys/socket.h) if test "x$ac_cv_header_sys_queue_h" = "xyes"; then AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) AC_EGREP_CPP(yes, diff --git a/evbuffer.c b/evbuffer.c index f968bb5a..f4e839c2 100644 --- a/evbuffer.c +++ b/evbuffer.c @@ -43,6 +43,10 @@ #include #endif +#ifdef WIN32 +#include +#endif + #include "evutil.h" #include "event.h" diff --git a/evdns.c b/evdns.c index e1f0fba2..06b9fcdc 100644 --- a/evdns.c +++ b/evdns.c @@ -43,16 +43,22 @@ #include "misc.h" #endif +#ifdef DNS_USE_FTIME_FOR_ID +#include +#endif + /* #define NDEBUG */ #ifndef DNS_USE_CPU_CLOCK_FOR_ID #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID #ifndef DNS_USE_OPENSSL_FOR_ID +#ifndef DNS_USE_FTIME_FOR_ID #error Must configure at least one id generation method. #error Please see the documentation. #endif #endif #endif +#endif /* #define _POSIX_C_SOURCE 200507 */ #define _GNU_SOURCE @@ -78,7 +84,9 @@ #include #include +#ifdef HAVE_SYS_TIME_H #include +#endif #ifdef HAVE_STDINT_H #include #endif @@ -86,7 +94,9 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include @@ -97,9 +107,10 @@ #include "evutil.h" #include "log.h" #ifdef WIN32 -#include #include +#include #include +#include #else #include #include @@ -131,10 +142,18 @@ typedef unsigned int uint; #endif #include -#define u64 uint64_t -#define u32 uint32_t -#define u16 uint16_t -#define u8 uint8_t +#define u64 ev_uint64_t +#define u32 ev_uint32_t +#define u16 ev_uint16_t +#define u8 ev_uint8_t + +#ifdef WIN32 +#define snprintf _snprintf +#define open _open +#define read _read +#define close _close +#define strdup _strdup +#endif #define MAX_ADDRS 32 /* maximum number of addresses from a single packet */ /* which we bother recording */ @@ -316,7 +335,7 @@ static int search_request_new(int type, const char *const name, int flags, evdns static void evdns_requests_pump_waiting_queue(void); static u16 transaction_id_pick(void); static struct request *request_new(int type, const char *name, int flags, evdns_callback_type callback, void *ptr); -static void request_submit(struct request *req); +static void request_submit(struct request *const req); static int server_request_free(struct server_request *req); static void server_request_free_answers(struct server_request *req); @@ -1029,6 +1048,12 @@ default_transaction_id_fn(void) trans_id = ts.tv_nsec & 0xffff; #endif +#ifdef DNS_USE_FTIME_FOR_ID + struct _timeb tb; + _ftime(&tb); + trans_id = tb.millitm & 0xffff; +#endif + #ifdef DNS_USE_GETTIMEOFDAY_FOR_ID struct timeval tv; gettimeofday(&tv, NULL); @@ -1636,7 +1661,7 @@ evdns_server_request_format_response(struct server_request *req, int err) if (r < 0) goto overflow; j = r; - _t = htons( (j-name_start) ); + _t = htons( (short) (j-name_start) ); memcpy(buf+len_idx, &_t, 2); } else { APPEND16(item->datalen); diff --git a/evdns.h b/evdns.h index 7922c9df..0ad22712 100644 --- a/evdns.h +++ b/evdns.h @@ -164,7 +164,8 @@ extern "C" { #endif -#include +/* For integer types. */ +#include /** Error codes 0-5 are as described in RFC 1035. */ #define DNS_ERR_NONE 0 @@ -397,7 +398,7 @@ int evdns_set_option(const char *option, const char *val, int flags); occurred (see above) @see resolv.conf(3), evdns_config_windows_nameservers() */ -int evdns_resolv_conf_parse(int flags, const char *filename); +int evdns_resolv_conf_parse(int flags, const char *const filename); /** @@ -461,7 +462,7 @@ void evdns_set_log_fn(evdns_debug_log_fn_type fn); @param fn the new callback, or NULL to use the default. */ -void evdns_set_transaction_id_fn(uint16_t (*fn)(void)); +void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)); #define DNS_NO_SEARCH 1 diff --git a/event.h b/event.h index 6af47206..7eeaccbc 100644 --- a/event.h +++ b/event.h @@ -163,10 +163,17 @@ extern "C" { #ifdef _EVENT_HAVE_SYS_TYPES_H #include #endif +#ifdef _EVENT_HAVE_SYS_TIME_H #include +#endif +#ifdef _EVENT_HAVE_STDINT_H #include +#endif #include +/* For int types. */ +#include + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -1000,8 +1007,8 @@ void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_ void evtag_init(void); -void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, - uint32_t len); +void evtag_marshal(struct evbuffer *evbuf, ev_uint8_t tag, const void *data, + ev_uint32_t len); /** Encode an integer and store it in an evbuffer. @@ -1013,34 +1020,34 @@ void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, @param evbuf evbuffer to store the encoded number @param number a 32-bit integer */ -void encode_int(struct evbuffer *evbuf, uint32_t number); +void encode_int(struct evbuffer *evbuf, ev_uint32_t number); -void evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer); +void evtag_marshal_int(struct evbuffer *evbuf, ev_uint8_t tag, ev_uint32_t integer); -void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, +void evtag_marshal_string(struct evbuffer *buf, ev_uint8_t tag, const char *string); -void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, +void evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint8_t tag, struct timeval *tv); void evtag_test(void); -int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); -int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); -int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); -int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); +int evtag_unmarshal(struct evbuffer *src, ev_uint8_t *ptag, struct evbuffer *dst); +int evtag_peek(struct evbuffer *evbuf, ev_uint8_t *ptag); +int evtag_peek_length(struct evbuffer *evbuf, ev_uint32_t *plength); +int evtag_payload_length(struct evbuffer *evbuf, ev_uint32_t *plength); int evtag_consume(struct evbuffer *evbuf); -int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, - uint32_t *pinteger); +int evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint8_t need_tag, + ev_uint32_t *pinteger); -int evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, +int evtag_unmarshal_fixed(struct evbuffer *src, ev_uint8_t need_tag, void *data, size_t len); -int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_string(struct evbuffer *evbuf, ev_uint8_t need_tag, char **pstring); -int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint8_t need_tag, struct timeval *ptv); #ifdef __cplusplus diff --git a/event_tagging.c b/event_tagging.c index 93ded7e5..1646fb10 100644 --- a/event_tagging.c +++ b/event_tagging.c @@ -25,15 +25,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include - #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include #include #undef WIN32_LEAN_AND_MEAN #else @@ -52,7 +57,9 @@ #ifndef WIN32 #include #endif +#ifdef HAVE_UNISTD_H #include +#endif #include "event.h" #include "log.h" diff --git a/evrpc.c b/evrpc.c index 8c9031a9..7e1c8e36 100644 --- a/evrpc.c +++ b/evrpc.c @@ -42,8 +42,6 @@ #endif #ifdef HAVE_SYS_TIME_H #include -#else -#include #endif #include #include diff --git a/evutil.h b/evutil.h index ca57e6ce..d156e663 100644 --- a/evutil.h +++ b/evutil.h @@ -109,6 +109,19 @@ int evutil_make_socket_nonblocking(int sock); #define evutil_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) #endif +#ifdef _EVENT_HAVE_STDINT_H +#include +#define ev_uint64_t uint64_t +#define ev_uint32_t uint32_t +#define ev_uint16_t uint16_t +#define ev_uint8_t uint8_t +#elif defined(WIN32) +#define ev_uint64_t __uint64_t +#define ev_uint32_t unsigned int +#define ev_uint16_t unsigned short +#define ev_uint8_t unsigned char +#endif + #ifdef __cplusplus } #endif diff --git a/http.c b/http.c index bd55b258..06462538 100644 --- a/http.c +++ b/http.c @@ -25,13 +25,17 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include - #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif + #ifdef HAVE_SYS_TIME_H #include #endif @@ -53,6 +57,10 @@ #include #endif +#ifdef WIN32 +#include +#endif + #include #include #include @@ -64,8 +72,12 @@ #endif #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_FCNTL_H #include +#endif #undef timeout_pending #undef timeout_initialized @@ -77,6 +89,13 @@ #include "log.h" #include "http-internal.h" +#ifdef WIN32 +#define snprintf _snprintf +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define strdup _strdup +#endif + #ifndef HAVE_GETADDRINFO struct addrinfo { int ai_family; diff --git a/min_heap.h b/min_heap.h index 8ffb3575..389d6dbe 100644 --- a/min_heap.h +++ b/min_heap.h @@ -83,7 +83,7 @@ struct event* min_heap_pop(min_heap_t* s) int min_heap_erase(min_heap_t* s, struct event* e) { - if(-1u != e->min_heap_idx) + if(((unsigned int)-1) != e->min_heap_idx) { min_heap_shift_down_(s, e->min_heap_idx, s->p[--s->n]); e->min_heap_idx = -1; diff --git a/signal.c b/signal.c index fa233e4e..3636b4f4 100644 --- a/signal.c +++ b/signal.c @@ -39,8 +39,6 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include #endif #include #ifdef HAVE_SYS_SOCKET_H @@ -50,7 +48,9 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #ifdef HAVE_FCNTL_H #include @@ -73,7 +73,11 @@ evsignal_cb(int fd, short what, void *arg) { static char signals[100]; struct event *ev = arg; +#ifdef WIN32 + SSIZE_T n; +#else ssize_t n; +#endif n = recv(fd, signals, sizeof(signals), 0); if (n == -1) -- 2.40.0