r10896: added a strcasestr() replacement function
authorAndrew Tridgell <tridge@samba.org>
Tue, 11 Oct 2005 12:30:34 +0000 (12:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:39:41 +0000 (13:39 -0500)
(This used to be commit 4483d275e12006e5acc72ae143c0a01da01bd00d)

source4/lib/replace/config.m4
source4/lib/replace/replace.c
source4/lib/replace/replace.h

index 98c491fd38eee406af8d012339372eba31ce0550..70d13e40fd8b921867f468180f07dcf5b88386b2 100644 (file)
@@ -45,7 +45,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
 AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
 AC_HAVE_DECL(errno, [#include <errno.h>])
index 5e60252a67b6e8becdc127bd42cbc376435080d8..d87a009e8c346ba032115e9843ed24ebc94d83da 100644 (file)
@@ -22,6 +22,7 @@
 #include "system/wait.h"
 #include "system/time.h"
 #include "system/network.h"
+#include "system/iconv.h"
 
  void replace_dummy(void);
  void replace_dummy(void) {}
@@ -534,4 +535,17 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs
 }
 #endif
 
-
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *haystack, const char *needle)
+{
+       const char *s;
+       size_t nlen = strlen(needle);
+       for (s=haystack;*s;s++) {
+               if (toupper(*needle) == toupper(*s) &&
+                   strncasecmp(s, needle, nlen) == 0) {
+                       return discard_const_p(char, s);
+               }
+       }
+       return NULL;
+}
+#endif
index 572113af8cfaf753e213c4fedd4e8f13617083a1..e3eef56eeb7a46b6679023a47c70882c77663b79 100644 (file)
@@ -84,6 +84,10 @@ int setenv(const char *name, const char *value, int overwrite);
 int rename(const char *zfrom, const char *zto);
 #endif
 
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *haystack, const char *needle);
+#endif
+
 #ifndef HAVE_FTRUNCATE
 int ftruncate(int f,long l);
 #endif