summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ares.h11
-rw-r--r--ares__close_sockets.c4
-rw-r--r--ares__get_hostent.c4
-rw-r--r--ares_expand_name.c2
-rw-r--r--ares_expand_string.c2
-rw-r--r--ares_fds.c4
-rw-r--r--ares_free_hostent.c4
-rw-r--r--ares_init.c12
-rw-r--r--ares_private.h6
-rw-r--r--ares_process.c13
-rw-r--r--ares_query.c2
-rw-r--r--ares_search.c2
-rw-r--r--ares_send.c2
-rw-r--r--ares_timeout.c5
-rw-r--r--nameser.h12
-rw-r--r--setup.h35
-rw-r--r--windows_port.c16
17 files changed, 88 insertions, 48 deletions
diff --git a/ares.h b/ares.h
index af1a52a..44a9d08 100644
--- a/ares.h
+++ b/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__close_sockets.c b/ares__close_sockets.c
index 48f49af..fb883f9 100644
--- a/ares__close_sockets.c
+++ b/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__get_hostent.c b/ares__get_hostent.c
index 896f516..551b597 100644
--- a/ares__get_hostent.c
+++ b/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_expand_name.c b/ares_expand_name.c
index 40b9f2e..0f95c07 100644
--- a/ares_expand_name.c
+++ b/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_expand_string.c b/ares_expand_string.c
index 776a2fb..dcb0c02 100644
--- a/ares_expand_string.c
+++ b/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_fds.c b/ares_fds.c
index 6bb6cce..58cf67a 100644
--- a/ares_fds.c
+++ b/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_free_hostent.c b/ares_free_hostent.c
index b33064e..8d6967e 100644
--- a/ares_free_hostent.c
+++ b/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_init.c b/ares_init.c
index 0fbad97..1d4a015 100644
--- a/ares_init.c
+++ b/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_private.h b/ares_private.h
index c75ab97..0b16dc0 100644
--- a/ares_private.h
+++ b/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_process.c b/ares_process.c
index 9e5156e..4a88b76 100644
--- a/ares_process.c
+++ b/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_query.c b/ares_query.c
index 5e21f72..2b83265 100644
--- a/ares_query.c
+++ b/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_search.c b/ares_search.c
index 2e250c4..37826ee 100644
--- a/ares_search.c
+++ b/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_send.c b/ares_send.c
index 1c928b2..6f0a31d 100644
--- a/ares_send.c
+++ b/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_timeout.c b/ares_timeout.c
index 6a1ba89..775b0a9 100644
--- a/ares_timeout.c
+++ b/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/nameser.h b/nameser.h
index d3a95e8..f2653f1 100644
--- a/nameser.h
+++ b/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/setup.h b/setup.h
index a713ef9..7b93353 100644
--- a/setup.h
+++ b/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/windows_port.c b/windows_port.c
index d8c9bda..9aa72fa 100644
--- a/windows_port.c
+++ b/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;