Back to home page

Enduro/X

 
 

    


0001 BEXTREADCB(3)
0002 =============
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 Bextreadcb - Restore the buffer from printed text received from callback function
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 
0014 #include <ubf.h>
0015 
0016 int Bextreadcb (UBFH * 'p_ub', 
0017         long (*'p_readf')(char *'buffer', long 'bufsz', void *'dataptr1'), void *'dataptr1');
0018 
0019 Link with '-lubf -lnstd -lm -lpthread'
0020 
0021 DESCRIPTION
0022 -----------
0023 Restore the buffer from text populated by *Bprint(3)*, *Bprintf(3)* 
0024 or *Bprintfcb(3)*.
0025 
0026 The read format is "[COMMAND]<FIELD><TAB><VALUE><NEW_LINE>". Input also support 
0027 fields by id, then format for <FIELD> is "((BFLDID32)<FIELD_ID>)".
0028 
0029 To enable processing of *BFLD_PTR* fields, *ex_env(5)* configuration parameter
0030 *NDRX_APIFLAGS* shall contain flag *ubf_ptrparse*.
0031 
0032 Sample buffer:
0033 
0034 --------------------------------------------------------------------------------
0035 T_SHORT_FLD     1765
0036 T_LONG_FLD      3333111
0037 T_LONG_FLD      2
0038 T_CHAR_FLD      A
0039 T_FLOAT_FLD     1.33000
0040 T_DOUBLE_FLD    1111.220000
0041 T_DOUBLE_FLD    333.000000
0042 T_DOUBLE_FLD    444.000000
0043 T_STRING_FLD    HELLO WORLD
0044 T_CARRAY_FLD    \00\01\02\03HELLO BINARY\04\05\00\\
0045 ((BFLDID32)167772261)   HELLOSVC
0046 --------------------------------------------------------------------------------
0047 
0048 'p_ub' is buffer to write the data to, 'p_readf' is function from which to read
0049 the line by line data. Each call to callback shall return zero terminated 
0050 line with exactly one field, value and newline in the end. 
0051 The 'bufsz' denotes the buffer size of 'buffer', where data shall be put. 
0052 In case if success, the 'p_readf' must return number bytes written to 'buffer'.
0053 At the end of the buffer, the 'p_readf' must return *0*. In case of error, callback
0054 function shall return *-1*. The *dataptr1* passed to *Bextreadcb()* is forwarded
0055 to callback function and is meant to be used by user specific purposes. Field
0056 is optional and may be set to NULL, if not used by callback.
0057 
0058 Input format supports also macro commands. This is optional *COMMAND* block, 
0059 that can have following values:
0060 
0061 *+* set the field value at occurrence 0.
0062 
0063 *-* delete field from buffer.
0064 
0065 *=* copy the field value from field name which is stored at <VALUE>.
0066 
0067 *#* comment, line ignored
0068 
0069 For example:
0070 
0071 --------------------------------------------------------------------------------
0072 # Set the field value
0073 T_SHORT_FLD     123
0074 # Copy the value from T_SHORT_FLD to T_LONG_FLD
0075 =T_LONG_FLD     T_SHORT_FLD
0076 # Change the occurrence 0 to 444
0077 +T_SHORT_FLD    444
0078 --------------------------------------------------------------------------------
0079 
0080 The final buffer will be:
0081 
0082 --------------------------------------------------------------------------------
0083 T_SHORT_FLD     444
0084 T_LONG_FLD      123
0085 --------------------------------------------------------------------------------
0086 
0087 This format is used by *ud(8)* command line utility which allows to send 
0088 arbitrary buffer to specified service.
0089 
0090 RETURN VALUE
0091 ------------
0092 On success, *Bextreadcb()* return zero; on error, -1 is returned, with *Berror* 
0093 set to indicate the error.
0094 
0095 ERRORS
0096 ------
0097 Note that *Bstrerror()* returns generic error message plus custom message with 
0098 debug info from last function call.
0099 
0100 *BALIGNERR* Corrupted buffer or pointing to not aligned memory area.
0101 
0102 *BNOTFLD* Buffer not fielded, not correctly allocated or corrupted.
0103 
0104 *BEINVAL* 'p_readf' is NULL.
0105 
0106 *BSYNTAX* Missing tab between field id or missing newline.
0107 
0108 *BBADNAME* Field not found in field table.
0109 
0110 EXAMPLE
0111 -------
0112 See *ubftest/test_print.c* for sample code.
0113 
0114 BUGS
0115 ----
0116 Report bugs to support@mavimax.com
0117 
0118 SEE ALSO
0119 --------
0120 *Bextread(3)* *Bfprint(3)* *Bprint(3)* *Bread(3)* *Bwrite(3)* *ud(8)* *ex_env(5)*
0121 
0122 COPYING
0123 -------
0124 (C) Mavimax, Ltd
0125