* Removed endtag parameter of clixon_xml_parse_file()
This commit is contained in:
parent
f536b1dc67
commit
fb9917e81e
15 changed files with 19 additions and 27 deletions
|
|
@ -48,6 +48,7 @@ Expected: April
|
|||
|
||||
Developers may need to change their code
|
||||
|
||||
* Removed `endtag` parameter of `clixon_xml_parse_file()`
|
||||
* Restconf authentication callback (ca_auth) signature changed (again)
|
||||
* Minor modification to 5.0 change: userp removed.
|
||||
* New version is: `int ca_auth(h, req, auth_type, authp)`, where
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ nacm_load_external(clicon_handle h)
|
|||
if (yang_spec_parse_module(h, "ietf-netconf-acm", NULL, yspec) < 0)
|
||||
goto done;
|
||||
/* Read configfile */
|
||||
if (clixon_xml_parse_file(f, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
||||
if (clixon_xml_parse_file(f, YB_MODULE, yspec, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (xt == NULL){
|
||||
clicon_err(OE_XML, 0, "No xml tree in %s", filename);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ load_extraxml(clicon_handle h,
|
|||
}
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
/* No yang check yet because it has <config> as top symbol, do it later after that is removed */
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, yspec, NULL, &xt, &xerr) < 0)
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, yspec, &xt, &xerr) < 0)
|
||||
goto done;
|
||||
/* Replace parent w first child */
|
||||
if (xml_rootchild(xt, 0, &xt) < 0)
|
||||
|
|
|
|||
|
|
@ -826,7 +826,7 @@ load_config_file(clicon_handle h,
|
|||
clicon_err(OE_UNIX, errno, "open(%s)", filename);
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, NULL, &xt, NULL) < 0)
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (xt == NULL)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ example_statedata(clicon_handle h,
|
|||
}
|
||||
if ((xt = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, xpath) < 0)
|
||||
goto done;
|
||||
|
|
@ -991,7 +991,7 @@ example_daemon(clicon_handle h)
|
|||
clicon_err(OE_UNIX, errno, "open(%s)", _state_file);
|
||||
goto done;
|
||||
}
|
||||
if ((ret = clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &_state_xstate, NULL)) < 0)
|
||||
if ((ret = clixon_xml_parse_file(fp, YB_MODULE, yspec, &_state_xstate, NULL)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
fprintf(stderr, "%s error\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ int clicon_xml2cbuf(cbuf *cb, cxobj *x, int level, int prettyprint, int32_t dept
|
|||
char *clicon_xml2str(cxobj *x);
|
||||
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
|
||||
|
||||
int clixon_xml_parse_file(FILE *f, yang_bind yb, yang_stmt *yspec, char *endtag, cxobj **xt, cxobj **xerr);
|
||||
int clixon_xml_parse_file(FILE *f, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
|
||||
int clixon_xml_parse_string(const char *str, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ xmldb_readfile(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
else {
|
||||
if ((ret = clixon_xml_parse_file(fp, yb, yspec, NULL, &x0, NULL)) < 0){
|
||||
if ((ret = clixon_xml_parse_file(fp, yb, yspec, &x0, NULL)) < 0){
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ parse_configfile_one(const char *filename,
|
|||
return -1;
|
||||
}
|
||||
clicon_debug(2, "%s: Reading config file %s", __FUNCTION__, filename);
|
||||
if ((ret = clixon_xml_parse_file(fp, yspec?YB_MODULE:YB_NONE, yspec, NULL, &xt, &xerr)) < 0)
|
||||
if ((ret = clixon_xml_parse_file(fp, yspec?YB_MODULE:YB_NONE, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if ((cbret = cbuf_new()) ==NULL){
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ clixon_xml_changelog_init(clicon_handle h)
|
|||
clicon_err(OE_UNIX, errno, "fopen(%s)", filename);
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (xml_rootchild(xt, 0, &xt) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -572,8 +572,8 @@ FSM(char *tag,
|
|||
* @param[in] fd A file descriptor containing the XML file (as ASCII characters)
|
||||
* @param[in] yb How to bind yang to XML top-level when parsing
|
||||
* @param[in] yspec Yang specification (only if bind is TOP or CONFIG)
|
||||
* @param[in] endtag Read until encounter "endtag" in the stream, or NULL
|
||||
* @param[in,out] xt Pointer to XML parse tree. If empty, create.
|
||||
* @param[out] xerr Pointer to XML error tree, if retval is 0
|
||||
* @retval 1 Parse OK and all yang assignment made
|
||||
* @retval 0 Parse OK but yang assigment not made (or only partial) and xerr set
|
||||
* @retval -1 Error with clicon_err called. Includes parse error
|
||||
|
|
@ -584,7 +584,7 @@ FSM(char *tag,
|
|||
* FILE *f;
|
||||
* if ((f = fopen(filename, "r")) == NULL)
|
||||
* err;
|
||||
* if ((ret = clixon_xml_parse_file(f, YB_MODULE, yspec, "</config>", &xt, &xerr)) < 0)
|
||||
* if ((ret = clixon_xml_parse_file(f, YB_MODULE, yspec, &xt, &xerr)) < 0)
|
||||
* err;
|
||||
* xml_free(xt);
|
||||
* @endcode
|
||||
|
|
@ -597,7 +597,6 @@ int
|
|||
clixon_xml_parse_file(FILE *fp,
|
||||
yang_bind yb,
|
||||
yang_stmt *yspec,
|
||||
char *endtag,
|
||||
cxobj **xt,
|
||||
cxobj **xerr)
|
||||
{
|
||||
|
|
@ -608,8 +607,6 @@ clixon_xml_parse_file(FILE *fp,
|
|||
char *xmlbuf = NULL;
|
||||
char *ptr;
|
||||
int xmlbuflen = BUFLEN; /* start size */
|
||||
int endtaglen = 0;
|
||||
int state = 0;
|
||||
int oldxmlbuflen;
|
||||
int failed = 0;
|
||||
|
||||
|
|
@ -621,8 +618,6 @@ clixon_xml_parse_file(FILE *fp,
|
|||
clicon_err(OE_XML, EINVAL, "yspec is required if yb == YB_MODULE");
|
||||
return -1;
|
||||
}
|
||||
if (endtag != NULL)
|
||||
endtaglen = strlen(endtag);
|
||||
if ((xmlbuf = malloc(xmlbuflen)) == NULL){
|
||||
clicon_err(OE_XML, errno, "malloc");
|
||||
goto done;
|
||||
|
|
@ -635,13 +630,9 @@ clixon_xml_parse_file(FILE *fp,
|
|||
break;
|
||||
}
|
||||
if (ret != 0){
|
||||
if (endtag)
|
||||
state = FSM(endtag, ch, state);
|
||||
xmlbuf[len++] = ch;
|
||||
}
|
||||
if (ret == 0 ||
|
||||
(endtag && (state == endtaglen))){
|
||||
state = 0;
|
||||
if (ret == 0) {
|
||||
if (*xt == NULL)
|
||||
if ((*xt = xml_new(XML_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ main(int argc, char **argv)
|
|||
clicon_err(OE_UNIX, errno, "fopen(%s)", xmlfilename);
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, &xt, NULL) < 0)
|
||||
goto done;
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ main(int argc,
|
|||
* If fp=stdin, then continue reading from stdin (after CR)
|
||||
* XXX Note 0 above, stdin here
|
||||
*/
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, NULL, &x, NULL) < 0){
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, &x, NULL) < 0){
|
||||
fprintf(stderr, "Error: parsing: %s\n", clicon_err_reason);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ main(int argc,
|
|||
}
|
||||
}
|
||||
else{
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, NULL, &xt, NULL) < 0){
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, &xt, NULL) < 0){
|
||||
fprintf(stderr, "xml parse error: %s\n", clicon_err_reason);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ main(int argc,
|
|||
clicon_err(OE_YANG, errno, "fopen(%s)", top_input_filename);
|
||||
goto done;
|
||||
}
|
||||
if ((ret = clixon_xml_parse_file(tfp, YB_MODULE, yspec, NULL, &xtop, &xerr)) < 0){
|
||||
if ((ret = clixon_xml_parse_file(tfp, YB_MODULE, yspec, &xtop, &xerr)) < 0){
|
||||
fprintf(stderr, "xml parse error: %s\n", clicon_err_reason);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ main(int argc,
|
|||
yb = YB_MODULE;
|
||||
else
|
||||
yb = YB_PARENT;
|
||||
if ((ret = clixon_xml_parse_file(fp, yb, yspec, NULL, &xt, &xerr)) < 0){
|
||||
if ((ret = clixon_xml_parse_file(fp, yb, yspec, &xt, &xerr)) < 0){
|
||||
fprintf(stderr, "xml parse error: %s\n", clicon_err_reason);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ main(int argc,
|
|||
* If fp=stdin, then continue reading from stdin (after CR)
|
||||
* XXX Note 0 above, stdin here
|
||||
*/
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, NULL, &x0, NULL) < 0){
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, NULL, &x0, NULL) < 0){
|
||||
fprintf(stderr, "Error: parsing: %s\n", clicon_err_reason);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue