From d696272192e69a7c7c48fd8686886d3c00b1d40c Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 18 Apr 2014 09:29:38 +0000 Subject: made workaround for 64-bit time_t on win32. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3391 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 10 ++++++++++ libsylph/imap.c | 5 +++-- libsylph/mbox.c | 5 +++-- libsylph/pop.c | 2 +- libsylph/procheader.c | 10 ++++++---- libsylph/utils.c | 5 +++-- plugin/attachment_tool/attachment_tool.c | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e517fbcd..d0c4e404 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-04-18 + + * libsylph/utils.c + libsylph/procheader.c + libsylph/pop.c + libsylph/mbox.c + libsylph/imap.c + plugin/attachment_tool/attachment_tool.c: workaround for 64-bit + time_t on win32. + 2014-04-18 * makewin32.sh: added -mthreads gcc option. diff --git a/libsylph/imap.c b/libsylph/imap.c index 4c26e04b..9f3f2347 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -4275,14 +4275,15 @@ static gint imap_cmd_fetch(IMAPSession *session, guint32 uid, return ok; } -static void imap_get_date_time(gchar *buf, size_t len, time_t timer) +static void imap_get_date_time(gchar *buf, size_t len, stime_t timer) { static gchar monthstr[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; struct tm *lt; gchar date_time[64]; gchar tz[6]; + time_t timer_ = timer; - lt = localtime(&timer); + lt = localtime(&timer_); if (lt && lt->tm_mon >= 0 && lt->tm_mon < 12) { strftime(date_time, sizeof(date_time), "%d-___-%Y %H:%M:%S", lt); diff --git a/libsylph/mbox.c b/libsylph/mbox.c index 4a241aa1..d00b66de 100644 --- a/libsylph/mbox.c +++ b/libsylph/mbox.c @@ -499,6 +499,7 @@ gint export_msgs_to_mbox(FolderItem *src, GSList *mlist, const gchar *mbox) gchar buf[BUFFSIZE]; PrefsAccount *cur_ac; guint count = 0, length; + time_t date_t_; g_return_val_if_fail(src != NULL, -1); g_return_val_if_fail(src->folder != NULL, -1); @@ -539,8 +540,8 @@ gint export_msgs_to_mbox(FolderItem *src, GSList *mlist, const gchar *mbox) sizeof(buf)); extract_address(buf); - fprintf(mbox_fp, "From %s %s", - buf, ctime(&msginfo->date_t)); + date_t_ = msginfo->date_t; + fprintf(mbox_fp, "From %s %s", buf, ctime(&date_t_)); while (fgets(buf, sizeof(buf), msg_fp) != NULL) { if (!strncmp(buf, "From ", 5)) diff --git a/libsylph/pop.c b/libsylph/pop.c index 03c96cba..8cb7f5cb 100644 --- a/libsylph/pop.c +++ b/libsylph/pop.c @@ -273,7 +273,7 @@ gint pop3_getrange_uidl_recv(Pop3Session *session, const gchar *data, guint len) session->msg[num].uidl = g_strdup(id); - recv_time = (time_t)g_hash_table_lookup(session->uidl_table, id); + recv_time = GPOINTER_TO_INT(g_hash_table_lookup(session->uidl_table, id)); session->msg[num].recv_time = recv_time; if (!session->ac_prefs->getall && recv_time != RECV_TIME_NONE) diff --git a/libsylph/procheader.c b/libsylph/procheader.c index 6c942e70..1dcffa29 100644 --- a/libsylph/procheader.c +++ b/libsylph/procheader.c @@ -885,8 +885,9 @@ stime_t procheader_date_parse(gchar *dest, const gchar *src, gint len) GDateMonth dmonth = G_DATE_BAD_MONTH; struct tm t; gchar *p; - time_t timer; + time_t timer_; time_t tz_offset; + stime_t timer; if (procheader_scan_date_string(src, weekday, &day, month, &year, &hh, &mm, &ss, zone) < 0) { @@ -926,11 +927,11 @@ stime_t procheader_date_parse(gchar *dest, const gchar *src, gint len) t.tm_yday = 0; t.tm_isdst = -1; - timer = mktime(&t); - if (timer == -1) { + timer_ = mktime(&t); + if (timer_ == -1) { if (year >= 2038) { g_warning("mktime: date overflow: %s", src); - timer = G_MAXINT - 12 * 3600; + timer_ = G_MAXINT - 12 * 3600; } else { g_warning("mktime: can't convert date: %s", src); if (dest) @@ -939,6 +940,7 @@ stime_t procheader_date_parse(gchar *dest, const gchar *src, gint len) } } + timer = timer_; if (timer < G_MAXINT - 12 * 3600) { tz_offset = remote_tzoffset_sec(zone); if (tz_offset != -1) diff --git a/libsylph/utils.c b/libsylph/utils.c index 015406d5..3c54611c 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -4463,17 +4463,18 @@ void get_rfc822_date(gchar *buf, gint len) { struct tm *lt; time_t t; + stime_t t_; gchar day[4], mon[4]; gint dd, hh, mm, ss, yyyy; gchar off[6]; - t = time(NULL); + t_ = t = time(NULL); lt = localtime(&t); sscanf(asctime(lt), "%3s %3s %d %d:%d:%d %d\n", day, mon, &dd, &hh, &mm, &ss, &yyyy); g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s", - day, dd, mon, yyyy, hh, mm, ss, tzoffset_buf(off, &t)); + day, dd, mon, yyyy, hh, mm, ss, tzoffset_buf(off, &t_)); } /* just a wrapper to suppress the warning of gcc about %c */ diff --git a/plugin/attachment_tool/attachment_tool.c b/plugin/attachment_tool/attachment_tool.c index b7a324e4..de299a21 100644 --- a/plugin/attachment_tool/attachment_tool.c +++ b/plugin/attachment_tool/attachment_tool.c @@ -228,7 +228,7 @@ static gboolean remove_attachment(MsgInfo *msginfo) if (!err) { debug_print("overwriting original message file: %s\n", infile); if (copy_file(outfile, infile, FALSE) == 0) { - struct stat s; + GStatBuf s; if (g_stat(infile, &s) == 0) { msginfo->size = s.st_size; msginfo->mtime = s.st_mtime; -- cgit v1.2.3