0001 SYNOPSIS
0002 --------
0003
0004 #include <ubf.h>
0005
0006 int Bboolsetcbf (char +++*+++ 'funcname', long (* 'functionPtr')(UBFH * 'p_ub', char * 'funcname'));
0007
0008 int Bboolsetcbf2 (char +++*+++ 'funcname', long (* 'functionPtr')(UBFH * 'p_ub', char * 'funcname', char * 'arg1'));
0009
0010 Link with '-lubf -lnstd -lm -lpthread'
0011
0012 DESCRIPTION
0013 -----------
0014 Register callback function to Boolean expression evaluator. The function name
0015 which appears in UBF expression is set in 'funcname' argument in callback.
0016 The callback function by it is self is set in 'functionPtr'. The callback
0017 function receives the buffer on which it is being evaluated in 'p_ub',
0018 and callback receives the function name too in 'funcname'.
0019
0020 In case if using *Bboolsetcbf2()* additionally 'arg1' argument is received from
0021 Boolean expression script.
0022
0023 Min length for function name is 1 symbols and max length is 64.
0024
0025 Min 'arg1' length is 0 (just two single quotes) and 'arg1' length is 510.
0026
0027 Example:
0028
0029 --------------------------------------------------------------------------------
0030
0031 long callback_no_args(UBFH *p_ub, char *funcname)
0032 {
0033 return 888;
0034 }
0035
0036 long callback_with_args(UBFH *p_ub, char *funcname, char *arg1)
0037 {
0038 if (0==strcmp(arg1, "OK"))
0039 return 0;
0040 else
0041 return 1;
0042 }
0043
0044
0045 Bboolsetcbf ("callback_no_args", callback_no_args);
0046
0047 Bboolsetcbf2 ("callback_with_args", callback_with_args);
0048
0049 tree=Bboolco ("callback_no_args()==888 && callback_with_args('OK')==0 && callback_with_args('NOK')==1");
0050
0051 --------------------------------------------------------------------------------
0052
0053 If calling *Bboolsetcbf()* or *Bboolsetcbf2()* with *NULL* function pointer, the
0054 function is removed from callback mappings. But this cannot be done in case if
0055 some tree is already compiled, as it holds the pointer to function map entry
0056 and this pointer is compiled tree is not reset. This shall be controlled by
0057 developer, otherwise if removing mapping for already compiled tree and tree
0058 is being evaluated, the segmentation fault is possible.
0059
0060 'arg1' for *Bboolsetcbf2()* is passed in callback function in single quotes.
0061 The single quotes cannot be escaped, other C escapes are not processed too.
0062 Argument data escaping is subject for future changes.
0063
0064 RETURN VALUE
0065 ------------
0066 On success, *Bboolsetcbf()* returns *0*. On error *-1* is returned, with
0067 *Berror* set to indicate the error.
0068
0069 ERRORS
0070 ------
0071 Note that *Bstrerror()* returns generic error message plus custom message
0072 with debug info from last function call.
0073
0074 *BBADNAME* Invalid function name
0075
0076 EXAMPLE
0077 -------
0078 See *ubftest/test_expr.c* for sample code.
0079
0080 BUGS
0081 ----
0082 Report bugs to support@mavimax.com
0083
0084 SEE ALSO
0085 --------
0086 *Bboolco(3)* *Bfloatev(3)* *Btreefree(3)*
0087
0088 COPYING
0089 -------
0090 (C) Mavimax, Ltd
0091