diff --git a/apps/cli/cli_handle.c b/apps/cli/cli_handle.c index 86a70351..70ce3c2d 100644 --- a/apps/cli/cli_handle.c +++ b/apps/cli/cli_handle.c @@ -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) diff --git a/apps/cli/cli_handle.h b/apps/cli/cli_handle.h index a9d67cbe..20c02321 100644 --- a/apps/cli/cli_handle.h +++ b/apps/cli/cli_handle.h @@ -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); diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 5f3e4dda..5a1a0af4 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -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 */ diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index b08dab53..c3d81d27 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -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 */ diff --git a/apps/cli/cli_plugin.h b/apps/cli/cli_plugin.h index 270550c5..d911cc4f 100644 --- a/apps/cli/cli_plugin.h +++ b/apps/cli/cli_plugin.h @@ -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); diff --git a/include/clixon_custom.h b/include/clixon_custom.h index 57913560..590ea782 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -101,8 +101,3 @@ */ #define STATE_ORDERED_BY_SYSTEM -/*! Use cligen 4.4 instead of master / cligen 4.5.pre - * Temporary fix - */ -#undef USE_CLIGEN44 - diff --git a/lib/clixon/clixon_string.h b/lib/clixon/clixon_string.h index 5795c690..ba69d491 100644 --- a/lib/clixon/clixon_string.h +++ b/lib/clixon/clixon_string.h @@ -107,9 +107,6 @@ char *clixon_trim(char *str); char *clixon_trim2(char *str, char *trims); int clicon_strcmp(char *s1, char *s2); -#ifdef USE_CLIGEN44 -int cbuf_append_str(cbuf *cb, char *str); -#endif #ifndef HAVE_STRNDUP char *clicon_strndup (const char *, size_t); #endif /* ! HAVE_STRNDUP */ diff --git a/lib/src/clixon_string.c b/lib/src/clixon_string.c index d7471b5c..7f536ba0 100644 --- a/lib/src/clixon_string.c +++ b/lib/src/clixon_string.c @@ -814,70 +814,6 @@ clicon_strndup(const char *str, } #endif /* ! HAVE_STRNDUP */ -#ifdef USE_CLIGEN44 - -#define CBUFLEN_THRESHOLD 65536 -struct cbuf { - char *cb_buffer; /* pointer to buffer */ - size_t cb_buflen; /* allocated bytes of buffer */ - size_t cb_strlen; /* length of string in buffer (< buflen) */ -}; - -static int -cbuf_realloc(cbuf *cb, - size_t sz) -{ - int retval = -1; - int diff; - - diff = cb->cb_buflen - (cb->cb_strlen + sz + 1); - if (diff <= 0){ - while (diff <= 0){ - if (cb->cb_buflen < CBUFLEN_THRESHOLD) - cb->cb_buflen *= 2; /* Double the space - exponential */ - else - cb->cb_buflen += CBUFLEN_THRESHOLD; /* Add - linear growth*/ - diff = cb->cb_buflen - (cb->cb_strlen + sz + 1); - } - if ((cb->cb_buffer = realloc(cb->cb_buffer, cb->cb_buflen)) == NULL) - goto done; - } - retval = 0; - done: - return retval; -} - -/*! Append a string to a cbuf - * - * An optimized special case of cprintf - * @param [in] cb cligen buffer allocated by cbuf_new(), may be reallocated. - * @param [in] str string - * @retval 0 OK - * @retval -1 Error - * @see cprintf for the generic function - */ -int -cbuf_append_str(cbuf *cb, - char *str) -{ - size_t len0; - size_t len; - - if (str == NULL){ - errno = EINVAL; - return -1; - } - len0 = strlen(str); - len = cb->cb_strlen + len0; - /* Ensure buffer is large enough */ - if (cbuf_realloc(cb, len) < 0) - return -1; - strncpy(cb->cb_buffer+cb->cb_strlen, str, len0+1); - cb->cb_strlen = len;; - return 0; -} -#endif - /* * Turn this on for uni-test programs * Usage: clixon_string join