User Tools

Site Tools


Sidebar

Table Of Contents

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

bfprintcb

Name

Bfprintcb — Print the buffer output in human/machine readable format to callback function

Synopsis

#include <ubf.h>

int Bfprintcb (UBFH p_ub, int (p_writef)(char *buffer, long datalen, void *dataptr1), void *dataptr1);

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Function prints the p_ub buffer content to callback function p_writef. The format of the output is "<FIELD><TAB><VALUE><NEW_LINE><EOS(0x00)>". The BFLD_CARRAY fields are printed in the way that non readable characters are printed in hex-decimal format, prefixed with \. If value contains \ char, then it is printed as \\. Example:

T_SHORT_FLD     1765
T_LONG_FLD      3333111
T_LONG_FLD      2
T_CHAR_FLD      A
T_FLOAT_FLD     1.33000
T_DOUBLE_FLD    1111.220000
T_DOUBLE_FLD    333.000000
T_DOUBLE_FLD    444.000000
T_STRING_FLD    HELLO WORLD
T_CARRAY_FLD    \00\01\02\03HELLO BINARY\04\05\00

The callback receives buffer parameter with ASCII chars to print. The datalen indicates the data length in the buffer, this includes a newline and EOS byte. dataptr1 is forwarded from the main Bfprintcb() call.

RETURN VALUE

On success, Bfprintcb() 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 outf is NULL.

EXAMPLE

See ubftest/test_print.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd