diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5a3ab3..198e2c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ Expected: May 2020 ### Major New features -* NACM RFC341 datanode read and write paths +* NACM RFC8341 datanode read and write paths * This completes the NACM RPC and Data node access checks (notification still remains) ### API changes on existing protocol/config features (You may have have to change how you use Clixon) @@ -43,6 +43,7 @@ Expected: May 2020 ### Minor changes +* Adapted to CLIgen 4.5 API changes, eg: `cliread()` and `cliread_parse()` * Renamed utility function `clixon_util_insert()` to `clixon_util_xml_mod()` and added merge functionality. * Sanity check of duplicates prefixes in Yang modules and submodules as defined in RFC 7950 Sec 7.1.4 diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 8c49a64e..86e29652 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -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; diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index 74f0fc63..b9e73c53 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -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; } /* diff --git a/apps/cli/cli_plugin.h b/apps/cli/cli_plugin.h index 365085f7..dadc2e50 100644 --- a/apps/cli/cli_plugin.h +++ b/apps/cli/cli_plugin.h @@ -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); diff --git a/configure b/configure index 1ede6834..9c7dd117 100755 --- a/configure +++ b/configure @@ -4606,7 +4606,7 @@ if test "x$ac_cv_header_cligen_cligen_h" = xyes; then : _ACEOF else - as_fn_error $? "cligen missing. Try: git clone https://github.com/olofhagsand/cligen.git" "$LINENO" 5 + as_fn_error $? "CLIgen missing. Try: git clone https://github.com/olofhagsand/cligen.git" "$LINENO" 5 fi done diff --git a/configure.ac b/configure.ac index f02e3a49..8fe9f0e3 100644 --- a/configure.ac +++ b/configure.ac @@ -184,7 +184,7 @@ if test "$ac_enable_publish" = "yes"; then AC_DEFINE(CLIXON_PUBLISH_STREAMS, 1, [Enable publish of notification streams using SSE and curl]) fi -AC_CHECK_HEADERS(cligen/cligen.h,, AC_MSG_ERROR(cligen missing. Try: git clone https://github.com/olofhagsand/cligen.git)) +AC_CHECK_HEADERS(cligen/cligen.h,, AC_MSG_ERROR([CLIgen missing. Try: git clone https://github.com/olofhagsand/cligen.git])) AC_CHECK_LIB(cligen, cligen_init,, AC_MSG_ERROR([CLIgen missing. Try: git clone https://github.com/olofhagsand/cligen.git])) diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index 9b65990b..b2b4c341 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -411,8 +411,7 @@ yang2api_path_fmt(yang_stmt *ys, * 2 : ip = "1.2.3.4" * api_path: /interfaces/interface=e/ipv4/address=1.2.3.4 * @param[in] api_path_fmt XML key format, eg /aaa/%s/name - * @param[in] cvv cligen variable vector, one for every wildchar in - * api_path_fmt + * @param[in] cvv cligen variable vector, one for every wildchar in api_path_fmt * @param[out] api_path api_path, eg /aaa/17. Free after use * @note first and last elements of cvv are not used,.. * @see api_path_fmt2xpath