Back to home page

Enduro/X

 
 

    


0001 SYNOPSIS
0002 --------
0003 
0004 #include <ubf.h>
0005 
0006 int Bvextread(char * 'cstruct', char * 'view', FILE * 'inf');
0007 
0008 int Bvextreadcb(char * 'cstruct', char * 'view', 
0009         long (* 'p_readf')(char * 'buffer', long 'bufsz', void * 'dataptr1'), void * 'dataptr1');
0010 
0011 
0012 Link with '-lubf -lnstd -lm -lpthread'
0013 
0014 DESCRIPTION
0015 -----------
0016 
0017 Restore the buffer from text populated by *Bvprint(3)*, *Bvfprint(3)* 
0018 or *Bvfprintcb(3)*.
0019 
0020 The input data each line must be in following format: "[COMMAND]<VIEW_CNAME><TAB><VALUE><NEW_LINE>".
0021 When reading by *Bvextreadcb()* additionally each read line string must be terminated
0022 with EOS (0x00 byte).
0023 
0024 Having view structure as:
0025 --------------------------------------------------------------------------------
0026 VIEW UBTESTVIEW1
0027 #type    cname      fbname              count   flag    size    null
0028 
0029 int      tint2      T_LONG_2_FLD        2       FS       -       0
0030 int      tint3      -                   1       -       -       -1
0031 int      tint4      -                   2       -       -       -1
0032 
0033 char     tchar1     T_CHAR_FLD          1       F       -       '\n'
0034 char     tchar2     T_CHAR_2_FLD        5       SC      -       'A'
0035 carray   tcarray2   T_CARRAY_2_FLD      1       LFSP    25      '\0\n\t\f\\\'\"\vHELLOWORL\n'
0036 
0037 END
0038 --------------------------------------------------------------------------------
0039 
0040 Data shall be formated as (example):
0041 --------------------------------------------------------------------------------
0042 
0043 tint2   54545
0044 tint2   23232
0045 tint3   -100
0046 tint4   1010101
0047 tint4   989898
0048 tchar1  A
0049 tchar2  A
0050 tchar2  B
0051 tchar2  C
0052 tchar2  \0a
0053 tchar2  \09
0054 tcarray2        \01\02\03\04\05
0055 --------------------------------------------------------------------------------
0056 
0057 When view is read, initially structure is initialized to NULL values. The read
0058 process will read and setup the fields till the EOF.
0059 
0060 When reading with Bvextreadcb(), 'p_readf' is function from which to read
0061 the line by line data. Each call to callback shall return zero (0x00 byte) terminated 
0062 line with exactly one field, value and newline in the end. 
0063 
0064 The 'bufsz' denotes the buffer size of 'buffer', where data shall be put. 
0065 In case if success, the 'p_readf' must return number bytes written to 'buffer'.
0066 At the end of the buffer (EOF), the 'p_readf' must return *0*. In case of error, callback
0067 function shall return *-1*. The *dataptr1* passed to *Bextreadcb()* is forwarded
0068 to callback function and is meant to be used by user specific purposes. Field
0069 is optional and may be set to NULL, if not used by callback.
0070 
0071 Input format supports also macro commands. This is optional *COMMAND* block, 
0072 that can have following values:
0073 
0074 *+* set the field value at array occurrence 0.
0075 
0076 *-* initialize array occurrence 0 to NULL value.
0077 
0078 *=* copy the field value from field name which is stored at <VALUE>.
0079 
0080 *#* comment, line ignored
0081 
0082 RETURN VALUE
0083 ------------
0084 On success, *Bextreadcb()* return zero; on error, -1 is returned, with *Berror* 
0085 set to indicate the error.
0086 
0087 ERRORS
0088 ------
0089 Note that *Bvextread()* and *Bvextreadcb()* returns generic error message 
0090 plus custom message with debug info from last function call.
0091 
0092 *BEINVAL* 'cstruct' is NULL, 'view' is NULL or EOS, 'inf' is NULL, 'p_readf' is NULL.
0093 
0094 *BBADVIEW* View not recognized (check the *VIEWFILES* env config).
0095 
0096 *BEINVAL* 'p_readf' is NULL.
0097 
0098 *BSYNTAX* Missing tab between field id or missing newline. Space does not follow
0099 the command. Invalid string escape.
0100 
0101 *BEUNIX* Malloc failed for temp buffers.
0102 
0103 *BNOCNAME* cname field not found in view definition.
0104 
0105 EXAMPLE
0106 -------
0107 See *ubftest/test_printv.c* for sample code.
0108 
0109 BUGS
0110 ----
0111 Report bugs to support@mavimax.com
0112 
0113 SEE ALSO
0114 --------
0115 *Bvprint(3)* *Bvfprint(3)* *Bvfprintcb(3)* *Bextread(3)* 
0116 
0117 COPYING
0118 -------
0119 (C) Mavimax, Ltd
0120