Changed C-API for xml translation/print the internal cxobj tree data structure to other formats

New API is as follows:
  * `clixon_xml2file()` - Print internal tree as XML to file
  * `clixon_xml2cbuf()` - Print internal tree as XML to buffer
  * `clixon_json2file()` - Print internal tree as JSON to file
  * `clixon_json2cbuf()` - Print internal tree as JSON to buffer
  * `clixon_cli2file()` - Print internal tree as CLI format to file
  * `clixon_txt2file()` - Print internal tree as text format to file
This commit is contained in:
Olof hagsand 2022-06-01 20:02:27 +02:00
parent 87719c623c
commit 0c79298e76
49 changed files with 421 additions and 503 deletions

View file

@ -1206,10 +1206,10 @@ xmldb_put(clicon_handle h,
}
pretty = clicon_option_bool(h, "CLICON_XMLDB_PRETTY");
if (strcmp(format,"json")==0){
if (xml2json_file(f, x0, pretty, fprintf, 0) < 0)
if (clixon_json2file(f, x0, pretty, fprintf, 0) < 0)
goto done;
}
else if (clicon_xml2file(f, x0, 0, pretty) < 0)
else if (clixon_xml2file(f, x0, 0, pretty, fprintf, 0) < 0)
goto done;
/* Remove modules state after writing to file
*/
@ -1264,10 +1264,10 @@ xmldb_dump(clicon_handle h,
}
pretty = clicon_option_bool(h, "CLICON_XMLDB_PRETTY");
if (strcmp(format,"json")==0){
if (xml2json_file(f, xt, pretty, fprintf, 0) < 0)
if (clixon_json2file(f, xt, pretty, fprintf, 0) < 0)
goto done;
}
else if (clicon_xml2file(f, xt, 0, pretty) < 0)
else if (clixon_xml2file(f, xt, 0, pretty, fprintf, 0) < 0)
goto done;
retval = 0;
done: