mail-transaction-log.h revision 838f56174b963779a88083a0d0e85b30d2d846e7
#ifndef MAIL_TRANSACTION_LOG_H
#define MAIL_TRANSACTION_LOG_H
struct mail_index;
struct mail_index_transaction;
#define MAIL_TRANSACTION_LOG_MAJOR_VERSION 1
#define MAIL_TRANSACTION_LOG_MINOR_VERSION 1
#define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24
struct mail_transaction_log_header {
};
enum mail_transaction_type {
MAIL_TRANSACTION_EXPUNGE = 0x00000001,
MAIL_TRANSACTION_APPEND = 0x00000002,
MAIL_TRANSACTION_FLAG_UPDATE = 0x00000004,
MAIL_TRANSACTION_HEADER_UPDATE = 0x00000020,
MAIL_TRANSACTION_EXT_INTRO = 0x00000040,
MAIL_TRANSACTION_EXT_RESET = 0x00000080,
MAIL_TRANSACTION_EXT_HDR_UPDATE = 0x00000100,
MAIL_TRANSACTION_EXT_REC_UPDATE = 0x00000200,
MAIL_TRANSACTION_KEYWORD_UPDATE = 0x00000400,
MAIL_TRANSACTION_KEYWORD_RESET = 0x00000800,
MAIL_TRANSACTION_TYPE_MASK = 0x0000ffff,
#define MAIL_TRANSACTION_EXT_MASK \
/* since we'll expunge mails based on data read from transaction log,
try to avoid the possibility of corrupted transaction log expunging
messages. this value is ORed to the actual MAIL_TRANSACTION_EXPUNGE
flag. if it's not present, assume corrupted log. */
MAIL_TRANSACTION_EXPUNGE_PROT = 0x0000cd90,
/* Mailbox synchronization noticed this change. */
MAIL_TRANSACTION_EXTERNAL = 0x10000000
};
struct mail_transaction_header {
};
struct mail_transaction_expunge {
};
struct mail_transaction_flag_update {
};
struct mail_transaction_keyword_update {
/* unsigned char name[];
array of { uint32_t uid1, uid2; }
*/
};
struct mail_transaction_keyword_reset {
};
struct mail_transaction_header_update {
/* unsigned char data[]; */
};
enum {
/* Ignore hdr_size, record_size and record_align */
};
struct mail_transaction_ext_intro {
/* old extension: set ext_id. don't set name.
new extension: ext_id = (uint32_t)-1. give name. */
/* unsigned char name[]; */
};
struct mail_transaction_ext_reset {
};
/* these are set for the last ext_intro */
struct mail_transaction_ext_hdr_update {
/* unsigned char data[]; */
};
struct mail_transaction_ext_rec_update {
/* unsigned char data[]; */
};
struct mail_transaction_log *
/* Open the transaction log. Returns 1 if ok, 0 if file doesn't exist or it's
is corrupted, -1 if there was some I/O error. */
/* Create, or recreate, the transaction log. Returns 0 if ok, -1 if error. */
/* Close all the open transactions log files. */
/* Notify of indexid change */
Since the log is rotated only when mailbox is fully synced, the sequence
points always to the latest file. This function doesn't actually find the
latest sync position, so you'll need to use eg. log_view_set() before
calling this. */
/* Set the current mailbox sync position. file_seq must always be the latest
log file's sequence. The offset written automatically to the log when
other transactions are being written. */
struct mail_transaction_log_view *
/* Set view boundaries. Returns -1 if error, 0 if files are lost, 1 if ok.
reset_r=TRUE if the whole index should be reset before applying any
changes. */
bool *reset_r);
/* Clear the view. Keep oldest_file_seq log referenced so we don't get
desynced. */
/* Read next transaction record from current position. The position is updated.
Returns -1 if error, 0 if we're at end of the view, 1 if ok. */
const struct mail_transaction_header **hdr_r,
const void **data_r);
/* Mark the current view's position to the record returned previously with
_log_view_next(). */
/* Seek to previously marked position. */
/* Returns the position of the record returned previously with
mail_transaction_log_view_next() */
void
/* Return the modseq of the change returned previously with _view_next(). */
/* Returns TRUE if we're at the end of the view window. */
/* Marks the log file in current position to be corrupted. */
void
const char *fmt, ...)
bool
/* Write data to transaction log. This is atomic operation. Sequences in
updates[] and expunges[] are relative to given view, they're modified
to real ones. If nothing is written, log_file_seq_r and log_file_offset_r
will be set to 0. */
int mail_transaction_log_append(struct mail_index_transaction *t,
/* Lock transaction log for index synchronization. Log cannot be read or
written to while it's locked. Returns end offset. */
/* Returns the current head. Works only when log is locked. */
/* Move currently opened log head file to memory (called by
mail_index_move_to_memory()) */
#endif