mail-index-transaction-export.c revision 0c909e3461607eadcd66f4eac69b7f34e37fccf1
8a5e793a0576250da80371e53aa3e7eba15cdb63Sumit Bose/* Copyright (c) 2003-2009 Dovecot authors, see the included COPYING file */
8a5e793a0576250da80371e53aa3e7eba15cdb63Sumit Bose struct mail_transaction_log_append_ctx *append_ctx;
8a5e793a0576250da80371e53aa3e7eba15cdb63Sumit Boselog_append_buffer(struct mail_index_export_context *ctx,
8a5e793a0576250da80371e53aa3e7eba15cdb63Sumit Bose const buffer_t *buf, enum mail_transaction_type type)
8a5e793a0576250da80371e53aa3e7eba15cdb63Sumit Bose mail_transaction_log_append_add(ctx->append_ctx, type,
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bosestatic const buffer_t *
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Boselog_get_hdr_update_buffer(struct mail_index_transaction *t, bool prepend)
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose memset(&u, 0, sizeof(u));
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose data = prepend ? t->pre_hdr_change : t->post_hdr_change;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose mask = prepend ? t->pre_hdr_mask : t->post_hdr_mask;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose buf = buffer_create_dynamic(pool_datastack_create(), 256);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose for (offset = 0; offset <= sizeof(t->pre_hdr_change); offset++) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose if (offset < sizeof(t->pre_hdr_change) && mask[offset]) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bosestatic void log_append_ext_intro(struct mail_index_export_context *ctx,
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose struct mail_transaction_ext_intro *intro, *resizes;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose unsigned int count;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose !mail_index_map_get_ext_idx(t->view->index->map, ext_id, &idx)) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* new extension */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose rext = array_idx(&t->view->index->extensions, ext_id);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose resizes = array_get_modifiable(&t->ext_resizes, &count);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose buf = buffer_create_dynamic(pool_datastack_create(), 128);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose if (ext_id < count && resizes[ext_id].name_size != 0) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* we're resizing the extension. use the resize struct. */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* generate a new intro structure */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose intro = buffer_append_space_unsafe(buf, sizeof(*intro));
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose intro->flags = MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_SHRINK;
2ca45dfa0144fea08bd360dafded57bc90111e68Sumit Bose /* we're going to reset this extension in this transaction */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* use the existing reset_id */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose array_idx(&t->view->index->map->extensions, idx);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* new extension, reset_id defaults to 0 */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose buffer_append(buf, rext->name, intro->name_size);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose strcmp(rext->name, MAIL_INDEX_MODSEQ_EXT_NAME) == 0) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose /* modseq tracking started */
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose log_append_buffer(ctx, buf, MAIL_TRANSACTION_EXT_INTRO);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Boselog_append_ext_hdr_update(struct mail_index_export_context *ctx,
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose const struct mail_index_transaction_ext_hdr_update *hdr)
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose memset(&u, 0, sizeof(u));
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose buf = buffer_create_dynamic(pool_datastack_create(), 256);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose for (offset = 0; offset <= hdr->alloc_size; offset++) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose if (offset < hdr->alloc_size && mask[offset] != 0) {
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose log_append_buffer(ctx, buf, MAIL_TRANSACTION_EXT_HDR_UPDATE);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bosemail_transaction_log_append_ext_intros(struct mail_index_export_context *ctx)
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose const struct mail_index_transaction_ext_hdr_update *hdrs;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose unsigned int hdrs_count, reset_id_count, reset_count;
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose resize = array_get(&t->ext_resizes, &resize_count);
6b5044001e4b0a0caf971a2cf5f27674e0d270f4Sumit Bose reset_ids = array_get(&t->ext_reset_ids, &reset_id_count);
hdrs_count = 0;
reset_id = 0;
T_BEGIN {
} T_END;
reset_id_count = 0;
static enum mail_index_sync_type
const char *const *keywords;
for (i = 0; i < count; i++) {
return change_mask;
if (t->pre_hdr_changed) {
if (t->post_hdr_changed) {