Initialize an IO stream
#include <img/img.h> io_stream_t *io_open( io_open_f *open_f, io_mode_t mode, ...)
- A pointer to a function to establish a stream. There are two functions supplied by the library: IO_FD (for fd-based reading/writing) and IO_MEM (for memory buffer based reading/writing). See below.
- The open mode, either IO_READ or IO_WRITE.
- Additional parameters depending on the open_f specified, described below.
Use the -l img option to qcc to link against this library.
This function initializes a stream. The stream can be a fd-based, or a memory buffer, depending on the open_f specified:
- Buffered streaming for unix-type fd's. An additional parmameter is required: an int specifying the (previously opened) fd that is ready for reading or writing.
- Streaming support for a memory buffer. Additional parameters are required (in order):
- an unsigned to specify size of the memory buffer. This must be non-zero.
- a void pointer to specify the address of the buffer.
When your application is finished with a stream, it should call io_close() to release it.
A pointer to the stream object, or NULL if an error occurred ( errno is set).
- Insufficient memory to allocate structures.
- Invalid open_f or mode.
- Mode not supported for stream.
Last modified: 2014-05-14