CBvgetallocr — Allocate space and get view sub-field from VIEW present in UBF (sub-)buffer
#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
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:
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)
On success, Bgetr() and Bgetrv() return zero; on error, -1 is returned, with Berror set to indicate the error.
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.