]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Added i_stream_create_sized_range()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 1 Nov 2016 12:47:05 +0000 (14:47 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 23 Feb 2017 10:42:59 +0000 (12:42 +0200)
This is just a small wrapper to i_stream_create_sized() to specify stream's
start offset.

src/lib/istream-sized.c
src/lib/istream-sized.h

index a60925b564a86776e5d9aa816f0e6dfd725adf3b..877a405d8a3592a17e77d73eafe1672afc8a331f 100644 (file)
@@ -176,6 +176,18 @@ struct istream *i_stream_create_sized(struct istream *input, uoff_t size)
        return &sstream->istream.istream;
 }
 
+struct istream *i_stream_create_sized_range(struct istream *input,
+                                           uoff_t offset, uoff_t size)
+{
+       uoff_t orig_offset = input->v_offset;
+       struct istream *ret;
+
+       input->v_offset = offset;
+       ret = i_stream_create_sized(input, size);
+       input->v_offset = orig_offset;
+       return ret;
+}
+
 #undef i_stream_create_sized_with_callback
 struct istream *
 i_stream_create_sized_with_callback(struct istream *input, uoff_t size,
index 61a78eb5d10eec50d45bc4efd201c81a02df10ab..946353197e227def33798830369b30f90e158838 100644 (file)
@@ -19,6 +19,8 @@ istream_sized_callback_t(const struct istream_sized_error_data *data,
 /* Assume that input is exactly the given size. If it's smaller, log an error
    and fail with EINVAL error. If it's larger, log an error but don't fail. */
 struct istream *i_stream_create_sized(struct istream *input, uoff_t size);
+struct istream *i_stream_create_sized_range(struct istream *input,
+                                           uoff_t offset, uoff_t size);
 /* Same as i_stream_create_sized(), but set the error message via the
    callback. */
 struct istream *