Changed C-API for xml translation/print to other formats.

* Added `skiptop` parameter, if set only apply to children of a node, skip top node
    * default is 0
* Functions are merged, ie removed and replaced with more generic functions
* `xml2json_cbuf()`: Added `skiptop` parameter: `xml2json_cbuf(..., int skiptop)`
* `xml2json()` and `xml2json_cb()` merged into `xml2json_file()` with `skiptop`
    * Replace `xml2json(...)` with `xml2json_file(..., stdout, 0)`
    * Replace `xml2json_cb(...)` with `xml2json_file(..., 0)`
* `clicon_xml2cbuf()`: Added `skiptop` parameter: `clicon_xml2cbuf(..., int skiptop)`
* `xml2cli()`: Added `skiptop` parameter: `xml2cli(..., int skiptop)`
This commit is contained in:
Olof hagsand 2022-06-01 10:48:39 +02:00
parent 724b94137f
commit 43a57dad79
39 changed files with 306 additions and 481 deletions

View file

@ -216,7 +216,7 @@ startup_common(clicon_handle h,
* See similar clause below
*/
}
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}
@ -276,7 +276,7 @@ startup_common(clicon_handle h,
if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xret)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}
@ -284,7 +284,7 @@ startup_common(clicon_handle h,
if ((ret = xml_non_config_data(xt, &xret)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}
@ -319,7 +319,7 @@ startup_common(clicon_handle h,
if ((ret = generic_validate(h, yspec, td, &xret)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
goto done;
goto fail; /* STARTUP_INVALID */
}
@ -625,7 +625,7 @@ candidate_validate(clicon_handle h,
clicon_err(OE_CFG, EINVAL, "xret is NULL");
goto done;
}
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
goto done;
if (!cbuf_len(cbret) &&
netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
@ -685,7 +685,7 @@ candidate_commit(clicon_handle h,
if ((ret = validate_common(h, db, td, &xret)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}
@ -957,7 +957,7 @@ from_client_restart_one(clicon_handle h,
if ((ret = xml_yang_validate_all_top(h, td->td_target, &xerr)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}
@ -1007,7 +1007,7 @@ from_client_restart_one(clicon_handle h,
if ((ret = generic_validate(h, yspec, td, &xerr)) < 0)
goto done;
if (ret == 0){
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
goto done;
goto fail;
}