]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
strcasestr does not exist on Solaris. Juraj Lutter provided configure patches plus...
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 4 Jan 2013 13:35:38 +0000 (13:35 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 4 Jan 2013 13:35:38 +0000 (13:35 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3020 d19b8d6e-7fed-0310-83ef-9ca221ded41b

configure.ac
pdns/json.cc

index 3fd969faacea19a8e8769c5180fd137abe219826..b495ba48510ef75dcd80b87646986f5e3b2f44d2 100644 (file)
@@ -80,7 +80,7 @@ AC_STRUCT_TM
 
 dnl Checks for library functions.
 AC_TYPE_SIGNAL
-AC_CHECK_FUNCS(gethostname gettimeofday mkdir mktime select socket strerror)
+AC_CHECK_FUNCS(gethostname gettimeofday mkdir mktime select socket strerror strcasestr)
 
 # Check for libdl
 
index 5d52d856272d582d0011f043118a916f3bd72430..2f350460090be4bcc33921dd526b9e1fa4b9b705 100644 (file)
@@ -9,6 +9,51 @@
 #include "rapidjson/document.h"
 #include "rapidjson/stringbuffer.h"
 #include "rapidjson/writer.h"
+#include "config.h"
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+
+#ifndef HAVE_STRCASESTR
+
+/*
+ * strcasestr() locates the first occurrence in the string s1 of the
+ * sequence of characters (excluding the terminating null character)
+ * in the string s2, ignoring case.  strcasestr() returns a pointer
+ * to the located string, or a null pointer if the string is not found.
+ * If s2 is empty, the function returns s1.
+ */
+
+static char *
+strcasestr(const char *s1, const char *s2)
+{
+        int *cm = __trans_lower;
+        const uchar_t *us1 = (const uchar_t *)s1;
+        const uchar_t *us2 = (const uchar_t *)s2;
+        const uchar_t *tptr;
+        int c;
+
+        if (us2 == NULL || *us2 == '\0')
+                return ((char *)us1);
+
+        c = cm[*us2];
+        while (*us1 != '\0') {
+                if (c == cm[*us1++]) {
+                        tptr = us1;
+                        while (cm[c = *++us2] == cm[*us1++] && c != '\0')
+                                continue;
+                        if (c == '\0')
+                                return ((char *)tptr - 1);
+                        us1 = tptr;
+                        us2 = (const uchar_t *)s2;
+                        c = cm[*us2];
+                }
+        }
+
+        return (NULL);
+}
+
+#endif // HAVE_STRCASESTR
 
 using namespace rapidjson;