[dovecot-cvs] dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.42, 1.43 istream-raw-mbox.h, 1.10, 1.11 mbox-file.c, 1.17, 1.18
cras at dovecot.org
cras at dovecot.org
Mon Aug 7 15:42:44 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv16694/lib-storage/index/mbox
Modified Files:
istream-raw-mbox.c istream-raw-mbox.h mbox-file.c
Log Message:
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.
Index: istream-raw-mbox.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- istream-raw-mbox.c 24 Jun 2006 20:53:37 -0000 1.42
+++ istream-raw-mbox.c 7 Aug 2006 12:42:38 -0000 1.43
@@ -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;
Index: istream-raw-mbox.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- istream-raw-mbox.h 13 Jan 2006 20:26:37 -0000 1.10
+++ istream-raw-mbox.h 7 Aug 2006 12:42:38 -0000 1.11
@@ -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);
Index: mbox-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-file.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mbox-file.c 17 Apr 2006 16:23:27 -0000 1.17
+++ mbox-file.c 7 Aug 2006 12:42:38 -0000 1.18
@@ -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;
}
More information about the dovecot-cvs
mailing list