diff --git a/CHANGELOG.md b/CHANGELOG.md index a5bfb897..5dd9ac21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,13 @@ Expected: July 2023 * Restructured and extended stats rpc to schema mountpoints * rpc `` is not backward compatible +### C/CLI-API changes on existing features +Developers may need to change their code + +* `yang2cli_yspec` removed last argument `printgen`. +* Removed obsolete: `cli_auto_show()` + + ### Minor features * CLI: Added `show statistics` example code for backend and CLI memory stats diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c index 1780f3e0..3bada048 100644 --- a/apps/cli/cli_common.c +++ b/apps/cli/cli_common.c @@ -269,6 +269,10 @@ identityref_add_ns(cxobj *x, * api-path01--------- * The result computed from the top-level yspec and montpoint xpath are: * - api_pathfmt10 Combined api-path for both trees + * @param[in] yspec0 Top-level yang-spec + * @param[in] mtpoint Mount-point, generic: if there are several with same yang, any will do + * @param[in] api_path_fmt1 Second part of api-path-fmt + * @param[out] api_path_fmt01 Combined api-path-fmt */ int mtpoint_paths(yang_stmt *yspec0, diff --git a/apps/cli/cli_generate.c b/apps/cli/cli_generate.c index 17451b69..6705d16d 100644 --- a/apps/cli/cli_generate.c +++ b/apps/cli/cli_generate.c @@ -1347,8 +1347,6 @@ yang2cli_post(clicon_handle h, * @param[in] h Clixon handle * @param[in] yspec Top-level Yang statement of type Y_SPEC * @param[in] treename Name of tree - * @param[in] xautocli Autocli config tree (instance of clixon-autocli.yang) - * @param[in] printgen Log the generated CLIgen syntax * @retval 0 OK * @retval -1 Error * @note Tie-break of same top-level symbol: prefix is NYI @@ -1356,8 +1354,7 @@ yang2cli_post(clicon_handle h, int yang2cli_yspec(clicon_handle h, yang_stmt *yspec, - char *treename, - int printgen) + char *treename) { int retval = -1; parse_tree *pt0 = NULL; @@ -1431,8 +1428,7 @@ yang2cli_yspec(clicon_handle h, goto done; } // pt_print(stderr,pt); - - if (printgen) + if (clicon_data_int_get(h, "autocli-print-debug") == 1) clicon_log(LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s", __FUNCTION__, treename, cbuf_get(cb)); else @@ -1453,13 +1449,17 @@ yang2cli_yspec(clicon_handle h, if (cligen_expandv_str2fn(pt0, (expandv_str2fn_t*)clixon_str2fn, NULL) < 0) goto done; /* Append cligen tree and name it */ - if ((ph = cligen_ph_add(cli_cligen(h), treename)) == NULL) + if ((ph = cligen_ph_add(cli_cligen(h), treename)) == NULL){ + clicon_err(OE_UNIX, 0, "cligen_ph_add"); goto done; - if (cligen_ph_parsetree_set(ph, pt0) < 0) + } + if (cligen_ph_parsetree_set(ph, pt0) < 0){ + clicon_err(OE_UNIX, 0, "cligen_ph_parsetree_set"); goto done; + } pt0 = NULL; #if 0 - if (printgen){ + if (clicon_data_int_get(h, "autocli-print-debug") == 1){ clicon_log(LOG_NOTICE, "%s: Top-level cli-spec %s", __FUNCTION__, treename); pt_print1(stderr, pt0, 0); } diff --git a/apps/cli/cli_generate.h b/apps/cli/cli_generate.h index b2b2c036..b1a3a168 100644 --- a/apps/cli/cli_generate.h +++ b/apps/cli/cli_generate.h @@ -56,7 +56,7 @@ /* * Prototypes */ -int yang2cli_yspec(clicon_handle h, yang_stmt *yspec, char *treename, int printgen); +int yang2cli_yspec(clicon_handle h, yang_stmt *yspec, char *treename); int yang2cli_init(clicon_handle h); #endif /* _CLI_GENERATE_H_ */ diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 0df7c3b1..8ae9fd5b 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -370,13 +370,11 @@ autocli_trees_default(clicon_handle h) * "tree reference" syntax. * * @param[in] h Clixon handle - * @param[in] printgen Print CLI syntax generated from dbspec * @retval 0 OK * @retval -1 Error */ static int -autocli_start(clicon_handle h, - int printgen) +autocli_start(clicon_handle h) { int retval = -1; yang_stmt *yspec; @@ -401,7 +399,7 @@ autocli_start(clicon_handle h, goto done; yspec = clicon_dbspec_yang(h); /* The actual generating call from yang to clispec for the complete yang spec */ - if (yang2cli_yspec(h, yspec, AUTOCLI_TREENAME, printgen) < 0) + if (yang2cli_yspec(h, yspec, AUTOCLI_TREENAME) < 0) goto done; /* XXX Create pre-5.5 tree-refs for backward compatibility */ if (autocli_trees_default(h) < 0) @@ -458,7 +456,6 @@ main(int argc, char *tmp; char *argv0 = argv[0]; clicon_handle h; - int printgen = 0; int logclisyntax = 0; int help = 0; int logdst = CLICON_LOG_STDERR; @@ -596,7 +593,7 @@ main(int argc, goto done; break; case 'G' : /* Print generated CLI syntax */ - printgen++; + clicon_data_int_set(h, "autocli-print-debug", 1); break; case 'L' : /* Debug print dynamic CLI syntax */ logclisyntax++; @@ -750,7 +747,7 @@ main(int argc, goto done; /* Create autocli from YANG */ - if (autocli_start(h, printgen) < 0) + if (autocli_start(h) < 0) goto done; /* Initialize cli syntax. diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 59b660ed..71ee0f0b 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -292,7 +292,7 @@ expand_dbvar(void *h, cprintf(cbxpath, "%s", mtpoint); if (xml_nsctx_yangspec(yspec0, &nsc0) < 0) goto done; - cv = NULL; /* Append cvv1 to cvv2 */ + cv = NULL; /* Append nsc0 to nsc */ while ((cv = cvec_each(nsc0, cv)) != NULL) cvec_append_var(nsc, cv); } @@ -449,7 +449,7 @@ show_yang(clicon_handle h, * @param[in] nsc Namespace mapping for xpath * @param[in] skiptop If set, do not show object itself, only its children */ -static int +int cli_show_common(clicon_handle h, char *db, enum format_enum format, @@ -569,7 +569,7 @@ done: * @retval 0 OK * @retval -1 Error */ -static int +int cli_show_option_format(cvec *argv, int argc, enum format_enum *format) @@ -595,7 +595,7 @@ cli_show_option_format(cvec *argv, * @retval 0 OK * @retval -1 Error */ -static int +int cli_show_option_bool(cvec *argv, int argc, int *bool @@ -635,7 +635,7 @@ cli_show_option_bool(cvec *argv, * @retval 0 OK * @retval -1 Error */ -static int +int cli_show_option_withdefault(cvec *argv, int argc, char **withdefault, @@ -947,7 +947,7 @@ cli_show_auto(clicon_handle h, if (api_path2xpath(api_path, yspec0, &xpath, &nsc, NULL) < 0) goto done; if (xpath == NULL){ - clicon_err(OE_FATAL, 0, "Invalid api-path-fmt: %s", api_path_fmt); + clicon_err(OE_FATAL, 0, "Invalid api-path: %s", api_path); goto done; } if (cli_show_common(h, dbname, format, pretty, state, @@ -983,7 +983,8 @@ cli_show_auto(clicon_handle h, * Retrieval mode: report-all, trim, explicit, report-all-tagged, * NULL, report-all-tagged-default, report-all-tagged-strip (extended) * CLI prefix: prepend before cli syntax output - * @code + * @cli_show_auto_ctrl +code * clispec: * show config, cli_show_auto_mode("candidate"); * cli run: @@ -1103,42 +1104,6 @@ cli_show_auto_mode(clicon_handle h, return retval; } -#if 1 // OBSOLETE -/*! Obsolete Show configuration callback for autocli edit modes using tree working point - * - * @note Please use cli_show_auto_mode instead, - * but since that function does not use treename(argv[0]) that must be stripped - */ -int -cli_auto_show(clicon_handle h, - cvec *cvv, - cvec *argv0) -{ - int retval = -1; - cvec *argv1 = NULL; - cg_var *cv; - - if ((argv1 = cvec_new(0)) == NULL){ - clicon_err(OE_UNIX, errno, "cvec_new"); - goto done; - } - cv = NULL; - while ((cv = cvec_each1(argv0, cv)) != NULL) { - if (cvec_append_var(argv1, cv) == NULL){ - clicon_err(OE_UNIX, errno, "cvec_append_var"); - goto done; - } - } - if (cli_show_auto_mode(h, cvv, argv1) < 0) - goto done; - retval = 0; - done: - if (argv1) - cvec_free(argv1); - return retval; -} -#endif - /*! Show clixon configuration options as loaded */ int diff --git a/apps/cli/clixon_cli_api.h b/apps/cli/clixon_cli_api.h index eda9e565..05349876 100644 --- a/apps/cli/clixon_cli_api.h +++ b/apps/cli/clixon_cli_api.h @@ -82,52 +82,29 @@ int cli_notification_register(clicon_handle h, char *stream, enum format_enum fo /* cli_common.c: CLIgen new vector callbacks */ +int mtpoint_paths(yang_stmt *yspec0, char *mtpoint, char *api_path_fmt1, char **api_path_fmt01); int cli_dbxml(clicon_handle h, cvec *vars, cvec *argv, enum operation_type op, cvec *nsctx); - -int cli_dbxml(clicon_handle h, cvec *vars, cvec *argv, enum operation_type op, cvec *nsctx); - int cli_set(clicon_handle h, cvec *vars, cvec *argv); - int cli_merge(clicon_handle h, cvec *vars, cvec *argv); - int cli_create(clicon_handle h, cvec *vars, cvec *argv); - int cli_remove(clicon_handle h, cvec *vars, cvec *argv); - int cli_del(clicon_handle h, cvec *vars, cvec *argv); - int cli_debug_cli(clicon_handle h, cvec *vars, cvec *argv); - int cli_debug_backend(clicon_handle h, cvec *vars, cvec *argv); - int cli_debug_restconf(clicon_handle h, cvec *vars, cvec *argv); - int cli_set_mode(clicon_handle h, cvec *vars, cvec *argv); - int cli_start_shell(clicon_handle h, cvec *vars, cvec *argv); - int cli_quit(clicon_handle h, cvec *vars, cvec *argv); - int cli_commit(clicon_handle h, cvec *vars, cvec *argv); - int cli_validate(clicon_handle h, cvec *vars, cvec *argv); - int compare_db_names(clicon_handle h, enum format_enum format, char *db1, char *db2); - int compare_dbs(clicon_handle h, cvec *vars, cvec *argv); - int load_config_file(clicon_handle h, cvec *vars, cvec *argv); - int save_config_file(clicon_handle h, cvec *vars, cvec *argv); - int delete_all(clicon_handle h, cvec *vars, cvec *argv); - int discard_changes(clicon_handle h, cvec *vars, cvec *argv); - int cli_notify(clicon_handle h, cvec *cvv, cvec *argv); - int db_copy(clicon_handle h, cvec *cvv, cvec *argv); - int cli_lock(clicon_handle h, cvec *cvv, cvec *argv); int cli_unlock(clicon_handle h, cvec *cvv, cvec *argv); int cli_copy_config(clicon_handle h, cvec *cvv, cvec *argv); @@ -140,10 +117,13 @@ int expand_dbvar(void *h, char *name, cvec *cvv, cvec *argv, int clixon_cli2file(clicon_handle h, FILE *f, cxobj *xn, char *prepend, clicon_output_cb *fn, int skiptop); /* cli_show.c: CLIgen new vector arg callbacks */ +int cli_show_common(clicon_handle h, char *db, enum format_enum format, int pretty, int state, char *withdefault, char *extdefault, char *prepend, char *xpath, cvec *nsc, int skiptop); + int show_yang(clicon_handle h, cvec *vars, cvec *argv); - int show_conf_xpath(clicon_handle h, cvec *cvv, cvec *argv); - +int cli_show_option_format(cvec *argv, int argc, enum format_enum *format); +int cli_show_option_bool(cvec *argv, int argc, int *bool); +int cli_show_option_withdefault(cvec *argv, int argc, char **withdefault, char **extdefault); int cli_show_config(clicon_handle h, cvec *cvv, cvec *argv); int cli_show_config_state(clicon_handle h, cvec *cvv, cvec *argv); @@ -157,9 +137,6 @@ int cli_show_options(clicon_handle h, cvec *cvv, cvec *argv); int cli_auto_edit(clicon_handle h, cvec *cvv1, cvec *argv); int cli_auto_up(clicon_handle h, cvec *cvv, cvec *argv); int cli_auto_top(clicon_handle h, cvec *cvv, cvec *argv); -#if 1 // Obsolete: Use cli_show_auto_mode instead -int cli_auto_show(clicon_handle h, cvec *cvv, cvec *argv); -#endif int cli_show_auto_mode(clicon_handle h, cvec *cvv, cvec *argv); int cli_auto_set(clicon_handle h, cvec *cvv, cvec *argv); int cli_auto_merge(clicon_handle h, cvec *cvv, cvec *argv); diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 06549a04..a412a7f8 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -560,7 +560,7 @@ xml_tree_prune_flagged_sub(cxobj *xt, yang_stmt *yt; mark = 0; - yt = xml_spec(xt); /* xan be null */ + yt = xml_spec(xt); /* can be null */ x = NULL; xprev = x = NULL; while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {