Back to home page

Enduro/X

 
 

    


0001 SYNOPSIS
0002 --------
0003 
0004 #include <ubf.h>
0005 
0006 
0007 int Bvprint (char * 'cstruct', char * 'view');
0008 
0009 int Bvfprint (char * 'cstruct', char * 'view', FILE * 'outf');
0010 
0011 int Bvfprintcb (char * 'cstruct', char * 'view', ndrx_plugin_tplogprintubf_hook_t 'p_writef', void * 'dataptr1');
0012 
0013 
0014 Link with '-lubf -lnstd -lm -lpthread'
0015 
0016 DESCRIPTION
0017 -----------
0018 Group of functions used for printing the VIEW type structure. *Bvprint()* prints
0019 the view to *stdout*. *Bvfprint()* prints the view to specified output file stream.
0020 *Bvfprintcb()* prints the buffer to callback function.
0021 
0022 The callback function shall be created according to *ndrx_plugin_tplogprintubf_hook_t*
0023 signature which is:
0024 
0025 --------------------------------------------------------------------------------
0026 typedef int (*ndrx_plugin_tplogprintubf_hook_t)(char **buffer, long datalen, void *dataptr1, 
0027         int *do_write, FILE * outf, int fid);
0028 --------------------------------------------------------------------------------
0029 
0030 The callback receives 'buffer' parameter with ASCII chars to print. The 'datalen'
0031 indicates the data length in the 'buffer', this includes a newline and EOS byte.
0032 'dataptr1' is forwarded from the *Bvfprintcb()* call to callback. Parameters:
0033 'do_write', 'outf' are not used. 'fid' is set field number starting from *0* which
0034 is being printed. On return callback function shall return *0* in case of success.
0035 In case of failure, non *0* value shall be returned.
0036 
0037 Data format for printing to *stdout* or *FILE* stream is following:
0038 "<FIELD><TAB><VALUE><NEW_LINE>". When printing to callback, additionally EOS (0x00)
0039 byte is added for each of the lines printed in '*buffer'.
0040 
0041 
0042 When printing char, strings or carray data output is escaped with following rules,
0043 if given ASCII chars is not *isprint()* or is *iscntrl()*, then data is escaped
0044 as "\xx", where xx is hex number of byte, in lower case.
0045 
0046 View structure:
0047 --------------------------------------------------------------------------------
0048 VIEW UBTESTVIEW1
0049 #type    cname      fbname              count   flag    size    null
0050 
0051 int      tint2      T_LONG_2_FLD        2       FS       -       0
0052 int      tint3      -                   1       -       -       -1
0053 int      tint4      -                   2       -       -       -1
0054 
0055 char     tchar1     T_CHAR_FLD          1       F       -       '\n'
0056 char     tchar2     T_CHAR_2_FLD        5       SC      -       'A'
0057 carray   tcarray2   T_CARRAY_2_FLD      1       LFSP    25      '\0\n\t\f\\\'\"\vHELLOWORL\n'
0058 
0059 END
0060 --------------------------------------------------------------------------------
0061 
0062 Would be printed as:
0063 --------------------------------------------------------------------------------
0064 
0065 tint2   54545
0066 tint2   23232
0067 tint3   -100
0068 tint4   1010101
0069 tint4   989898
0070 tchar1  A
0071 tchar2  A
0072 tchar2  B
0073 tchar2  C
0074 tchar2  \0a
0075 tchar2  \09
0076 tcarray2        \01\02\03\04\05
0077 --------------------------------------------------------------------------------
0078 
0079 When array fields are printed, if they have "C" count indicator, then this number of fields
0080 are printed (i.e. may be printed less fields than actually defined in array). If "L" length
0081 indicator is present for field definition for carray type, then only number of bytes set in
0082 length indicator is printed.
0083 
0084 
0085 RETURN VALUE
0086 ------------
0087 On success, *Bvprint()*, *Bvfprint()* and *Bvfprintcb()* return zero; on error, 
0088 -1 is returned, with *Berror* set to indicate the error.
0089 
0090 ERRORS
0091 ------
0092 Note that *Bstrerror()* returns generic error message plus custom message with 
0093 debug info from last function call.
0094 
0095 Following additional errors may be returned by this function:
0096 
0097 *BEINVAL* 'cstruct', 'view' or 'p_writef' is NULL. 'p_writef' callback failed (returned non 0).
0098 
0099 *BBADVIEW* View name specified in 'view' is not found in *VIEWFILES* env config.
0100 
0101 *BNOCNAME* Invalid counter "C" indicator specified in view structure (i.e. count set
0102 is higher than dimensions for array).
0103 
0104 *BMALLOC* Failed to malloc temporary buffers.
0105 
0106 
0107 EXAMPLE
0108 -------
0109 See *ubftest/test_printv.c* for sample code.
0110 
0111 BUGS
0112 ----
0113 Report bugs to support@mavimax.com
0114 
0115 SEE ALSO
0116 --------
0117 *ex_env(5)* *Bprint(3)*
0118 
0119 COPYING
0120 -------
0121 (C) Mavimax, Ltd
0122