mail-index-transaction-export.c revision 01e29d9d23a1844b4582592a473a3b3eac56b36b
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2003-2015 Dovecot authors, see the included COPYING file */
ccffb125d94adff0ad776de5a96e22f864d6fb0aTimo Sirainen struct mail_transaction_log_append_ctx *append_ctx;
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainenlog_append_buffer(struct mail_index_export_context *ctx,
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen const buffer_t *buf, enum mail_transaction_type type)
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen mail_transaction_log_append_add(ctx->append_ctx, type,
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainenstatic void log_append_flag_updates(struct mail_index_export_context *ctx,
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen ARRAY(struct mail_transaction_flag_update) log_updates;
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen struct mail_transaction_flag_update *log_update;
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen unsigned int i, count;
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen for (i = 0; i < count; i++) {
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen log_update = array_append_space(&log_updates);
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen log_update->add_flags = updates[i].add_flags & 0xff;
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen log_update->remove_flags = updates[i].remove_flags & 0xff;
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen if ((updates[i].add_flags & MAIL_INDEX_MAIL_FLAG_UPDATE_MODSEQ) != 0)
dc9de21d4375faeedbe5b7e941502ac578650da9Timo Sirainen log_append_buffer(ctx, log_updates.arr.buffer,
0371406d952fe51367c7be91703e5634b7d9d225Timo Sirainenlog_get_hdr_update_buffer(struct mail_index_transaction *t, bool prepend)
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen memset(&u, 0, sizeof(u));
ccffb125d94adff0ad776de5a96e22f864d6fb0aTimo Sirainen data = prepend ? t->pre_hdr_change : t->post_hdr_change;
ccffb125d94adff0ad776de5a96e22f864d6fb0aTimo Sirainen mask = prepend ? t->pre_hdr_mask : t->post_hdr_mask;
a0b89f3b1df99b3a32f44623f13ad1893118825bTimo Sirainen buf = buffer_create_dynamic(pool_datastack_create(), 256);
a0b89f3b1df99b3a32f44623f13ad1893118825bTimo Sirainen for (offset = 0; offset <= sizeof(t->pre_hdr_change); offset++) {
a0b89f3b1df99b3a32f44623f13ad1893118825bTimo Sirainen if (offset < sizeof(t->pre_hdr_change) && mask[offset]) {
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainenstatic unsigned int
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainenext_hdr_update_get_size(const struct mail_index_transaction_ext_hdr_update *hu)
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen unsigned int i;
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainenstatic void log_append_ext_intro(struct mail_index_export_context *ctx,
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen unsigned int *hdr_size_r)
3656c91dcb8336814bebd4500e81c3dde25233e6Timo Sirainen struct mail_index_transaction *t = ctx->trans;
3656c91dcb8336814bebd4500e81c3dde25233e6Timo Sirainen struct mail_transaction_ext_intro *intro, *resizes;
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen unsigned int count;
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen !mail_index_map_get_ext_idx(t->view->index->map, ext_id, &idx)) {
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen /* new extension */
1ac19c5c2b66a12f5598792aad15114ee3eb62e2Timo Sirainen rext = array_idx(&t->view->index->extensions, ext_id);
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen resizes = array_get_modifiable(&t->ext_resizes, &count);
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen buf = buffer_create_dynamic(pool_datastack_create(), 128);
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen if (ext_id < count && resizes[ext_id].name_size != 0) {
6c2c5f20760b06bfb4a40b0ee2ef5ab016bc41f0Timo Sirainen /* we're resizing the extension. use the resize struct. */
dc9de21d4375faeedbe5b7e941502ac578650da9Timo Sirainen /* generate a new intro structure */
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen intro = buffer_append_space_unsafe(buf, sizeof(*intro));
bfdf0fd7b6186f64cbdcbf1cb2bf9c42a9007b77Timo Sirainen ext = array_idx(&t->view->index->map->extensions, idx);
unsigned int hdr_update_size;
if (reset_id != 0) {
unsigned int ext_hdr_size)
struct mail_transaction_ext_hdr_update u;
memset(&u, 0, sizeof(u));
if (!started) {
if (started) {
if (use_32)
resize_count = 0;
reset_id_count = 0;
reset_count = 0;
hdrs_count = 0;
reset_id = 0;
hdr_size = 0;
T_BEGIN {
hdr_size);
} T_END;
reset_id_count = 0;
static enum mail_index_fsync_mask
const char *const *keywords;
for (i = 0; i < count; i++) {
return change_mask;
if (t->index_undeleted) {
if (t->pre_hdr_changed) {
if (t->post_hdr_changed) {
if (t->index_deleted) {