summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc4
-rw-r--r--Makefile.vc63
-rw-r--r--acountry.c15
-rw-r--r--adig.c15
-rw-r--r--ahost.c15
-rw-r--r--ares_private.h10
-rw-r--r--ares_strcasecmp.c67
-rw-r--r--ares_strcasecmp.h31
-rw-r--r--config-win32.h12
-rw-r--r--setup.h13
-rw-r--r--vc/areslib/areslib.dsp8
-rw-r--r--windows_port.c21
12 files changed, 178 insertions, 36 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 2a2c784..1c22abb 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -6,11 +6,11 @@ ares_timeout.c ares_destroy.c ares_mkquery.c ares_version.c \
ares_expand_name.c ares_parse_a_reply.c windows_port.c ares_strdup.c \
ares_expand_string.c ares_parse_ptr_reply.c ares_parse_aaaa_reply.c \
ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c \
-ares_parse_ns_reply.c ares_llist.c ares__timeval.c
+ares_parse_ns_reply.c ares_llist.c ares__timeval.c ares_strcasecmp.c
HHEADERS = ares.h ares_private.h setup.h ares_dns.h ares_version.h \
nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h \
- setup_once.h ares_llist.h ares_strdup.h
+ setup_once.h ares_llist.h ares_strdup.h ares_strcasecmp.h
MANPAGES= ares_destroy.3 ares_expand_name.3 ares_expand_string.3 ares_fds.3 \
ares_free_hostent.3 ares_free_string.3 ares_gethostbyaddr.3 \
diff --git a/Makefile.vc6 b/Makefile.vc6
index f02bd37..8bf5a08 100644
--- a/Makefile.vc6
+++ b/Makefile.vc6
@@ -57,6 +57,7 @@ OBJECTS = $(OBJ_DIR)\ares_fds.obj \
$(OBJ_DIR)\ares__read_line.obj \
$(OBJ_DIR)\ares_gethostbyname.obj \
$(OBJ_DIR)\ares_getnameinfo.obj \
+ $(OBJ_DIR)\ares_strcasecmp.obj \
$(OBJ_DIR)\ares_strerror.obj \
$(OBJ_DIR)\ares_cancel.obj \
$(OBJ_DIR)\ares_init.obj \
@@ -184,6 +185,8 @@ $(OBJ_DIR)\ares__read_line.obj: ares__read_line.c setup.h setup_once.h ares.h \
$(OBJ_DIR)\ares_gethostbyname.obj: ares_gethostbyname.c setup.h setup_once.h \
nameser.h ares.h ares_private.h ares_ipv6.h inet_net_pton.h bitncmp.h
+$(OBJ_DIR)\ares_strcasecmp.obj: ares_strcasecmp.c setup.h setup_once.h ares.h
+
$(OBJ_DIR)\ares_strerror.obj: ares_strerror.c setup.h setup_once.h ares.h
$(OBJ_DIR)\ares_cancel.obj: ares_cancel.c setup.h setup_once.h ares.h \
diff --git a/acountry.c b/acountry.c
index 169f814..f74577f 100644
--- a/acountry.c
+++ b/acountry.c
@@ -60,6 +60,21 @@
#include "inet_net_pton.h"
#include "inet_ntop.h"
+#ifndef HAVE_STRDUP
+# include "ares_strdup.h"
+# define strdup(ptr) ares_strdup(ptr)
+#endif
+
+#ifndef HAVE_STRCASECMP
+# include "ares_strcasecmp.h"
+# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# include "ares_strcasecmp.h"
+# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
+#endif
+
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
diff --git a/adig.c b/adig.c
index 707fc80..031ce81 100644
--- a/adig.c
+++ b/adig.c
@@ -50,6 +50,21 @@
#include "inet_ntop.h"
#include "ares_getopt.h"
+#ifndef HAVE_STRDUP
+# include "ares_strdup.h"
+# define strdup(ptr) ares_strdup(ptr)
+#endif
+
+#ifndef HAVE_STRCASECMP
+# include "ares_strcasecmp.h"
+# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# include "ares_strcasecmp.h"
+# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
+#endif
+
#ifdef WATT32
#undef WIN32 /* Redefined in MingW headers */
#endif
diff --git a/ahost.c b/ahost.c
index 882efcc..567c7a0 100644
--- a/ahost.c
+++ b/ahost.c
@@ -43,6 +43,21 @@
#include "inet_net_pton.h"
#include "ares_getopt.h"
+#ifndef HAVE_STRDUP
+# include "ares_strdup.h"
+# define strdup(ptr) ares_strdup(ptr)
+#endif
+
+#ifndef HAVE_STRCASECMP
+# include "ares_strcasecmp.h"
+# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# include "ares_strcasecmp.h"
+# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
+#endif
+
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void usage(void);
diff --git a/ares_private.h b/ares_private.h
index 877985b..e138cdd 100644
--- a/ares_private.h
+++ b/ares_private.h
@@ -99,6 +99,16 @@
# define strdup(ptr) ares_strdup(ptr)
#endif
+#ifndef HAVE_STRCASECMP
+# include "ares_strcasecmp.h"
+# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# include "ares_strcasecmp.h"
+# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
+#endif
+
struct query;
struct send_request {
diff --git a/ares_strcasecmp.c b/ares_strcasecmp.c
new file mode 100644
index 0000000..c3d1df9
--- /dev/null
+++ b/ares_strcasecmp.c
@@ -0,0 +1,67 @@
+
+/* $Id$ */
+
+/* Copyright 1998 by the Massachusetts Institute of Technology.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of M.I.T. not be used in
+ * advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ */
+
+#include "setup.h"
+#include "ares_strcasecmp.h"
+
+#ifndef HAVE_STRCASECMP
+int ares_strcasecmp(const char *a, const char *b)
+{
+#if defined(HAVE_STRCMPI)
+ return strcmpi(a, b);
+#elif defined(HAVE_STRICMP)
+ return stricmp(a, b);
+#else
+ size_t i;
+
+ for (i = 0; i < (size_t)-1; i++) {
+ int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
+ int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
+ if (c1 != c2)
+ return c1-c2;
+ if (!c1)
+ break;
+ }
+ return 0;
+#endif
+}
+#endif
+
+#ifndef HAVE_STRNCASECMP
+int ares_strncasecmp(const char *a, const char *b, size_t n)
+{
+#if defined(HAVE_STRNCMPI)
+ return strncmpi(a, b, n);
+#elif defined(HAVE_STRNICMP)
+ return strnicmp(a, b, n);
+#else
+ size_t i;
+
+ for (i = 0; i < n; i++) {
+ int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
+ int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
+ if (c1 != c2)
+ return c1-c2;
+ if (!c1)
+ break;
+ }
+ return 0;
+#endif
+}
+#endif
+
diff --git a/ares_strcasecmp.h b/ares_strcasecmp.h
new file mode 100644
index 0000000..85b053a
--- /dev/null
+++ b/ares_strcasecmp.h
@@ -0,0 +1,31 @@
+#ifndef HEADER_CARES_STRCASECMP_H
+#define HEADER_CARES_STRCASECMP_H
+
+/* $Id$ */
+
+/* Copyright 1998 by the Massachusetts Institute of Technology.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of M.I.T. not be used in
+ * advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ */
+
+#include "setup.h"
+
+#ifndef HAVE_STRCASECMP
+extern int ares_strcasecmp(const char *a, const char *b);
+#endif
+
+#ifndef HAVE_STRNCASECMP
+extern int ares_strncasecmp(const char *a, const char *b, size_t n);
+#endif
+
+#endif /* HEADER_CARES_STRCASECMP_H */
diff --git a/config-win32.h b/config-win32.h
index 5e26fa6..6e548dc 100644
--- a/config-win32.h
+++ b/config-win32.h
@@ -79,9 +79,21 @@
/* Define if you have the ioctlsocket function. */
#define HAVE_IOCTLSOCKET 1
+/* Define if you have the strcasecmp function. */
+/* #define HAVE_STRCASECMP 1 */
+
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
+/* Define if you have the stricmp function. */
+#define HAVE_STRICMP 1
+
+/* Define if you have the strncasecmp function. */
+/* #define HAVE_STRNCASECMP 1 */
+
+/* Define if you have the strnicmp function. */
+#define HAVE_STRNICMP 1
+
/* Define if you have the recv function. */
#define HAVE_RECV 1
diff --git a/setup.h b/setup.h
index 5ae3b9e..5a8b2fa 100644
--- a/setup.h
+++ b/setup.h
@@ -139,19 +139,6 @@
#define HAVE_SYS_UIO_H
#endif
-#if (defined(WIN32) || defined(WATT32)) && \
- !(defined(__MINGW32__) || defined(NETWARE) || defined(__DJGPP__))
-/* 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
-
/* IPv6 compatibility */
#if !defined(HAVE_AF_INET6)
#if defined(HAVE_PF_INET6)
diff --git a/vc/areslib/areslib.dsp b/vc/areslib/areslib.dsp
index 47805bd..83cab07 100644
--- a/vc/areslib/areslib.dsp
+++ b/vc/areslib/areslib.dsp
@@ -181,6 +181,10 @@ SOURCE=..\..\ares_send.c
# End Source File
# Begin Source File
+SOURCE=..\..\ares_strcasecmp.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\ares_strerror.c
# End Source File
# Begin Source File
@@ -233,6 +237,10 @@ SOURCE=..\..\ares_private.h
# End Source File
# Begin Source File
+SOURCE=..\..\ares_strcasecmp.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\ares_version.h
# End Source File
# Begin Source File
diff --git a/windows_port.c b/windows_port.c
index 7ea6579..8b5e149 100644
--- a/windows_port.c
+++ b/windows_port.c
@@ -34,27 +34,6 @@ WINAPI DllMain (HINSTANCE hnd, DWORD reason, LPVOID reserved)
}
#endif
-#ifndef __MINGW32__
-int
-ares_strncasecmp(const char *a, const char *b, int n)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
- int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
- if (c1 != c2) return c1-c2;
- }
- return 0;
-}
-
-int
-ares_strcasecmp(const char *a, const char *b)
-{
- return strncasecmp(a, b, strlen(a)+1);
-}
-#endif
-
int
ares_writev (ares_socket_t s, const struct iovec *vector, size_t count)
{