* Removed cli callback vector functions. Set COMPAT_COMPAT_CLIV if you need to keep these functions in clixon_custom.h.

* Added --enable-debug.
This commit is contained in:
Olof hagsand 2018-05-30 22:38:12 +02:00
parent c8733e5ed8
commit ea13727e97
9 changed files with 232 additions and 129 deletions

View file

@ -3,10 +3,32 @@
## 3.7.0 (Upcoming)
### Major changes:
### Minor changes:
* Removed cli callback vector functions. Set COMPAT_COMPAT_CLIV if you need to keep these functions in clixon_custom.h.
* Replace functions as follows in CLI SPEC files:
* cli_setv --> cli_set
* cli_mergev --> cli_merge
* cli_delv --> cli_del
* cli_debug_cliv --> cli_debug_cli
* cli_debug_backendv --> cli_debug_backend
* cli_set_modev --> cli_set_mode
* cli_start_shellv --> cli_start_shell
* cli_quitv --> cli_quit
* cli_commitv --> cli_commit
* cli_validatev --> cli_validate
* compare_dbsv --> compare_dbs
* load_config_filev --> load_config_file
* save_config_filev --> save_config_file
* delete_allv --> delete_all
* discard_changesv --> discard_changes
* cli_notifyv --> cli_notify
* show_yangv --> show_yang
* show_confv_xpath --> show_conf_xpath
* Added --enable-debug.
* Added cligen variable translation.
* See FAQ and example
### Corrected Bugs
* Fixed JSON unbalanced braces resultin assert.
* Fixed JSON unbalanced braces resulting in assert.
## 3.6.1 (29 May 2018)
@ -460,7 +482,7 @@ If you submit "nopresence" without a leaf, it will automatically be removed:
Instead use the rpc calls in clixon_proto_client.[ch]
In clients (eg cli/netconf) replace xmldb_get() in client code with
clicon_rpc_get_config().
pIf you use the vector arguments of xmldb_get(), replace as follows:
If you use the vector arguments of xmldb_get(), replace as follows:
xmldb_get(h, db, api_path, &xt, &xvec, &xlen);
with
clicon_rpc_get_config(h, dbstr, api_path, &xt);

View file

