From 4dbae90e80ea16719b33a641571fff46645e3125 Mon Sep 17 00:00:00 2001 From: Alexander Nedotsukov Date: Thu, 19 Oct 2006 08:12:29 +0000 Subject: [PATCH] Handled platform specific differences in time zone calculation. --- bootstrap | 1 + configure.ac | 8 ++++++++ libisofs/util.c | 29 ++++++++++++++++++----------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/bootstrap b/bootstrap index ad2bf02..a0b6469 100755 --- a/bootstrap +++ b/bootstrap @@ -3,4 +3,5 @@ aclocal libtoolize --copy --force autoconf +autoheader automake --foreign --add-missing --copy --include-deps diff --git a/configure.ac b/configure.ac index d101994..d7784f8 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,8 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([subdir-objects]) +AM_CONFIG_HEADER(config.h) + dnl Making releases: dnl BURN_MICRO_VERSION += 1; dnl BURN_INTERFACE_AGE += 1; @@ -69,6 +71,12 @@ AC_PROG_INSTALL AC_CHECK_HEADERS() +AC_CHECK_MEMBER([struct tm.tm_gmtoff], + [AC_DEFINE(HAVE_TM_GMTOFF, 1, + [Define this if tm structure includes a tm_gmtoff entry.])], + , + [#include ]) + THREAD_LIBS=-lpthread AC_SUBST(THREAD_LIBS) diff --git a/libisofs/util.c b/libisofs/util.c index 186c795..2187b6f 100755 --- a/libisofs/util.c +++ b/libisofs/util.c @@ -4,6 +4,9 @@ /** * Utility functions for the Libisofs library. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include @@ -421,16 +424,11 @@ void iso_bb(uint8_t *buf, uint32_t num, int bytes) void iso_datetime_7(unsigned char *buf, time_t t) { static int tzsetup = 0; - static int tzoffset; + int tzoffset; struct tm tm; if (!tzsetup) { tzset(); - - tzoffset = -timezone / 60 / 15; - if (tzoffset < -48) - tzoffset += 101; - tzsetup = 1; } @@ -442,6 +440,13 @@ void iso_datetime_7(unsigned char *buf, time_t t) buf[3] = tm.tm_hour; buf[4] = tm.tm_min; buf[5] = tm.tm_sec; +#ifdef HAVE_TM_GMTOFF + tzoffset = -tm.tm_gmtoff / 60 / 15; +#else + tzoffset = -timezone / 60 / 15; +#endif + if (tzoffset < -48) + tzoffset += 101; buf[6] = tzoffset; } @@ -472,11 +477,6 @@ void iso_datetime_17(unsigned char *buf, time_t t) } else { if (!tzsetup) { tzset(); - - tzoffset = -timezone / 60 / 15; - if (tzoffset < -48) - tzoffset += 101; - tzsetup = 1; } @@ -489,6 +489,13 @@ void iso_datetime_17(unsigned char *buf, time_t t) sprintf((char*)&buf[10], "%02d", tm.tm_min); sprintf((char*)&buf[12], "%02d", MIN(59, tm.tm_sec)); memcpy(&buf[14], "00", 2); +#ifdef HAVE_TM_GMTOFF + tzoffset = -tm.tm_gmtoff / 60 / 15; +#else + tzoffset = -timezone / 60 / 15; +#endif + if (tzoffset < -48) + tzoffset += 101; buf[16] = tzoffset; } }