User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:ubf:bwritecb.3

bwritecb

Name

Bwritecb — Write the UBF buffer to callback function

Synopsis

#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

DESCRIPTION

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.

RETURN VALUE

On success, Bwrite() return zero; on error, -1 is returned, with Berror set to indicate the error.

ERRORS

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.

EXAMPLE

See ubftest/test_readwrite.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd