Adapted to CLIgen 4.5 API changes, eg: and
This commit is contained in:
parent
8897df202e
commit
1dff0e681b
7 changed files with 27 additions and 18 deletions
|
|
@ -220,15 +220,17 @@ cli_interactive(clicon_handle h)
|
|||
/* Loop through all commands */
|
||||
while(!cligen_exiting(cli_cligen(h))) {
|
||||
new_mode = cli_syntax_mode(h);
|
||||
if ((cmd = clicon_cliread(h)) == NULL) {
|
||||
cligen_exiting_set(cli_cligen(h), 1); /* EOF */
|
||||
goto ok; /* EOF should not be -1 error? */
|
||||
cmd = NULL;
|
||||
if (clicon_cliread(h, &cmd) < 0)
|
||||
goto done;
|
||||
if (cmd == NULL) { /* EOF */
|
||||
cligen_exiting_set(cli_cligen(h), 1);
|
||||
continue;
|
||||
}
|
||||
if (clicon_parse(h, cmd, &new_mode, &result, NULL) < 0)
|
||||
goto done;
|
||||
/* Why not check result? */
|
||||
}
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -603,14 +603,16 @@ done:
|
|||
}
|
||||
|
||||
/*! Read command from CLIgen's cliread() using current syntax mode.
|
||||
* @param[in] h Clicon handle
|
||||
* @retval string char* buffer containing CLIgen command
|
||||
* @retval NULL Fatal error
|
||||
* @param[in] h Clicon handle
|
||||
* @param[out] stringp Pointer to command buffer or NULL on EOF
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
char *
|
||||
clicon_cliread(clicon_handle h)
|
||||
int
|
||||
clicon_cliread(clicon_handle h,
|
||||
char **stringp)
|
||||
{
|
||||
char *ret;
|
||||
int retval = -1;
|
||||
char *pfmt = NULL;
|
||||
cli_syntaxmode_t *mode;
|
||||
cli_syntax_t *stx;
|
||||
|
|
@ -632,10 +634,15 @@ clicon_cliread(clicon_handle h)
|
|||
else
|
||||
cli_prompt_set(h, cli_prompt(pfmt ? pfmt : mode->csm_prompt));
|
||||
cligen_tree_active_set(cli_cligen(h), mode->csm_name);
|
||||
ret = cliread(cli_cligen(h));
|
||||
if (cliread(cli_cligen(h), stringp) < 0){
|
||||
clicon_err(OE_FATAL, errno, "CLIgen");
|
||||
goto done;
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (pfmt)
|
||||
free(pfmt);
|
||||
return ret;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ int clicon_eval(clicon_handle h, char *cmd, cg_obj *match_obj, cvec *vr);
|
|||
|
||||
int clicon_parse(clicon_handle h, char *cmd, char **mode, cligen_result *result, int *evalres);
|
||||
|
||||
char *clicon_cliread(clicon_handle h);
|
||||
int clicon_cliread(clicon_handle h, char **stringp);
|
||||
|
||||
int cli_plugin_finish(clicon_handle h);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue