Adapted to CLIgen 4.5 API changes, eg: and

This commit is contained in:
Olof hagsand 2020-04-20 13:14:40 +02:00
parent 8897df202e
commit 1dff0e681b
7 changed files with 27 additions and 18 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;
}
/*

View file

@ -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);

2
configure vendored
View file

@ -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

View file

@ -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]))

View file

@ -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