mail-cache-compress.c revision e015e2f7e7f48874495f9df8b0dd192b7ffcb5cc
/* 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_decision_type dec;
unsigned int field;
/* duplicate */
return 1;
}
if (dec == MAIL_CACHE_DECISION_NO)
return 1;
} else {
if (dec != MAIL_CACHE_DECISION_YES)
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;
/* 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)
}
if (cache->fields_count != 0) {
mail_cache_uint32_to_offset(sizeof(hdr));
}
if (cache->fields_count != 0) {
t_push();
t_pop();
}
ctx.field_seen_value = 0;
if (++ctx.field_seen_value == 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;
/* get the latest info on fields */
if (mail_cache_header_fields_read(cache) < 0) {
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;
else if (mail_cache_header_fields_read(cache) < 0)
ret = -1;
}
}
if (locked)
if (ret == 0)
return ret;
}
{
return cache->need_compress;
}