* Use new cligen cvv options.
* NOTE cannot use old CLIgen API
This commit is contained in:
parent
a52b92bd43
commit
46647089ad
4 changed files with 34 additions and 19 deletions
|
|
@ -105,7 +105,7 @@ The 5.3 release has pagination support, Linkref changes in validation and auto-c
|
||||||
* Updated state callback signature containing parameters for pagination
|
* Updated state callback signature containing parameters for pagination
|
||||||
* See API changes below
|
* See API changes below
|
||||||
* Work-in-progress
|
* Work-in-progress
|
||||||
* Enable remaining attriute with LIST_PAGINATION_REMAINING compile-time option
|
* Enable remaining attribute with LIST_PAGINATION_REMAINING compile-time option
|
||||||
* sort/direction/where etc not supported
|
* sort/direction/where etc not supported
|
||||||
* For documentation: [User manual pagination](https://clixon-docs.readthedocs.io/en/latest/misc.html#pagination)
|
* For documentation: [User manual pagination](https://clixon-docs.readthedocs.io/en/latest/misc.html#pagination)
|
||||||
* YANG Leafref feature update
|
* YANG Leafref feature update
|
||||||
|
|
|
||||||
|
|
@ -620,7 +620,7 @@ main(int argc,
|
||||||
Should be 0 but default is 1 since all legacy apps use 1
|
Should be 0 but default is 1 since all legacy apps use 1
|
||||||
Test legacy before shifting default to 0
|
Test legacy before shifting default to 0
|
||||||
*/
|
*/
|
||||||
cv_exclude_keys(clicon_cli_varonly(h));
|
cligen_exclude_keys_set(cli_cligen(h), clicon_cli_varonly(h));
|
||||||
|
|
||||||
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
||||||
if (clixon_plugin_module_init(h) < 0)
|
if (clixon_plugin_module_init(h) < 0)
|
||||||
|
|
|
||||||
|
|
@ -525,34 +525,50 @@ cli_handler_err(FILE *f)
|
||||||
/*! Variant of eval for context checking
|
/*! Variant of eval for context checking
|
||||||
* @see cligen_eval
|
* @see cligen_eval
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
cligen_clixon_eval(cligen_handle h,
|
clixon_cligen_eval(cligen_handle h,
|
||||||
cg_obj *co,
|
cg_obj *co,
|
||||||
cvec *cvv)
|
cvec *cvv)
|
||||||
{
|
{
|
||||||
struct cg_callback *cc;
|
struct cg_callback *cc;
|
||||||
int retval = 0;
|
int retval = -1;
|
||||||
cvec *argv;
|
cvec *argv;
|
||||||
plugin_context_t *pc = NULL;
|
cvec *cvv1 = NULL; /* Modified */
|
||||||
|
plugin_context_t *pc = NULL; /* Clixon-specific */
|
||||||
|
|
||||||
|
|
||||||
|
/* Save matched object for plugin use */
|
||||||
if (h)
|
if (h)
|
||||||
cligen_co_match_set(h, co);
|
cligen_co_match_set(h, co);
|
||||||
|
/* Make a copy of var argument for modifications */
|
||||||
|
if ((cvv1 = cvec_dup(cvv)) == NULL)
|
||||||
|
goto done;
|
||||||
|
/* Make modifications to cvv */
|
||||||
|
if (cligen_expand_first_get(h) &&
|
||||||
|
cvec_expand_first(cvv1) < 0)
|
||||||
|
goto done;
|
||||||
|
if (cligen_exclude_keys_get(h) &&
|
||||||
|
cvec_exclude_keys(cvv1) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Traverse callbacks */
|
||||||
for (cc = co->co_callbacks; cc; cc=cc->cc_next){
|
for (cc = co->co_callbacks; cc; cc=cc->cc_next){
|
||||||
/* Vector cvec argument to callback */
|
/* Vector cvec argument to callback */
|
||||||
if (cc->cc_fn_vec){
|
if (cc->cc_fn_vec){
|
||||||
argv = cc->cc_cvec ? cvec_dup(cc->cc_cvec) : NULL;
|
argv = cc->cc_cvec ? cvec_dup(cc->cc_cvec) : NULL;
|
||||||
cligen_fn_str_set(h, cc->cc_fn_str);
|
cligen_fn_str_set(h, cc->cc_fn_str);
|
||||||
if ((pc = plugin_context_get()) == NULL)
|
/* Clixon-specific */
|
||||||
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
break;
|
break;
|
||||||
if ((retval = (*cc->cc_fn_vec)(
|
if ((retval = (*cc->cc_fn_vec)(
|
||||||
cligen_userhandle(h)?cligen_userhandle(h):h,
|
cligen_userhandle(h)?cligen_userhandle(h):h,
|
||||||
cvv,
|
cvv1,
|
||||||
argv)) < 0){
|
argv)) < 0){
|
||||||
if (argv != NULL)
|
if (argv != NULL)
|
||||||
cvec_free(argv);
|
cvec_free(argv);
|
||||||
cligen_fn_str_set(h, NULL);
|
cligen_fn_str_set(h, NULL);
|
||||||
break;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Clixon-specific */
|
||||||
if (plugin_context_check(pc, "CLIgen", cc->cc_fn_str) < 0)
|
if (plugin_context_check(pc, "CLIgen", cc->cc_fn_str) < 0)
|
||||||
break;
|
break;
|
||||||
if (pc){
|
if (pc){
|
||||||
|
|
@ -564,8 +580,12 @@ cligen_clixon_eval(cligen_handle h,
|
||||||
cligen_fn_str_set(h, NULL);
|
cligen_fn_str_set(h, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pc)
|
retval = 0;
|
||||||
|
done:
|
||||||
|
if (pc) /* Clixon-specific */
|
||||||
free(pc);
|
free(pc);
|
||||||
|
if (cvv1)
|
||||||
|
cvec_free(cvv1);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -589,7 +609,7 @@ clicon_eval(clicon_handle h,
|
||||||
if (!cligen_exiting(cli_cligen(h))) {
|
if (!cligen_exiting(cli_cligen(h))) {
|
||||||
clicon_err_reset();
|
clicon_err_reset();
|
||||||
|
|
||||||
if ((retval = cligen_clixon_eval(cli_cligen(h), match_obj, cvv)) < 0) {
|
if ((retval = clixon_cligen_eval(cli_cligen(h), match_obj, cvv)) < 0) {
|
||||||
#if 0 /* This is removed since we get two error messages on failure.
|
#if 0 /* This is removed since we get two error messages on failure.
|
||||||
But maybe only sometime?
|
But maybe only sometime?
|
||||||
Both a real log when clicon_err is called, and the here again.
|
Both a real log when clicon_err is called, and the here again.
|
||||||
|
|
@ -663,11 +683,7 @@ clicon_parse(clicon_handle h,
|
||||||
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((cvv = cvec_new(0)) == NULL){
|
if (cliread_parse(cli_cligen(h), cmd, pt, &match_obj, &cvv, result, &reason) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "cvec_new");
|
|
||||||
goto done;;
|
|
||||||
}
|
|
||||||
if (cliread_parse(cli_cligen(h), cmd, pt, &match_obj, cvv, result, &reason) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
/* Debug command and result code */
|
/* Debug command and result code */
|
||||||
clicon_debug(1, "%s result:%d command: \"%s\"", __FUNCTION__, *result, cmd);
|
clicon_debug(1, "%s result:%d command: \"%s\"", __FUNCTION__, *result, cmd);
|
||||||
|
|
|
||||||
|
|
@ -581,10 +581,11 @@ xml_parent(cxobj *xn)
|
||||||
return xn->x_up;
|
return xn->x_up;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set parent of xnode, parent is copied.
|
/*! Set parent of xml node.
|
||||||
* @param[in] xn xml node
|
* @param[in] xn xml node
|
||||||
* @param[in] parent pointer to new parent xml node
|
* @param[in] parent pointer to new parent xml node
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
|
* @see xml_child_rm remove child from parent
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_parent_set(cxobj *xn,
|
xml_parent_set(cxobj *xn,
|
||||||
|
|
@ -1986,8 +1987,6 @@ xml_copy(cxobj *x0,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! Create and return a copy of xml tree.
|
/*! Create and return a copy of xml tree.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue