From: Timo Sirainen Date: Fri, 20 Mar 2009 22:23:12 +0000 (-0400) Subject: Added i_stream_is_eof(). X-Git-Tag: 2.0.alpha1~1038^2~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3c197999dfe2b0c8ea38cb77cfa5e95026005c0;p=thirdparty%2Fdovecot%2Fcore.git Added i_stream_is_eof(). --HG-- branch : HEAD --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 413cae1be3..b3ec39ca22 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -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; diff --git a/src/lib/istream.h b/src/lib/istream.h index 607ebf0169..9c99af2375 100644 --- a/src/lib/istream.h +++ b/src/lib/istream.h @@ -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