Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2788:f322b24da429 HEAD
Added i_stream_have_bytes_left().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Oct 2004 20:03:23 +0300 |
parents | ce98a0248ea1 |
children | c6f128e5520b |
files | src/lib/istream.c src/lib/istream.h |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/istream.c Wed Oct 20 17:02:12 2004 +0300 +++ b/src/lib/istream.c Wed Oct 20 20:03:23 2004 +0300 @@ -90,6 +90,13 @@ return _stream->get_size(_stream); } +int i_stream_have_bytes_left(struct istream *stream) +{ + struct _istream *_stream = stream->real_stream; + + return !stream->eof || _stream->skip != _stream->pos; +} + char *i_stream_next_line(struct istream *stream) { struct _istream *_stream = stream->real_stream;
--- a/src/lib/istream.h Wed Oct 20 17:02:12 2004 +0300 +++ b/src/lib/istream.h Wed Oct 20 20:03:23 2004 +0300 @@ -7,7 +7,8 @@ int stream_errno; unsigned int mmaped:1; /* be careful when copying data */ unsigned int closed:1; - unsigned int eof:1; + unsigned int eof:1; /* read() has reached to end of file + (but may still be data available in buffer) */ struct _istream *real_stream; }; @@ -49,6 +50,9 @@ void i_stream_seek(struct istream *stream, uoff_t v_offset); /* Returns size of the stream, or (uoff_t)-1 if unknown */ uoff_t i_stream_get_size(struct istream *stream); +/* Returns TRUE if there are any bytes left to be read or in buffer. */ +int i_stream_have_bytes_left(struct istream *stream); + /* Gets the next line from stream and returns it, or NULL if more data is needed to make a full line. NOTE: modifies the data in buffer for the \0, so it works only with buffered streams (currently only file). */ @@ -56,6 +60,7 @@ /* Like i_stream_next_line(), but reads for more data if needed. Returns NULL if more data is needed or error occured. */ char *i_stream_read_next_line(struct istream *stream); + /* Returns pointer to beginning of read data, or NULL if there's no data buffered. */ const unsigned char *i_stream_get_data(struct istream *stream, size_t *size);