dovecot-2.2: istream-hash: Allow seeking, but only after reading...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 12 03:00:26 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/c8f17405ff71
changeset: 16724:c8f17405ff71
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 12 02:32:47 2013 +0300
description:
istream-hash: Allow seeking, but only after reading the hash.
diffstat:
src/lib/istream-hash.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diffs (36 lines):
diff -r 96fa57cacfc7 -r c8f17405ff71 src/lib/istream-hash.c
--- a/src/lib/istream-hash.c Thu Sep 12 01:38:54 2013 +0300
+++ b/src/lib/istream-hash.c Thu Sep 12 02:32:47 2013 +0300
@@ -38,6 +38,20 @@
return ret;
}
+static void
+i_stream_hash_seek(struct istream_private *stream,
+ uoff_t v_offset, bool mark ATTR_UNUSED)
+{
+ struct hash_istream *hstream = (struct hash_istream *)stream;
+
+ if (hstream->hash_context != NULL) {
+ /* we support seeking only after the hash is finished */
+ stream->istream.stream_errno = ESPIPE;
+ }
+ stream->istream.v_offset = v_offset;
+ stream->skip = stream->pos = 0;
+}
+
struct istream *
i_stream_create_hash(struct istream *input, const struct hash_method *method,
void *hash_context)
@@ -49,9 +63,10 @@
hstream->istream.stream_size_passthrough = TRUE;
hstream->istream.read = i_stream_hash_read;
+ hstream->istream.seek = i_stream_hash_seek;
hstream->istream.istream.blocking = input->blocking;
- hstream->istream.istream.seekable = FALSE;
+ hstream->istream.istream.seekable = input->seekable;
hstream->method = method;
hstream->hash_context = hash_context;
More information about the dovecot-cvs
mailing list