[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.68, 1.69 index-mail.c, 1.109, 1.110 index-mail.h, 1.43, 1.44

tss at dovecot.org tss at dovecot.org
Fri Oct 13 16:33:08 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv18788/lib-storage/index

Modified Files:
	index-mail-headers.c index-mail.c index-mail.h 
Log Message:
Don't use time_t anymore in cache file. uint32_t is large enough and makes
cache files compatible between 32bit and 64bit systems.



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- index-mail-headers.c	10 Sep 2006 12:48:25 -0000	1.68
+++ index-mail-headers.c	13 Oct 2006 15:33:05 -0000	1.69
@@ -268,7 +268,7 @@
 
 	if (hdr == NULL) {
 		/* end of headers */
-		if (data->sent_date.time != (time_t)-1) {
+		if (data->sent_date.time != (uint32_t)-1) {
 			index_mail_cache_add(mail, MAIL_CACHE_SENT_DATE,
 					     &data->sent_date,
 					     sizeof(data->sent_date));

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- index-mail.c	17 Sep 2006 17:49:04 -0000	1.109
+++ index-mail.c	13 Oct 2006 15:33:05 -0000	1.110
@@ -20,9 +20,9 @@
 	{ "date.sent", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
 	  sizeof(struct mail_sent_date), 0 },
 	{ "date.received", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
-	  sizeof(time_t), 0 },
+	  sizeof(uint32_t), 0 },
 	{ "date.save", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
-	  sizeof(time_t), 0 },
+	  sizeof(uint32_t), 0 },
 	{ "size.virtual", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
 	  sizeof(uoff_t), 0 },
 	{ "size.physical", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
@@ -206,10 +206,13 @@
 	struct index_mail_data *data = &mail->data;
 
 	if (data->received_date == (time_t)-1) {
+		uint32_t t;
+
 		if (!index_mail_get_fixed_field(mail, MAIL_CACHE_RECEIVED_DATE,
-						&data->received_date,
-						sizeof(data->received_date)))
+						&t, sizeof(t)))
 			return (time_t)-1;
+
+		data->received_date = t;
 	}
 
 	return data->received_date;
@@ -221,10 +224,13 @@
 	struct index_mail_data *data = &mail->data;
 
 	if (data->save_date == (time_t)-1) {
+		uint32_t t;
+
 		if (!index_mail_get_fixed_field(mail, MAIL_CACHE_SAVE_DATE,
-						&data->save_date,
-						sizeof(data->save_date)))
+						&t, sizeof(t)))
 			return (time_t)-1;
+
+		data->save_date = t;
 	}
 
 	return data->save_date;
@@ -235,9 +241,8 @@
 	struct index_mail *mail = (struct index_mail *) _mail;
 	struct index_mail_data *data = &mail->data;
 	const char *str;
-	int tz;
 
-	if (data->sent_date.time != (time_t)-1) {
+	if (data->sent_date.time != (uint32_t)-1) {
 		if (timezone != NULL)
 			*timezone = data->sent_date.timezone;
 		return data->sent_date.time;
@@ -247,16 +252,19 @@
 					 &data->sent_date,
 					 sizeof(data->sent_date));
 
-	if (data->sent_date.time == (time_t)-1) {
+	if (data->sent_date.time == (uint32_t)-1) {
+		time_t t;
+		int tz;
+
 		str = mail_get_first_header(_mail, "Date");
 		if (str == NULL ||
 		    !message_date_parse((const unsigned char *)str,
-					strlen(str),
-					&data->sent_date.time, &tz)) {
+					strlen(str), &t, &tz)) {
 			/* 0 = not found / invalid */
-			data->sent_date.time = 0;
+			t = 0;
 			tz = 0;
 		}
+		data->sent_date.time = t;
 		data->sent_date.timezone = tz;
 		index_mail_cache_add(mail, MAIL_CACHE_SENT_DATE,
 				     &data->sent_date, sizeof(data->sent_date));
@@ -870,7 +878,7 @@
 	data->physical_size = (uoff_t)-1;
 	data->save_date = (time_t)-1;
 	data->received_date = (time_t)-1;
-	data->sent_date.time = (time_t)-1;
+	data->sent_date.time = (uint32_t)-1;
 }
 
 static void check_envelope(struct index_mail *mail)

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- index-mail.h	30 Jul 2006 23:02:16 -0000	1.43
+++ index-mail.h	13 Oct 2006 15:33:05 -0000	1.44
@@ -53,7 +53,7 @@
 };
 
 struct mail_sent_date {
-	time_t time;
+	uint32_t time;
 	int32_t timezone;
 };
 



More information about the dovecot-cvs mailing list