yumapro
24.10-1
YumaPro SDK
|
XPath 1.0 parser implementation used by multiple programs. More...
Macros | |
#define | SET_SKIP_MODE(pcb) (pcb)->flags |= XP_FL_SKIP_MODE |
Set the current skip mode active used only by internal xpath1_pred.c XPath requires that AND and OR expressions only be evaluated until the final value is known. More... | |
#define | CLEAR_SKIP_MODE(pcb) (pcb)->flags &= ~XP_FL_SKIP_MODE |
Clear the current skip mode. | |
#define | IS_SKIP_MODE(pcb) ((pcb)->flags & XP_FL_SKIP_MODE) |
Check if skip mode is active. | |
Functions | |
status_t | xpath1_parse_expr (tk_chain_t *tkc, ncx_module_t *mod, xpath_pcb_t *pcb, xpath_source_t source) |
Parse the XPATH 1.0 expression string. More... | |
status_t | xpath1_validate_expr (ncx_module_t *mod, obj_template_t *obj, xpath_pcb_t *pcb) |
Validate the previously parsed expression string. More... | |
status_t | xpath1_validate_expr_ex (ncx_module_t *mod, obj_template_t *obj, xpath_pcb_t *pcb, boolean missing_is_error, boolean set_backptrs, ncx_xpath_type_t backptr_type) |
Validate the previously parsed expression string. More... | |
status_t | xpath1_eval_obj_expr (xpath_pcb_t *pcb) |
Evaluate an OBJECT expression. More... | |
status_t | xpath1_validate_when_expr (ncx_module_t *mod, obj_template_t *when_obj, obj_template_t *context_obj, xpath_pcb_t *pcb) |
Validate the previously parsed expression string WHEN-STMT. More... | |
xpath_result_t * | xpath1_eval_expr (xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, status_t *res) |
Evaluate an XPath expression use if the prefixes are YANG: must/when. More... | |
xpath_result_t * | xpath1_eval_expr2 (xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, boolean force_only, status_t *res) |
Evaluate an XPath expression (alt) More... | |
xpath_result_t * | xpath1_eval_expr3 (xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, boolean force_only, xml_msg_hdr_t *get2_mhdr, boolean get_when, xpath_get2_node_t *val_get2, status_t *res) |
Evaluate an XPath expression (alt3) More... | |
status_t | xpath1_test_data_rule (xpath_pcb_t *pcb, getcb_get2_t *get2cb, boolean *testres) |
Test a NACM data rule expression against a GET2 control block. More... | |
xpath_result_t * | xpath1_eval_xmlexpr (xmlTextReaderPtr reader, xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, status_t *res) |
Evaluate an XML document expression. More... | |
void | xpath1_prune_nodeset (xpath_pcb_t *pcb, xpath_result_t *result) |
Check the current result nodeset and remove any redundant nodes from a NETCONF POV. More... | |
boolean | xpath1_check_node_exists (xpath_pcb_t *pcb, dlq_hdr_t *resultQ, const val_value_t *val) |
Check if any ancestor-ot-self node is already in the specified Q. More... | |
boolean | xpath1_check_node_exists_slow (xpath_pcb_t *pcb, dlq_hdr_t *resultQ, const val_value_t *val) |
Check if any ancestor-ot-self node is already in the specified Q Slow version. More... | |
boolean | xpath1_check_resnode_exists (xpath_pcb_t *pcb, dlq_hdr_t *resultQ, xpath_resnode_t *resnode) |
Check if any ancestor-ot-self node is already in the specified Q. More... | |
status_t | xpath1_stringify_nodeset (xpath_pcb_t *pcb, const xpath_result_t *result, xmlChar **str) |
Convert a value node pointer to a string node. More... | |
status_t | xpath1_stringify_node (xpath_pcb_t *pcb, val_value_t *val, xmlChar **str) |
Convert a value node to a string node. More... | |
boolean | xpath1_compare_result_to_string (xpath_pcb_t *pcb, xpath_result_t *result, xmlChar *strval, status_t *res) |
Compare an XPath result to the specified string. More... | |
boolean | xpath1_compare_result_to_number (xpath_pcb_t *pcb, xpath_result_t *result, ncx_num_t *numval, status_t *res) |
Compare an XPath result to the specified number. More... | |
boolean | xpath1_compare_nodeset_results (xpath_pcb_t *pcb, xpath_result_t *result1, xpath_result_t *result2, status_t *res) |
Compare an XPath result to another result. More... | |
boolean | xpath1_find_val_in_nodeset (xpath_result_t *result, const xmlChar *valstr) |
Check a nodeset result and find the same value in one of the nodes. More... | |
boolean | xpath1_find_val_in_nodeset_ex (xpath_result_t *result, val_value_t *testval) |
Check a nodeset result and find the same value in one of the nodes. More... | |
xpath_result_t * | xpath1_parse_expr_int (xpath_pcb_t *pcb, status_t *res) |
Parse an XPath Expr sequence It has already been tokenized. More... | |
xpath_result_t * | xpath1_parse_relational_expr_int (xpath_pcb_t *pcb, status_t *res) |
Parse an XPath Relational Expr sequence It has already been tokenized. More... | |
boolean | xpath1_keep_object (obj_template_t *testobj, boolean textmode, xmlns_id_t nsid, const xmlChar *name) |
Test if an object should be kept in a resnode node-test. More... | |
void | xpath1_dump_result (log_debug_t lvl, xpath_pcb_t *pcb, xpath_result_t *result, const char *banner) |
Generate log output displaying the contents of a result. More... | |
void | xpath1_dump_resnode (log_debug_t lvl, xpath_resnode_t *resnode, const char *banner) |
Generate log output displaying the contents of an XPath resnode. More... | |
boolean | xpath1_check_when_object (xpath_pcb_t *pcb, obj_template_t *obj) |
Check if the object is supposed to be deleted from the XPath context because of self-referencing when-stmt. More... | |
boolean | xpath1_cmp_results (xpath_pcb_t *pcb, xpath_result_t *val1, xpath_result_t *val2, xpath_exop_t exop, status_t *res) |
Compare 2 results, using the specified logic operator. More... | |
const xpath_fncb_t * | xpath1_fn_get_functions_ptr (void) |
Get the start of the function array for XPath 1.0 plus the current() function. More... | |
status_t | xpath1_pred_parse_predicate (xpath_pcb_t *pcb, xpath_result_t **result) |
Parse an XPath Predicate sequence It has already been tokenized. More... | |
status_t | xpath_wr_expr (ses_cb_t *scb, val_value_t *xpathval) |
Write the specified XPath expression to the current session using the default prefixes. More... | |
XPath 1.0 parser implementation used by multiple programs.
Debug function to write an Xpath expression.
XPath 1.0 predicate parsing support.
XPath 1.0 function library support.
XPath 1.0 parser compare support.
#define SET_SKIP_MODE | ( | pcb | ) | (pcb)->flags |= XP_FL_SKIP_MODE |
Set the current skip mode active used only by internal xpath1_pred.c XPath requires that AND and OR expressions only be evaluated until the final value is known.
Skip mode allows the tokens to be skipped without processing the sub-expression
boolean xpath1_check_node_exists | ( | xpath_pcb_t * | pcb, |
dlq_hdr_t * | resultQ, | ||
const val_value_t * | val | ||
) |
Check if any ancestor-ot-self node is already in the specified Q.
ONLY FOR VALUE NODES IN THE RESULT
This is only done after all the nodes have been processed and the nodeset is complete. For NETCONF purposes, the entire path to root is added for the context node, and the entire context node contexts are always returned
pcb | parser control block to use |
resultQ | Q of xpath_resnode_t structs to check DOES NOT HAVE TO BE WITHIN A RESULT NODE Q |
val | value node pointer value to find |
boolean xpath1_check_node_exists_slow | ( | xpath_pcb_t * | pcb, |
dlq_hdr_t * | resultQ, | ||
const val_value_t * | val | ||
) |
Check if any ancestor-ot-self node is already in the specified Q Slow version.
ONLY FOR VALUE NODES IN THE RESULT
This is only done after all the nodes have been processed and the nodeset is complete. For NETCONF purposes, the entire path to root is added for the context node, and the entire context node contexts are always returned
pcb | parser control block to use |
resultQ | Q of xpath_resnode_t structs to check DOES NOT HAVE TO BE WITHIN A RESULT NODE Q |
val | value node pointer value to find |
boolean xpath1_check_resnode_exists | ( | xpath_pcb_t * | pcb, |
dlq_hdr_t * | resultQ, | ||
xpath_resnode_t * | resnode | ||
) |
Check if any ancestor-ot-self node is already in the specified Q.
ONLY FOR VALUE NODES IN THE RESULT
This is only done after all the nodes have been processed and the nodeset is complete. For NETCONF purposes, the entire path to root is added for the context node, and the entire context node contexts are always returned
pcb | parser control block to use |
resultQ | Q of xpath_resnode_t structs to check DOES NOT HAVE TO BE WITHIN A RESULT NODE Q |
resnode | resnode to find |
boolean xpath1_check_when_object | ( | xpath_pcb_t * | pcb, |
obj_template_t * | obj | ||
) |
Check if the object is supposed to be deleted from the XPath context because of self-referencing when-stmt.
INTERNAL API
pcb | XPath control block to check |
obj | object pointer to check |
boolean xpath1_cmp_results | ( | xpath_pcb_t * | pcb, |
xpath_result_t * | val1, | ||
xpath_result_t * | val2, | ||
xpath_exop_t | exop, | ||
status_t * | res | ||
) |
Compare 2 results, using the specified logic operator.
pcb | parser control block to use | |
val1 | first result struct to compare | |
val2 | second result struct to compare | |
exop | XPath exression operator to use | |
[out] | res | address of resturn status
|
boolean xpath1_compare_nodeset_results | ( | xpath_pcb_t * | pcb, |
xpath_result_t * | result1, | ||
xpath_result_t * | result2, | ||
status_t * | res | ||
) |
Compare an XPath result to another result.
pcb | parser control block to use | |
result1 | result1 struct to compare | |
result2 | result2 struct to compare | |
[out] | res | address of return status
|
boolean xpath1_compare_result_to_number | ( | xpath_pcb_t * | pcb, |
xpath_result_t * | result, | ||
ncx_num_t * | numval, | ||
status_t * | res | ||
) |
Compare an XPath result to the specified number.
result = number
pcb | parser control block to use | |
result | result struct to compare | |
numval | number struct to compare to result MUST BE TYPE NCX_BT_FLOAT64 | |
[out] | res | address of return status
|
boolean xpath1_compare_result_to_string | ( | xpath_pcb_t * | pcb, |
xpath_result_t * | result, | ||
xmlChar * | strval, | ||
status_t * | res | ||
) |
Compare an XPath result to the specified string.
result = 'string'
pcb | parser control block to use | |
result | result struct to compare | |
strval | string value to compare to result | |
[out] | res | address of return status
|
void xpath1_dump_resnode | ( | log_debug_t | lvl, |
xpath_resnode_t * | resnode, | ||
const char * | banner | ||
) |
Generate log output displaying the contents of an XPath resnode.
Debugging function
lvl | debug level for output |
resnode | resnode to dump |
banner | optional first banner string to use |
void xpath1_dump_result | ( | log_debug_t | lvl, |
xpath_pcb_t * | pcb, | ||
xpath_result_t * | result, | ||
const char * | banner | ||
) |
Generate log output displaying the contents of a result.
Debugging function
lvl | debug level for output |
pcb | parser control block to use |
result | result to dump |
banner | optional first banner string to use |
xpath_result_t * xpath1_eval_expr | ( | xpath_pcb_t * | pcb, |
val_value_t * | val, | ||
val_value_t * | docroot, | ||
boolean | logerrors, | ||
boolean | configonly, | ||
status_t * | res | ||
) |
Evaluate an XPath expression use if the prefixes are YANG: must/when.
Evaluate the expression and get the expression nodeset result
pcb | XPath parser control block to use | |
val | start context node for value of current() | |
docroot | ptr to cfg->root or top of rpc/rpc-replay/notif tree | |
logerrors | TRUE if log_error and ncx_print_errormsg should be used to log XPath errors and warnings FALSE if internal error info should be recorded in the xpath_result_t struct instead | |
configonly | config mode XP_SRC_XML: TRUE if this is a <get-config> call and all config=false nodes should be skipped FALSE if <get> call and non-config nodes will not be skipped XP_SRC_YANG and XP_SRC_LEAFREF: should be set to false | |
[out] | res | address of return status
|
xpath_result_t * xpath1_eval_expr2 | ( | xpath_pcb_t * | pcb, |
val_value_t * | val, | ||
val_value_t * | docroot, | ||
boolean | logerrors, | ||
boolean | configonly, | ||
boolean | force_only, | ||
status_t * | res | ||
) |
Evaluate an XPath expression (alt)
use if the prefixes are YANG: must/when Evaluate the expression and get the expression nodeset result
pcb | XPath parser control block to use | |
val | start context node for value of current() | |
docroot | ptr to cfg->root or top of rpc/rpc-replay/notif tree | |
logerrors | TRUE if log_error and ncx_print_errormsg should be used to log XPath errors and warnings FALSE if internal error info should be recorded in the xpath_result_t struct instead | |
configonly | config mode XP_SRC_XML: TRUE if this is a <get-config> call and all config=false nodes should be skipped FALSE if <get> call and non-config nodes will not be skipped XP_SRC_YANG and XP_SRC_LEAFREF: should be set to false | |
force_only | TRUE to force configonly == FALSE | |
[out] | res | address of return status
|
xpath_result_t * xpath1_eval_expr3 | ( | xpath_pcb_t * | pcb, |
val_value_t * | val, | ||
val_value_t * | docroot, | ||
boolean | logerrors, | ||
boolean | configonly, | ||
boolean | force_only, | ||
xml_msg_hdr_t * | get2_mhdr, | ||
boolean | get_when, | ||
xpath_get2_node_t * | val_get2, | ||
status_t * | res | ||
) |
Evaluate an XPath expression (alt3)
use if the prefixes are YANG: must/when Evaluate the expression and get the expression nodeset result
pcb | XPath parser control block to use | |
val | start context node for value of current() | |
docroot | ptr to cfg->root or top of rpc/rpc-replay/notif tree | |
logerrors | TRUE if log_error and ncx_print_errormsg should be used to log XPath errors and warnings FALSE if internal error info should be recorded in the xpath_result_t struct instead | |
configonly | config mode XP_SRC_XML: TRUE if this is a <get-config> call and all config=false nodes should be skipped FALSE if <get> call and non-config nodes will not be skipped XP_SRC_YANG and XP_SRC_LEAFREF: should be set to false | |
force_only | TRUE to force configonly == FALSE | |
get2_mhdr | message header to use if GET2 callbacks will be used | |
get_when | TRUE if this eval is for a when-stmt in a data node so all the value will be retrieved instead of using temp values with a wlaker callback; FALSE == normal | |
val_get2 | XPAth GET2 node to use as the context node instead of 'val' | |
[out] | res | address of return status
|
status_t xpath1_eval_obj_expr | ( | xpath_pcb_t * | pcb | ) |
Evaluate an OBJECT expression.
pcb->exprstr must be set pcb->source must be set
pcb | the XPath parser control block to process
|
xpath_result_t * xpath1_eval_xmlexpr | ( | xmlTextReaderPtr | reader, |
xpath_pcb_t * | pcb, | ||
val_value_t * | val, | ||
val_value_t * | docroot, | ||
boolean | logerrors, | ||
boolean | configonly, | ||
status_t * | res | ||
) |
Evaluate an XML document expression.
use if the prefixes are XML: select Evaluate the expression and get the expression nodeset result Called from inside the XML parser, so the XML reader must be used to get the XML namespace to prefix mappings
reader | XML reader to use | |
pcb | XPath parser control block to use | |
val | start context node for value of current() | |
docroot | ptr to cfg->root or top of rpc/rpc-replay/notif tree | |
logerrors | TRUE if log_error and ncx_print_errormsg should be used to log XPath errors and warnings FALSE if internal error info should be recorded in the xpath_result_t struct instead | |
configonly | config mode XP_SRC_XML: TRUE if this is a <get-config> call and all config=false nodes should be skipped FALSE if <get> call and non-config nodes will not be skipped XP_SRC_YANG and XP_SRC_LEAFREF: should be set to false | |
[out] | res | address of return status
|
boolean xpath1_find_val_in_nodeset | ( | xpath_result_t * | result, |
const xmlChar * | valstr | ||
) |
Check a nodeset result and find the same value in one of the nodes.
result | result struct to compare |
valstr | value string to find |
boolean xpath1_find_val_in_nodeset_ex | ( | xpath_result_t * | result, |
val_value_t * | testval | ||
) |
Check a nodeset result and find the same value in one of the nodes.
Use val_value instead of plain string to make sure that in case of idref node the string value will be evaluated accordingly
result | result struct to compare |
testval | value to find and compare with |
const xpath_fncb_t * xpath1_fn_get_functions_ptr | ( | void | ) |
Get the start of the function array for XPath 1.0 plus the current() function.
boolean xpath1_keep_object | ( | obj_template_t * | testobj, |
boolean | textmode, | ||
xmlns_id_t | nsid, | ||
const xmlChar * | name | ||
) |
Test if an object should be kept in a resnode node-test.
Support for the node-test rule in XPath 1.0 Any test present can cause the node to be excluded Default is keep if all test params off
testobj | object to test |
textmode | true if testing for text nodes; false to ignore |
nsid | child node NSID or 0 for any |
name | child name or NULL if any |
status_t xpath1_parse_expr | ( | tk_chain_t * | tkc, |
ncx_module_t * | mod, | ||
xpath_pcb_t * | pcb, | ||
xpath_source_t | source | ||
) |
Parse the XPATH 1.0 expression string.
Main API entry point
parse initial expr with YANG prefixes: must/when the object is left out in case it is in a grouping
This is just a first pass done when the XPath string is consumed. If this is a YANG file source then the prefixes will be checked against the 'mod' import Q
The expression is parsed into XPath tokens and checked for well-formed syntax and function invocations. Any variable
If the source is XP_SRC_INSTANCEID, then YANG instance-identifier syntax is followed, not XPath 1.0 This is only used by instance-identifiers in default-stmt, conf file, CLI, etc.
Error messages are printed by this function!! Do not duplicate error messages upon error return
tkc | parent token chain | |
mod | module in progress | |
[in,out] | pcb | initialized xpath parser control block for the expression;
|
source | enum indicating source of this expression |
xpath_result_t * xpath1_parse_expr_int | ( | xpath_pcb_t * | pcb, |
status_t * | res | ||
) |
Parse an XPath Expr sequence It has already been tokenized.
Error messages are printed by this function!! Do not duplicate error messages upon error return
[14] Expr ::= OrExpr
pcb | parser control block in progress | |
[out] | res | address of result status
|
xpath_result_t * xpath1_parse_relational_expr_int | ( | xpath_pcb_t * | pcb, |
status_t * | res | ||
) |
Parse an XPath Relational Expr sequence It has already been tokenized.
pcb | parser control block in progress | |
[out] | res | address of result status
|
status_t xpath1_pred_parse_predicate | ( | xpath_pcb_t * | pcb, |
xpath_result_t ** | result | ||
) |
Parse an XPath Predicate sequence It has already been tokenized.
Error messages are printed by this function!! Do not duplicate error messages upon error return
[8] Predicate ::= '[' PredicateExpr ']' [9] PredicateExpr ::= Expr
pcb | parser control block in progress | |
[in,out] | result | address of result in progress to filter
|
void xpath1_prune_nodeset | ( | xpath_pcb_t * | pcb, |
xpath_result_t * | result | ||
) |
Check the current result nodeset and remove any redundant nodes from a NETCONF POV.
Any node that has an ancestor already in the result will be deleted
pcb | XPath parser control block to use | |
[in,out] | result | XPath result nodeset to prune
|
status_t xpath1_stringify_node | ( | xpath_pcb_t * | pcb, |
val_value_t * | val, | ||
xmlChar ** | str | ||
) |
Convert a value node to a string node.
string(node)
pcb | parser control block to use | |
val | value node to stringify | |
[out] | str | address of return string
|
status_t xpath1_stringify_nodeset | ( | xpath_pcb_t * | pcb, |
const xpath_result_t * | result, | ||
xmlChar ** | str | ||
) |
Convert a value node pointer to a string node.
ONLY FOR VALUE NODES IN THE RESULT
string(nodeset)
pcb | parser control block to use | |
result | result to stringify | |
[out] | str | address of return string
|
status_t xpath1_test_data_rule | ( | xpath_pcb_t * | pcb, |
getcb_get2_t * | get2cb, | ||
boolean * | testres | ||
) |
Test a NACM data rule expression against a GET2 control block.
Determine if the specified data node is covered by the rule in the pcb
pcb | the XPath parser control block to process | |
get2cb | GET2 control block to use | |
[out] | testres | address of test result
|
status_t xpath1_validate_expr | ( | ncx_module_t * | mod, |
obj_template_t * | obj, | ||
xpath_pcb_t * | pcb | ||
) |
Validate the previously parsed expression string.
parse expr with YANG prefixes: must/when called from final OBJ xpath check after all cooked objects are in place
Called after all 'uses' and 'augment' expansion so validation against cooked object tree can be done
Error messages are printed by this function!! Do not duplicate error messages upon error return
mod | module containing the 'obj' (in progress) | |
obj | object containing the XPath clause | |
[in,out] | pcb | the XPath parser control block to process
|
status_t xpath1_validate_expr_ex | ( | ncx_module_t * | mod, |
obj_template_t * | obj, | ||
xpath_pcb_t * | pcb, | ||
boolean | missing_is_error, | ||
boolean | set_backptrs, | ||
ncx_xpath_type_t | backptr_type | ||
) |
Validate the previously parsed expression string.
parse expr with YANG prefixes: must/when called from final OBJ xpath check after all cooked objects are in place
Called after all 'uses' and 'augment' expansion so validation against cooked object tree can be done
Error messages are printed by this function!! Do not duplicate error messages upon error return
mod | module containing the 'obj' (in progress) | |
obj | object containing the XPath clause | |
[in,out] | pcb | the XPath parser control block to process
|
missing_is_error | TRUE if a missing node is an error == FALSE if a warning | |
set_backptrs | TRUE if this is the special mode to go through the expression and set obj_template_t back ptrs; used only by the server is ncx_use_xpath_backptrs() == FALSE for normal mode | |
backptr_type | enum identifying xpath_backptr type ignored unless set_backptrs == TRUE |
status_t xpath1_validate_when_expr | ( | ncx_module_t * | mod, |
obj_template_t * | when_obj, | ||
obj_template_t * | context_obj, | ||
xpath_pcb_t * | pcb | ||
) |
Validate the previously parsed expression string WHEN-STMT.
mod | module containing the 'obj' (in progress) |
when_obj | object containing the XPath clause |
context_obj | object containing the XPath clause or augment target |
pcb | the XPath parser control block to process |
status_t xpath_wr_expr | ( | ses_cb_t * | scb, |
val_value_t * | xpathval | ||
) |
Write the specified XPath expression to the current session using the default prefixes.
The XPath pcb must be previously parsed and found valid
scb | session control block to use |
xpathval | the value containing the XPath expr to write |