ibuffer.h revision b646fdb90f75ab80ea7feca42fa2e1f8e788b004
#ifndef __IBUFFER_H
#define __IBUFFER_H
#include "ioloop.h" /* TimeoutFunc */
struct _IBuffer {
int buf_errno;
unsigned int closed:1;
void *real_buffer;
};
int autoclose_fd);
int autoclose_fd);
/* Reference counting. References start from 1, so calling i_buffer_unref()
destroys the buffer if i_buffer_ref() is never used. */
/* Return file descriptor for buffer, or -1 if none is available. */
/* Mark the buffer closed. Any reads after this will return -1. The data
already in buffer can still be used. */
/* Change the maximum size for buffer to grow. */
/* Change the start_offset and drop all data in buffers. Doesn't do anything
if offset is the same as existing start_offset. */
/* Input buffer won't be read past specified offset. Giving 0 as offset
removes the limit. The offset is */
/* Makes reads blocking until at least one byte is read. timeout_func is
called if nothing is read in specified time. The blocking state in file
descriptor isn't changed, but for timeout to work it must be in
non-blocking state. Setting timeout_msecs to 0 makes it non-blocking. */
/* Returns number of bytes read if read was ok, -1 if EOF or error, -2 if the
buffer is full. */
/* Skip forward a number of bytes. Returns 1 if all bytes were actually
skipped, or -1 if EOF or error. */
/* Seek to specified position from beginning of file. This works only for
files. Returns 1 if successful, -1 if error. */
/* Returns the next line from input buffer, or NULL if more data is needed
to make a full line. NOTE: modifies the data in the buffer for the \0, so
it works only with ibuffers that allow it (currently only file). */
/* Returns pointer to beginning of data in buffer, or NULL if there's
no data. */
/* Like i_buffer_get_data(), but read it when needed. Returns 1 if more
than threshold bytes were stored into buffer, 0 if less, -1 if error or
EOF with no bytes in buffer or -2 if buffer is full. */
#endif