]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
rearrange to allow internal/private use of ares_strcasecmp to any system that
authorYang Tse <yangsita@gmail.com>
Mon, 15 Sep 2008 15:28:26 +0000 (15:28 +0000)
committerYang Tse <yangsita@gmail.com>
Mon, 15 Sep 2008 15:28:26 +0000 (15:28 +0000)
lacks the strcasecmp function.

12 files changed:
ares/Makefile.inc
ares/Makefile.vc6
ares/acountry.c
ares/adig.c
ares/ahost.c
ares/ares_private.h
ares/ares_strcasecmp.c [new file with mode: 0644]
ares/ares_strcasecmp.h [new file with mode: 0644]
ares/config-win32.h
ares/setup.h
ares/vc/areslib/areslib.dsp
ares/windows_port.c

index 2a2c784200dfeaf5bee4bc13fcaf79728679f0bd..1c22abb98936554397f5c5800b91842774008fe3 100644 (file)
@@ -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               \
index f02bd37e8a93909a9253ea164679d34513562654..8bf5a08d2ac75bb8e7c8da4f915b91f5064582e6 100644 (file)
@@ -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          \
index 169f81425daa1557f51a3c773a62e90d1f0a3705..f74577f91dba18686f9987361e61ce11a5aa1339 100644 (file)
 #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
index 707fc8094643c23ce4c51d98ac4b31f8992220a9..031ce8153bb12726002f2b69cb8cd2df8291a381 100644 (file)
 #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
index 882efcc77490c8532b4c371a4787d79518897fb0..567c7a024a6371b466f96888e40e1cf9b6a84a80 100644 (file)
 #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);
 
index 877985bc99cfe6898b20c89c9c2bd41ae3ab62ed..e138cdd212eb29d4a683c1683890b5489d23f4b6 100644 (file)
 #  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/ares_strcasecmp.c b/ares/ares_strcasecmp.c
new file mode 100644 (file)
index 0000000..c3d1df9
--- /dev/null
@@ -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/ares_strcasecmp.h b/ares/ares_strcasecmp.h
new file mode 100644 (file)
index 0000000..85b053a
--- /dev/null
@@ -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 */
index 5e26fa61d217526f92ddf9397cb4b3eec7805e18..6e548dcdfa5d1e645c9e32a0b225e571eb910363 100644 (file)
 /* 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
 
index 5ae3b9e4e349d499cfd793440a21edccf6de732e..5a8b2fa6a2e1b3ef3db0c2cc0cae058eb844cf71 100644 (file)
 #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)
index 47805bd46c26254697a9a9e61466f9fe94ba3ca3..83cab07cbdb739b21c4d9e1ac3aa5a53b22181dc 100644 (file)
@@ -181,6 +181,10 @@ SOURCE=..\..\ares_send.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\ares_strcasecmp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\ares_strerror.c\r
 # End Source File\r
 # Begin Source File\r
@@ -233,6 +237,10 @@ SOURCE=..\..\ares_private.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\ares_strcasecmp.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\ares_version.h\r
 # End Source File\r
 # Begin Source File\r
index 7ea6579fd47fe911d4b0751a35bae0ecd96d30cb..8b5e149770487d3e7b6211438354ce8b6823202c 100644 (file)
@@ -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)
 {