]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixes for big endian systems.
authorTimo Sirainen <tss@iki.fi>
Tue, 20 Jul 2004 17:52:38 +0000 (20:52 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 20 Jul 2004 17:52:38 +0000 (20:52 +0300)
--HG--
branch : HEAD

src/lib-index/mail-cache-decisions.c
src/lib-index/mail-cache-fields.c
src/lib-index/mail-cache-private.h

index be4fbe05f09d27250c7a6f0b72b2ae754cc07d04..53e9ea71ab50738b19f9c2256939a0de3a248df1 100644 (file)
@@ -93,7 +93,7 @@ void mail_cache_decision_lookup(struct mail_cache_view *view, uint32_t seq,
 
        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 6a94071c870bcaff5b2535ebbac3d09609455761..57482a5e29fa7758845b4ecd85320ce62fd8c979 100644 (file)
@@ -215,10 +215,8 @@ int mail_cache_header_fields_read(struct mail_cache *cache)
                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(struct mail_cache *cache, buffer_t *dest,
        }
 }
 
+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 @@ int mail_cache_header_fields_update(struct mail_cache *cache)
                          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 @@ void mail_cache_header_fields_get(struct mail_cache *cache, buffer_t *dest)
                    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 38cfc781b31d6b3206e2cfe61221c782cf9b3e10..9ea833a0f2ba4a075f303016ab22973e91626959 100644 (file)
@@ -108,7 +108,7 @@ struct mail_cache_field_private {
        struct mail_cache_field field;
 
        uint32_t uid_highwater;
-       time_t last_used;
+       uint32_t last_used;
 
        unsigned int decision_dirty:1;
 };