Bwritecb — Write the UBF buffer to callback function
#include <ubf.h>
int Bwritecb (UBFH *p_ub, long (*p_writef)(char *buffer, long bufsz, void *dataptr1), void *dataptr1);
Link with -lubf -lnstd -lm -lpthread
Transfer UBF buffer presented by p_ub to callback function set by p_writef. The callback function accepts buffer which contains UBF buffer, the bufsz contains the number of bytes in buffer. The dataptr1 from main function is forwarded to callback, so that customer user pointer can be passed to callback. The callback must return number of bytes written, which for case of success must be equal to the bufsz passed to callback function. Otherwise error will be generated. In case if callback fails, -1 shall be returned to callback function. Currently the whole buffer is present in single write callback, but this subject of change in future.
On success, Bwrite() return zero; 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.
BEINVAL p_writef is NULL.
BEUNIX Failed to read from stream.
BNOSPACE No space in p_ub.