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:
parent
724b94137f
commit
43a57dad79
39 changed files with 306 additions and 481 deletions
|
|
@ -326,12 +326,14 @@ example_rpc(clicon_handle h, /* Clicon handle */
|
|||
cprintf(cbret, ">");
|
||||
if (!xml_child_nr_type(xe, CX_ELMNT))
|
||||
cprintf(cbret, "<ok/>");
|
||||
else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
else {
|
||||
while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
if (xmlns_set(x, NULL, namespace) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, x, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2cbuf(cbret, xe, 0, 0, -1, 1) < 0)
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "</rpc-reply>");
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -85,12 +85,14 @@ netconf_client_rpc(clicon_handle h,
|
|||
cprintf(cbret, "<rpc-reply xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
|
||||
if (!xml_child_nr_type(xe, CX_ELMNT))
|
||||
cprintf(cbret, "<ok/>");
|
||||
else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
else{
|
||||
while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
if (xmlns_set(x, NULL, namespace) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, x, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2cbuf(cbret, xe, 0, 0, -1, 1) < 0)
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "</rpc-reply>");
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -325,12 +325,14 @@ restconf_client_rpc(clicon_handle h,
|
|||
cprintf(cbret, "<rpc-reply xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
|
||||
if (!xml_child_nr_type(xe, CX_ELMNT))
|
||||
cprintf(cbret, "<ok/>");
|
||||
else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
else {
|
||||
while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
|
||||
if (xmlns_set(x, NULL, namespace) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, x, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2cbuf(cbret, xe, 0, 0, -1, 1) < 0)
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "</rpc-reply>");
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue