Misc formatting
This commit is contained in:
parent
43d9bc845d
commit
3be786c211
7 changed files with 165 additions and 168 deletions
|
|
@ -1733,6 +1733,10 @@ cli_restart_plugin(clixon_handle h,
|
||||||
|
|
||||||
/* Append cvv1 to cvv0 and return a new cvec
|
/* Append cvv1 to cvv0 and return a new cvec
|
||||||
*
|
*
|
||||||
|
* @param[in] cvv0 First cvv
|
||||||
|
* @param[in] cvv1 Second cvv
|
||||||
|
* @retval cvv New cvv, free with cvec_free
|
||||||
|
* @retval NULL Error
|
||||||
* @note if cvv0 is non-null, the first element of cvv1 is skipped
|
* @note if cvv0 is non-null, the first element of cvv1 is skipped
|
||||||
*/
|
*/
|
||||||
cvec*
|
cvec*
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,8 @@ clicon_db_elmnt_set(clixon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xmldb_db2file1(clixon_handle h,
|
xmldb_db2file1(clixon_handle h,
|
||||||
const char *db,
|
const char *db,
|
||||||
int multi,
|
int multi,
|
||||||
char **filename)
|
char **filename)
|
||||||
{
|
{
|
||||||
|
|
@ -206,10 +206,10 @@ xmldb_db2subdir(clixon_handle h,
|
||||||
const char *db,
|
const char *db,
|
||||||
char **subdirp)
|
char **subdirp)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
char *dir;
|
char *dir;
|
||||||
char *subdir = NULL;
|
char *subdir = NULL;
|
||||||
|
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
clixon_err(OE_XML, errno, "cbuf_new");
|
clixon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,6 @@ xml_copy_bottom_recurse(cxobj *x0t,
|
||||||
if (xml_copy(x0k, x1k) < 0)
|
if (xml_copy(x0k, x1k) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (xml_sort(x1p) < 0)
|
if (xml_sort(x1p) < 0)
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ text2file(cxobj *xn,
|
||||||
else{
|
else{
|
||||||
*leafl = 0;
|
*leafl = 0;
|
||||||
*leaflname = NULL;
|
*leaflname = NULL;
|
||||||
(*fn)(f, "%*s\n", PRETTYPRINT_INDENT*(level), "]");
|
(*fn)(f, "%*s]\n", PRETTYPRINT_INDENT*(level), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xc = NULL; /* count children (elements and bodies, not attributes) */
|
xc = NULL; /* count children (elements and bodies, not attributes) */
|
||||||
|
|
@ -260,7 +260,7 @@ text2file(cxobj *xn,
|
||||||
/* Stop leaf-list printing (ie []) if no longer leaflist and same name */
|
/* Stop leaf-list printing (ie []) if no longer leaflist and same name */
|
||||||
if (yn && yang_keyword_get(yn) != Y_LEAF_LIST && *leafl != 0){
|
if (yn && yang_keyword_get(yn) != Y_LEAF_LIST && *leafl != 0){
|
||||||
*leafl = 0;
|
*leafl = 0;
|
||||||
(*fn)(f, "%*s\n", PRETTYPRINT_INDENT*(level+1), "]");
|
(*fn)(f, "%*s]\n", PRETTYPRINT_INDENT*(level+1), "");
|
||||||
}
|
}
|
||||||
if (!tleaf(xn))
|
if (!tleaf(xn))
|
||||||
(*fn)(f, "%*s}\n", PRETTYPRINT_INDENT*level, "");
|
(*fn)(f, "%*s}\n", PRETTYPRINT_INDENT*level, "");
|
||||||
|
|
|
||||||
|
|
@ -1970,10 +1970,10 @@ done:
|
||||||
* until nodes marked with XML_FLAG_MARK are reached, where
|
* until nodes marked with XML_FLAG_MARK are reached, where
|
||||||
* (2) the complete subtree of that node is copied.
|
* (2) the complete subtree of that node is copied.
|
||||||
* (3) Special case: key nodes in lists are copied if any node in list is marked
|
* (3) Special case: key nodes in lists are copied if any node in list is marked
|
||||||
* @param[in] x0
|
* @param[in] x0 XML tree source
|
||||||
* @param[in] x1
|
* @param[in] x1 XML tree target
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @note you may want to check:!yang_config(ys)
|
* @note you may want to check:!yang_config(ys)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,16 @@
|
||||||
|
|
||||||
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
|
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
|
||||||
*
|
*
|
||||||
* Note on xcur parameter to most xpath functions:
|
* Note on xcur parameter to most XPath functions:
|
||||||
* The W3 standard defines the document root / element as the top-level.
|
* The W3 standard defines the document root / element as the top-level.
|
||||||
* In the clixon xpath API, the document root is defined as the top of the xml tree.
|
* In the clixon XPath API, the document root is defined as the top of the xml tree.
|
||||||
* The xcur argument of xpath_first and others is the "current" xml node (xcur) which can
|
* The xcur argument of XPath_first and others is the "current" xml node (xcur) which can
|
||||||
* be any node in that tree, not necessarily the document root.
|
* be any node in that tree, not necessarily the document root.
|
||||||
* This is convenient if you want to use relative xpaths from any location in the tree (eg ../../foo/bar).
|
* This is convenient if you want to use relative XPaths from any location in the tree (eg ../../foo/bar).
|
||||||
* It may be confusing if you expect xcur to be the root node.
|
* It may be confusing if you expect xcur to be the root node.
|
||||||
*
|
*
|
||||||
* Some notes on namespace extensions in Netconf/Yang
|
* Some notes on namespace extensions in Netconf/Yang
|
||||||
* 1) The xpath is not "namespace-aware" in the sense that if you look for a path, eg
|
* 1) The XPath is not "namespace-aware" in the sense that if you look for a path, eg
|
||||||
* "n:a/n:b", those must match the XML, so they need to match prefixes AND name in the xml
|
* "n:a/n:b", those must match the XML, so they need to match prefixes AND name in the xml
|
||||||
* such as <n:a><n:b>. An xml with <m:a><m:b> (or <a><b>) will NOT match EVEN IF they have the
|
* such as <n:a><n:b>. An xml with <m:a><m:b> (or <a><b>) will NOT match EVEN IF they have the
|
||||||
* same namespace given by xmlns settings.
|
* same namespace given by xmlns settings.
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
* select="/t:top/t:users/t:user[t:name='fred']"/>
|
* select="/t:top/t:users/t:user[t:name='fred']"/>
|
||||||
* </get-config>
|
* </get-config>
|
||||||
* One observation is that the namespace context is static, so it can not be a part
|
* One observation is that the namespace context is static, so it can not be a part
|
||||||
* of the xpath-tree, which is context-dependent.
|
* of the XPath-tree, which is context-dependent.
|
||||||
* Best is to send it as a (read-only) parameter to the xp_eval family of functions
|
* Best is to send it as a (read-only) parameter to the xp_eval family of functions
|
||||||
* as an exlicit namespace context.
|
* as an exlicit namespace context.
|
||||||
* 3) localonly flag refers to https://www.w3.org/TR/REC-xml-names/, where :
|
* 3) localonly flag refers to https://www.w3.org/TR/REC-xml-names/, where :
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
#include "clixon_xpath_parse.h"
|
#include "clixon_xpath_parse.h"
|
||||||
#include "clixon_xpath_eval.h"
|
#include "clixon_xpath_eval.h"
|
||||||
|
|
||||||
/* Use apostrophe(') in xpath literals, eg a/[x='foo'], not double-quotes(")
|
/* Use apostrophe(') in XPath literals, eg a/[x='foo'], not double-quotes(")
|
||||||
* If not set, use ": a/[x="foo"]
|
* If not set, use ": a/[x="foo"]
|
||||||
* Advantage with ' is it works well in clispecs, " must be escaped
|
* Advantage with ' is it works well in clispecs, " must be escaped
|
||||||
* @see https://www.w3.org/TR/xpath-10/#NT-Literal
|
* @see https://www.w3.org/TR/xpath-10/#NT-Literal
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
* Variables
|
* Variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Mapping between xpath_tree node name string <--> int
|
/* Mapping between XPath_tree node name string <--> int
|
||||||
* @see xpath_tree_int2str
|
* @see xpath_tree_int2str
|
||||||
*/
|
*/
|
||||||
static const map_str2int xpath_tree_map[] = {
|
static const map_str2int xpath_tree_map[] = {
|
||||||
|
|
@ -179,7 +179,7 @@ axis_type_str2int(char *name)
|
||||||
return clicon_str2int(axis_type_map, name);
|
return clicon_str2int(axis_type_map, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Map from xpath_tree node name int to string
|
/*! Map from XPath_tree node name int to string
|
||||||
*/
|
*/
|
||||||
char*
|
char*
|
||||||
xpath_tree_int2str(int nodetype)
|
xpath_tree_int2str(int nodetype)
|
||||||
|
|
@ -220,7 +220,7 @@ xpath_tree_print0(cbuf *cb,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Print a xpath_tree to CLIgen buf
|
/*! Print a XPath_tree to CLIgen buf
|
||||||
*
|
*
|
||||||
* @param[out] cb CLIgen buffer
|
* @param[out] cb CLIgen buffer
|
||||||
* @param[in] xs XPath tree
|
* @param[in] xs XPath tree
|
||||||
|
|
@ -233,7 +233,7 @@ xpath_tree_print_cb(cbuf *cb,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Print a xpath_tree
|
/*! Print a XPath_tree
|
||||||
*
|
*
|
||||||
* @param[in] f UNIX output stream
|
* @param[in] f UNIX output stream
|
||||||
* @param[in] xs XPath tree
|
* @param[in] xs XPath tree
|
||||||
|
|
@ -260,7 +260,7 @@ xpath_tree_print(FILE *f,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Create an xpath string from an xpath tree, ie "unparsing"
|
/*! Create an XPath string from an XPath tree, ie "unparsing"
|
||||||
*
|
*
|
||||||
* @param[in] xs XPath tree
|
* @param[in] xs XPath tree
|
||||||
* @param[out] xpath XPath string as CLIgen buf
|
* @param[out] xpath XPath string as CLIgen buf
|
||||||
|
|
@ -392,7 +392,7 @@ xpath_tree_append(xpath_tree *xt,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Check if two xpath-trees (parsed xpaths) ar equal
|
/*! Check if two xpath-trees (parsed XPaths) ar equal
|
||||||
*
|
*
|
||||||
* @param[in] xt1 XPath parse 1
|
* @param[in] xt1 XPath parse 1
|
||||||
* @param[in] xt2 XPath parse 2
|
* @param[in] xt2 XPath parse 2
|
||||||
|
|
@ -515,7 +515,7 @@ xpath_tree_traverse(xpath_tree *xt,
|
||||||
return xs;
|
return xs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Free a xpath_tree
|
/*! Free a XPath_tree
|
||||||
*
|
*
|
||||||
* @param[in] xs XPath tree
|
* @param[in] xs XPath tree
|
||||||
* @see xpath_parse creates a xpath_tree
|
* @see xpath_parse creates a xpath_tree
|
||||||
|
|
@ -537,7 +537,7 @@ xpath_tree_free(xpath_tree *xs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given xpath, parse it, and return structured xpath tree
|
/*! Given XPath, parse it, and return structured XPath tree
|
||||||
*
|
*
|
||||||
* @param[in] xpath String with XPath 1.0 syntax
|
* @param[in] xpath String with XPath 1.0 syntax
|
||||||
* @param[out] xptree XPath-tree, parsed, structured XPath, free:xpath_tree_free
|
* @param[out] xptree XPath-tree, parsed, structured XPath, free:xpath_tree_free
|
||||||
|
|
@ -551,7 +551,7 @@ xpath_tree_free(xpath_tree *xs)
|
||||||
* xpath_tree_free(xpt);
|
* xpath_tree_free(xpt);
|
||||||
* @endcode
|
* @endcode
|
||||||
* @see xpath_tree_free
|
* @see xpath_tree_free
|
||||||
* @see xpath_tree2cbuf for unparsing, ie producing an original xpath string
|
* @see xpath_tree2cbuf for unparsing, ie producing an original XPath string
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpath_parse(const char *xpath,
|
xpath_parse(const char *xpath,
|
||||||
|
|
@ -604,9 +604,9 @@ xpath_parse(const char *xpath,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given XML tree and xpath, parse xpath, eval it and return xpath context,
|
/*! Given XML tree and XPath, parse XPath, eval it and return XPath context,
|
||||||
*
|
*
|
||||||
* This is a raw form of xpath where you can do type conversion of the return
|
* This is a raw form of XPath where you can do type conversion of the return
|
||||||
* value, etc, not just a nodeset.
|
* value, etc, not just a nodeset.
|
||||||
* @param[in] xcur XML-tree where to search
|
* @param[in] xcur XML-tree where to search
|
||||||
* @param[in] nsc External XML namespace context, or NULL
|
* @param[in] nsc External XML namespace context, or NULL
|
||||||
|
|
@ -775,7 +775,7 @@ xpath_first_localonly(cxobj *xcur,
|
||||||
return cx;
|
return cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given XML tree and xpath, returns nodeset as xml node vector
|
/*! Given XML tree and XPath, returns nodeset as xml node vector
|
||||||
*
|
*
|
||||||
* If result is not nodeset, return empty nodeset
|
* If result is not nodeset, return empty nodeset
|
||||||
* @param[in] xcur xml-tree where to search
|
* @param[in] xcur xml-tree where to search
|
||||||
|
|
@ -815,12 +815,12 @@ xpath_vec(cxobj *xcur,
|
||||||
va_start(ap, veclen);
|
va_start(ap, veclen);
|
||||||
len = vsnprintf(NULL, 0, xpformat, ap);
|
len = vsnprintf(NULL, 0, xpformat, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
/* allocate an xpath string exactly fitting the length */
|
/* allocate an XPath string exactly fitting the length */
|
||||||
if ((xpath = malloc(len+1)) == NULL){
|
if ((xpath = malloc(len+1)) == NULL){
|
||||||
clixon_err(OE_UNIX, errno, "malloc");
|
clixon_err(OE_UNIX, errno, "malloc");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* second round: actually compute xpath string content */
|
/* second round: actually compute XPath string content */
|
||||||
va_start(ap, veclen);
|
va_start(ap, veclen);
|
||||||
if (vsnprintf(xpath, len+1, xpformat, ap) < 0){
|
if (vsnprintf(xpath, len+1, xpformat, ap) < 0){
|
||||||
clixon_err(OE_UNIX, errno, "vsnprintf");
|
clixon_err(OE_UNIX, errno, "vsnprintf");
|
||||||
|
|
@ -926,7 +926,7 @@ xpath_vec_flag(cxobj *xcur,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given XML tree and xpath, returns boolean
|
/*! Given XML tree and XPath, returns boolean
|
||||||
*
|
*
|
||||||
* Returns true if the nodeset is non-empty
|
* Returns true if the nodeset is non-empty
|
||||||
* @param[in] xcur xml-tree where to search
|
* @param[in] xcur xml-tree where to search
|
||||||
|
|
@ -1028,10 +1028,10 @@ traverse_canonical_str(xpath_tree *xs,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Translate an xpath/nsc pair to a "canonical" form using yang prefixes
|
/*! Translate an XPath/nsc pair to a "canonical" form using yang prefixes
|
||||||
*
|
*
|
||||||
* Returns new namespace context and rewrites the xpath tree
|
* Returns new namespace context and rewrites the XPath tree
|
||||||
* @param[in] xs Parsed xpath - xpath_tree
|
* @param[in] xs Parsed XPath - xpath_tree
|
||||||
* @param[in] yspec Yang spec containing all modules, associated with namespaces
|
* @param[in] yspec Yang spec containing all modules, associated with namespaces
|
||||||
* @param[in] nsc0 Input namespace context
|
* @param[in] nsc0 Input namespace context
|
||||||
* @param[in] exprstr Interpret strings as <prefix>:<name> (primaryexpr/literal/string)
|
* @param[in] exprstr Interpret strings as <prefix>:<name> (primaryexpr/literal/string)
|
||||||
|
|
@ -1040,7 +1040,7 @@ traverse_canonical_str(xpath_tree *xs,
|
||||||
* @retval 1 OK with nsc1 containing the transformed nsc
|
* @retval 1 OK with nsc1 containing the transformed nsc
|
||||||
* @retval 0 XPath failure with reason set to why
|
* @retval 0 XPath failure with reason set to why
|
||||||
* @retval -1 Fatal Error
|
* @retval -1 Fatal Error
|
||||||
* @note Setting str to 1 requires a knowledge of the context of the xpath, ie that strings are
|
* @note Setting str to 1 requires a knowledge of the context of the XPath, ie that strings are
|
||||||
* something like identityref and is safe to translate into canonical form
|
* something like identityref and is safe to translate into canonical form
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
|
@ -1143,13 +1143,13 @@ xpath_traverse_canonical(xpath_tree *xs,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Translate an xpath/nsc pair to a "canonical" form using yang prefixes
|
/*! Translate an XPath/nsc pair to a "canonical" form using yang prefixes
|
||||||
*
|
*
|
||||||
* @param[in] xpath0 Input xpath
|
* @param[in] xpath0 Input XPath
|
||||||
* @param[in] nsc0 Input namespace context
|
* @param[in] nsc0 Input namespace context
|
||||||
* @param[in] yspec Yang spec containing all modules, associated with namespaces
|
* @param[in] yspec Yang spec containing all modules, associated with namespaces
|
||||||
* @param[in] exprstr Interpret strings as <prefix>:<name> (primaryexpr/literal/string)
|
* @param[in] exprstr Interpret strings as <prefix>:<name> (primaryexpr/literal/string)
|
||||||
* @param[out] xpath1 Output xpath. Free after use
|
* @param[out] xpath1 Output XPath. Free after use
|
||||||
* @param[out] nsc1 Output namespace context. Free after use with xml_nsctx_free
|
* @param[out] nsc1 Output namespace context. Free after use with xml_nsctx_free
|
||||||
* @param[out] cbreason reason if retval = 0
|
* @param[out] cbreason reason if retval = 0
|
||||||
* @retval 1 OK, xpath1 and nsc1 allocated
|
* @retval 1 OK, xpath1 and nsc1 allocated
|
||||||
|
|
@ -1175,7 +1175,7 @@ xpath_traverse_canonical(xpath_tree *xs,
|
||||||
* if (nsc1) xml_nsctx_free(nsc1);
|
* if (nsc1) xml_nsctx_free(nsc1);
|
||||||
* if (reason) cbuf_free(reason);
|
* if (reason) cbuf_free(reason);
|
||||||
* @endcode
|
* @endcode
|
||||||
* @note Unsolvable issue of mountpoints, eg an xpath of //x:foo where foo is under one or several
|
* @note Unsolvable issue of mountpoints, eg an XPath of //x:foo where foo is under one or several
|
||||||
* mountpoints: a well-defined namespace cannot be determined. Therefore just allow
|
* mountpoints: a well-defined namespace cannot be determined. Therefore just allow
|
||||||
* inconsistencies and hope that it will be covered by other code
|
* inconsistencies and hope that it will be covered by other code
|
||||||
* @see xpath2xml
|
* @see xpath2xml
|
||||||
|
|
@ -1294,12 +1294,12 @@ xpath_count(cxobj *xcur,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given an XML node, build an xpath recursively to root, internal function
|
/*! Given an XML node, build an XPath recursively to root, internal function
|
||||||
*
|
*
|
||||||
* @param[in] x XML object
|
* @param[in] x XML object
|
||||||
* @param[in] nsc Namespace context
|
* @param[in] nsc Namespace context
|
||||||
* @param[in] spec If set, recursively continue only to root without spec
|
* @param[in] spec If set, recursively continue only to root without spec
|
||||||
* @param[in] apostrophe If set, use apostrophe in xpath literals, eg a/[x='foo'], not double-quotes(") * @param[out] cb XPath string as cbuf.
|
* @param[in] apostrophe If set, use apostrophe in XPath literals, eg a/[x='foo'], not double-quotes(") * @param[out] cb XPath string as cbuf.
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error. eg XML malformed
|
* @retval -1 Error. eg XML malformed
|
||||||
*/
|
*/
|
||||||
|
|
@ -1407,18 +1407,18 @@ xml2xpath1(cxobj *x,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given an XML node, build an xpath to root
|
/*! Given an XML node, build an XPath to root
|
||||||
*
|
*
|
||||||
* Creates an XPath from an XML node with some limitations, see notes below.
|
* Creates an XPath from an XML node with some limitations, see notes below.
|
||||||
* The prefixes used are from the given namespace context if any, otherwise the native prefixes are used, if any.
|
* The prefixes used are from the given namespace context if any, otherwise the native prefixes are used, if any.
|
||||||
* Note that this means that prefixes may be translated such as if the XML namespace mapping is different than the once used
|
* Note that this means that prefixes may be translated such as if the XML namespace mapping is different than the once used
|
||||||
* in the XML.
|
* in the XML.
|
||||||
* Therefore, if nsc is "canonical", the returned xpath is also "canonical", even though the XML is not.
|
* Therefore, if nsc is "canonical", the returned XPath is also "canonical", even though the XML is not.
|
||||||
* @param[in] x XML object
|
* @param[in] x XML object
|
||||||
* @param[in] nsc Namespace context
|
* @param[in] nsc Namespace context
|
||||||
* @param[in] spec If set, recursively continue only to root without spec (added in 6.1 for yang mount)
|
* @param[in] spec If set, recursively continue only to root without spec (added in 6.1 for yang mount)
|
||||||
* @param[in] apostrophe If set, use apostrophe in xpath literals, eg a/[x='foo'], not double-quotes(")
|
* @param[in] apostrophe If set, use apostrophe in XPath literals, eg a/[x='foo'], not double-quotes(")
|
||||||
* @param[out] xpath Malloced xpath string. Need to free() after use
|
* @param[out] xpath Malloced XPath string. Need to free() after use
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error. (eg XML malformed)
|
* @retval -1 Error. (eg XML malformed)
|
||||||
* @code
|
* @code
|
||||||
|
|
@ -1430,7 +1430,7 @@ xml2xpath1(cxobj *x,
|
||||||
* free(xpath);
|
* free(xpath);
|
||||||
* @endcode
|
* @endcode
|
||||||
* @note x needs to be bound to YANG, see eg xml_bind_yang()
|
* @note x needs to be bound to YANG, see eg xml_bind_yang()
|
||||||
* @note namespaces of xpath is not well-defined, follows xml, should be canonical?
|
* @note namespaces of XPath is not well-defined, follows xml, should be canonical?
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml2xpath(cxobj *x,
|
xml2xpath(cxobj *x,
|
||||||
|
|
@ -1465,16 +1465,16 @@ xml2xpath(cxobj *x,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Create xml tree from xpath as xpath-tree
|
/*! Create xml tree from XPath as xpath-tree
|
||||||
*
|
*
|
||||||
* @param[in] xs Parsed xpath - xpath_tree
|
* @param[in] xs Parsed XPath - xpath_tree
|
||||||
* @param[in] nsc Namespace context for xpath
|
* @param[in] nsc Namespace context for XPath
|
||||||
* @param[in] x0 XML tree so far
|
* @param[in] x0 XML tree so far
|
||||||
* @param[out] xbotp Resulting xml tree (end of xpath) (optional)
|
* @param[out] xbotp Resulting xml tree (end of XPath) (optional)
|
||||||
* @param[out] xerr Netconf error message (if retval=0)
|
* @param[out] xerr Netconf error message (if retval=0)
|
||||||
* @retval 1 OK
|
* @retval 1 OK
|
||||||
* @retval 0 Invalid xpath
|
* @retval 0 Invalid XPath
|
||||||
* @retval -1 Fatal error, clixon_err called
|
* @retval -1 Fatal error, clixon_err called
|
||||||
* @see xpath_traverse_canonical
|
* @see xpath_traverse_canonical
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
|
@ -1572,18 +1572,18 @@ xpath2xml_traverse(xpath_tree *xs,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Create xml tree from restricted xpath
|
/*! Create xml tree from restricted XPath
|
||||||
*
|
*
|
||||||
* Create an XML tree from "scratch" using xpath.
|
* Create an XML tree from "scratch" using XPath.
|
||||||
* @param[in] xpath (Absolute) XPath
|
* @param[in] xpath (Absolute) XPath
|
||||||
* @param[in] nsc Namespace context for xpath
|
* @param[in] nsc Namespace context for xpath
|
||||||
* @param[in,out] xtop Incoming XML tree
|
* @param[in,out] xtop Incoming XML tree
|
||||||
* @param[in] yspec Yang spec for xtop
|
* @param[in] yspec Yang spec for xtop
|
||||||
* @param[out] xbotp Resulting xml tree (end of xpath) (optional)
|
* @param[out] xbotp Resulting xml tree (end of XPath) (optional)
|
||||||
* @param[out] ybotp Yang spec matching xpathp
|
* @param[out] ybotp Yang spec matching xpathp
|
||||||
* @param[out] xerr Netconf error message (if retval=0)
|
* @param[out] xerr Netconf error message (if retval=0)
|
||||||
* @retval 1 OK
|
* @retval 1 OK
|
||||||
* @retval 0 Invalid xpath
|
* @retval 0 Invalid XPath
|
||||||
* @retval -1 Fatal error, clixon_err called
|
* @retval -1 Fatal error, clixon_err called
|
||||||
* @see api_path2xml
|
* @see api_path2xml
|
||||||
* @see xml2xpath
|
* @see xml2xpath
|
||||||
|
|
@ -1608,12 +1608,12 @@ xpath2xml(char *xpath,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (*xpath != '/'){
|
if (*xpath != '/'){
|
||||||
cprintf(cberr, "Invalid absolute xpath: %s (must start with '/')", xpath);
|
cprintf(cberr, "Invalid absolute XPath: %s (must start with '/')", xpath);
|
||||||
if (xerr && netconf_invalid_value_xml(xerr, "application", cbuf_get(cberr)) < 0)
|
if (xerr && netconf_invalid_value_xml(xerr, "application", cbuf_get(cberr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* Parse input xpath into an xpath-tree */
|
/* Parse input XPath into an xpath-tree */
|
||||||
if (xpath_parse(xpath, &xpt) < 0)
|
if (xpath_parse(xpath, &xpt) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((retval = xpath2xml_traverse(xpt, nsc, xtop, ytop, xbotp, ybotp, xerr)) < 1)
|
if ((retval = xpath2xml_traverse(xpt, nsc, xtop, ytop, xbotp, ybotp, xerr)) < 1)
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,6 @@
|
||||||
#include "clixon_xml_map.h"
|
#include "clixon_xml_map.h"
|
||||||
#include "clixon_yang_parse_lib.h"
|
#include "clixon_yang_parse_lib.h"
|
||||||
|
|
||||||
/*! Force add ietf-yang-library@2019-01-04 on all mount-points
|
|
||||||
*
|
|
||||||
* This is a limitation of of the current implementation
|
|
||||||
*/
|
|
||||||
#define YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
|
|
||||||
|
|
||||||
/*! Create modstate structure
|
/*! Create modstate structure
|
||||||
*
|
*
|
||||||
* @retval md modstate struct
|
* @retval md modstate struct
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue