From: Timo Sirainen Date: Fri, 1 Oct 2010 17:33:19 +0000 (+0100) Subject: Added i_stream_get_absolute_offset(). X-Git-Tag: 2.0.5~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=923115fd382904fa13bb09bf307bf2835b52df60;p=thirdparty%2Fdovecot%2Fcore.git Added i_stream_get_absolute_offset(). --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 21865b062e..3a227eb689 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -292,6 +292,11 @@ bool i_stream_is_eof(struct istream *stream) return !i_stream_have_bytes_left(stream); } +uoff_t i_stream_get_absolute_offset(struct istream *stream) +{ + return stream->real_stream->abs_start_offset + stream->v_offset; +} + static char *i_stream_next_line_finish(struct istream_private *stream, size_t i) { char *ret; diff --git a/src/lib/istream.h b/src/lib/istream.h index dd66b47165..319036ae00 100644 --- a/src/lib/istream.h +++ b/src/lib/istream.h @@ -107,6 +107,9 @@ int i_stream_get_size(struct istream *stream, bool exact, uoff_t *size_r); bool i_stream_have_bytes_left(const struct istream *stream) ATTR_PURE; /* Returns TRUE if there are no bytes buffered and read() returns EOF. */ bool i_stream_is_eof(struct istream *stream); +/* Returns the absolute offset of the stream. This is the stream's current + v_offset + the parent's absolute offset when the stream was created. */ +uoff_t i_stream_get_absolute_offset(struct istream *stream); /* Gets the next line from stream and returns it, or NULL if more data is needed to make a full line. i_stream_set_return_partial_line() specifies