* Added output function to JSON output:

* `xml2json_vec(...,skiptop)` --> `xml2json_vec(..., cligen_output, skiptop)`
This commit is contained in:
Olof hagsand 2023-05-17 16:25:35 +02:00
parent 25cc14c1a2
commit 307a992f36
4 changed files with 13 additions and 9 deletions

View file

@ -52,6 +52,8 @@ Expected: July 2023
### C/CLI-API changes on existing features
Developers may need to change their code
* Added output function to JSON output:
* `xml2json_vec(...,skiptop)` --> `xml2json_vec(..., cligen_output, skiptop)`
* `yang2cli_yspec` removed last argument `printgen`.
* Removed obsolete: `cli_auto_show()`

View file

@ -506,7 +506,7 @@ cli_show_common(clicon_handle h,
if (format == FORMAT_JSON){
switch (format){
case FORMAT_JSON:
if (xml2json_vec(stdout, vec, veclen, pretty, skiptop) < 0) // XXX cligen_output
if (xml2json_vec(stdout, vec, veclen, pretty, cligen_output, skiptop) < 0)
goto done;
break;
default:

View file

@ -48,7 +48,7 @@ int clixon_json2cbuf(cbuf *cb, cxobj *x, int pretty, int skiptop, int autocliext
int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty, int skiptop);
int clixon_json2file(FILE *f, cxobj *x, int pretty, clicon_output_cb *fn, int skiptop, int autocliext);
int json_print(FILE *f, cxobj *x);
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty, int skiptop);
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty, clicon_output_cb *fn, int skiptop);
int clixon_json_parse_string(char *str, int rfc7951, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);
int clixon_json_parse_file(FILE *fp, int rfc7951, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);

View file

@ -1227,7 +1227,7 @@ xml2json_cbuf_vec(cbuf *cb,
* @param[in] f File to print to
* @param[in] xn XML tree to translate from
* @param[in] pretty Set if output is pretty-printed
* @param[in] fn File print function (if NULL, use fprintf)
* @param[in] fn File print function
* @param[in] skiptop 0: Include top object 1: Skip top-object, only children,
* @param[in] autocliext How to handle autocli extensions: 0: ignore 1: follow
* @retval 0 OK
@ -1286,6 +1286,7 @@ json_print(FILE *f,
* @param[in] vec Vector of xml objecst
* @param[in] veclen Length of vector
* @param[in] pretty Set if output is pretty-printed (2 for debug)
* @param[in] fn File print function
* @param[in] skiptop 0: Include top object 1: Skip top-object, only children,
* @retval 0 OK
* @retval -1 Error
@ -1294,11 +1295,12 @@ json_print(FILE *f,
* @see xml2json1_cbuf
*/
int
xml2json_vec(FILE *f,
cxobj **vec,
size_t veclen,
int pretty,
int skiptop)
xml2json_vec(FILE *f,
cxobj **vec,
size_t veclen,
int pretty,
clicon_output_cb *fn,
int skiptop)
{
int retval = 1;
cbuf *cb = NULL;
@ -1309,7 +1311,7 @@ xml2json_vec(FILE *f,
}
if (xml2json_cbuf_vec(cb, vec, veclen, pretty, skiptop) < 0)
goto done;
fprintf(f, "%s\n", cbuf_get(cb));
(*fn)(f, "%s\n", cbuf_get(cb));
retval = 0;
done:
if (cb)