[dovecot-cvs] dovecot/src/lib-mail istream-header-filter.c, 1.33,
1.33.2.1
cras at dovecot.org
cras at dovecot.org
Thu Jun 8 22:26:24 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv18386/lib-mail
Modified Files:
Tag: branch_1_0
istream-header-filter.c
Log Message:
Handle i_stream_stat() better.
Index: istream-header-filter.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/istream-header-filter.c,v
retrieving revision 1.33
retrieving revision 1.33.2.1
diff -u -d -r1.33 -r1.33.2.1
--- istream-header-filter.c 14 Jan 2006 18:47:35 -0000 1.33
+++ istream-header-filter.c 8 Jun 2006 19:26:22 -0000 1.33.2.1
@@ -235,21 +235,26 @@
return ret;
}
-static void _seek(struct _istream *stream, uoff_t v_offset,
- bool mark __attr_unused__)
+static void parse_header(struct header_filter_istream *mstream)
{
- struct header_filter_istream *mstream =
- (struct header_filter_istream *)stream;
size_t pos;
while (!mstream->header_read) {
- if (_read(stream) == -1)
+ if (_read(&mstream->istream) == -1)
break;
- (void)i_stream_get_data(&stream->istream, &pos);
- i_stream_skip(&stream->istream, pos);
+ (void)i_stream_get_data(&mstream->istream.istream, &pos);
+ i_stream_skip(&mstream->istream.istream, pos);
}
+}
+
+static void _seek(struct _istream *stream, uoff_t v_offset,
+ bool mark __attr_unused__)
+{
+ struct header_filter_istream *mstream =
+ (struct header_filter_istream *)stream;
+ parse_header(mstream);
stream->istream.v_offset = v_offset;
stream->skip = stream->pos = 0;
stream->buffer = NULL;
@@ -280,9 +285,22 @@
}
static const struct stat *
-_stat(struct _istream *stream, bool exact __attr_unused__)
+_stat(struct _istream *stream, bool exact)
{
- /* return size and others as unknown */
+ struct header_filter_istream *mstream =
+ (struct header_filter_istream *)stream;
+ const struct stat *st;
+
+ st = i_stream_stat(mstream->input, exact);
+ if (st == NULL || st->st_size == -1 || !exact)
+ return st;
+
+ parse_header(mstream);
+
+ stream->statbuf = *st;
+ stream->statbuf.st_size -=
+ (off_t)mstream->header_size.physical_size -
+ (off_t)mstream->header_size.virtual_size;
return &stream->statbuf;
}
More information about the dovecot-cvs
mailing list