Generic stream I/O functions
Stream-I/O function | Description |
---|---|
mi_stream_close() | Close the stream. |
mi_stream_eof() | Check the stream for the end-of-stream condition. |
mi_stream_get_error() | Obtain the last error that occurred on the specified stream. |
mi_stream_getpos() | Obtain the current stream seek position, returning it in a function parameter. |
mi_stream_length() | Obtain the length of the stream data. |
mi_stream_read() | Read a specified number of bytes from the stream. |
mi_stream_seek() | Move the stream seek position to the desired location. |
mi_stream_set_error() | Sets the last error status on the specified stream. |
mi_stream_setpos() | Set the stream seek position. |
mi_stream_tell() | Obtain the current stream seek position, returning it from the function. |
mi_stream_write() | Write a specified number of bytes to the stream. |
The advantage of accessing data through a stream is that the call to the generic stream I/O function is the same, regardless of the format of the underlying data. With these generic stream-I/O functions, the DataBlade API provides a common interface for the transportation and access of data independent of the data type or destination.
nbytes_read = mi_stream_read(strm_desc, buf, 164);
The calling code does not need to concern itself about the format of the underlying data. Whether mi_stream_read() reads the data from a file, character array, varying-length structure, or user-defined stream depends on which stream-open function has obtained the pointer to the stream descriptor (MI_STREAM structure).
In addition to the generic stream I/O functions in the preceding table, the stream I/O interface contains the following functions for different stream classes.
Classes of stream I/O function | Stream I/O function | More information |
---|---|---|
Stream-open functions for the predefined stream classes: | Using predefined stream classes | |
|
|
|
Abstract stream I/O functions for user-defined streams | mi_stream_init() Type-specific stream-open function |
Create a user-defined stream class |