* Added new cli show functions to work with cligen_output for cligen pageing to work. To acheive this, add a callback function as follows:

* xml2txt(...) --> xml2txt_cb(..., cligen_output)
  * xml2cli(...) --> xml2cli_cb(..., cligen_output)
  * clicon_xml2file(...) --> clicon_xml2file_cb(..., cligen_output)
  * xml2json(...) --> xml2json_cb(..., cligen_output)
  * yang_print(...) --> yang_print_cb(..., cligen_output)
This commit is contained in:
Olof hagsand 2020-06-17 14:04:19 +02:00
parent 6e714beea5
commit 0adcd94f3f
13 changed files with 291 additions and 114 deletions

View file

@ -53,6 +53,20 @@ typedef void *clicon_handle;
/* The dynamicically loadable plugin object handle (should be in clixon_plugin.h) */
typedef void *plghndl_t;
/*! Indirect output functions to print with something else than fprintf
* @param[in] h Clicon handle
* @param[in] xn Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg Domain specific arg, ec client-entry or FCGX_Request
* @param[in] regarg User argument given at rpc_callback_register()
* @retval 0 OK
* @retval -1 Error
*/
typedef int (clicon_output_cb)(
FILE *f,
const char *templ, ...
) __attribute__ ((format (printf, 2, 3)));
/*
* Prototypes
*/

View file

@ -47,6 +47,7 @@ int json2xml_decode(cxobj *x, cxobj **xerr);
int xml2json_cbuf(cbuf *cb, cxobj *x, int pretty);
int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty);
int xml2json(FILE *f, cxobj *x, int pretty);
int xml2json_cb(FILE *f, cxobj *x, int pretty, clicon_output_cb *fn);
int json_print(FILE *f, cxobj *x);
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty);
int clixon_json_parse_string(char *str, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);

View file

@ -43,7 +43,8 @@
/*
* Prototypes
*/
int clicon_xml2file(FILE *f, cxobj *x, int level, int prettyprint);
int clicon_xml2file_cb(FILE *f, cxobj *x, int level, int prettyprint, clicon_output_cb *fn);
int clicon_xml2file(FILE *f, cxobj *x, int level, int prettyprint);
int xml_print(FILE *f, cxobj *xn);
int clicon_xml2cbuf(cbuf *cb, cxobj *x, int level, int prettyprint, int32_t depth);
char *clicon_xml2str(cxobj *x);

View file

@ -40,14 +40,19 @@
#ifndef _CLIXON_XML_MAP_H_
#define _CLIXON_XML_MAP_H_
/* declared in clixon_yang_internal */
/*
* Types
*/
/* Declared in clixon_yang_internal */
typedef enum yang_class yang_class;
/*
* Prototypes
*/
int isxmlns(cxobj *x);
int xml2txt_cb(FILE *f, cxobj *x, clicon_output_cb *fn);
int xml2txt(FILE *f, cxobj *x, int level);
int xml2cli_cb(FILE *f, cxobj *x, char *prepend, enum genmodel_type gt, clicon_output_cb *fn);
int xml2cli(FILE *f, cxobj *x, char *prepend, enum genmodel_type gt);
int xmlns_assign(cxobj *x);
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);

View file

@ -227,6 +227,7 @@ int yang_find_prefix_by_namespace(yang_stmt *ys, char *namespace, char **
yang_stmt *yang_myroot(yang_stmt *ys);
yang_stmt *yang_choice(yang_stmt *y);
int yang_order(yang_stmt *y);
int yang_print_cb(FILE *f, yang_stmt *yn, clicon_output_cb *fn);
int yang_print(FILE *f, yang_stmt *yn);
int yang_print_cbuf(cbuf *cb, yang_stmt *yn, int marginal);
int if_feature(yang_stmt *yspec, char *module, char *feature);