mail-index-view-sync.c revision bbf796c17f02538058d7559bfe96d677e5b55015
/* 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"
struct mail_index_view_sync_ctx {
struct mail_index_view *view;
const struct mail_transaction_header *hdr;
const void *data;
unsigned int skipped_some:1;
unsigned int last_read:1;
unsigned int sync_map_update:1;
};
static int
{
const struct mail_transaction_header *hdr;
const void *data;
int ret;
/* with mask 0 we don't get anything, we'll just read the expunges
while seeking to end */
MAIL_TRANSACTION_EXPUNGE) < 0)
return -1;
}
if (ret == 0) {
/* convert to sequences */
else
dest++;
}
} else {
}
return ret;
}
#define MAIL_INDEX_VIEW_VISIBLE_SYNC_MASK \
struct mail_index_view_sync_ctx **ctx_r)
{
const struct mail_index_header *hdr;
struct mail_index_view_sync_ctx *ctx;
struct mail_index_map *map;
/* We must sync flags as long as view is mmap()ed, as the flags may
have already changed under us. */
return -1;
if ((sync_mask & MAIL_INDEX_SYNC_TYPE_EXPUNGE) != 0) {
/* get list of all expunges first */
return -1;
}
/* only flags, appends and expunges can be left to be synced later */
return -1;
}
if ((sync_mask & MAIL_INDEX_SYNC_TYPE_EXPUNGE) != 0) {
/* keep the old mapping without expunges until we're
fully synced */
} else {
/* we need a private copy of the map if we don't want to
sync expunges. we need to sync mapping only if we're not
using the latest one. */
}
return 0;
}
{
return 0;
return 1;
}
return 0;
}
{
&skipped);
if (ret <= 0) {
if (ret < 0)
return -1;
return 1;
}
if (skipped)
/* skip flag changes that we committed ourself or have already synced */
return 0;
/* expunges have to be synced afterwards so that caller can still get
information of the messages. otherwise caller most likely wants to
see only updated information. */
if (ctx->sync_map_update &&
struct mail_index_sync_map_ctx sync_map_ctx;
&sync_map_ctx) < 0)
return -1;
}
return 0;
return 1;
}
#define FLAG_UPDATE_IS_INTERNAL(u, empty) \
((((u)->add_flags | (u)->remove_flags) & \
~(MAIL_INDEX_MAIL_FLAG_DIRTY | MAIL_RECENT)) == 0 && \
static int
struct mail_index_sync_rec *rec)
{
static keywords_mask_t empty_keywords = { 0, };
case MAIL_TRANSACTION_APPEND: {
break;
}
case MAIL_TRANSACTION_EXPUNGE: {
const struct mail_transaction_expunge *exp =
break;
}
case MAIL_TRANSACTION_FLAG_UPDATE: {
const struct mail_transaction_flag_update *update =
for (;;) {
break;
return 0;
}
break;
}
default:
i_unreached();
}
return 1;
}
struct mail_index_sync_rec *sync_rec)
{
int ret;
do {
ctx->data_offset = 0;
do {
&offset);
if (ret < 0)
return -1;
return 0;
if (!ctx->skipped_some) {
}
} while (ret == 0);
if (ctx->skipped_some) {
seq,
offset);
}
}
return 1;
}
const uint32_t *
{
return data;
}
{
/* we didn't sync everything */
}
}
}
{
}
sizeof(log_file_offset));
}