istream.h revision 03f5c621d06d6b6d77a145196c9633a7aa64dc78
#ifndef __ISTREAM_H
#define __ISTREAM_H
struct istream {
int stream_errno;
unsigned int closed:1;
struct _istream *real_stream;
};
int autoclose_fd);
/* Reference counting. References start from 1, so calling i_stream_unref()
destroys the stream if i_stream_ref() is never used. */
/* Return file descriptor for stream, or -1 if none is available. */
/* Mark the stream closed. Any reads after this will return -1. The data
already read can still be used. */
/* Change the maximum size for stream's input buffer to grow. Useful only
for buffered streams (currently only file). */
/* Change the start_offset and drop all data in buffers. Doesn't do anything
if offset is the same as existing start_offset. */
/* Stream won't be read past specified offset. Giving 0 as offset
removes the limit. */
/* Makes reads blocking until at least one byte is read. timeout_cb is
called if nothing is read in specified time. Setting timeout_msecs to 0
makes it non-blocking. This call changes non-blocking state of file
descriptor. */
void (*timeout_cb)(void *), void *context);
/* Returns number of bytes read if read was ok, -1 if EOF or error, -2 if the
input buffer is full. */
/* Skip forward a number of bytes. Never fails, the next read tells if it
was successful. */
/* Seek to specified position from beginning of file. Never fails, the next
read tells if it was successful. This works only for files. */
/* Reads 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). */
/* Returns pointer to beginning of read data, or NULL if there's no data
buffered. */
/* Like i_stream_get_data(), but returns non-const data. This only works with
buffered streams (currently only file), others return NULL. */
/* Like i_stream_get_data(), but read more when needed. Returns 1 if more
than threshold bytes are available, 0 if less, -1 if error or EOF with no
bytes available, or -2 if stream's input buffer is full. */
#endif