stricter xml populate made some cornercase errors appear
This commit is contained in:
parent
bab3b5ad56
commit
3855508622
4 changed files with 17 additions and 5 deletions
|
|
@ -365,7 +365,7 @@ api_data_write(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
if ((xdata0 = xml_new("data0", NULL, NULL)) == NULL)
|
if ((xdata0 = xml_new("data0", NULL, NULL)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
{ /* XXX mv to copy? */
|
if (api_path){ /* XXX mv to copy? */
|
||||||
cxobj *xfrom;
|
cxobj *xfrom;
|
||||||
cxobj *xac;
|
cxobj *xac;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,13 @@
|
||||||
*/
|
*/
|
||||||
#define XML_EXPLICIT_INDEX
|
#define XML_EXPLICIT_INDEX
|
||||||
|
|
||||||
/*! Treat <config> specially in a xmldb datastore.
|
/*! Treat <config> and <data> specially in a xmldb datastore.
|
||||||
* config is treated as a "neutral" tag that does not have a yang spec.
|
* config/data is treated as a "neutral" tag that does not have a yang spec.
|
||||||
* In particular when binding xml to yang, if <config> is encountered as top-of-tree, do not
|
* In particular when binding xml to yang, if <config> is encountered as top-of-tree, do not
|
||||||
* try to bind a yang-spec to this symbol.
|
* try to bind a yang-spec to this symbol.
|
||||||
|
* The root of this is GET and PUT commands where the <config> and <data> tag belongs to the
|
||||||
|
* RPC rather than the data.
|
||||||
|
* This is a hack, there must be a way to make this more generic
|
||||||
*/
|
*/
|
||||||
#define XMLDB_CONFIG_HACK
|
#define XMLDB_CONFIG_HACK
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -436,12 +436,14 @@ _xml_parse(const char *str,
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
failed++;
|
failed++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YB_TOP:
|
case YB_TOP:
|
||||||
/* xt:<top> nospec
|
/* xt:<top> nospec
|
||||||
* x: <a> <-- populate from modules
|
* x: <a> <-- populate from modules
|
||||||
*/
|
*/
|
||||||
#ifdef XMLDB_CONFIG_HACK
|
#ifdef XMLDB_CONFIG_HACK
|
||||||
if (strcmp(xml_name(x),"config") == 0){
|
if (strcmp(xml_name(x),"config") == 0 ||
|
||||||
|
strcmp(xml_name(x),"data") == 0){
|
||||||
/* xt:<top> nospec
|
/* xt:<top> nospec
|
||||||
* x: <config>
|
* x: <config>
|
||||||
* <a> <-- populate from modules
|
* <a> <-- populate from modules
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ main(int argc,
|
||||||
char *top_path = NULL;
|
char *top_path = NULL;
|
||||||
cxobj *xbot; /* Place in xtop where base cxobj is parsed */
|
cxobj *xbot; /* Place in xtop where base cxobj is parsed */
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
|
enum yang_bind yb;
|
||||||
|
|
||||||
/* In the startup, logs to stderr & debug flag set later */
|
/* In the startup, logs to stderr & debug flag set later */
|
||||||
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
|
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
|
||||||
|
|
@ -291,7 +292,13 @@ main(int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ /* XML */
|
else{ /* XML */
|
||||||
if ((ret = xml_parse_file2(fd, (xt==NULL)?YB_TOP:YB_PARENT, yspec, NULL, &xt, &xerr)) < 0){
|
if (!yang_file_dir)
|
||||||
|
yb = YB_NONE;
|
||||||
|
else if (xt == NULL)
|
||||||
|
yb = YB_TOP;
|
||||||
|
else
|
||||||
|
yb = YB_PARENT;
|
||||||
|
if ((ret = xml_parse_file2(fd, yb, yspec, NULL, &xt, &xerr)) < 0){
|
||||||
fprintf(stderr, "xml parse error: %s\n", clicon_err_reason);
|
fprintf(stderr, "xml parse error: %s\n", clicon_err_reason);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue