mail-transaction-log-view.c revision a0c8af555ec481ab12c2a99518cf7b20debd1627
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen/* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenmail_transaction_log_view_open(struct mail_transaction_log *log)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen view = i_new(struct mail_transaction_log_view, 1);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen array_append(&view->file_refs, &view->head, 1);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenmail_transaction_log_view_unref_all(struct mail_transaction_log_view *view)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mail_transaction_log_file *const *files;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen unsigned int i, count;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen for (i = 0; i < count; i++)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenvoid mail_transaction_log_view_close(struct mail_transaction_log_view **_view)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mail_transaction_log_view *view = *_view;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen for (p = &view->log->views; *p != NULL; p = &(*p)->next) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenstatic const char *
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenmail_transaction_log_get_file_seqs(struct mail_transaction_log *log)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen for (file = log->files; file != NULL; file = file->next)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenint mail_transaction_log_view_set(struct mail_transaction_log_view *view,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen uint32_t min_file_seq, uoff_t min_file_offset,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen uint32_t max_file_seq, uoff_t max_file_offset,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mail_transaction_log_file *file, *const *files;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen unsigned int i;
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen /* transaction log is closed already. this log view shouldn't
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen be used anymore. */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* index file doesn't exist yet. this transaction log should
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen start from the beginning */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen if (view->log->files->hdr.prev_file_seq != 0) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* but it doesn't */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen "Wanted log beginning, but found prev_file_seq=%u",
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen min_file_seq = view->log->files->hdr.file_seq;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen for (file = view->log->files; file != NULL; file = file->next) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen if (file != NULL && min_file_offset == file->hdr.prev_file_offset) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* we can (and sometimes must) skip to the next file */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen for (file = view->log->files; file != NULL; file = file->next) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen if (file != NULL && max_file_offset == file->hdr.prev_file_offset) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* we can skip to the next file. we've delayed checking for
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen min_file_seq <= max_file_seq until now, because it's not
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen really an error to specify the same position twice (even if
if (ret <= 0) {
if (ret < 0) {
if (min_file_offset == 0) {
if (ret <= 0) {
return ret;
int ret;
if (ret < 0) {
if (ret == 0) {
const char *reason;
if (oldest_file_seq != 0 &&
return TRUE;
return last;
const char *fmt, ...)
T_BEGIN {
} T_END;
return FALSE;
} else if (count == 0) {
return FALSE;
return FALSE;
return FALSE;
return TRUE;
const void *data)
return FALSE;
return FALSE;
if (rec_size == 0) {
return FALSE;
switch (rec_type) {
case MAIL_TRANSACTION_APPEND:
return FALSE;
case MAIL_TRANSACTION_EXPUNGE:
sizeof(struct mail_transaction_expunge));
case MAIL_TRANSACTION_EXPUNGE_GUID: {
unsigned int i, count;
return FALSE;
for (i = 0; i < count; i++) {
return FALSE;
sizeof(struct mail_transaction_flag_update));
case MAIL_TRANSACTION_KEYWORD_UPDATE: {
unsigned int seqset_offset;
return FALSE;
return FALSE;
sizeof(struct mail_transaction_keyword_reset));
case MAIL_TRANSACTION_EXT_INTRO: {
for (i = 0; i < rec_size; ) {
return FALSE;
attr_changes[i]);
return FALSE;
attr_changes[i]);
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
const void **data_r)
const void *data;
int ret;
T_BEGIN {
} T_END;
if (ret > 0) {
return ret;
const void **data_r)
const void *data;
int ret = 0;
if (ret <= 0) {
if (ret < 0)
return ret;