Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4548:2eb8af6f1285 HEAD
Added MAILBOX_OPEN_MBOX_ONE_MSG_ONLY flag for mailbox_open() which makes it
ignore all but the first From-line in a mbox. This kludge is required for
deliver which builds a temporary mbox stream from the input. Later it
should be fixed to use some plain-mailbox format instead of mbox.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 07 Aug 2006 15:42:37 +0300 |
parents | 912e6d3053e8 |
children | 11e9f405d18e |
files | src/deliver/deliver.c src/lib-storage/index/index-storage.c src/lib-storage/index/index-storage.h src/lib-storage/index/mbox/istream-raw-mbox.c src/lib-storage/index/mbox/istream-raw-mbox.h src/lib-storage/index/mbox/mbox-file.c src/lib-storage/mail-storage.h |
diffstat | 7 files changed, 31 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/deliver/deliver.c Mon Aug 07 01:22:22 2006 +0300 +++ b/src/deliver/deliver.c Mon Aug 07 15:42:37 2006 +0300 @@ -510,7 +510,8 @@ MAIL_STORAGE_LOCK_FCNTL); input = create_mbox_stream(0); box = mailbox_open(mbox_storage, "Dovecot Delivery Mail", input, - MAILBOX_OPEN_NO_INDEX_FILES); + MAILBOX_OPEN_NO_INDEX_FILES | + MAILBOX_OPEN_MBOX_ONE_MSG_ONLY); if (box == NULL) i_fatal("Can't open delivery mail as mbox"); if (sync_quick(box) < 0)
--- a/src/lib-storage/index/index-storage.c Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/index/index-storage.c Mon Aug 07 15:42:37 2006 +0300 @@ -348,6 +348,7 @@ break; } + ibox->open_flags = flags; ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0; ibox->keep_recent = (flags & MAILBOX_OPEN_KEEP_RECENT) != 0; ibox->keep_locked = (flags & MAILBOX_OPEN_KEEP_LOCKED) != 0;
--- a/src/lib-storage/index/index-storage.h Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/index/index-storage.h Mon Aug 07 15:42:37 2006 +0300 @@ -38,6 +38,7 @@ struct index_mailbox { struct mailbox box; struct index_storage *storage; + enum mailbox_open_flags open_flags; struct mail_index *index; struct mail_index_view *view;
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Mon Aug 07 15:42:37 2006 +0300 @@ -16,6 +16,7 @@ struct istream *input; uoff_t input_peak_offset; + unsigned int one_mail_only:1; unsigned int corrupted:1; unsigned int eof:1; }; @@ -232,13 +233,15 @@ rest of the line buffered. FIXME: if From-line is longer than input buffer, we break. probably irrelevant.. */ - i++; - from_after_pos = i; - from_start_pos = i - 6; - if (from_start_pos > 0 && - buf[from_start_pos-1] == '\r') { - /* CR also belongs to it. */ - from_start_pos--; + if (!rstream->one_mail_only) { + i++; + from_after_pos = i; + from_start_pos = i - 6; + if (from_start_pos > 0 && + buf[from_start_pos-1] == '\r') { + /* CR also belongs to it. */ + from_start_pos--; + } } fromp = mbox_from; } else if (from_start_pos != (size_t)-1) { @@ -330,7 +333,8 @@ return &stream->statbuf; } -struct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input) +struct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input, + bool kludge_one_mail_only) { struct raw_mbox_istream *rstream; @@ -338,6 +342,7 @@ rstream = p_new(pool, struct raw_mbox_istream, 1); + rstream->one_mail_only = kludge_one_mail_only; rstream->input = input; rstream->body_offset = (uoff_t)-1; rstream->mail_size = (uoff_t)-1;
--- a/src/lib-storage/index/mbox/istream-raw-mbox.h Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.h Mon Aug 07 15:42:37 2006 +0300 @@ -3,7 +3,8 @@ /* Create a mbox stream for parsing mbox. Reading stops before From-line, you'll have to call istream_raw_mbox_next() to get to next message. */ -struct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input); +struct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input, + bool kludge_one_mail_only); /* Return offset to beginning of the "\nFrom"-line. */ uoff_t istream_raw_mbox_get_start_offset(struct istream *stream);
--- a/src/lib-storage/index/mbox/mbox-file.c Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/index/mbox/mbox-file.c Mon Aug 07 15:42:37 2006 +0300 @@ -60,16 +60,22 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox) { + bool one_mail_only; + if (mbox->mbox_stream != NULL) return 0; + one_mail_only = + (mbox->ibox.open_flags & MAILBOX_OPEN_MBOX_ONE_MSG_ONLY) != 0; + if (mbox->mbox_file_stream != NULL) { /* read-only mbox stream */ i_assert(mbox->mbox_fd == -1 && mbox->mbox_readonly); mbox->mbox_stream = i_stream_create_raw_mbox(default_pool, - mbox->mbox_file_stream); + mbox->mbox_file_stream, + one_mail_only); return 0; } @@ -93,7 +99,8 @@ } mbox->mbox_stream = - i_stream_create_raw_mbox(default_pool, mbox->mbox_file_stream); + i_stream_create_raw_mbox(default_pool, mbox->mbox_file_stream, + one_mail_only); return 0; }
--- a/src/lib-storage/mail-storage.h Mon Aug 07 01:22:22 2006 +0300 +++ b/src/lib-storage/mail-storage.h Mon Aug 07 15:42:37 2006 +0300 @@ -45,7 +45,9 @@ /* Don't create index files for the mailbox */ MAILBOX_OPEN_NO_INDEX_FILES = 0x10, /* Keep mailbox exclusively locked all the time while it's open */ - MAILBOX_OPEN_KEEP_LOCKED = 0x20 + MAILBOX_OPEN_KEEP_LOCKED = 0x20, + /* FIXME: Kludge for deliver: Ignore all but the first From-line */ + MAILBOX_OPEN_MBOX_ONE_MSG_ONLY = 0x40 }; enum mailbox_list_flags {