svn commit: samba r17842 - in branches/SAMBA_4_0/source/lib:
ldb/replace replace
vlendec at samba.org
vlendec at samba.org
Sat Aug 26 17:19:58 GMT 2006
Author: vlendec
Date: 2006-08-26 17:19:58 +0000 (Sat, 26 Aug 2006)
New Revision: 17842
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17842
Log:
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
Modified:
branches/SAMBA_4_0/source/lib/ldb/replace/replace.c
branches/SAMBA_4_0/source/lib/ldb/replace/timegm.c
branches/SAMBA_4_0/source/lib/replace/config.m4
branches/SAMBA_4_0/source/lib/replace/replace.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/replace/replace.c 2006-08-26 16:44:10 UTC (rev 17841)
+++ branches/SAMBA_4_0/source/lib/ldb/replace/replace.c 2006-08-26 17:19:58 UTC (rev 17842)
@@ -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
**/
Modified: branches/SAMBA_4_0/source/lib/ldb/replace/timegm.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/replace/timegm.c 2006-08-26 16:44:10 UTC (rev 17841)
+++ branches/SAMBA_4_0/source/lib/ldb/replace/timegm.c 2006-08-26 17:19:58 UTC (rev 17842)
@@ -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)
{
Modified: branches/SAMBA_4_0/source/lib/replace/config.m4
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/config.m4 2006-08-26 16:44:10 UTC (rev 17841)
+++ branches/SAMBA_4_0/source/lib/replace/config.m4 2006-08-26 17:19:58 UTC (rev 17842)
@@ -50,7 +50,7 @@
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>])
Modified: branches/SAMBA_4_0/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.c 2006-08-26 16:44:10 UTC (rev 17841)
+++ branches/SAMBA_4_0/source/lib/replace/replace.c 2006-08-26 17:19:58 UTC (rev 17842)
@@ -387,6 +387,20 @@
}
#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)
{
@@ -519,3 +533,35 @@
return token;
}
#endif
+
+#if !defined(HAVE_TIMEGM)
+
+static int is_leap(unsigned y)
+{
+ y += 1900;
+ return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
+}
+
+time_t timegm(struct tm *tm)
+{
+ static const unsigned ndays[2][12] ={
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
+ time_t res = 0;
+ unsigned i;
+
+ for (i = 70; i < tm->tm_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
More information about the samba-cvs
mailing list