From 809f740166e4c71e7b7027c626336d1e4c58f485 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 30 Oct 2002 12:03:40 +0000 Subject: added a timegm() function for systems that don't have it (This used to be commit 732bc4519f1119100607cc84400e8f84e0c0ba9d) --- source3/configure.in | 2 +- source3/include/includes.h | 4 ++++ source3/lib/replace.c | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source3/configure.in b/source3/configure.in index 206a9edb50..78ed4a953c 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -749,7 +749,7 @@ AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64) AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf) AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink) -AC_CHECK_FUNCS(syslog vsyslog getgrouplist) +AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm) # setbuffer is needed for smbtorture AC_CHECK_FUNCS(setbuffer) diff --git a/source3/include/includes.h b/source3/include/includes.h index 01b9f14979..a7dd967bf3 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -1165,5 +1165,9 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #define VA_COPY(dest, src) (dest) = (src) #endif +#ifndef HAVE_TIMEGM +time_t timegm(struct tm *tm); +#endif + #endif /* _INCLUDES_H */ diff --git a/source3/lib/replace.c b/source3/lib/replace.c index fd7b2cf7f0..afdf32dbe8 100644 --- a/source3/lib/replace.c +++ b/source3/lib/replace.c @@ -430,3 +430,25 @@ char *rep_inet_ntoa(struct in_addr ip) #endif /* HAVE_VSYSLOG */ +#ifndef HAVE_TIMEGM +/* + see the timegm man page on linux +*/ + time_t timegm(struct tm *tm) +{ + time_t ret; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) { + setenv("TZ", tz, 1); + } else { + unsetenv("TZ"); + } + tzset(); + return ret; +} +#endif -- cgit