dovecot: Added support for seeking forwards in the stream. Also ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Feb 28 06:26:13 EET 2008
details: http://hg.dovecot.org/dovecot/rev/e063797bdcd5
changeset: 7295:e063797bdcd5
user: Timo Sirainen <tss at iki.fi>
date: Thu Feb 28 06:28:51 2008 +0200
description:
Added support for seeking forwards in the stream. Also mark the stream as
non-seekable since seeking backwards doesn't work.
diffstat:
1 file changed, 25 insertions(+), 6 deletions(-)
src/lib/istream-crlf.c | 31 +++++++++++++++++++++++++------
diffs (48 lines):
diff -r 446899ed6a65 -r e063797bdcd5 src/lib/istream-crlf.c
--- a/src/lib/istream-crlf.c Wed Feb 27 21:54:00 2008 +0200
+++ b/src/lib/istream-crlf.c Thu Feb 28 06:28: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 *
@@ -184,7 +203,7 @@ i_stream_create_crlf_full(struct istream
cstream->istream.stat = i_stream_crlf_stat;
cstream->istream.istream.blocking = input->blocking;
- cstream->istream.istream.seekable = input->seekable;
+ cstream->istream.istream.seekable = FALSE;
return i_stream_create(&cstream->istream, input,
i_stream_get_fd(input));
}
More information about the dovecot-cvs
mailing list