Initializing help system before first use

# bindrv_newreader

Purpose
Create a new BinDrv context for parsing an input stream.
Synopsis
`s_bindrvctx bindrv_newreader(size_t (*doread)(void *,size_t,size_t,void*), void *rctx);`
Arguments

doread | Callback function to retrieve data from the input stream
rctx | File descriptor to be passed as the last argument of doread

Return value
The new context or NULL in case of error.
Example
In the following example the file "bindata is opened using the C function fopen and a reader is created based on the resulting file descriptor:

    f=fopen("bindata", "r");
    bdrv=bindrv_newreader((size_t (*)(void *,size_t,size_t,void*))fread, f);

Further information
1. Each context created using this function must be released by a call to bindrv_delete.
2. The doread routine is used by the reader whenever it requires further data to process. The function receives as input a buffer (where read data has to be copied), its size and, as the last argument, the pointer rctx. The third argument of doread is always 1. The return value must be 1 if successful ( i.e. the requested amount of data has been read), any other value is interpreted as an error condition.
3. The required doread function has the same signature as the C function fread such that a BinDrv reader can use as input a file opened with the C function fopen.
Related topics
bindrv_delete.
Parent Topic Reader

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.