* Added output function to JSON output:
* `xml2json_vec(...,skiptop)` --> `xml2json_vec(..., cligen_output, skiptop)`
This commit is contained in:
parent
25cc14c1a2
commit
307a992f36
4 changed files with 13 additions and 9 deletions
|
|
@ -52,6 +52,8 @@ Expected: July 2023
|
||||||
### C/CLI-API changes on existing features
|
### C/CLI-API changes on existing features
|
||||||
Developers may need to change their code
|
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`.
|
* `yang2cli_yspec` removed last argument `printgen`.
|
||||||
* Removed obsolete: `cli_auto_show()`
|
* Removed obsolete: `cli_auto_show()`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ cli_show_common(clicon_handle h,
|
||||||
if (format == FORMAT_JSON){
|
if (format == FORMAT_JSON){
|
||||||
switch (format){
|
switch (format){
|
||||||
case FORMAT_JSON:
|
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;
|
goto done;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -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 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 clixon_json2file(FILE *f, cxobj *x, int pretty, clicon_output_cb *fn, int skiptop, int autocliext);
|
||||||
int json_print(FILE *f, cxobj *x);
|
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_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);
|
int clixon_json_parse_file(FILE *fp, int rfc7951, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1227,7 +1227,7 @@ xml2json_cbuf_vec(cbuf *cb,
|
||||||
* @param[in] f File to print to
|
* @param[in] f File to print to
|
||||||
* @param[in] xn XML tree to translate from
|
* @param[in] xn XML tree to translate from
|
||||||
* @param[in] pretty Set if output is pretty-printed
|
* @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] skiptop 0: Include top object 1: Skip top-object, only children,
|
||||||
* @param[in] autocliext How to handle autocli extensions: 0: ignore 1: follow
|
* @param[in] autocliext How to handle autocli extensions: 0: ignore 1: follow
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
|
|
@ -1286,6 +1286,7 @@ json_print(FILE *f,
|
||||||
* @param[in] vec Vector of xml objecst
|
* @param[in] vec Vector of xml objecst
|
||||||
* @param[in] veclen Length of vector
|
* @param[in] veclen Length of vector
|
||||||
* @param[in] pretty Set if output is pretty-printed (2 for debug)
|
* @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,
|
* @param[in] skiptop 0: Include top object 1: Skip top-object, only children,
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
|
|
@ -1294,11 +1295,12 @@ json_print(FILE *f,
|
||||||
* @see xml2json1_cbuf
|
* @see xml2json1_cbuf
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml2json_vec(FILE *f,
|
xml2json_vec(FILE *f,
|
||||||
cxobj **vec,
|
cxobj **vec,
|
||||||
size_t veclen,
|
size_t veclen,
|
||||||
int pretty,
|
int pretty,
|
||||||
int skiptop)
|
clicon_output_cb *fn,
|
||||||
|
int skiptop)
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
|
|
@ -1309,7 +1311,7 @@ xml2json_vec(FILE *f,
|
||||||
}
|
}
|
||||||
if (xml2json_cbuf_vec(cb, vec, veclen, pretty, skiptop) < 0)
|
if (xml2json_cbuf_vec(cb, vec, veclen, pretty, skiptop) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
fprintf(f, "%s\n", cbuf_get(cb));
|
(*fn)(f, "%s\n", cbuf_get(cb));
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (cb)
|
if (cb)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue