Function ion_c_sys::ion_reader_open_stream [−][src]
pub unsafe extern "C" fn ion_reader_open_stream(
p_hreader: *mut hREADER,
handler_state: *mut c_void,
fn_input_handler: ION_STREAM_HANDLER,
p_options: *mut ION_READER_OPTIONS
) -> iERR
Expand description
Create hREADER object, and associate it with the stream for reading.
The hREADER object itself does not have a read data buffer, it’s using the buffer from handler_state, which usually contains a BYTE[].
hREADER object will invoke fn_input_handler to read from input data source (File, for example) and fill the BYTE[] in handler_state.
typedef struct _test_file { FILE *in; int block_size; BYTE *buffer; } TEST_FILE; BYTE g_buffer[1024]; TEST_FILE g_test_file = { NULL, TEST_FILE_BUF_MAX, g_buffer }; iERR test_stream_handler(struct _ion_stream *pstream) { iENTER; TEST_FILE *tfile; SIZE len; tfile = (TEST_FILE *)pstream->handler_state; pstream->curr = tfile->buffer; len = fread( tfile->buffer, sizeof(*tfile->buffer), tfile->block_size, g_test_file.in ); if (len < 1) { pstream->limit = NULL; DONTFAILWITH(IERR_EOF); } pstream->limit = pstream->curr + len; iRETURN; } fstream = fopen(pathname, "r"); g_test_file.in = fstream; ion_reader_open_stream(&reader, &g_test_file, test_stream_handler, NULL);
@param p_hreader Newly created reader object will be stored here. @param p_stream stream opened with ion_stream functions @param p_options const, Reader configuration data object, used while creating reader object. @return IERR_OK if succeeded