User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v8.0.x:api:ubf:bgetrv.3

bgetrv

Name

Bgetrv — Get data from UBF buffer, recursive, var-args path

Synopsis

#include <ubf.h>

int Bgetr (UBFH * p_ub, BFLDID *fldidocc, char * buf, BFLDLEN * buflen);

int Bgetrv (UBFH * p_ub, char * buf, BFLDLEN * buflen, …);

int CBgetr (UBFH * p_ub, BFLDID *fldidocc, char * buf, BFLDLEN * buflen, int usrtype);

int CBgetrv (UBFH * p_ub, char * buf, BFLDLEN * buflen, int usrtype, …);

char* Bfindr (UBFH *p_ub, BFLDID *fldidocc, BFLDLEN *p_len);

char* Bfindrv (UBFH *p_ub, BFLDLEN *p_len, …);

char *CBfindr (UBFH *p_ub, BFLDID *fldidocc, BFLDLEN *len, int usrtype);

char *CBfindrv (UBFH *p_ub, BFLDLEN *len, int usrtype, …);

int Bpresr (UBFH *p_ub, BFLDID *fldidocc);

int Bpresrv (UBFH *p_ub, …);

int CBvgetr(UBFH *p_ub, BFLDID *fldidocc, char *cname, BFLDOCC occ, char *buf, BFLDLEN *len, int usrtype, long flags);

int CBvgetrv(UBFH *p_ub, char *cname, BFLDOCC occ, char *buf, BFLDLEN *len, int usrtype, long flags, …);

char * CBgetallocr (UBFH *p_ub, BFLDID *fldidocc, int usrtype, BFLDLEN *extralen);

char * CBgetallocrv (UBFH *p_ub, int usrtype, BFLDLEN *extralen, …);

int Bvnullr(UBFH *p_ub, BFLDID *fldidocc, char *cname, BFLDOCC occ);

int Bvnullrv(UBFH *p_ub, char *cname, BFLDOCC occ, …);

char * CBvgetallocr(UBFH *p_ub, BFLDID *fldidocc, char *cname, BFLDOCC occ, int usrtype, long flags, BFLDLEN *extralen);

char* CBvgetallocrv(UBFH *p_ub, char *cname, BFLDOCC occ, int usrtype, long flags, BFLDLEN *extralen, …);

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Group of macro functions used lookup to the field in sub-UBF buffers. The exact field from which to take the value at given sub-level, is specified in field id sequence. Functions with r suffix encodes the field id sequence in array specified in fldidocc parameter. Functions with rv suffix encodes the field id sequence in var-args. Last field id in sequence (leaf) identifies the UBF field id on which the target operation must be executed. For view operations, this field must correspond to the view field present in UBF buffer.

Field id sequence must be present in following form:

<FLDID>, <OCC>, …, <FLDID>, <OCC>, BBADFLDOCC.

Internally function uses Bfind(3) to search the sub-UBF buffer from internal UBF field IDs.

Function mapping is following where leaf field id is executed on sub-ubf buffer:

  1. Bgetr(3) and Bgetrv(3) translates to Bget(3) call.
  2. CBgetr(3) and CBgetrv(3) translates to CBget(3) call.
  3. CBgetallocr(3) and CBgetallocrv(3) translates to CBgetalloc(3) call.
  4. Bfindr(3) and Bfindrv(3) translates to Bfindr(3) call.
  5. Bpresr(3) and Bpresrv(3) translates to Bpres(3) call.
  6. CBvgetr(3) and CBvgetrv(3) translates to CBvget(3) call. Note that here it is expected that leaf field in field id sequence matches the view typed field in UBF buffer. Thus on this field value in UBF buffer CBvget(3) is executed.
  7. CBvgetallocr(3) and CBvgetallocrv(3) translates to CBvgetalloc(3) call. Note that here it is expected that leaf field in field id sequence matches the view typed field in UBF buffer. Thus on this field value in UBF buffer CBvgetalloc(3) is executed.
  8. Bvnullr(3) and Bvnullrv(3) translates to Bvnull(3) call. Note that here it is expected that leaf field in field id sequence matches the view typed field in UBF buffer. Thus on this field value in UBF buffer Bvnull(3) is executed.

Usage:

Assuming that UBF buffer contains following data:

T_STRING_8_FLD  HELLO WORLD1
T_STRING_9_FLD  01
T_STRING_9_FLD  20
T_STRING_9_FLD  31
T_CARRAY_2_FLD
T_CARRAY_2_FLD  TEST CARRAY
T_PTR_3_FLD     0xc7
T_PTR_3_FLD     0x12b
T_UBF_FLD
        T_SHORT_1_FLD   6500
        T_LONG_1_FLD    3200
T_UBF_FLD
        T_LONG_3_FLD    9999
        T_LONG_3_FLD    8888
        T_UBF_3_FLD
                T_STRING_9_FLD  HELLO WORLD ONE
                T_STRING_9_FLD  HELLO WORLD TWO
                T_STRING_9_FLD  HELLO WORLD THREE

To extract T_STRING_9_FLD third occurrence value from T_UBF_FLD/T_UBF_3_FLD sub-buffer field, use following syntax:

ret=Bgetr(p_ub, (int []){ T_UBF_FLD, 1, T_UBF_3_FLD, 0, T_UBF_2_FLD, 0, T_STRING_9_FLD, 2, BBADFLDOCC}, buf, &len)

or with var-args:

ret=Bgetrv(p_ub, buf, &len, T_UBF_FLD, 1, T_UBF_3_FLD, 0, T_UBF_2_FLD, 0, T_STRING_9_FLD, 2, BBADFLDOCC)

RETURN VALUE

On success, Bgetr() and Bgetrv() 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. Function my return errors from Bfind(3) and corresponding mapped operation, e.g. Bget(3), Bfind(3), etc.

Following additional errors may be returned by this function:

BBADFLD Invalid sequence of field identifier, not encoded according the the rules.

BEBADOP For view operations (CBvgetr/CBvgetrv/Bvnullr/Bvnullrv), the leaf field identifier in sequence does not match the view type.

EXAMPLE

See ubftest/test_embubf.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd