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
|
|
@ -88,7 +88,6 @@ main(int argc,
|
|||
{
|
||||
int retval = -1;
|
||||
cxobj *xt = NULL;
|
||||
cxobj *xc;
|
||||
cbuf *cb = cbuf_new();
|
||||
int c;
|
||||
int logdst = CLICON_LOG_STDERR;
|
||||
|
|
@ -145,20 +144,10 @@ main(int argc,
|
|||
xml_print(stderr, xerr);
|
||||
goto done;
|
||||
}
|
||||
#if 0
|
||||
if (json)
|
||||
xml2json_cbuf(cb, xt, pretty); /* print json */
|
||||
xml2json_cbuf(cb, xt, pretty, 1); /* print json */
|
||||
else
|
||||
clicon_xml2cbuf(cb, xt, 0, pretty, -1); /* print xml */
|
||||
#else
|
||||
xc = NULL;
|
||||
/* XXX This is troublesome for JSON top-level lists */
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
|
||||
if (json)
|
||||
xml2json_cbuf(cb, xc, pretty); /* print json */
|
||||
else
|
||||
clicon_xml2cbuf(cb, xc, 0, pretty, -1); /* print xml */
|
||||
#endif
|
||||
clicon_xml2cbuf(cb, xt, 0, pretty, -1, 1); /* print xml */
|
||||
fprintf(stdout, "%s", cbuf_get(cb));
|
||||
fflush(stdout);
|
||||
retval = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue