changeset 12225:0c82fe7ce578

Added i_stream_get_absolute_offset().
author Timo Sirainen <tss@iki.fi>
date Fri, 01 Oct 2010 18:33:19 +0100
parents e7768ec9d3de
children 766564bb051f
files src/lib/istream.c src/lib/istream.h
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/istream.c	Fri Oct 01 17:46:03 2010 +0100
+++ b/src/lib/istream.c	Fri Oct 01 18:33:19 2010 +0100
@@ -292,6 +292,11 @@
 	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;
--- a/src/lib/istream.h	Fri Oct 01 17:46:03 2010 +0100
+++ b/src/lib/istream.h	Fri Oct 01 18:33:19 2010 +0100
@@ -107,6 +107,9 @@
 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