leafref bug

This commit is contained in:
Olof Hagsand 2017-12-09 20:48:29 +01:00
parent 4742fde1e9
commit 0076a8b838
9 changed files with 91 additions and 42 deletions

View file

@ -56,6 +56,8 @@
#undef CLIXON_VERSION_MINOR
#undef CLIXON_VERSION_PATCH
#undef XML_COMPAT
/*
* Use this constant to disable some prototypes that should not be visible outside the lib.
* This is an alternative to use separate internal include files.

View file

@ -38,6 +38,10 @@
#ifndef _CLIXON_XML_H
#define _CLIXON_XML_H
/*
* Constants
*/
/*
* Types
*/
@ -113,12 +117,6 @@ cxobj *xml_child_each(cxobj *xparent, cxobj *xprev, enum cxobj_type type);
cxobj **xml_childvec_get(cxobj *x);
int xml_childvec_set(cxobj *x, int len);
#ifdef OBSOLETE /* Changed in 3.3.3, see CHANGELOG */
/* Changed: */
cxobj *xml_new(char *name, cxobj *xn_parent);
/* Removed: */
cxobj *xml_new_spec(char *name, cxobj *xn_parent, void *spec);
#endif
cxobj *xml_new(char *name, cxobj *xn_parent, yang_stmt *spec);
yang_stmt *xml_spec(cxobj *x);
int xml_spec_set(cxobj *x, yang_stmt *spec);
@ -142,15 +140,6 @@ int xml_free(cxobj *xn);
int xml_print(FILE *f, cxobj *xn);
int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint);
int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint);
#ifdef OBSOLETE /* Changed in 3.3.3, see CHANGELOG */
/* Changed: */
int clicon_xml_parse(cxobj **cxtop, char *format, ...);
int clicon_xml_parse_file(int fd, cxobj **xml_top, char *endtag);
int clicon_xml_parse_str(char *str, cxobj **xml_top);
/* Removed: */
int xml_parse(char *str, yang_spec *yspec, cxobj *xt);
int clicon_xml_parse_string(char **str, cxobj **xml_top);
#endif
int xml_parse_file(int fd, char *endtag, yang_spec *yspec, cxobj **xt);
int xml_parse_string(const char *str, yang_spec *yspec, cxobj **xml_top);
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...);
@ -180,4 +169,16 @@ int xml_hash_add(cxobj *x);
int xml_hash_rm_only(cxobj *x);
int xml_hash_rm_entry(cxobj *x);
#ifdef XML_COMPAT /* See CHANGELOG */
/* MANUAL CHANGE: xml_new(name, parent) --> xml_new(name, parent, NULL) */
#define xml_new_spec(name, parent) xml_new(name, parent, NULL)
#define clicon_xml_parse(xt, fmt, ...) xml_parse_va(xt, NULL, fmt, __VA_ARGS__)
#define clicon_xml_parse_file(fd, xt, etag) xml_parse_file(fd, etag, NULL, xt)
#define clicon_xml_parse_string(strp, xt) xml_parse_string(*strp, NULL, xt)
#define clicon_xml_parse_str(str, xt) xml_parse_string(str, NULL, xt)
#define xml_parse(str, xt) xml_parse_string(str, NULL, &xt)
#endif
#endif /* _CLIXON_XML_H */

View file

@ -955,12 +955,14 @@ clicon_xml2file(FILE *f,
cxobj *xc;
int hasbody;
int haselement;
char *val;
name = xml_name(x);
namespace = xml_namespace(x);
switch(xml_type(x)){
case CX_BODY:
fprintf(f, "%s", xml_value(x));
if ((val = xml_value(x)) != NULL) /* incomplete tree */
fprintf(f, "%s", xml_value(x));
break;
case CX_ATTR:
fprintf(f, " ");
@ -1191,7 +1193,7 @@ xmltree2cbuf(cbuf *cb,
* @see xml_parse_va
*/
static int
xml_parse(const char *str,
_xml_parse(const char *str,
yang_spec *yspec,
cxobj *xt)
{
@ -1297,7 +1299,7 @@ xml_parse_file(int fd,
if (*xt == NULL)
if ((*xt = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
goto done;
if (xml_parse(ptr, yspec, *xt) < 0)
if (_xml_parse(ptr, yspec, *xt) < 0)
goto done;
break;
}
@ -1349,7 +1351,7 @@ xml_parse_string(const char *str,
if (*xtop == NULL)
if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
return -1;
return xml_parse(str, yspec, *xtop);
return _xml_parse(str, yspec, *xtop);
}
/*! Read XML from var-arg list and parse it into xml tree
@ -1397,7 +1399,7 @@ xml_parse_va(cxobj **xtop,
if (*xtop == NULL)
if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
goto done;
if (xml_parse(str, yspec, *xtop) < 0)
if (_xml_parse(str, yspec, *xtop) < 0)
goto done;
retval = 0;
done:

View file

@ -680,10 +680,8 @@ match_base_child(cxobj *x0,
cvi = NULL; i = 0;
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi);
if ((b1 = xml_find_body(x1c, keyname)) == NULL){
clicon_err(OE_UNIX, errno, "key %s not found", keyname);
goto done;
}
if ((b1 = xml_find_body(x1c, keyname)) == NULL)
goto ok; /* not found */
b1vec[i++] = b1;
}
/* Iterate over x0 tree to (1) find a child that matches name