@ -184,7 +184,7 @@ cli_signal_flush(clicon_handle h)
cli_signal_block (h);
}
/*! Modify xml database from a callback using xml key format strings
/*! Modify xml datastore from a callback using xml key format strings
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
@ -283,8 +283,15 @@ cli_dbxml(clicon_handle h,
return retval;
}
/*! Set datastore xml entry
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
*/
int
cli_set(clicon_handle h, cvec *cvv, cvec *argv)
cli_set(clicon_handle h,
cvec *cvv,
cvec *argv)
{
int retval = 1;
@ -294,13 +301,16 @@ cli_set(clicon_handle h, cvec *cvv, cvec *argv)
done:
return retval;
}
int cli_setv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_set(h, vars, argv);
}
/*! Merge datastore xml entry
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
*/
int
cli_merge(clicon_handle h, cvec *cvv, cvec *argv)
cli_merge(clicon_handle h,
cvec *cvv,
cvec *argv)
{
int retval = -1;
@ -310,13 +320,16 @@ cli_merge(clicon_handle h, cvec *cvv, cvec *argv)
done:
return retval;
}
int cli_mergev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_merge(h, vars, argv);
}
/*! Create datastore xml entry
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
*/
int
cli_create(clicon_handle h, cvec *cvv, cvec *argv)
cli_create(clicon_handle h,
cvec *cvv,
cvec *argv)
{
int retval = -1;
@ -326,11 +339,16 @@ cli_create(clicon_handle h, cvec *cvv, cvec *argv)
done:
return retval;
}
/*!
/*! Remove datastore xml entry
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
* @see cli_del
*/
int
cli_remove(clicon_handle h, cvec *cvv, cvec *argv)
cli_remove(clicon_handle h,
cvec *cvv,
cvec *argv)
{
int retval = -1;
@ -341,8 +359,15 @@ cli_remove(clicon_handle h, cvec *cvv, cvec *argv)
return retval;
}
/*! Delete datastore xml
* @param[in] h Clicon handle
* @param[in] cvv Vector of cli string and instantiated variables
* @param[in] argv Vector. First element xml key format string, eg "/aaa/%s"
*/
int
cli_del(clicon_handle h, cvec *cvv, cvec *argv)
cli_del(clicon_handle h,
cvec *cvv,
cvec *argv)
{
int retval = -1;
@ -352,11 +377,6 @@ cli_del(clicon_handle h, cvec *cvv, cvec *argv)
done:
return retval;
}
int cli_delv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_del(h, vars, argv);
}
/*! Set debug level on CLI client (not backend daemon)
* @param[in] h Clicon handle
@ -388,10 +408,6 @@ cli_debug_cli(clicon_handle h,
done:
return retval;
}
int cli_debug_cliv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_debug_cli(h, vars, argv);
}
/*! Set debug level on backend daemon (not CLI)
* @param[in] h Clicon handle
@ -422,10 +438,6 @@ cli_debug_backend(clicon_handle h,
done:
return retval;
}
int cli_debug_backendv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_debug_backend(h, vars, argv);
}
/*! Set debug level on restconf daemon
* @param[in] h Clicon handle
@ -479,10 +491,6 @@ cli_set_mode(clicon_handle h,
done:
return retval;
}
int cli_set_modev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_set_mode(h, vars, argv);
}
/*! Start bash from cli callback
* XXX Application specific??
@ -540,10 +548,6 @@ cli_start_shell(clicon_handle h,
return 0;
}
int cli_start_shellv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_start_shell(h, vars, argv);
}
/*! Generic quit callback
*/
@ -555,10 +559,6 @@ cli_quit(clicon_handle h,
cligen_exiting_set(cli_cligen(h), 1);
return 0;
}
int cli_quitv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_quit(h, vars, argv);
}
/*! Generic commit callback
* @param[in] argv No arguments expected
@ -576,10 +576,6 @@ cli_commit(clicon_handle h,
done:
return retval;
}
int cli_commitv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_commit(h, vars, argv);
}
/*! Generic validate callback
*/
@ -596,10 +592,6 @@ cli_validate(clicon_handle h,
done:
return retval;
}
int cli_validatev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_validate(h, vars, argv);
}
/*! Compare two dbs using XML. Write to file and run diff
*/
@ -709,10 +701,6 @@ compare_dbs(clicon_handle h,
return retval;
}
int compare_dbsv(clicon_handle h, cvec *vars, cvec *argv)
{
return compare_dbs(h, vars, argv);
}
/*! Load a configuration file to candidate database
* Utility function used by cligen spec file
@ -724,7 +712,7 @@ int compare_dbsv(clicon_handle h, cvec *vars, cvec *argv)
* @note file is assumed to have a dummy top-tag, eg <clicon></clicon>
* @code
* # cligen spec
* load file <name2:string>, load_config_filev("name2","merge");
* load file <name2:string>, load_config_file("name2","merge");
* @endcode
* @see save_config_file
*/
@ -804,10 +792,6 @@ load_config_file(clicon_handle h,
close(fd);
return ret;
}
int load_config_filev(clicon_handle h, cvec *vars, cvec *argv)
{
return load_config_file(h, vars, argv);
}
/*! Copy database to local file
* Utility function used by cligen spec file
@ -889,10 +873,6 @@ save_config_file(clicon_handle h,
fclose(f);
return retval;
}
int save_config_filev(clicon_handle h, cvec *vars, cvec *argv)
{
return save_config_file(h, vars, argv);
}
/*! Delete all elements in a database
* Utility function used by cligen spec file
@ -922,10 +902,6 @@ delete_all(clicon_handle h,
done:
return retval;
}
int delete_allv(clicon_handle h, cvec *vars, cvec *argv)
{
return delete_all(h, vars, argv);
}
/*! Discard all changes in candidate and replace with running
*/
@ -935,12 +911,8 @@ discard_changes(clicon_handle h,
cvec *argv)
{
return clicon_rpc_discard_changes(h);
}
int discard_changesv(clicon_handle h, cvec *vars, cvec *argv)
{
return discard_changes(h, vars, argv);
}
}
/*! Copy from one database to another, eg running->startup
* @param[in] argv a string: "<db1> <db2>" Copy from db1 to db2
*/
@ -1024,7 +996,7 @@ cli_notification_cb(int s,
* and <format> is XXX
* Example code: Start logging of mystream and show logs as xml
* @code
* cmd("comment"), cli_notifyv("mystream","1","xml");
* cmd("comment"), cli_notify("mystream","1","xml");
* @endcode
* XXX: format is a memory leak
*/
@ -1062,10 +1034,79 @@ cli_notify(clicon_handle h,
done:
return retval;
}
/* Backward compatible Set if you want to enable "v" cli callback functions,
* such as cli_setv()
* This was obsoleted in 3.7.
* @see include/clixon_custom.h
*/
#ifdef COMPAT_CLIV
int cli_setv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_set(h, vars, argv);
}
int cli_mergev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_merge(h, vars, argv);
}
int cli_delv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_del(h, vars, argv);
}
int cli_debug_cliv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_debug_cli(h, vars, argv);
}
int cli_debug_backendv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_debug_backend(h, vars, argv);
}
int cli_set_modev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_set_mode(h, vars, argv);
}
int cli_start_shellv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_start_shell(h, vars, argv);
}
int cli_quitv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_quit(h, vars, argv);
}
int cli_commitv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_commit(h, vars, argv);
}
int cli_validatev(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_validate(h, vars, argv);
}
int compare_dbsv(clicon_handle h, cvec *vars, cvec *argv)
{
return compare_dbs(h, vars, argv);
}
int load_config_filev(clicon_handle h, cvec *vars, cvec *argv)
{
return load_config_file(h, vars, argv);
}
int save_config_filev(clicon_handle h, cvec *vars, cvec *argv)
{
return save_config_file(h, vars, argv);
}
int delete_allv(clicon_handle h, cvec *vars, cvec *argv)
{
return delete_all(h, vars, argv);
}
int discard_changesv(clicon_handle h, cvec *vars, cvec *argv)
{
return discard_changes(h, vars, argv);
}
int cli_notifyv(clicon_handle h, cvec *vars, cvec *argv)
{
return cli_notify(h, vars, argv);
}
#endif /* COMPAT_CLIV */
/*! Lock database
*

View file

@ -409,10 +409,6 @@ show_yang(clicon_handle h,
yang_print(stdout, yn);
return 0;
}
int show_yangv(clicon_handle h, cvec *vars, cvec *argv)
{
return show_yang(h, vars, argv);
}
/*! Generic show configuration CLIGEN callback
* Utility function used by cligen spec file
@ -598,13 +594,19 @@ done:
return retval;
}
int show_confv_xpath(clicon_handle h, cvec *vars, cvec *argv)
{
return show_conf_xpath(h, vars, argv);
}
int cli_show_version(clicon_handle h, cvec *vars, cvec *argv)
{
cli_output(stdout, "%s\n", CLIXON_VERSION_STRING);
return 0;
}
#ifdef COMPAT_CLIV
int show_yangv(clicon_handle h, cvec *vars, cvec *argv)
{
return show_yang(h, vars, argv);
}
int show_confv_xpath(clicon_handle h, cvec *vars, cvec *argv)
{
return show_conf_xpath(h, vars, argv);
}
#endif /* COMPAT_CLIV */

