mail-index-sync.c revision 7888a9d2008eab9985096c46e1da9ee985c22a2a
/* Copyright (C) 2003-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 "mail-transaction-util.h"
#include <stdlib.h>
{
const struct mail_transaction_flag_update *dest;
size_t i, dest_count;
dest_count /= sizeof(*dest);
new_update = *src;
/* find seq1 */
new_update.seq1 +=
/* find seq2 */
new_update.seq2 +=
/* insert it into buffer, split it in multiple parts if needed
to make sure the ordering stays the same */
for (; i < dest_count; i++) {
continue;
break;
/* partial */
&new_update, sizeof(new_update));
dest_count++;
}
&new_update, sizeof(new_update));
dest_count++;
}
}
{
case MAIL_TRANSACTION_EXPUNGE:
} else {
}
break;
} else {
}
break;
case MAIL_TRANSACTION_APPEND:
break;
}
}
int external)
{
enum mail_transaction_type flag;
int ret;
}
return ret;
}
{
/* already synced */
return 0;
}
return 1;
}
struct mail_index_sync_ctx **ctx_r,
struct mail_index_view **view_r,
{
struct mail_index_sync_ctx *ctx;
unsigned int lock_id;
return -1;
return -1;
}
return -1;
}
return 0;
}
MAIL_TRANSACTION_TYPE_MASK) < 0) {
return -1;
}
/* we need to have all the transactions sorted to optimize
caller's mailbox access patterns */
return -1;
}
return 1;
}
static void
const struct mail_transaction_expunge *exp)
{
}
static void
const struct mail_transaction_flag_update *update)
{
sizeof(rec->add_custom_flags));
sizeof(rec->remove_custom_flags));
}
struct mail_index_sync_rec *rec)
{
"Broken sequence: %u..%u",
return FALSE;
}
"Sequence out of range: %u > %u",
return FALSE;
}
break;
break;
}
return TRUE;
}
struct mail_index_sync_rec *rec,
const struct mail_transaction_header *hdr,
{
case MAIL_TRANSACTION_APPEND: {
sizeof(struct mail_index_record) - 1;
break;
}
case MAIL_TRANSACTION_EXPUNGE: {
const struct mail_transaction_expunge *exp =
*data_offset += sizeof(*exp);
break;
}
case MAIL_TRANSACTION_FLAG_UPDATE: {
const struct mail_transaction_flag_update *update =
*data_offset += sizeof(*update);
break;
}
default:
i_unreached();
}
}
struct mail_index_sync_rec *sync_rec)
{
const struct mail_transaction_expunge *next_exp;
const struct mail_transaction_flag_update *next_update;
/* the ugliness here is to avoid returning overlapping expunge
and update areas. For example:
updates[] = A { 1, 7 }, B { 1, 3 }
expunges[] = { 5, 6 }
will make us return
update A: 1, 4
update B: 1, 3
expunge : 5, 6
update A: 7, 7
*/
while (next_update != NULL &&
/* it's overlapping.. */
}
ctx->update_idx++;
}
break;
next_update++;
}
/* a few sanity checks here, we really don't ever want to
accidentally expunge a message. If sequence and UID matches,
it's quite unlikely this expunge was caused by some bug. */
"larger than message count %u",
return -1;
}
return -1;
return -1;
"UIDs %u..%u doesn't match real UIDs %u..%u",
return -1;
}
ctx->expunge_idx++;
/* scan updates again from the beginning */
ctx->update_idx = 0;
}
if (ctx->sync_appends) {
sizeof(struct mail_index_record);
return 1;
}
return 0;
}
{
}
{
const struct mail_index_header *hdr;
int ret = 0;
ret = -1;
if (ret == 0) {
ret = -1;
}
if (ret == 0) {
if (mail_index_sync_update_index(ctx) < 0)
ret = -1;
}
return ret;
}
{
int i;
for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
custom_flags[i] =
sync_rec->add_custom_flags[i];
}
}