dovecot-1.1: Added support for seeking forwards in the stream.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 4 08:01:57 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/c1c977afe06c
changeset: 7342:c1c977afe06c
user: Timo Sirainen <tss at iki.fi>
date: Tue Mar 04 08:01:51 2008 +0200
description:
Added support for seeking forwards in the stream.
diffstat:
1 file changed, 24 insertions(+), 5 deletions(-)
src/lib/istream-crlf.c | 29 ++++++++++++++++++++++++-----
diffs (39 lines):
diff -r af998ae4254b -r c1c977afe06c src/lib/istream-crlf.c
--- a/src/lib/istream-crlf.c Tue Mar 04 07:54:53 2008 +0200
+++ b/src/lib/istream-crlf.c Tue Mar 04 08:01:51 2008 +0200
@@ -151,11 +151,30 @@ static ssize_t i_stream_crlf_read_lf(str
return ret;
}
-static void ATTR_NORETURN
-i_stream_crlf_seek(struct istream_private *stream ATTR_UNUSED,
- uoff_t v_offset ATTR_UNUSED, bool mark ATTR_UNUSED)
-{
- i_panic("crlf-istream: seeking unsupported currently");
+static void
+i_stream_crlf_seek(struct istream_private *stream,
+ uoff_t v_offset, bool mark ATTR_UNUSED)
+{
+ size_t available;
+
+ if (stream->istream.v_offset > v_offset)
+ i_panic("crlf-istream: seeking unsupported currently");
+
+ while (stream->istream.v_offset < v_offset) {
+ (void)i_stream_crlf_read_crlf(stream);
+
+ available = stream->pos - stream->skip;
+ if (available == 0) {
+ stream->istream.stream_errno = ESPIPE;
+ return;
+ }
+ if (available <= v_offset - stream->istream.v_offset)
+ i_stream_skip(&stream->istream, available);
+ else {
+ i_stream_skip(&stream->istream,
+ v_offset - stream->istream.v_offset);
+ }
+ }
}
static const struct stat *
More information about the dovecot-cvs
mailing list