User Tools

Site Tools


Sidebar

Table Of Contents

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

bchg

Name

Bchg — Change (add or update) field occurrance in UBF buffer

Synopsis

#include <ubf.h>

int Bchg (UBFH *p_ub, BFLDID bfldid, BFLDOCC occ, char *buf, BFLDLEN len);

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Change (add or update) field in UBF buffer. The UBF buffer pointer is passed by p_ub, field id in bfldid. occ is occurrance to change. The field value is passed in buf. The len is used only if bfldid type is BFLD_CARRAY, for which length cannot be detected from passed data. The buf field type must match the bfldid field type.

If occ is bigger than last existing index+1 in buffer then non existing occurrences (which are not being set directly by this function) are initialized with defaults. For numerics it is 0, for BFLD_CHAR it is 0x00, for BFLD_STRING it is empty string, for BFLD_CARRAY it is empty byte array (with length 0).

For performance reasons, it is recommended to use Bchg over CBchg, to skip the conversion step.

RETURN VALUE

On success, Bchg() 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.

BNOSPACE No space in buffer for string data.

BBADFLD Invalid field id passed.

EXAMPLE

See ubftest/ubfunit1.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd