mail-cache-compress.c revision aff7542e1d2f48b030560a4f01096a2cc3f671ce
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "ostream.h"
#include "file-set-size.h"
#include "mail-cache-private.h"
static unsigned char null4[4] = { 0, 0, 0, 0 };
struct mail_cache_copy_context {
int new_msg;
};
static int
enum mail_cache_field field,
{
int i;
return 1;
} else {
return 1;
}
/* drop duplicates */
return 1;
}
for (i = 0; i < MAIL_CACHE_HEADERS_COUNT; i++) {
if (mail_cache_header_fields[i] == field) {
/* it's header - save it into header field */
if (size32 > 0) {
/* remove old terminating \0 */
}
return 1;
}
}
}
if ((data_size & 3) != 0)
return 1;
}
static int
{
struct mail_cache_copy_context ctx;
struct mail_cache_view *cache_view;
struct mail_index_transaction *t;
const struct mail_index_header *idx_hdr;
struct mail_cache_header hdr;
struct mail_cache_record cache_rec;
enum mail_cache_field field;
const char *str;
int i, ret, header_idx;
/* get sequence of first message which doesn't need it's temp fields
removed. */
return -1;
first_new_seq = 1;
} else {
&message_count) < 0)
return -1;
if (first_new_seq == 0)
}
sizeof(hdr.field_usage_decision_type));
sizeof(hdr.field_usage_last_used));
} else {
sizeof(hdr.field_usage_decision_type));
}
for (i = 0; i < 32; i++) {
else if (hdr.field_usage_decision_type[i] &
}
}
/* merge all the header pieces into one. if some message doesn't have
all the required pieces, we'll just have to drop them all. */
for (i = MAIL_CACHE_HEADERS_COUNT-1; i >= 0; i--) {
break;
}
header_idx = -1;
else {
hdr.header_offsets[0] =
header_idx = i;
if ((size32 & 3) != 0)
}
ret = 0;
size32);
if ((size32 & 3) != 0) {
}
}
continue;
}
o_stream_seek(output, 0);
if (o_stream_flush(output) < 0) {
(void)mail_index_transaction_rollback(t);
return -1;
}
/* grow the file some more. doesn't matter if it fails */
}
(void)mail_index_transaction_rollback(t);
return -1;
}
}
{
return -1;
#ifdef DEBUG
#endif
if (fd == -1) {
return -1;
}
// FIXME: check that cache file wasn't just recreated
ret = 0;
ret = -1;
} else {
-1, FALSE) < 0) {
"file_dotlock_replace()");
ret = -1;
} else {
if (mail_cache_map(cache, 0, 0) < 0)
ret = -1;
}
}
/* headers could have changed, reread them */
if (locked)
if (ret == 0)
return ret;
}
{
return cache->need_compress;
}