diff options
author | Gisle Vanem <gvanem@broadpark.no> | 2004-08-20 13:45:26 +0000 |
---|---|---|
committer | Gisle Vanem <gvanem@broadpark.no> | 2004-08-20 13:45:26 +0000 |
commit | b17e32baa750d9ce9459e06b144e4ed376dbaa32 (patch) | |
tree | ff1096681439c771456586b8e9e0d542e28ff1ca /ares | |
parent | cd52b9f0da6ad17287e85e55363248d9f7430ba4 (diff) |
Changes for Watt-32 on Windows. I've assumed Configure
sets the required HAVE_xx defines for non-DOS/Win targets.
Diffstat (limited to 'ares')
-rw-r--r-- | ares/ares.h | 11 | ||||
-rw-r--r-- | ares/ares__close_sockets.c | 4 | ||||
-rw-r--r-- | ares/ares__get_hostent.c | 4 | ||||
-rw-r--r-- | ares/ares_expand_name.c | 2 | ||||
-rw-r--r-- | ares/ares_expand_string.c | 2 | ||||
-rw-r--r-- | ares/ares_fds.c | 4 | ||||
-rw-r--r-- | ares/ares_free_hostent.c | 4 | ||||
-rw-r--r-- | ares/ares_init.c | 12 | ||||
-rw-r--r-- | ares/ares_private.h | 6 | ||||
-rw-r--r-- | ares/ares_process.c | 13 | ||||
-rw-r--r-- | ares/ares_query.c | 2 | ||||
-rw-r--r-- | ares/ares_search.c | 2 | ||||
-rw-r--r-- | ares/ares_send.c | 2 | ||||
-rw-r--r-- | ares/ares_timeout.c | 5 | ||||
-rw-r--r-- | ares/nameser.h | 12 | ||||
-rw-r--r-- | ares/setup.h | 35 | ||||
-rw-r--r-- | ares/windows_port.c | 16 |
17 files changed, 88 insertions, 48 deletions
diff --git a/ares/ares.h b/ares/ares.h index af1a52a9e..44a9d087c 100644 --- a/ares/ares.h +++ b/ares/ares.h @@ -27,11 +27,14 @@ #include <sys/select.h> #endif -#ifdef WIN32 -#include <winsock.h> -#include <windows.h> +#if defined(WATT32) + #include <netinet/in.h> + #include <tcp.h> +#elif defined(WIN32) + #include <winsock.h> + #include <windows.h> #else -#include <netinet/in.h> + #include <netinet/in.h> #endif #define ARES_SUCCESS 0 diff --git a/ares/ares__close_sockets.c b/ares/ares__close_sockets.c index 48f49af9e..fb883f9a9 100644 --- a/ares/ares__close_sockets.c +++ b/ares/ares__close_sockets.c @@ -16,10 +16,10 @@ #include "setup.h" #include <stdlib.h> -#ifdef WIN32 -#else +#ifdef HAVE_UNISTD_H #include <unistd.h> #endif + #include "ares.h" #include "ares_private.h" diff --git a/ares/ares__get_hostent.c b/ares/ares__get_hostent.c index 896f516d2..551b597c0 100644 --- a/ares/ares__get_hostent.c +++ b/ares/ares__get_hostent.c @@ -16,9 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 - -#else +#if !defined(WIN32) || defined(WATT32) #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/ares/ares_expand_name.c b/ares/ares_expand_name.c index 40b9f2e5e..0f95c07e3 100644 --- a/ares/ares_expand_name.c +++ b/ares/ares_expand_name.c @@ -16,7 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #else #include <netinet/in.h> diff --git a/ares/ares_expand_string.c b/ares/ares_expand_string.c index 776a2fbed..dcb0c0290 100644 --- a/ares/ares_expand_string.c +++ b/ares/ares_expand_string.c @@ -16,7 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #else #include <netinet/in.h> diff --git a/ares/ares_fds.c b/ares/ares_fds.c index 6bb6ccee4..58cf67a3e 100644 --- a/ares/ares_fds.c +++ b/ares/ares_fds.c @@ -16,9 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 - -#else +#ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif diff --git a/ares/ares_free_hostent.c b/ares/ares_free_hostent.c index b33064e82..8d6967eed 100644 --- a/ares/ares_free_hostent.c +++ b/ares/ares_free_hostent.c @@ -16,9 +16,7 @@ #include "setup.h" #include <stdlib.h> -#ifdef WIN32 - -#else +#if !defined(WIN32) || defined(WATT32) #include <netdb.h> #endif diff --git a/ares/ares_init.c b/ares/ares_init.c index 0fbad973b..1d4a015ad 100644 --- a/ares/ares_init.c +++ b/ares/ares_init.c @@ -16,19 +16,25 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #include <iphlpapi.h> #include <malloc.h> + #else #include <sys/param.h> +#ifdef HAVE_SYS_TIME_H #include <sys/time.h> +#endif + #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <arpa/nameser.h> +#ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#endif #include <stdio.h> #include <stdlib.h> @@ -39,6 +45,10 @@ #include "ares.h" #include "ares_private.h" +#ifdef WATT32 +#undef WIN32 /* Redefined in MingW/MSVC headers */ +#endif + static int init_by_options(ares_channel channel, struct ares_options *options, int optmask); static int init_by_environment(ares_channel channel); diff --git a/ares/ares_private.h b/ares/ares_private.h index c75ab97c0..0b16dc0df 100644 --- a/ares/ares_private.h +++ b/ares/ares_private.h @@ -18,9 +18,7 @@ #include <stdio.h> #include <sys/types.h> -#ifdef WIN32 - -#else +#if !defined(WIN32) || defined(WATT32) #include <netinet/in.h> /* We define closesocket() here so that we can use this function all over the source code for closing sockets. */ @@ -41,7 +39,7 @@ #define INADDR_NONE 0xffffffff #endif -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #define IsNT ((int)GetVersion()>0) #define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP" diff --git a/ares/ares_process.c b/ares/ares_process.c index 9e5156e4e..4a88b76a8 100644 --- a/ares/ares_process.c +++ b/ares/ares_process.c @@ -16,27 +16,33 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" + #else #include <sys/socket.h> +#ifdef HAVE_SYS_UIO_H #include <sys/uio.h> +#endif #include <netinet/in.h> #include <netdb.h> #include <arpa/nameser.h> +#ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#endif #include <string.h> #include <stdlib.h> #include <fcntl.h> #include <time.h> #include <errno.h> + #include "ares.h" #include "ares_dns.h" #include "ares_private.h" -#ifdef WIN32 +#if defined(WIN32) || defined(WATT32) #define GET_ERRNO() WSAGetLastError() #else #define GET_ERRNO() errno @@ -234,7 +240,8 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, time_t now) */ process_answer(channel, server->tcp_buffer, server->tcp_length, i, 1, now); - free(server->tcp_buffer); + if (server->tcp_buffer) + free(server->tcp_buffer); server->tcp_buffer = NULL; server->tcp_lenbuf_pos = 0; } diff --git a/ares/ares_query.c b/ares/ares_query.c index 5e21f72f0..2b832654f 100644 --- a/ares/ares_query.c +++ b/ares/ares_query.c @@ -16,7 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #else #include <netinet/in.h> diff --git a/ares/ares_search.c b/ares/ares_search.c index 2e250c42c..37826ee39 100644 --- a/ares/ares_search.c +++ b/ares/ares_search.c @@ -19,7 +19,7 @@ #include <string.h> #include <ctype.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #endif diff --git a/ares/ares_send.c b/ares/ares_send.c index 1c928b2e5..6f0a31d58 100644 --- a/ares/ares_send.c +++ b/ares/ares_send.c @@ -16,7 +16,7 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include "nameser.h" #else #include <netinet/in.h> diff --git a/ares/ares_timeout.c b/ares/ares_timeout.c index 6a1ba8948..775b0a915 100644 --- a/ares/ares_timeout.c +++ b/ares/ares_timeout.c @@ -16,13 +16,12 @@ #include "setup.h" #include <sys/types.h> -#ifdef WIN32 - -#else +#ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif #include <time.h> + #include "ares.h" #include "ares_private.h" diff --git a/ares/nameser.h b/ares/nameser.h index d3a95e8cc..f2653f127 100644 --- a/ares/nameser.h +++ b/ares/nameser.h @@ -221,16 +221,4 @@ typedef enum __ns_rcode { #define T_MAILA ns_t_maila #define T_ANY ns_t_any -#if !(defined(__MINGW32__) || defined(NETWARE)) -/* protos for the functions we provide in windows_port.c */ -int ares_strncasecmp(const char *s1, const char *s2, size_t n); -int ares_strcasecmp(const char *s1, const char *s2); - -/* use this define magic to prevent us from adding symbol names to the library - that is a high-risk to collide with another libraries' attempts to do the - same */ -#define strncasecmp(a,b,c) ares_strncasecmp(a,b,c) -#define strcasecmp(a,b) ares_strcasecmp(a,b) -#endif - #endif /* ARES_NAMESER_H */ diff --git a/ares/setup.h b/ares/setup.h index a713ef9cb..7b933531b 100644 --- a/ares/setup.h +++ b/ares/setup.h @@ -19,6 +19,12 @@ #else /* simple work-around for now, for systems without configure support */ #define ssize_t int + +#ifdef __MINGW32__ +#define HAVE_SYS_TIME_H +#define HAVE_UNISTD_H +#endif + #endif /* Recent autoconf versions define these symbols in config.h. We don't want @@ -33,7 +39,7 @@ #undef PACKAGE /* now typedef our socket type */ -#ifdef WIN32 +#if defined(WIN32) && !defined(WATT32) #include <winsock.h> typedef SOCKET ares_socket_t; #define ARES_SOCKET_BAD INVALID_SOCKET @@ -42,4 +48,31 @@ typedef int ares_socket_t; #define ARES_SOCKET_BAD -1 #endif +/* Assume a few thing unless they're set by configure + */ +#if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) +#define HAVE_SYS_TIME_H +#endif + +#if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER) +#define HAVE_UNISTD_H +#endif + +#if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) +#define HAVE_SYS_UIO_H +#endif + +#if (defined(WIN32) || defined(WATT32)) && \ + !(defined(__MINGW32__) || defined(NETWARE)) +/* protos for the functions we provide in windows_port.c */ +int ares_strncasecmp(const char *s1, const char *s2, int n); +int ares_strcasecmp(const char *s1, const char *s2); + +/* use this define magic to prevent us from adding symbol names to the library + that is a high-risk to collide with another libraries' attempts to do the + same */ +#define strncasecmp(a,b,c) ares_strncasecmp(a,b,c) +#define strcasecmp(a,b) ares_strcasecmp(a,b) +#endif + #endif /* ARES_SETUP_H */ diff --git a/ares/windows_port.c b/ares/windows_port.c index d8c9bda1c..9aa72fa7f 100644 --- a/ares/windows_port.c +++ b/ares/windows_port.c @@ -1,6 +1,8 @@ #include "setup.h" -#ifdef WIN32 /* only do the following on windows */ +/* only do the following on windows + */ +#if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS) #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -8,13 +10,19 @@ #include <errno.h> #include <malloc.h> +#ifdef WATT32 +#include <sys/socket.h> +#else #include "nameser.h" +#endif +#include "ares.h" +#include "ares_private.h" #ifndef __MINGW32__ int -ares_strncasecmp(const char *a, const char *b, size_t n) +ares_strncasecmp(const char *a, const char *b, int n) { - size_t i; + int i; for (i = 0; i < n; i++) { int c1 = isupper(a[i]) ? tolower(a[i]) : a[i]; @@ -57,7 +65,7 @@ ares_gettimeofday(struct timeval *tv, struct timezone *tz) } int -ares_writev (SOCKET s, const struct iovec *vector, size_t count) +ares_writev (ares_socket_t s, const struct iovec *vector, size_t count) { char *buffer, *bp; size_t i, bytes = 0; |