]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added i_stream_is_eof().
authorTimo Sirainen <tss@iki.fi>
Fri, 20 Mar 2009 22:23:12 +0000 (18:23 -0400)
committerTimo Sirainen <tss@iki.fi>
Fri, 20 Mar 2009 22:23:12 +0000 (18:23 -0400)
--HG--
branch : HEAD

src/lib/istream.c
src/lib/istream.h

index 413cae1be3987636c897014199d50b694603e157..b3ec39ca2262d82b68acf759c53cd2d501868ead 100644 (file)
@@ -208,6 +208,15 @@ bool i_stream_have_bytes_left(const struct istream *stream)
        return !stream->eof || _stream->skip != _stream->pos;
 }
 
+bool i_stream_is_eof(struct istream *stream)
+{
+       const struct istream_private *_stream = stream->real_stream;
+
+       if (_stream->skip == _stream->pos)
+               (void)i_stream_read(stream);
+       return !i_stream_have_bytes_left(stream);
+}
+
 static char *i_stream_next_line_finish(struct istream_private *stream, size_t i)
 {
        char *ret;
index 607ebf01691eac5c2cc0ebf5565d40827aa1a51e..9c99af23750e5b67c6f3a9f0e604894181847f28 100644 (file)
@@ -87,6 +87,8 @@ const struct stat *i_stream_stat(struct istream *stream, bool exact);
 int i_stream_get_size(struct istream *stream, bool exact, uoff_t *size_r);
 /* Returns TRUE if there are any bytes left to be read or in buffer. */
 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);
 
 /* 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