mail-cache-compress.c revision df4018ae2f0a95be602f724ca70df7e0e3bd6a7d
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "ostream.h"
#include "file-cache.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) {
}
/* @UNSAFE: 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;
/* 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 uint32_t
{
const struct mail_index_ext *ext;
}
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. */
first_new_seq = 1;
} else {
&message_count) < 0)
return -1;
if (first_new_seq == 0)
}
ctx.field_seen_value = 0;
if (++ctx.field_seen_value == 0) {
}
continue;
&old_offset);
}
if (cache->fields_count != 0) {
/* we wrote everything using our internal field ids. so we want
mail_cache_header_fields_get() to use them and ignore any
existing id mappings in the old cache file. */
cache->file_fields_count = 0;
for (i = 0; i < cache->fields_count; i++)
t_push();
t_pop();
}
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;
}
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;
}