aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2014-04-18 06:26:43 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2014-04-18 06:26:43 +0000
commit26b2f9567dc0bd7b70e6cc66eee800a1e0d89b73 (patch)
tree3eb93151b98eabb35e7c52b7ea6e6a79648227bd /libsylph
parentd6433225cb188bace23a80686df3be09edaa6036 (diff)
wrapped time_t as stime_t. stime_t will be 32-bit on win32 for backward compatibility.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3386 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/folder.c6
-rw-r--r--libsylph/folder.h7
-rw-r--r--libsylph/pop.h5
-rw-r--r--libsylph/procheader.c7
-rw-r--r--libsylph/procheader.h4
-rw-r--r--libsylph/procmsg.h5
-rw-r--r--libsylph/session.h3
-rw-r--r--libsylph/utils.c18
-rw-r--r--libsylph/utils.h16
9 files changed, 45 insertions, 26 deletions
diff --git a/libsylph/folder.c b/libsylph/folder.c
index 0299fc5e..f188dba5 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -1634,7 +1634,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
#endif
path = attr->value;
} else if (!strcmp(attr->name, "mtime"))
- mtime = strtoull(attr->value, NULL, 10);
+ mtime = strtoll(attr->value, NULL, 10);
else if (!strcmp(attr->name, "new"))
new = atoi(attr->value);
else if (!strcmp(attr->name, "unread"))
@@ -1945,8 +1945,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
}
fprintf(fp,
- " mtime=\"%llu\" new=\"%d\" unread=\"%d\" total=\"%d\"",
- (guint64)item->mtime, item->new, item->unread, item->total);
+ " mtime=\"%lld\" new=\"%d\" unread=\"%d\" total=\"%d\"",
+ (gint64)item->mtime, item->new, item->unread, item->total);
if (item->account)
fprintf(fp, " account_id=\"%d\"",
diff --git a/libsylph/folder.h b/libsylph/folder.h
index 5a9e9669..ef9eda28 100644
--- a/libsylph/folder.h
+++ b/libsylph/folder.h
@@ -20,6 +20,10 @@
#ifndef __FOLDER_H__
#define __FOLDER_H__
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <glib.h>
#include <time.h>
@@ -127,6 +131,7 @@ typedef void (*FolderDestroyNotify) (Folder *folder,
#include "prefs_account.h"
#include "session.h"
#include "procmsg.h"
+#include "utils.h"
struct _Folder
{
@@ -272,7 +277,7 @@ struct _FolderItem
gchar *name; /* UTF-8 */
gchar *path; /* UTF-8 */
- time_t mtime;
+ stime_t mtime;
gint new;
gint unread;
diff --git a/libsylph/pop.h b/libsylph/pop.h
index c3e67e89..050caf52 100644
--- a/libsylph/pop.h
+++ b/libsylph/pop.h
@@ -29,6 +29,7 @@
#include "session.h"
#include "prefs_account.h"
+#include "utils.h"
typedef struct _Pop3MsgInfo Pop3MsgInfo;
typedef struct _Pop3Session Pop3Session;
@@ -99,7 +100,7 @@ struct _Pop3MsgInfo
{
gint size;
gchar *uidl;
- time_t recv_time;
+ stime_t recv_time;
guint received : 1;
guint deleted : 1;
};
@@ -132,7 +133,7 @@ struct _Pop3Session
gboolean new_msg_exist;
gboolean uidl_is_valid;
- time_t current_time;
+ stime_t current_time;
Pop3ErrorValue error_val;
gchar *error_msg;
diff --git a/libsylph/procheader.c b/libsylph/procheader.c
index 93ef99e7..96cca15c 100644
--- a/libsylph/procheader.c
+++ b/libsylph/procheader.c
@@ -873,7 +873,7 @@ static gint procheader_scan_date_string(const gchar *str,
return -1;
}
-time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
+stime_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
{
static gchar monthstr[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
gchar weekday[11];
@@ -951,14 +951,15 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
return timer;
}
-void procheader_date_get_localtime(gchar *dest, gint len, const time_t timer)
+void procheader_date_get_localtime(gchar *dest, gint len, const stime_t timer)
{
+ time_t timer_ = timer;
struct tm *lt;
gchar *default_format = "%y/%m/%d(%a) %H:%M";
gchar *buf;
gchar tmp[BUFFSIZE];
- lt = localtime(&timer);
+ lt = localtime(&timer_);
if (!lt) {
g_warning("can't get localtime of %ld\n", timer);
dest[0] = '\0';
diff --git a/libsylph/procheader.h b/libsylph/procheader.h
index 0260b45e..fa8095a6 100644
--- a/libsylph/procheader.h
+++ b/libsylph/procheader.h
@@ -91,11 +91,11 @@ MsgInfo *procheader_parse_stream (FILE *fp,
gchar *procheader_get_fromname (const gchar *str);
gchar *procheader_get_toname (const gchar *str);
-time_t procheader_date_parse (gchar *dest,
+stime_t procheader_date_parse (gchar *dest,
const gchar *src,
gint len);
void procheader_date_get_localtime (gchar *dest,
gint len,
- const time_t timer);
+ const stime_t timer);
#endif /* __PROCHEADER_H__ */
diff --git a/libsylph/procmsg.h b/libsylph/procmsg.h
index a309bc8d..77f0d8ad 100644
--- a/libsylph/procmsg.h
+++ b/libsylph/procmsg.h
@@ -37,6 +37,7 @@ typedef struct _MsgEncryptInfo MsgEncryptInfo;
#include "folder.h"
#include "procmime.h"
+#include "utils.h"
typedef enum
{
@@ -172,8 +173,8 @@ struct _MsgInfo
{
guint msgnum;
gsize size;
- time_t mtime;
- time_t date_t;
+ stime_t mtime;
+ stime_t date_t;
MsgFlags flags;
diff --git a/libsylph/session.h b/libsylph/session.h
index 5fb25851..41c10e24 100644
--- a/libsylph/session.h
+++ b/libsylph/session.h
@@ -31,6 +31,7 @@
#include "socket.h"
#include "socks.h"
+#include "utils.h"
#define SESSION_BUFFSIZE 8192
@@ -116,7 +117,7 @@ struct _Session
SessionState state;
- time_t last_access_time;
+ stime_t last_access_time;
GTimeVal tv_prev;
gint conn_id;
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 1e54ebc5..2b4f9f3c 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -4315,7 +4315,7 @@ gint play_sound(const gchar *file, gboolean async)
return 0;
}
-time_t remote_tzoffset_sec(const gchar *zone)
+stime_t remote_tzoffset_sec(const gchar *zone)
{
static gchar ustzstr[] = "PSTPDTMSTMDTCSTCDTESTEDT";
gchar zone3[4];
@@ -4383,15 +4383,16 @@ time_t remote_tzoffset_sec(const gchar *zone)
return remoteoffset;
}
-time_t tzoffset_sec(time_t *now)
+stime_t tzoffset_sec(stime_t *now)
{
+ time_t now_ = *now;
struct tm gmt, *tmp, *lt;
gint off;
- tmp = gmtime(now);
+ tmp = gmtime(&now_);
g_return_val_if_fail(tmp != NULL, -1);
gmt = *tmp;
- lt = localtime(now);
+ lt = localtime(&now_);
g_return_val_if_fail(lt != NULL, -1);
off = (lt->tm_hour - gmt.tm_hour) * 60 + lt->tm_min - gmt.tm_min;
@@ -4414,16 +4415,17 @@ time_t tzoffset_sec(time_t *now)
}
/* calculate timezone offset (buf must not be less than 6 bytes) */
-gchar *tzoffset_buf(gchar *buf, time_t *now)
+gchar *tzoffset_buf(gchar *buf, stime_t *now)
{
+ time_t now_ = *now;
struct tm gmt, *tmp, *lt;
gint off;
gchar sign = '+';
- tmp = gmtime(now);
+ tmp = gmtime(&now_);
g_return_val_if_fail(tmp != NULL, NULL);
gmt = *tmp;
- lt = localtime(now);
+ lt = localtime(&now_);
g_return_val_if_fail(lt != NULL, NULL);
off = (lt->tm_hour - gmt.tm_hour) * 60 + lt->tm_min - gmt.tm_min;
@@ -4450,7 +4452,7 @@ gchar *tzoffset_buf(gchar *buf, time_t *now)
return buf;
}
-gchar *tzoffset(time_t *now)
+gchar *tzoffset(stime_t *now)
{
static gchar offset_string[6];
diff --git a/libsylph/utils.h b/libsylph/utils.h
index 79ece425..f93f4ce8 100644
--- a/libsylph/utils.h
+++ b/libsylph/utils.h
@@ -95,6 +95,14 @@ gint syl_link (const gchar *src,
#define HAVE_U32_TYPEDEF
#endif
+#if defined(G_OS_WIN32) && !defined(_WIN64) && defined(HAVE_64BIT_TIME_T)
+ /* for backward binary compatibility. Use only in struct definition and
+ pointer arguments. */
+ typedef gint32 stime_t;
+#else
+ typedef time_t stime_t;
+#endif
+
#ifndef BIG_ENDIAN_HOST
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
#define BIG_ENDIAN_HOST 1
@@ -514,11 +522,11 @@ gint play_sound (const gchar *file,
gboolean async);
/* time functions */
-time_t remote_tzoffset_sec (const gchar *zone);
-time_t tzoffset_sec (time_t *now);
+stime_t remote_tzoffset_sec (const gchar *zone);
+stime_t tzoffset_sec (stime_t *now);
gchar *tzoffset_buf (gchar *buf,
- time_t *now);
-gchar *tzoffset (time_t *now);
+ stime_t *now);
+gchar *tzoffset (stime_t *now);
void get_rfc822_date (gchar *buf,
gint len);