The mi_stream_seek() function

The mi_stream_seek() function sets the stream seek position for the next read or write operation on an open stream.

Syntax

mi_integer mi_stream_seek(strm_desc, offset, whence)
   MI_STREAM *strm_desc;
   mi_int8 *offset;
   mi_integer whence;
strm_desc
A pointer to a stream descriptor for an open stream.
offset
A pointer to a positive or negative byte offset from the whence seek position.
whence
A constant that specifies the position from which to start the seek operation to the offset position.
Valid in client LIBMI application? Valid in user-defined routine?
No Yes
Important: Enterprise Replication does not support this function.

Usage

The mi_stream_seek() function uses the whence and offset arguments to determine the new seek position of the stream that strm_desc references, as follows:
  • The whence argument identifies the position from which to start the seek operation.
    Valid values include the following whence constants.
    Whence constant
    Starting position for seek operation
    MI_LO_SEEK_SET
    The start of the stream
    MI_LO_SEEK_CUR
    The current seek position of the stream
    MI_LO_SEEK_END
    The end of the stream
    • The offset argument identifies the offset, in bytes, from the starting position (which the whence argument specifies) at which to begin the seek operation.

      This offset value can be negative for all values of whence. For more information about how to access eight-bit (INT8) integers, see the HCL OneDB™ DataBlade® API Programmer's Guide.

Use the associated stream-open function to obtain the stream descriptor for one of these data streams. You can then pass this stream descriptor to mi_stream_seek() to set the seek position on any of these streams. You can also implement an mi_stream_seek() function for your own user-defined stream. For more information, see the HCL OneDB DataBlade API Programmer's Guide.

On success, mi_stream_seek() returns MI_OK. To obtain the new stream seek position, use the mi_stream_tell() function.

Return values

MI_OK
The new stream seek position has been set to the combination of whence and offset.
MI_STREAM_EBADARG
The stream descriptor that strm_desc references or the offset value is invalid, or that the specified seek position is past the end of the data.
MI_STREAM_ENIMPL
The stream class does not implement the seek position.
MI_ERROR
The function was not successful.
MI_STREAM_EWHENCE
The whence value is invalid.