mail-transaction-log.h revision 6d3bb841d4ec2c12ac2d4ecf6146ef8d8a7dd731
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen#define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24
bf87a5247ca33660ab8f20c12556ad16d7159395Timo Sirainen uint64_t initial_modseq; /* v1.1+ (note: log's major/minor version) */
bf87a5247ca33660ab8f20c12556ad16d7159395Timo Sirainen uint8_t compat_flags; /* enum mail_index_header_compat_flags, v1.2+ */
bf87a5247ca33660ab8f20c12556ad16d7159395Timo Sirainen uint32_t unused2; /* so that this struct is 64bit aligned */
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen MAIL_TRANSACTION_EXT_HDR_UPDATE32 = 0x00010000,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen MAIL_TRANSACTION_INDEX_UNDELETED = 0x00040000,
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen (MAIL_TRANSACTION_EXT_INTRO | MAIL_TRANSACTION_EXT_RESET | \
9b7eeffb5752b500ac62ba1fd01c4a8c4ada14e9Timo Sirainen MAIL_TRANSACTION_EXT_HDR_UPDATE | MAIL_TRANSACTION_EXT_HDR_UPDATE32 | \
9b7eeffb5752b500ac62ba1fd01c4a8c4ada14e9Timo Sirainen MAIL_TRANSACTION_EXT_REC_UPDATE | MAIL_TRANSACTION_EXT_ATOMIC_INC)
43834f87bf431198f986e86052a4f6e558fdb07dTimo Sirainen /* since we'll expunge mails based on data read from transaction log,
43834f87bf431198f986e86052a4f6e558fdb07dTimo Sirainen try to avoid the possibility of corrupted transaction log expunging
93fa87cf1a96c4f279ec4f5c311820313ba12c34Timo Sirainen messages. this value is ORed to the actual MAIL_TRANSACTION_EXPUNGE*
93fa87cf1a96c4f279ec4f5c311820313ba12c34Timo Sirainen flag. if it's not present, assume corrupted log. */
43834f87bf431198f986e86052a4f6e558fdb07dTimo Sirainen /* Mailbox synchronization noticed this change. */
f4735bf7ec2019fdc730e9ebdb39e5a4ea580405Timo Sirainen uint32_t type; /* enum mail_transaction_type */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* don't use uint64_t here. it adds extra 32 bits of paddiong and also
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen causes problems with CPUs that require alignment */
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen uint8_t modify_type; /* enum modify_type : MODIFY_ADD / MODIFY_REMOVE */
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen /* unsigned char name[];
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen array of { uint32_t uid1, uid2; }
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen /* unsigned char data[]; */
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen /* Don't shrink hdr_size, record_size or record_align but grow them
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen if necessary. */
59151b71059df1190acd75d8717ed04a7920c862Timo Sirainen MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_SHRINK = 0x01
556f95092c3bc850517d5ab2bb502024a55645f1Timo Sirainen /* old extension: set ext_id. don't set name.
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen new extension: ext_id = (uint32_t)-1. give name. */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* unsigned char name[]; */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* these are set for the last ext_intro */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* unsigned char data[]; */
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainen/* this _update32 version should have been the only ext_hdr_update,
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen but since 16bit integers were originally used for now we'll just use this
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen only when actually needed to be backwards compatible. */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* unsigned char data[]; */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* unsigned char data[]; */
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen#define LOG_IS_BEFORE(seq1, offset1, seq2, offset2) \
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen (((offset1) < (offset2) && (seq1) == (seq2)) || (seq1) < (seq2))
b90fb7f78aca271243c26074ddd6587cce112a1eTimo Sirainenmail_transaction_log_alloc(struct mail_index *index);
b90fb7f78aca271243c26074ddd6587cce112a1eTimo Sirainenvoid mail_transaction_log_free(struct mail_transaction_log **log);
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen/* Open the transaction log. Returns 1 if ok, 0 if file doesn't exist or it's
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen is corrupted, -1 if there was some I/O error. */
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainenint mail_transaction_log_open(struct mail_transaction_log *log);
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen/* Create, or recreate, the transaction log. Returns 0 if ok, -1 if error. */
71da447014454c84828d9dface77219875554d7dTimo Sirainenint mail_transaction_log_create(struct mail_transaction_log *log, bool reset);
71da447014454c84828d9dface77219875554d7dTimo Sirainen/* Close all the open transactions log files. */
71da447014454c84828d9dface77219875554d7dTimo Sirainenvoid mail_transaction_log_close(struct mail_transaction_log *log);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* Notify of indexid change */
struct mail_transaction_log_view *
bool *reset_r);
const void **data_r);
const char *fmt, ...)