User Tools

Site Tools


Sidebar

Table Of Contents

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

bvextread

Name

Bvextread — Read the view contents from file stream

Synopsis

#include <ubf.h>

int Bvextread(char * cstruct, char * view, FILE * inf);

int Bvextreadcb(char * cstruct, char * view, long (* p_readf)(char * buffer, long bufsz, void * dataptr1), void * dataptr1);

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Restore the buffer from text populated by Bvprint(3), Bvfprint(3) or Bvfprintcb(3).

The input data each line must be in following format: "[COMMAND]<VIEW_CNAME><TAB><VALUE><NEW_LINE>". When reading by Bvextreadcb() additionally each read line string must be terminated with EOS (0x00 byte).

Having view structure as:

VIEW UBTESTVIEW1
#type    cname      fbname              count   flag    size    null

int      tint2      T_LONG_2_FLD        2       FS       -       0
int      tint3      -                   1       -       -       -1
int      tint4      -                   2       -       -       -1

char     tchar1     T_CHAR_FLD          1       F       -       '\n'
char     tchar2     T_CHAR_2_FLD        5       SC      -       'A'
carray   tcarray2   T_CARRAY_2_FLD      1       LFSP    25      '\0\n\t\f\\\'\"\vHELLOWORL\n'

END

Data shall be formated as (example):

tint2   54545
tint2   23232
tint3   -100
tint4   1010101
tint4   989898
tchar1  A
tchar2  A
tchar2  B
tchar2  C
tchar2  \0a
tchar2  \09
tcarray2        \01\02\03\04\05

When view is read, initially structure is initialized to NULL values. The read process will read and setup the fields till the EOF.

When reading with Bvextreadcb(), p_readf is function from which to read the line by line data. Each call to callback shall return zero (0x00 byte) terminated line with exactly one field, value and newline in the end.

The bufsz denotes the buffer size of buffer, where data shall be put. In case if success, the p_readf must return number bytes written to buffer. At the end of the buffer (EOF), the p_readf must return 0. In case of error, callback function shall return -1. The dataptr1 passed to Bextreadcb()