diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-10-11 12:30:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:41 -0500 |
commit | 1584f64920431d15276dd44c59fc35dc5506c0e7 (patch) | |
tree | 871d90b8f19bd811dc79ae221f73fae39300371f /source4/lib | |
parent | 16279c67702671c3b5a620fa9372fa77a67eaaf5 (diff) | |
download | samba-1584f64920431d15276dd44c59fc35dc5506c0e7.tar.gz samba-1584f64920431d15276dd44c59fc35dc5506c0e7.tar.bz2 samba-1584f64920431d15276dd44c59fc35dc5506c0e7.zip |
r10896: added a strcasestr() replacement function
(This used to be commit 4483d275e12006e5acc72ae143c0a01da01bd00d)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/replace/config.m4 | 2 | ||||
-rw-r--r-- | source4/lib/replace/replace.c | 16 | ||||
-rw-r--r-- | source4/lib/replace/replace.h | 4 |
3 files changed, 20 insertions, 2 deletions
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 98c491fd38..70d13e40fd 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -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>]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5e60252a67..d87a009e8c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -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 diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 572113af8c..e3eef56eeb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -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 |