Initialize an IO stream
Synopsis:
#include <io/io.h>
io_stream_t *io_open( io_open_f *open_f,
                      io_mode_t  mode, ...)
 
Arguments:
- open_f
  
 
- 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.
  
 
- mode
  
 
- The open mode, either IO_READ or IO_WRITE.
  
 
- ...
  
 
- Additional parameters depending on the open_f specified, described below.
 
 
Library:
libimg
Use the -l img option to
qcc
to link against this library.
 
Description:
This function initializes a stream.  The stream can be a fd-based, or a memory buffer, depending on the open_f specified:
- IO_FD()
   
 
- 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.
   
 
- IO_MEM()
   
 
- 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.
 
Returns:
A pointer to the stream object, or NULL
if an error occurred (errno is set).
 
Errors:
- ENOMEM
  
 
- Insufficient memory to allocate structures.
  
 
- EINVAL
  
 
- Invalid open_f or mode.
  
 
- ENOTSUP
  
 
- Mode not supported for stream.
 
 
Classification:
Image library
| Safety: | 
  | 
| Interrupt handler | 
No | 
| Signal handler | 
No | 
| Thread | 
No |