mail-cache-compress.c revision a13dd0ece98f62f61c64bff9c9c29ed3f3d82d54
/* 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"
struct mail_cache_copy_context {
int new_msg;
};
{
void *buf_data;
unsigned int i, buf_data_size;
if (buf_data_size == (unsigned int)-1) {
}
if (buf_file_field == file_field) {
/* found it, do the merging */
for (i = 0; i < buf_data_size; i++)
break;
}
}
}
static int
{
struct mail_cache_field *cache_field;
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) {
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;
}