View file

@ -72,57 +72,51 @@ int cli_notification_register(clicon_handle h, char *stream, enum format_enum fo
int cli_set(clicon_handle h, cvec *vars, cvec *argv);
int cli_setv(clicon_handle h, cvec *vars, cvec *argv);
int cli_merge(clicon_handle h, cvec *vars, cvec *argv);
int cli_mergev(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_delv(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_cli(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_cliv(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_backend(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_backendv(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_set_modev(clicon_handle h, cvec *vars, cvec *argv);
int cli_start_shell(clicon_handle h, cvec *vars, cvec *argv);
int cli_start_shellv(clicon_handle h, cvec *vars, cvec *argv);
int cli_quit(clicon_handle h, cvec *vars, cvec *argv);
int cli_quitv(clicon_handle h, cvec *vars, cvec *argv);
int cli_commit(clicon_handle h, cvec *vars, cvec *argv);
int cli_commitv(clicon_handle h, cvec *vars, cvec *argv);
int cli_validate(clicon_handle h, cvec *vars, cvec *argv);
int cli_validatev(clicon_handle h, cvec *vars, cvec *argv);
int compare_dbs(clicon_handle h, cvec *vars, cvec *argv);
int compare_dbsv(clicon_handle h, cvec *vars, cvec *argv);
int load_config_file(clicon_handle h, cvec *vars, cvec *argv);
int load_config_filev(clicon_handle h, cvec *vars, cvec *argv);
int save_config_file(clicon_handle h, cvec *vars, cvec *argv);
int save_config_filev(clicon_handle h, cvec *vars, cvec *argv);
int delete_all(clicon_handle h, cvec *vars, cvec *argv);
int delete_allv(clicon_handle h, cvec *vars, cvec *argv);
int discard_changes(clicon_handle h, cvec *vars, cvec *argv);
int discard_changesv(clicon_handle h, cvec *vars, cvec *argv);
int cli_notify(clicon_handle h, cvec *cvv, cvec *argv);
int cli_notifyv(clicon_handle h, cvec *cvv, cvec *argv);
int db_copy(clicon_handle h, cvec *cvv, cvec *argv);
@ -141,11 +135,32 @@ int expandv_dbvar(void *h, char *name, cvec *cvv, cvec *argv,
/* cli_show.c: CLIgen new vector arg callbacks */
int show_yang(clicon_handle h, cvec *vars, cvec *argv);
int show_yangv(clicon_handle h, cvec *vars, cvec *argv);
int show_conf_xpath(clicon_handle h, cvec *cvv, cvec *argv);
int show_confv_xpath(clicon_handle h, cvec *cvv, cvec *argv);
int cli_show_config(clicon_handle h, cvec *cvv, cvec *argv);
#ifdef COMPAT_CLIV
int cli_setv(clicon_handle h, cvec *vars, cvec *argv);
int cli_mergev(clicon_handle h, cvec *vars, cvec *argv);
int cli_delv(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_cliv(clicon_handle h, cvec *vars, cvec *argv);
int cli_debug_backendv(clicon_handle h, cvec *vars, cvec *argv);
int cli_set_modev(clicon_handle h, cvec *vars, cvec *argv);
int cli_start_shellv(clicon_handle h, cvec *vars, cvec *argv);
int cli_quitv(clicon_handle h, cvec *vars, cvec *argv);
int cli_commitv(clicon_handle h, cvec *vars, cvec *argv);
int cli_validatev(clicon_handle h, cvec *vars, cvec *argv);
int compare_dbsv(clicon_handle h, cvec *vars, cvec *argv);
int load_config_filev(clicon_handle h, cvec *vars, cvec *argv);
int save_config_filev(clicon_handle h, cvec *vars, cvec *argv);
int delete_allv(clicon_handle h, cvec *vars, cvec *argv);
int discard_changesv(clicon_handle h, cvec *vars, cvec *argv);
int cli_notifyv(clicon_handle h, cvec *cvv, cvec *argv);
int show_yangv(clicon_handle h, cvec *vars, cvec *argv);
int show_confv_xpath(clicon_handle h, cvec *cvv, cvec *argv);
#endif /* COMPAT_CLIV */
#endif /* _CLIXON_CLI_API_H_ */

42
configure vendored
View file

@ -634,13 +634,8 @@ EXEEXT
ac_ct_CC
with_restconf
RANLIB
AR
EXE_SUFFIX
SH_SUFFIX
AR_SUFFIX
OBJ_SUFFIX
INSTALLFLAGS
INSTALL_LIB
INSTALL
INSTALL_DATA
INSTALL_SCRIPT
@ -710,6 +705,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_debug
with_cligen
with_restconf
with_configfile
@ -1344,6 +1340,12 @@ if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug Build with debug symbols, default: no
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
@ -2444,11 +2446,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# If yes, compile apps/restconf
#
ac_ext=c
@ -3382,6 +3379,27 @@ CPPFLAGS="-DHAVE_CONFIG_H ${CPPFLAGS}"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: compiler is $CC" >&5
$as_echo "compiler is $CC" >&6; }
# Debug flag
# Check whether --enable-debug was given.
if test "${enable_debug+set}" = set; then :
enableval=$enable_debug;
if test "$enableval" = no; then
ac_enable_debug=no
else
ac_enable_debug=yes
fi
else
ac_enable_debug=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: debug is $ac_enable_debug" >&5
$as_echo "debug is $ac_enable_debug" >&6; }
if test "$ac_enable_debug" = "yes"; then
CFLAGS="-g -Wall"
INSTALLFLAGS=""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: CPPFLAGS is $CPPFLAGS" >&5
$as_echo "CPPFLAGS is $CPPFLAGS" >&6; }
@ -3643,11 +3661,7 @@ _ACEOF
fi
EXE_SUFFIX=""
OBJ_SUFFIX=".o"
AR_SUFFIX=".a"
SH_SUFFIX=".so"
AR="ar"
# This is for cligen

View file

@ -81,16 +81,11 @@ AC_SUBST(INCLUDES)
AC_SUBST(CPPFLAGS)
AC_PROG_INSTALL
AC_SUBST(INSTALL)
AC_SUBST(INSTALL_LIB)
AC_SUBST(INSTALL_DATA)
AC_SUBST(INSTALL_PROGRAM)
AC_SUBST(INSTALLFLAGS)
AC_SUBST(LIBS)
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(AR_SUFFIX)
AC_SUBST(SH_SUFFIX)
AC_SUBST(EXE_SUFFIX)
AC_SUBST(AR)
AC_SUBST(RANLIB)
AC_SUBST(with_restconf) # If yes, compile apps/restconf
#
@ -100,6 +95,21 @@ AC_PROG_CPP
CPPFLAGS="-DHAVE_CONFIG_H ${CPPFLAGS}"
AC_MSG_RESULT(compiler is $CC)
# Debug flag
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Build with debug symbols, default: no]),[
if test "$enableval" = no; then
ac_enable_debug=no
else
ac_enable_debug=yes
fi
],
[ ac_enable_debug=no])
AC_MSG_RESULT(debug is $ac_enable_debug)
if test "$ac_enable_debug" = "yes"; then
CFLAGS="-g -Wall"
INSTALLFLAGS=""
fi
AC_MSG_RESULT(CPPFLAGS is $CPPFLAGS)
AC_MSG_RESULT(CFLAGS is $CFLAGS)
@ -119,11 +129,7 @@ if test "$prefix" = "NONE"; then
fi
AC_CHECK_LIB(m, main)
EXE_SUFFIX=""
OBJ_SUFFIX=".o"
AR_SUFFIX=".a"
SH_SUFFIX=".so"
AR="ar"
# This is for cligen
AC_ARG_WITH(cligen, [ --with-cligen=dir Use CLIGEN here ] )

View file

@ -342,7 +342,7 @@ plugin_credentials(clicon_handle h,
To authenticate, the callback needs to return the value 1 and supply a username.
See [../apps/example/example_restconf.c] plugin_credentials() for
See [../apps/example/example_restconf.c] example_restconf_credentials() for
an example of HTTP basic auth.
## How do I write a CLI translator function

View file

@ -43,6 +43,7 @@
int strverscmp (__const char *__s1, __const char *__s2);
#endif
/* Set if you want to enable "v" cli callback functions, such as cli_setv()
* This was obsoleted in 3.7
*/
#undef COMPAT_CLIV

View file

@ -52,6 +52,8 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@
VPATH = @srcdir@
CC = @CC@
CFLAGS = -fPIC @CFLAGS@
INSTALL = @INSTALL@
INSTALL_LIB = @INSTALL@
INSTALLFLAGS = @INSTALLFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
@ -182,8 +184,8 @@ install: install-lib
install-include:
install-lib: $(MYLIB)
install -m 0755 -d $(DESTDIR)$(libdir)
install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir)
$(INSTALL) -m 0755 -d $(DESTDIR)$(libdir)
$(INSTALL_LIB) -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir)
ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon.so.3
ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon.so