mail-index-transaction-private.h revision f153a2cec0319f549388d28f8cfd4d50229d1132
2ronwalf#ifndef MAIL_INDEX_TRANSACTION_PRIVATE_H
2ronwalf#define MAIL_INDEX_TRANSACTION_PRIVATE_H
2ronwalf
2ronwalf#include "seq-range-array.h"
2ronwalf#include "mail-transaction-log.h"
2ronwalf
2ronwalfARRAY_DEFINE_TYPE(seq_array_array, ARRAY_TYPE(seq_array));
2ronwalf
2ronwalfstruct mail_index_transaction_keyword_update {
2ronwalf ARRAY_TYPE(seq_range) add_seq;
2ronwalf ARRAY_TYPE(seq_range) remove_seq;
2ronwalf};
2ronwalf
2ronwalfstruct mail_index_transaction_ext_hdr_update {
2ronwalf size_t alloc_size;
2ronwalf /* mask is in bytes, not bits */
2ronwalf unsigned char *mask;
2ronwalf unsigned char *data;
2ronwalf};
2ronwalf
2ronwalfstruct mail_index_transaction_vfuncs {
2ronwalf int (*commit)(struct mail_index_transaction *t,
2ronwalf uint32_t *log_file_seq_r, uoff_t *log_file_offset_r);
2ronwalf void (*rollback)(struct mail_index_transaction *t);
2ronwalf};
2ronwalf
2ronwalfunion mail_index_transaction_module_context {
2ronwalf struct mail_index_module_register *reg;
2ronwalf};
2ronwalf
2ronwalfstruct mail_index_transaction {
2ronwalf int refcount;
2ronwalf
2ronwalf enum mail_index_transaction_flags flags;
2ronwalf struct mail_index_transaction_vfuncs v;
2ronwalf struct mail_index_view *view;
2ronwalf
2ronwalf /* NOTE: If you add anything new, remember to update
2ronwalf mail_index_transaction_reset() to reset it. */
2ronwalf ARRAY_DEFINE(appends, struct mail_index_record);
2ronwalf uint32_t first_new_seq, last_new_seq;
2ronwalf uint32_t highest_append_uid;
2ronwalf /* lowest/highest sequence that updates flags/keywords */
2ronwalf uint32_t min_flagupdate_seq, max_flagupdate_seq;
2ronwalf
2ronwalf ARRAY_TYPE(seq_range) expunges;
2ronwalf ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
2ronwalf size_t last_update_idx;
2ronwalf
2ronwalf unsigned char pre_hdr_change[sizeof(struct mail_index_header)];
2ronwalf unsigned char pre_hdr_mask[sizeof(struct mail_index_header)];
2ronwalf unsigned char post_hdr_change[sizeof(struct mail_index_header)];
2ronwalf unsigned char post_hdr_mask[sizeof(struct mail_index_header)];
2ronwalf
2ronwalf ARRAY_DEFINE(ext_hdr_updates,
2ronwalf struct mail_index_transaction_ext_hdr_update);
2ronwalf ARRAY_TYPE(seq_array_array) ext_rec_updates;
2ronwalf ARRAY_TYPE(seq_array_array) ext_rec_atomics;
2ronwalf ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
2ronwalf ARRAY_DEFINE(ext_resets, struct mail_transaction_ext_reset);
2ronwalf ARRAY_DEFINE(ext_reset_ids, uint32_t);
2ronwalf ARRAY_DEFINE(ext_reset_atomic, uint32_t);
2ronwalf
2ronwalf ARRAY_DEFINE(keyword_updates,
2ronwalf struct mail_index_transaction_keyword_update);
2ronwalf ARRAY_TYPE(seq_range) keyword_resets;
2ronwalf
2ronwalf uint64_t max_modseq;
2ronwalf ARRAY_TYPE(seq_range) *conflict_seqs;
2ronwalf
2ronwalf struct mail_cache_transaction_ctx *cache_trans_ctx;
2ronwalf
2ronwalf /* Module-specific contexts. */
2ronwalf ARRAY_DEFINE(module_contexts,
2ronwalf union mail_index_transaction_module_context *);
2ronwalf
2ronwalf unsigned int no_appends:1;
2ronwalf
2ronwalf unsigned int sync_transaction:1;
2ronwalf unsigned int appends_nonsorted:1;
2ronwalf unsigned int pre_hdr_changed:1;
2ronwalf unsigned int post_hdr_changed:1;
2ronwalf unsigned int reset:1;
2ronwalf /* non-extension updates. flag updates don't change this because
2ronwalf they may be added and removed, so be sure to check that the updates
2ronwalf array is non-empty also. */
2ronwalf unsigned int log_updates:1;
2ronwalf /* extension updates */
2ronwalf unsigned int log_ext_updates:1;
2ronwalf};
2ronwalf
2ronwalfextern void (*hook_mail_index_transaction_created)
2ronwalf (struct mail_index_transaction *t);
2ronwalf
2ronwalfstruct mail_index_record *
2ronwalfmail_index_transaction_lookup(struct mail_index_transaction *t, uint32_t seq);
2ronwalf
2ronwalfvoid mail_index_transaction_ref(struct mail_index_transaction *t);
2ronwalfvoid mail_index_transaction_unref(struct mail_index_transaction **t);
2ronwalf
2ronwalfvoid mail_index_transaction_sort_appends(struct mail_index_transaction *t);
2ronwalfuint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t);
2ronwalfvoid mail_index_transaction_convert_to_uids(struct mail_index_transaction *t);
2ronwalfvoid mail_index_transaction_check_conflicts(struct mail_index_transaction *t);
2ronwalf
2ronwalfunsigned int
2ronwalfmail_index_transaction_get_flag_update_pos(struct mail_index_transaction *t,
2ronwalf unsigned int left_idx,
2ronwalf unsigned int right_idx,
2ronwalf uint32_t seq);
2ronwalf
2ronwalfbool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array,
2ronwalf uint32_t seq, unsigned int *idx_r);
2ronwalf
2ronwalf#endif
2ronwalf