ostream.h revision c0435c854a0e7246373b9752d163095cc4fbe985
#ifndef __OSTREAM_H
#define __OSTREAM_H
struct ostream {
int stream_errno;
unsigned int closed:1;
void *real_stream;
};
struct ostream *
int priority, int autoclose_fd);
/* Reference counting. References start from 1, so calling o_stream_unref()
destroys the stream if o_stream_ref() is never used. */
/* Mark the stream closed. Nothing will be sent after this call. */
/* Change the maximum size for stream's output buffer to grow. */
/* Stream is made to be flushed out whenever it gets full (assumes max_size
is already set), ie. writes will never be partial. Also makes any blocking
writes to fail after specified timeout, calling timeout_func if it's
set. This call changes non-blocking state of file descriptor. */
void (*timeout_func)(void *), void *context);
/* Delays sending as far as possible, writing only full buffers. Also sets
TCP_CORK on if supported. o_stream_flush() removes the cork. */
/* Flush the output stream, blocks until everything is sent.
Returns 1 if ok, -1 if error. */
/* Returns 1 if specified amount of data currently fits into stream's output
buffer, 0 if not. */
/* Seek to specified position from beginning of file. This works only for
files. Returns 1 if successful, -1 if error. */
/* Returns number of bytes sent or buffered, or -1 if disconnected */
/* Send data from input stream. Returns number of bytes sent, or -1 if error.
Note that this function may block if either instream or outstream is
blocking. */
#endif