[dovecot-cvs] dovecot/src/lib-index mail-cache-decisions.c, 1.6, 1.7 mail-cache-fields.c, 1.2, 1.3 mail-cache-private.h, 1.12, 1.13

cras at dovecot.org cras at dovecot.org
Tue Jul 20 20:52:40 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv24832/lib-index

Modified Files:
	mail-cache-decisions.c mail-cache-fields.c 
	mail-cache-private.h 
Log Message:
Fixes for big endian systems.



Index: mail-cache-decisions.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-decisions.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mail-cache-decisions.c	20 Jul 2004 16:50:56 -0000	1.6
+++ mail-cache-decisions.c	20 Jul 2004 17:52:38 -0000	1.7
@@ -93,7 +93,7 @@
 
 	if (ioloop_time - cache->fields[field].last_used > 3600*24) {
 		/* update last_used about once a day */
-		cache->fields[field].last_used = ioloop_time;
+		cache->fields[field].last_used = (uint32_t)ioloop_time;
 		cache->field_header_write_pending = TRUE;
 	}
 

Index: mail-cache-fields.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-fields.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mail-cache-fields.c	20 Jul 2004 16:50:56 -0000	1.2
+++ mail-cache-fields.c	20 Jul 2004 17:52:38 -0000	1.3
@@ -215,10 +215,8 @@
 		cache->file_field_map[i] = field.idx;
 
 		/* update last_used if it's newer than ours */
-		if ((time_t)last_used[i] > cache->fields[field.idx].last_used) {
-			cache->fields[field.idx].last_used =
-				(time_t)last_used[i];
-		}
+		if (last_used[i] > cache->fields[field.idx].last_used)
+			cache->fields[field.idx].last_used = last_used[i];
 
                 names = p + 1;
 	}
@@ -244,6 +242,28 @@
 	}
 }
 
+static void copy_to_buf_byte(struct mail_cache *cache, buffer_t *dest,
+			     size_t offset)
+{
+	const int *data;
+	unsigned int i, field;
+	uint8_t byte;
+
+	for (i = 0; i < cache->file_fields_count; i++) {
+		field = cache->file_field_map[i];
+                data = CONST_PTR_OFFSET(&cache->fields[field], offset);
+		byte = (uint8_t)*data;
+		buffer_append(dest, &byte, 1);
+	}
+	for (i = 0; i < cache->fields_count; i++) {
+		if (cache->field_file_map[i] != (uint32_t)-1)
+			continue;
+		data = CONST_PTR_OFFSET(&cache->fields[i], offset);
+		byte = (uint8_t)*data;
+		buffer_append(dest, &byte, 1);
+	}
+}
+
 int mail_cache_header_fields_update(struct mail_cache *cache)
 {
 	int locked = cache->locked;
@@ -274,9 +294,8 @@
 			  offset + MAIL_CACHE_FIELD_LAST_USED());
 	if (ret == 0) {
 		buffer_set_used_size(buffer, 0);
-		copy_to_buf(cache, buffer,
-			    offsetof(struct mail_cache_field, decision),
-			    sizeof(uint8_t));
+		copy_to_buf_byte(cache, buffer,
+				 offsetof(struct mail_cache_field, decision));
 
 		ret = pwrite_full(cache->fd, buffer_get_data(buffer, NULL),
 			sizeof(uint8_t) * cache->file_fields_count, offset +
@@ -314,10 +333,9 @@
 		    sizeof(uint32_t));
 	copy_to_buf(cache, dest, offsetof(struct mail_cache_field, field_size),
 		    sizeof(uint32_t));
-	copy_to_buf(cache, dest, offsetof(struct mail_cache_field, type),
-		    sizeof(uint8_t));
-	copy_to_buf(cache, dest, offsetof(struct mail_cache_field, decision),
-		    sizeof(uint8_t));
+	copy_to_buf_byte(cache, dest, offsetof(struct mail_cache_field, type));
+	copy_to_buf_byte(cache, dest,
+			 offsetof(struct mail_cache_field, decision));
 
 	i_assert(buffer_get_used_size(dest) == sizeof(hdr) +
 		 (sizeof(uint32_t)*2 + 2) * hdr.fields_count);

Index: mail-cache-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mail-cache-private.h	20 Jul 2004 17:06:25 -0000	1.12
+++ mail-cache-private.h	20 Jul 2004 17:52:38 -0000	1.13
@@ -108,7 +108,7 @@
 	struct mail_cache_field field;
 
 	uint32_t uid_highwater;
-	time_t last_used;
+	uint32_t last_used;
 
 	unsigned int decision_dirty:1;
 };



More information about the dovecot-cvs mailing list