2004-01-08 Richard Hult <richard@imendio.com>
* loudmouth/lm-connection.c (connection_timeout_check_open):
Remove debug output.
* acinclude.m4: Add gmtoff check.
* loudmouth/lm-utils.c (lm_utils_get_localtime): Use tm_gmtoff if
available.
--- a/ChangeLog Mon Jan 05 23:44:41 2004 +0000
+++ b/ChangeLog Thu Jan 08 14:43:02 2004 +0000
@@ -1,3 +1,13 @@
+2004-01-08 Richard Hult <richard@imendio.com>
+
+ * loudmouth/lm-connection.c (connection_timeout_check_open):
+ Remove debug output.
+
+ * acinclude.m4: Add gmtoff check.
+
+ * loudmouth/lm-utils.c (lm_utils_get_localtime): Use tm_gmtoff if
+ available.
+
2004-01-06 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-connection.c:
--- a/acinclude.m4 Mon Jan 05 23:44:41 2004 +0000
+++ b/acinclude.m4 Thu Jan 08 14:43:02 2004 +0000
@@ -217,3 +217,32 @@
])
+dnl ***************
+dnl Timezone checks
+dnl ***************
+AC_DEFUN([LM_CHECK_TIMEZONE],[
+AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
+ AC_TRY_COMPILE([
+ #include <time.h>
+ ], [
+ struct tm tm;
+ tm.tm_gmtoff = 1;
+ ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
+if test $ac_cv_struct_tm_gmtoff = yes; then
+ AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff member])
+else
+ AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
+ AC_TRY_COMPILE([
+ #include <time.h>
+ ], [
+ timezone = 1;
+ ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
+ if test $ac_cv_var_timezone = yes; then
+ AC_DEFINE(HAVE_TIMEZONE, 1, [Define if libc defines a timezone variable])
+ else
+ AC_ERROR(unable to find a way to determine timezone)
+ fi
+fi
+])
+
+
--- a/configure.in Mon Jan 05 23:44:41 2004 +0000
+++ b/configure.in Thu Jan 08 14:43:02 2004 +0000
@@ -33,6 +33,8 @@
AC_SUBST(GLIB2_REQUIRED)
AC_SUBST(GNUTLS_REQUIRED)
+LM_CHECK_TIMEZONE
+
PKG_CHECK_MODULES(LOUDMOUTH, glib-2.0 >= $GLIB2_REQUIRED)
dnl +--------------------+
--- a/loudmouth/lm-connection.c Mon Jan 05 23:44:41 2004 +0000
+++ b/loudmouth/lm-connection.c Thu Jan 08 14:43:02 2004 +0000
@@ -435,9 +435,10 @@
connection_do_close (connection);
return FALSE;
}
-
+
+#if 0
g_print ("In timeoutfunc\n");
-
+#endif
m = lm_message_new (connection->server, LM_MESSAGE_TYPE_STREAM);
lm_message_node_set_attributes (m->node,
"xmlns:stream", "http://etherx.jabber.org/streams",
@@ -453,9 +454,11 @@
}
lm_message_unref (m);
-
+
+#if 0
g_print ("Success!!\n");
-
+#endif
+
/* Success */
return FALSE;
}
--- a/loudmouth/lm-utils.c Mon Jan 05 23:44:41 2004 +0000
+++ b/loudmouth/lm-utils.c Thu Jan 08 14:43:02 2004 +0000
@@ -65,22 +65,30 @@
struct tm *
lm_utils_get_localtime (const gchar *stamp)
{
- struct tm tmp_tm;
+ struct tm tm;
time_t t;
gint year, month;
/* 20021209T23:51:30 */
sscanf (stamp, "%4d%2d%2dT%2d:%2d:%2d",
- &year, &month, &tmp_tm.tm_mday, &tmp_tm.tm_hour,
- &tmp_tm.tm_min, &tmp_tm.tm_sec);
+ &year, &month, &tm.tm_mday, &tm.tm_hour,
+ &tm.tm_min, &tm.tm_sec);
+
+ tm.tm_year = year - 1900;
+ tm.tm_mon = month - 1;
+ tm.tm_isdst = -1;
+
+ t = mktime (&tm);
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month - 1;
- tmp_tm.tm_isdst = -1;
-
- t = mktime (&tmp_tm);
- t = t - (int) timezone;
+#if defined(HAVE_TM_GMTOFF)
+ t += tm.tm_gmtoff;
+#elif defined(HAVE_TIMEZONE)
+ t -= timezone;
+ if (tm.tm_isdst > 0) {
+ t += 3600;
+ }
+#endif
return localtime (&t);
}