[dovecot-cvs] dovecot/src/lib-index mail-index-open.c,1.46,1.47
mail-index.h,1.90,1.91
cras at procontrol.fi
cras at procontrol.fi
Sun Aug 24 11:06:08 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv17430/lib-index
Modified Files:
mail-index-open.c mail-index.h
Log Message:
Added back compat_data[]. It wasn't so simple to access data portably in
index files after all..
Index: mail-index-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-open.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-index-open.c 17 Aug 2003 00:00:13 -0000 1.46
+++ mail-index-open.c 24 Aug 2003 07:06:06 -0000 1.47
@@ -196,6 +196,16 @@
return TRUE;
}
+static void get_compat_data(unsigned char compat_data[4])
+{
+#ifndef WORDS_BIGENDIAN
+ compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+#endif
+ compat_data[1] = sizeof(uoff_t);
+ compat_data[2] = sizeof(time_t);
+ compat_data[3] = 0;
+}
+
void mail_index_init_header(struct mail_index_header *hdr)
{
i_assert(sizeof(struct mail_index_header) < 256);
@@ -204,6 +214,7 @@
hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
hdr->header_size = (uint8_t)sizeof(struct mail_index_header);
+ get_compat_data(hdr->compat_data);
hdr->indexid = ioloop_time;
@@ -278,6 +289,7 @@
enum mail_index_open_flags flags)
{
struct mail_index_header hdr;
+ unsigned char compat_data[4];
int ret;
if ((flags & _MAIL_INDEX_OPEN_FLAG_CREATING) == 0)
@@ -299,8 +311,10 @@
return FALSE;
index->indexid = hdr.indexid;
+ get_compat_data(compat_data);
if (ret == 0 || hdr.major_version != MAIL_INDEX_MAJOR_VERSION ||
(hdr.flags & MAIL_INDEX_HDR_FLAG_REBUILD) != 0 ||
+ memcmp(compat_data, hdr.compat_data, sizeof(compat_data)) != 0 ||
!mail_index_mmap_update(index)) {
if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
return FALSE;
Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- mail-index.h 24 Aug 2003 06:49:55 -0000 1.90
+++ mail-index.h 24 Aug 2003 07:06:06 -0000 1.91
@@ -24,6 +24,10 @@
_MAIL_INDEX_OPEN_FLAG_CREATING = 0x100
};
+enum mail_index_header_compat_flags {
+ MAIL_INDEX_COMPAT_LITTLE_ENDIAN = 0x01
+};
+
enum mail_index_header_flag {
/* Rebuild flag is set while index is being rebuilt or when
some error is noticed in the index file. If this flag is set,
@@ -103,6 +107,12 @@
uint8_t minor_version;
uint8_t header_size;
uint8_t reserved;
+
+ /* 0 = flags
+ 1 = sizeof(uoff_t)
+ 2 = sizeof(time_t)
+ 3 = reserved, 0 for now */
+ uint8_t compat_data[4];
uint32_t indexid;
More information about the dovecot-cvs
mailing list