From 6e9097045fcea332d91791d9820d7ad8e086f6d4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Aug 2006 17:19:58 +0000 Subject: r17842: After talking to Simo, apply the next attempt to resolve the strnlen problem. Timegm is the same. Simo says this is just a workaround, but it helps for now. Feel free to revert. Volker (This used to be commit fd166ca0c079d83081bc1d631fe40b965c7873d4) --- source4/lib/ldb/replace/replace.c | 2 +- source4/lib/ldb/replace/timegm.c | 2 +- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 46 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/source4/lib/ldb/replace/replace.c b/source4/lib/ldb/replace/replace.c index faa5771a76..a63613fc10 100644 --- a/source4/lib/ldb/replace/replace.c +++ b/source4/lib/ldb/replace/replace.c @@ -23,7 +23,7 @@ #include "includes.h" #include "ldb/include/includes.h" -#ifndef HAVE_STRNLEN +#if !defined(HAVE_STRNLEN) && !defined(_SAMBA_BUILD_) /** Some platforms don't have strnlen **/ diff --git a/source4/lib/ldb/replace/timegm.c b/source4/lib/ldb/replace/timegm.c index 5fb15475f3..10631befd9 100644 --- a/source4/lib/ldb/replace/timegm.c +++ b/source4/lib/ldb/replace/timegm.c @@ -38,7 +38,7 @@ #include "includes.h" #include "ldb/include/includes.h" -#ifndef HAVE_TIMEGM +#if !defined(HAVE_TIMEGM) && !defined(_SAMBA_BUILD_) static int is_leap(unsigned y) { diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 93f0bb34a7..adaba74568 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -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 ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..f8bd62109d 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -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; itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif -- cgit