User Tools

Site Tools


Sidebar

Table Of Contents

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

cbchg

Name

CBchg — Convert and change (add/update) field occurrance in UBF buffer

Synopsis

#include <ubf.h>

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

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Change (add or update) field in UBF buffer by converting given user type usrtype to buffer field’s type (see BFLD_* types). The UBF buffer pointer is passed by p_ub, field id in bfldid. occ is occurrance to change. The user field value is passed in buf. The len is used only if usrtype is BFLD_CARRAY, for which length cannot be detected from passed data.

If occ is bigger than last existing index+1 in buffer then non existing occurrences (which are not being set by this function) are initialised 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).

RETURN VALUE

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

BMALLOC Failed to allocate type conversion buffer.

BBADFLD Invalid field id passed.

EXAMPLE

See ubftest/test_cbchg.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd