r17840: A step towards building on Solaris which appears not to have strnlen.
authorVolker Lendecke <vlendec@samba.org>
Sat, 26 Aug 2006 16:19:22 +0000 (16:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:16:47 +0000 (14:16 -0500)
Volker

source/lib/replace/config.m4
source/lib/replace/replace.c

index 93f0bb34a776d8f6ba284366147bc674319613c8..adaba74568f43c950f5ccff7b6c68aa176a68f8f 100644 (file)
@@ -50,7 +50,7 @@ AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
+AC_CHECK_FUNCS(pread pwrite strndup strnlen strcasestr strtok_r mkdtemp)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
 AC_HAVE_DECL(errno, [#include <errno.h>])
index b8f4bc1c3c9eb15b516750db4e8e8a8767d4ad22..1cf91751b3c2be0f3a5bde58464121ec7081a6e8 100644 (file)
@@ -387,6 +387,20 @@ duplicate a string
 }
 #endif
 
+#ifndef HAVE_STRNLEN
+/**
+ Some platforms don't have strnlen
+**/
+
+ size_t strnlen(const char *s, size_t n)
+{
+       size_t i;
+       for (i=0; i<n && s[i] != '\0'; i++)
+               /* noop */ ;
+       return i;
+}
+#endif
+
 #ifndef HAVE_WAITPID
 int waitpid(pid_t pid,int *status,int options)
 {