Refined netconf none semantics in tests and text datastore
This commit is contained in:
parent
2f30bda7d4
commit
69ff0e3891
19 changed files with 247 additions and 91 deletions
|
|
@ -67,6 +67,7 @@ typedef int (xml_applyfn_t)(cxobj *yn, void *arg);
|
|||
#define XML_FLAG_ADD 0x02 /* Node is added (commits) or parent added rec*/
|
||||
#define XML_FLAG_DEL 0x04 /* Node is deleted (commits) or parent deleted rec */
|
||||
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
||||
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
@ -102,6 +103,7 @@ int xml_childvec_set(cxobj *x, int len);
|
|||
cxobj *xml_new(char *name, cxobj *xn_parent);
|
||||
cxobj *xml_new_spec(char *name, cxobj *xn_parent, void *spec);
|
||||
void *xml_spec(cxobj *x);
|
||||
void *xml_spec_set(cxobj *x, void *spec);
|
||||
cxobj *xml_find(cxobj *xn_parent, char *name);
|
||||
|
||||
int xml_addsub(cxobj *xp, cxobj *xc);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ typedef int (xmldb_delete_t)(xmldb_handle xh, char *db);
|
|||
/* Type of xmldb init function */
|
||||
typedef int (xmldb_init_t)(xmldb_handle xh, char *db);
|
||||
|
||||
/* grideye agent plugin init struct for the api */
|
||||
/* plugin init struct for the api */
|
||||
struct xmldb_api{
|
||||
int xa_version;
|
||||
int xa_magic;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ int xml_diff(yang_spec *yspec, cxobj *xt1, cxobj *xt2,
|
|||
int yang2xmlkeyfmt(yang_stmt *ys, int inclkey, char **xkfmt);
|
||||
int xmlkeyfmt2key(char *xkfmt, cvec *cvv, char **xk);
|
||||
int xmlkeyfmt2xpath(char *xkfmt, cvec *cvv, char **xk);
|
||||
int xml_tree_prune_unmarked(cxobj *xt, int *upmark);
|
||||
int xml_tree_prune_flagged(cxobj *xt, int flag, int test, int *upmark);
|
||||
int xml_default(cxobj *x, void *arg);
|
||||
int xml_order(cxobj *x, void *arg);
|
||||
int xml_sanity(cxobj *x, void *arg);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue