mail-index-sync.c revision 757726d9acbd04cf0d0d4be8ce14e11525476a0b
/* 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 "mail-cache.h"
#include <stdlib.h>
static void
const struct mail_transaction_flag_update *src,
{
const struct mail_transaction_flag_update *src_end;
struct mail_transaction_flag_update *dest;
size_t i, dest_count;
int j;
dest_count /= sizeof(*dest);
if (dest_count == 0) {
return;
}
new_update = *src;
/* insert it into buffer, split and merge it with existing
updates if needed. */
for (; i < dest_count; i++) {
continue;
break;
/* at least partially overlapping */
/* { 5..6 } + { 1..5 } -> { 1..4 } + { 5..6 } */
&tmp_update, sizeof(tmp_update));
NULL);
dest_count++; i++;
/* { 5..7 } + { 6..6 } ->
split old to { 5..5 } + { 6..7 } */
tmp_update = dest[i];
&tmp_update, sizeof(tmp_update));
NULL);
dest_count++; i++;
}
/* { 5..7 } + { 5..6 } -> { 5..6 } + { 7..7 } */
tmp_update = dest[i];
(i+1) * sizeof(tmp_update),
&tmp_update, sizeof(tmp_update));
NULL);
dest_count++;
new_update.uid2 = 0;
} else {
/* full match, or continues. */
}
/* dest[i] now contains the overlapping area.
merge them - new_update overrides old changes. */
for (j = 0; j < INDEX_KEYWORDS_BYTE_COUNT; j++) {
dest[i].add_keywords[j] |=
dest[i].add_keywords[j] &=
dest[i].remove_keywords[j] |=
dest[i].remove_keywords[j] &=
~new_update.add_keywords[j];
}
}
&new_update, sizeof(new_update));
dest_count++;
}
}
}
{
case MAIL_TRANSACTION_EXPUNGE:
break;
break;
case MAIL_TRANSACTION_APPEND: {
if (ctx->append_uid_first == 0 ||
break;
}
}
}
{
struct mail_transaction_flag_update update;
const struct mail_index_record *rec;
int i;
return -1;
continue;
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
}
return 0;
}
{
struct mail_transaction_flag_update update;
const struct mail_index_record *rec;
return -1;
continue;
}
return 0;
}
static int
{
int ret;
ctx->sync_dirty) {
/* show dirty flags as flag updates */
if (mail_index_sync_add_dirty_updates(ctx) < 0)
return -1;
}
if (sync_recent) {
if (mail_index_sync_add_recent_updates(ctx) < 0)
return -1;
}
}
return ret;
}
{
return 1;
/* already synced */
}
return 1;
}
struct mail_index_sync_ctx **ctx_r,
struct mail_index_view **view_r,
int sync_recent, int sync_dirty)
{
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;
}
void
const struct mail_transaction_expunge *exp)
{
}
void
const struct mail_transaction_flag_update *update)
{
sizeof(rec->add_keywords));
sizeof(rec->remove_keywords));
}
struct mail_index_sync_rec *rec)
{
"Broken UID range: %u..%u (type 0x%x)",
return FALSE;
}
break;
break;
}
return TRUE;
}
struct mail_index_sync_rec *sync_rec)
{
const struct mail_transaction_expunge *next_exp;
const struct mail_transaction_flag_update *next_update;
if (next_update != NULL &&
/* it's overlapping with next expunge */
}
/* overlapping with previous expunge */
/* hide this update completely */
ctx->update_idx++;
}
}
ctx->update_idx++;
}
return -1;
ctx->expunge_idx++;
return 1;
}
if (ctx->sync_appends) {
return 1;
}
return 0;
}
{
}
{
}
{
const struct mail_index_header *hdr;
int ret = 0;
ret = -1;
if (ret == 0) {
ret = -1;
else if (mail_index_sync_update_index(ctx) < 0)
ret = -1;
}
ret = -1;
else {
/* cache_offsets have changed, sync them */
ret = -1;
else if (mail_index_sync_update_index(ctx) < 0)
ret = -1;
}
}
return ret;
}
{
}
{
int i;
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
sync_rec->add_keywords[i];
}
}