enabled and removed USE_CLIGEN44
This commit is contained in:
parent
ac1f36009f
commit
132122c937
8 changed files with 1 additions and 250 deletions
|
|
@ -193,15 +193,6 @@ cli_interrupt_hook(clicon_handle h,
|
|||
return cligen_interrupt_hook(ch, fn);
|
||||
}
|
||||
|
||||
#ifdef USE_CLIGEN44
|
||||
char *
|
||||
cli_nomatch(clicon_handle h)
|
||||
{
|
||||
cligen_handle ch = cligen(h);
|
||||
|
||||
return cligen_nomatch(ch);
|
||||
}
|
||||
#endif
|
||||
int
|
||||
cli_prompt_set(clicon_handle h,
|
||||
char *prompt)
|
||||
|
|
|
|||
|
|
@ -53,10 +53,6 @@ int cli_susp_hook(clicon_handle h, cligen_susp_cb_t *fn);
|
|||
|
||||
int cli_interrupt_hook(clicon_handle h, cligen_interrupt_cb_t *fn);
|
||||
|
||||
#ifdef USE_CLIGEN44
|
||||
char *cli_nomatch(clicon_handle h);
|
||||
#endif
|
||||
|
||||
int cli_prompt_set(clicon_handle h, char *prompt);
|
||||
|
||||
int cli_logsyntax_set(clicon_handle h, int status);
|
||||
|
|
|
|||
|
|
@ -209,32 +209,6 @@ cli_signal_init (clicon_handle h)
|
|||
* @retval -1
|
||||
* @see cligen_loop
|
||||
*/
|
||||
#ifdef USE_CLIGEN44
|
||||
static int
|
||||
cli_interactive(clicon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
int res;
|
||||
char *cmd;
|
||||
char *new_mode;
|
||||
int eval;
|
||||
|
||||
/* 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? */
|
||||
}
|
||||
if ((res = clicon_parse(h, cmd, &new_mode, &eval)) < 0)
|
||||
goto done;
|
||||
}
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
}
|
||||
#else /* USE_CLIGEN44 */
|
||||
static int
|
||||
cli_interactive(clicon_handle h)
|
||||
{
|
||||
|
|
@ -261,7 +235,6 @@ cli_interactive(clicon_handle h)
|
|||
done:
|
||||
return retval;
|
||||
}
|
||||
#endif /* USE_CLIGEN44 */
|
||||
|
||||
static void
|
||||
usage(clicon_handle h,
|
||||
|
|
@ -633,15 +606,6 @@ main(int argc, char **argv)
|
|||
/* Launch interfactive event loop, unless -1 */
|
||||
if (restarg != NULL && strlen(restarg)){
|
||||
char *mode = cli_syntax_mode(h);
|
||||
#ifdef USE_CLIGEN44
|
||||
int result;
|
||||
|
||||
/* */
|
||||
if (clicon_parse(h, restarg, &mode, &result) != 1)
|
||||
goto done;
|
||||
if (result < 0)
|
||||
goto done;
|
||||
#else /* USE_CLIGEN44 */
|
||||
cligen_result result; /* match result */
|
||||
int evalresult = 0; /* if result == 1, calback result */
|
||||
|
||||
|
|
@ -651,7 +615,6 @@ main(int argc, char **argv)
|
|||
goto done;
|
||||
if (evalresult < 0)
|
||||
goto done;
|
||||
#endif /* USE_CLIGEN44 */
|
||||
}
|
||||
|
||||
/* Go into event-loop unless -1 command-line */
|
||||
|
|
|
|||
|
|
@ -511,94 +511,6 @@ clicon_eval(clicon_handle h,
|
|||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
#ifdef USE_CLIGEN44
|
||||
int
|
||||
clicon_parse(clicon_handle h,
|
||||
char *cmd,
|
||||
char **modenamep,
|
||||
int *evalres)
|
||||
{
|
||||
int retval = -1;
|
||||
char *modename;
|
||||
char *modename0;
|
||||
int r;
|
||||
cli_syntax_t *stx = NULL;
|
||||
cli_syntaxmode_t *smode;
|
||||
parse_tree *pt; /* Orig */
|
||||
cg_obj *match_obj;
|
||||
cvec *cvv = NULL;
|
||||
FILE *f;
|
||||
|
||||
if (clicon_get_logflags()&CLICON_LOG_STDOUT)
|
||||
f = stdout;
|
||||
else
|
||||
f = stderr;
|
||||
stx = cli_syntax(h);
|
||||
if ((modename = *modenamep) == NULL) {
|
||||
smode = stx->stx_active_mode;
|
||||
modename = smode->csm_name;
|
||||
}
|
||||
else {
|
||||
if ((smode = syntax_mode_find(stx, modename, 0)) == NULL) {
|
||||
fprintf(f, "Can't find syntax mode '%s'\n", modename);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (smode){
|
||||
modename0 = NULL;
|
||||
if ((pt = cligen_tree_active_get(cli_cligen(h))) != NULL)
|
||||
modename0 = pt->pt_name;
|
||||
if (cligen_tree_active_set(cli_cligen(h), modename) < 0){
|
||||
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
||||
goto done;
|
||||
}
|
||||
if ((pt = cligen_tree_active_get(cli_cligen(h))) == NULL){
|
||||
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
||||
goto done;
|
||||
}
|
||||
if ((cvv = cvec_new(0)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cvec_new");
|
||||
goto done;;
|
||||
}
|
||||
retval = cliread_parse(cli_cligen(h), cmd, pt, &match_obj, cvv);
|
||||
if (retval != CG_MATCH)
|
||||
pt_expand_cleanup_1(pt); /* XXX change to pt_expand_treeref_cleanup */
|
||||
if (modename0){
|
||||
cligen_tree_active_set(cli_cligen(h), modename0);
|
||||
modename0 = NULL;
|
||||
}
|
||||
switch (retval) {
|
||||
case CG_EOF: /* eof */
|
||||
case CG_ERROR:
|
||||
fprintf(f, "CLI parse error: %s\n", cmd);
|
||||
break;
|
||||
case CG_NOMATCH: /* no match */
|
||||
/* clicon_err(OE_CFG, 0, "CLI syntax error: \"%s\": %s",
|
||||
cmd, cli_nomatch(h));*/
|
||||
fprintf(f, "CLI syntax error: \"%s\": %s\n", cmd, cli_nomatch(h));
|
||||
break;
|
||||
case CG_MATCH:
|
||||
if (strcmp(modename, *modenamep)){ /* Command in different mode */
|
||||
*modenamep = modename;
|
||||
cli_set_syntax_mode(h, modename);
|
||||
}
|
||||
if ((r = clicon_eval(h, cmd, match_obj, cvv)) < 0)
|
||||
cli_handler_err(stdout);
|
||||
pt_expand_cleanup_1(pt); /* XXX change to pt_expand_treeref_cleanup */
|
||||
if (evalres)
|
||||
*evalres = r;
|
||||
break;
|
||||
default:
|
||||
fprintf(f, "CLI syntax error: \"%s\" is ambiguous\n", cmd);
|
||||
break;
|
||||
} /* switch retval */
|
||||
}
|
||||
done:
|
||||
if (cvv)
|
||||
cvec_free(cvv);
|
||||
return retval;
|
||||
}
|
||||
#else /* USE_CLIGEN44 */
|
||||
int
|
||||
clicon_parse(clicon_handle h,
|
||||
char *cmd,
|
||||
|
|
@ -689,7 +601,6 @@ done:
|
|||
cvec_free(cvv);
|
||||
return retval;
|
||||
}
|
||||
#endif /* USE_CLIGEN44 */
|
||||
|
||||
/*! Read command from CLIgen's cliread() using current syntax mode.
|
||||
* @param[in] h Clicon handle
|
||||
|
|
@ -697,38 +608,6 @@ done:
|
|||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
#ifdef USE_CLIGEN44
|
||||
char *
|
||||
clicon_cliread(clicon_handle h)
|
||||
{
|
||||
char *ret;
|
||||
char *pfmt = NULL;
|
||||
cli_syntaxmode_t *mode;
|
||||
cli_syntax_t *stx;
|
||||
cli_prompthook_t *fn;
|
||||
clixon_plugin *cp;
|
||||
|
||||
stx = cli_syntax(h);
|
||||
mode = stx->stx_active_mode;
|
||||
/* Get prompt from plugin callback? */
|
||||
cp = NULL;
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if ((fn = cp->cp_api.ca_prompt) == NULL)
|
||||
continue;
|
||||
pfmt = fn(h, mode->csm_name);
|
||||
break;
|
||||
}
|
||||
if (clicon_quiet_mode(h))
|
||||
cli_prompt_set(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 (pfmt)
|
||||
free(pfmt);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int
|
||||
clicon_cliread(clicon_handle h,
|
||||
char **stringp)
|
||||
|
|
@ -766,7 +645,6 @@ clicon_cliread(clicon_handle h,
|
|||
free(pfmt);
|
||||
return retval;
|
||||
}
|
||||
#endif /* USE_CLIGEN44 */
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
@ -774,7 +652,6 @@ clicon_cliread(clicon_handle h,
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/*! Set syntax mode mode for existing current plugin group.
|
||||
* @param[in] h Clicon handle
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -66,13 +66,9 @@ void *clixon_str2fn(char *name, void *handle, char **error);
|
|||
|
||||
int clicon_eval(clicon_handle h, char *cmd, cg_obj *match_obj, cvec *vr);
|
||||
|
||||
#ifdef USE_CLIGEN44
|
||||
int clicon_parse(clicon_handle h, char *cmd, char **modenamep, int *evalres);
|
||||
char *clicon_cliread(clicon_handle h);
|
||||
#else
|
||||
int clicon_parse(clicon_handle h, char *cmd, char **mode, cligen_result *result, int *evalres);
|
||||
|
||||
int clicon_cliread(clicon_handle h, char **stringp);
|
||||
#endif
|
||||
|
||||
int cli_plugin_finish(clicon_handle h);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue