Refined netconf none semantics in tests and text datastore

This commit is contained in:
Olof hagsand 2017-05-01 12:46:09 +02:00
parent 2f30bda7d4
commit 69ff0e3891
19 changed files with 247 additions and 91 deletions

View file

@ -521,12 +521,21 @@ xml_new_spec(char *name,
return x;
}
void *
xml_spec(cxobj *x)
{
return x->x_spec;
}
void *
xml_spec_set(cxobj *x,
void *spec)
{
x->x_spec = spec;
return 0;
}
/*! Find an XML node matching name among a parent's children.
*
* Get first XML node directly under x_up in the xml hierarchy with

View file

@ -63,6 +63,9 @@
#include "clixon_options.h"
#include "clixon_xml_db.h"
/* Set to log get and put requests */
#define DEBUG 0
/*! Load an xmldb storage plugin according to filename
* If init function fails (not found, wrong version, etc) print a log and dont
* add it.
@ -350,7 +353,7 @@ xmldb_get(clicon_handle h,
goto done;
}
retval = xa->xa_get_fn(xh, db, xpath, xtop, xvec, xlen);
#if 0 /* XXX DEBUG */
#if DEBUG
if (retval == 0) {
cbuf *cb = cbuf_new();
clicon_xml2cbuf(cb, *xtop, 0, 0);
@ -407,7 +410,7 @@ xmldb_put(clicon_handle h,
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
goto done;
}
#if 0 /* XXX DEBUG */
#if DEBUG
{
cbuf *cb = cbuf_new();
if (xt)

View file

@ -1076,16 +1076,23 @@ xmlkeyfmt2xpath(char *xkfmt,
return retval;
}
/*! Prune everything that has not been marked
/*! Prune everything that does not pass test
* @param[in] xt XML tree with some node marked
* @param[in] flag Which flag to test for
* @param[in] test 1: test that flag is set, 0: test that flag is not set
* @param[out] upmark Set if a child (recursively) has marked set.
* The function removes all branches that does not contain a marked child
* XXX: maybe key leafs should not be purged if list is not purged?
* XXX: consider move to clicon_xml
* The function removes all branches that does not a child that pass the test
* Purge all nodes that dont have MARK flag set recursively.
* Save all nodes that is MARK:ed or have at least one (grand*)child that is MARKed
* @code
* xml_tree_prune_flagged(xt, XML_FLAG_MARK, 1, NULL);
* @endcode
*/
int
xml_tree_prune_unmarked(cxobj *xt,
int *upmark)
xml_tree_prune_flagged(cxobj *xt,
int flag,
int test,
int *upmark)
{
int retval = -1;
int submark;
@ -1097,12 +1104,12 @@ xml_tree_prune_unmarked(cxobj *xt,
x = NULL;
xprev = x = NULL;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
if (xml_flag(x, XML_FLAG_MARK)){
if (xml_flag(x, flag) == test?flag:0){
mark++;
xprev = x;
continue; /* mark and stop here */
}
if (xml_tree_prune_unmarked(x, &submark) < 0)
if (xml_tree_prune_flagged(x, flag, test, &submark) < 0)
goto done;
if (submark)
mark++;

View file

@ -358,6 +358,13 @@ xpath_parse(char *xpath,
else if (strncmp(s,"descendant-or-self::", strlen("descendant-or-self::"))==0){
xpath_element_new(A_DESCENDANT_OR_SELF, s+strlen("descendant-or-self::"), &xpnext);
}
#if 1
else if (strncmp(s,"..", strlen(".."))==0) /* abbreviatedstep */
xpath_element_new(A_PARENT, s+strlen(".."), &xpnext);
#else
else if (strncmp(s,"..", strlen(s))==0) /* abbreviatedstep */
xpath_element_new(A_PARENT, NULL, &xpnext);
#endif
#if 1 /* Problems with .[userid=1321] */
else if (strncmp(s,".", strlen("."))==0)
xpath_element_new(A_SELF, s+strlen("."), &xpnext);
@ -368,13 +375,7 @@ xpath_parse(char *xpath,
else if (strncmp(s,"self::", strlen("self::"))==0)
xpath_element_new(A_SELF, s+strlen("self::"), &xpnext);
#if 1
else if (strncmp(s,"..", strlen(".."))==0) /* abbreviatedstep */
xpath_element_new(A_PARENT, s+strlen(".."), &xpnext);
#else
else if (strncmp(s,"..", strlen(s))==0) /* abbreviatedstep */
xpath_element_new(A_PARENT, NULL, &xpnext);
#endif
else if (strncmp(s,"parent::", strlen("parent::"))==0)
xpath_element_new(A_PARENT, s+strlen("parent::"), &xpnext);
else if (strncmp(s,"ancestor::", strlen("ancestor::"))==0)
@ -1076,7 +1077,7 @@ int
main(int argc, char **argv)
{
int i;
cxobj **xv;
cxobj **xv
cxobj *x;
cxobj *xn;
size_t xlen = 0;