Table of Contents
#include <ubf.h>
int Bnext (UBFH *p_ub, BFLDID *bfldid, BFLDOCC *occ, char *buf, BFLDLEN *len);
Link with -lubf -lnstd -lm -lpthread
Iterate over the UBF buffer pointed by p_ub. To start (or restart) loop over the buffer, bfldid value must be set to BFIRSTFLDID. If function succeeds it returns field id in bfldid, occurrence in occ and data value in buf/len pair. buf and len both are optional fields. len on input indicate the buffer length, on output it indicates the the length of data loaded. If len is set to NULL, then it is assumed that on input buffer is large enough to store data. The state of iteration is stored in thread local storage (TLS).
When Bnext steps onto BFLD_VIEW type field, Bnext initializes the buf as BVIEWFLD with trailing data. Thus the BVIEWFLD.data is set to memory address of buf + sizeof(BVIEWFLD). If len was specified, before returning the data len is reduced by sizeof(BVIEWFLD).
On success, Bnext() return 1, if End Of Buffer reached, then 0 is returned; on error, -1 is returned, with Berror set to indicate the error.
Note that Bstrerror() returns generic error message plus custom message with debug info from last function call.
BALIGNERR Corrupted buffer or pointing to not aligned memory area.
BNOTFLD Buffer not fielded, not correctly allocated or corrupted.
BNOSPACE No space in buf.
Report bugs to support@mavimax.com