mail-index-sync-ext.c revision 86a36f74bbcd06f8ba6d0cbbacb350247c62c13f
/* Copyright (C) 2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "mail-index-view-private.h"
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
#include <stdlib.h>
{
const mail_index_expunge_handler_t *const *handlers;
const struct mail_index_ext *extensions;
struct mail_index_expunge_handler eh;
return;
handlers_count /= sizeof(*handlers);
if (handlers_count == 0)
return;
/* set expunge handlers */
else {
}
id_map_size /= sizeof(*id_map);
continue;
}
}
void
{
const struct mail_index_expunge_handler *eh;
return;
for (i = 0; i < size; i++) {
}
}
{
return;
/* set space for extra contexts */
sizeof(struct mail_index_ext));
} else {
}
ctx->extra_context =
}
{
const struct mail_index_sync_handler *sync_handlers;
const struct mail_index_ext *ext;
return;
&synch_size);
synch_size /= sizeof(*sync_handlers);
/* sync_handlers[] is ordered by index->extensions while
extra_context is ordered by map->extensions. */
for (i = 0; i < size; i++) {
&ctx->extra_context[i]);
}
}
}
static struct mail_index_ext_header *
{
struct mail_index_ext_header *ext_hdr;
void *hdr_base;
/* do some kludgy jumping to get to it. */
MAIL_INDEX_HEADER_SIZE_ALIGN(sizeof(*ext_hdr) +
return ext_hdr;
}
{
}
static struct mail_index_map *
{
struct mail_index_map *new_map;
struct mail_index_ext_header *ext_hdr;
const void *src;
t_push();
/* @UNSAFE */
for (i = 0; i < size; i++) {
ext[i].record_offset = 0;
}
/* we simply try to use the extensions with largest alignment
requirement first. FIXME: if the extension sizes don't match
alignmentation, this may not give the minimal layout. */
offset = sizeof(struct mail_index_record);
for (;;) {
for (i = 0; i < size; i++) {
if (sorted[i]->record_offset == 0) {
break;
}
}
if (i == size) {
/* all done */
break;
}
/* we have to leave space here */
} else {
}
}
/* keep 32bit alignment */
}
/* create a new mapping without records. a bit kludgy. */
map->records_count = 0;
/* we are shrinking the record */
}
/* now copy the records to new mapping */
offset = 0;
sizeof(struct mail_index_record));
for (i = 0; i < size; i++) {
ext[i].record_size);
}
}
/* we didn't fully write the last record */
}
/* update record offsets in headers */
for (i = 0; i < size; i++) {
}
t_pop();
return new_map;
}
static void
struct mail_index_sync_map_ctx *ctx)
{
struct mail_index_ext *ext;
struct mail_index_ext_header *ext_hdr;
/* header shrinked */
/* header grown */
}
if (old_record_size != u->record_size)
if (modified) {
}
/* move all hdr_offset of all extensions after this one */
ext[i].hdr_offset +=
}
}
if (old_record_size != u->record_size) {
}
}
const struct mail_transaction_ext_intro *u)
{
struct mail_index_ext_header ext_hdr;
const struct mail_index_ext *ext;
const char *name;
"Extension introduction for unknown id %u", u->ext_id);
return -1;
}
"Extension introduction without id or name");
return -1;
}
t_push();
} else {
}
/* exists already */
/* check if we need to resize anything */
} else {
/* extension was reset and this transaction hadn't
yet seen it. ignore this update. */
}
t_pop();
return 1;
}
/* we need to add padding between base header and extensions */
}
/* register record offset initially using zero,
sync_ext_reorder() will fix it. */
hdr_offset, u->hdr_size, 0,
u->record_size, u->record_align,
u->reset_id);
/* <ext_hdr> <name> [padding] [header data] */
/* header must begin and end in correct alignment */
t_pop();
return 1;
}
const struct mail_transaction_ext_reset *u)
{
struct mail_index_ext_header *ext_hdr;
struct mail_index_ext *ext;
struct mail_index_record *rec;
uint32_t i;
"Extension reset without intro prefix");
return -1;
}
if (ctx->cur_ext_ignore)
return 1;
ext->record_size);
}
return 1;
}
int
const struct mail_transaction_ext_hdr_update *u)
{
const struct mail_index_ext *ext;
"Extension header update without intro prefix");
return -1;
}
if (ctx->cur_ext_ignore)
return 1;
u + 1, u->size);
return 1;
}
int
const struct mail_transaction_ext_rec_update *u)
{
struct mail_index_record *rec;
const struct mail_index_sync_handler *sync_handlers;
const struct mail_index_ext *ext;
void *old_data;
int ret;
return -1;
if (seq == 0)
return 1;
/* call sync handlers only when we're syncing index (not view) */
if (ret <= 0)
return ret;
}
/* @UNSAFE */
return 1;
}