diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec9d819..97553a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,10 +49,24 @@ * yang_parse() changed to take either filename or module name and revision. * Removed clicon_dbspec_name[_set](). * Use yang_main_module_name() instead. - * Replaced yang_spec_main with yang_spec_parse_module - * Added yang_spec_parse_file + * Replace code for initializing the main yang module + * Replace yang_spec_main() with yang_spec_parse_module() as follows: +``` + /* old code */ + if ((yspec = yang_spec_main(ch)) == NULL) + goto done; + /* new code */ + if ((yspec = yspec_new()) == NULL) + goto done; + clicon_dbspec_yang_set(h, yspec); + if (yang_spec_parse_module(h, clicon_yang_module_main(h), + clicon_yang_dir(h), clicon_yang_module_revision(h), yspec) < 0) + goto done; +``` + ### Minor changes +* Added CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml as option and in example (so you dont need to provide -f command-line option). * Yang 1.1 action syntax added (but function is not supported) * New function: clicon_conf_xml() returns configuration tree * Obsoleted COMPAT_CLIV and COMPAT_XSL that were optional in 3.7 diff --git a/configure b/configure index c7d2bd1c..ebf7fcef 100755 --- a/configure +++ b/configure @@ -638,6 +638,7 @@ wwwdir with_restconf RANLIB SH_SUFFIX +CLIXON_DEFAULT_CONFIG INSTALLFLAGS INSTALL INSTALL_DATA @@ -685,6 +686,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -761,6 +763,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -1013,6 +1016,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1150,7 +1162,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1303,6 +1315,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -2438,6 +2451,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + # If yes, compile apps/restconf wwwdir=/www-data @@ -4057,12 +4071,11 @@ fi fi # Set default config file location +CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml # Check whether --with-configfile was given. if test "${with_configfile+set}" = set; then : - withval=$with_configfile; DEFAULT_CONFIG="$withval" -else - DEFAULT_CONFIG="$(eval echo ${sysconfdir}/clixon.xml)" + withval=$with_configfile; CLIXON_DEFAULT_CONFIG="$withval" fi @@ -4315,7 +4328,7 @@ _ACEOF # Default location for config file cat >>confdefs.h <<_ACEOF -#define CLIXON_DEFAULT_CONFIG "${DEFAULT_CONFIG}" +#define CLIXON_DEFAULT_CONFIG "${CLIXON_DEFAULT_CONFIG}" _ACEOF diff --git a/configure.ac b/configure.ac index 7161ff62..d5625abc 100644 --- a/configure.ac +++ b/configure.ac @@ -85,6 +85,7 @@ AC_SUBST(INSTALL) AC_SUBST(INSTALL_DATA) AC_SUBST(INSTALL_PROGRAM) AC_SUBST(INSTALLFLAGS) +AC_SUBST(CLIXON_DEFAULT_CONFIG) AC_SUBST(LIBS) AC_SUBST(SH_SUFFIX) AC_SUBST(RANLIB) @@ -158,10 +159,10 @@ if test "x${with_restconf}" == xyes; then fi # Set default config file location +CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml AC_ARG_WITH([configfile], [AS_HELP_STRING([--with-configfile=FILE],[set default path to config file])], - [DEFAULT_CONFIG="$withval"], - [DEFAULT_CONFIG="$(eval echo ${sysconfdir}/clixon.xml)"]) + [CLIXON_DEFAULT_CONFIG="$withval"],) AC_CHECK_LIB(crypt, crypt) AC_CHECK_HEADERS(crypt.h) @@ -186,7 +187,7 @@ CLIXON_DATADIR="${prefix}/share/clixon" AC_DEFINE_UNQUOTED(CLIXON_DATADIR, "${CLIXON_DATADIR}", [Clixon data dir for system yang files etc]) # Default location for config file -AC_DEFINE_UNQUOTED(CLIXON_DEFAULT_CONFIG,"${DEFAULT_CONFIG}",[Location for apps to find default config file]) +AC_DEFINE_UNQUOTED(CLIXON_DEFAULT_CONFIG,"${CLIXON_DEFAULT_CONFIG}",[Location for apps to find default config file]) AH_BOTTOM([#include ]) diff --git a/example/Makefile.in b/example/Makefile.in index c95ff1de..26345185 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -43,6 +43,8 @@ localstatedir = @localstatedir@ libdir = @exec_prefix@/lib APPNAME = example +# Install here if you want default clixon location: +CLIXON_DEFAULT_CONFIG = @CLIXON_DEFAULT_CONFIG@ CC = @CC@ CFLAGS = @CFLAGS@ -rdynamic -fPIC @@ -56,6 +58,8 @@ CLI_PLUGIN = $(APPNAME)_cli.so NETCONF_PLUGIN = $(APPNAME)_netconf.so RESTCONF_PLUGIN = $(APPNAME)_restconf.so + + # Example docker image. PLEASE CHANGE THIS IMAGE = olofhagsand/clixon_example @@ -120,6 +124,7 @@ distclean: clean install: $(YANGSPECS) $(CLISPECS) $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) $(APPNAME).xml install -d -m 0755 $(DESTDIR)$(sysconfdir) install -m 0644 $(APPNAME).xml $(DESTDIR)$(sysconfdir) +# install -m 0644 $(APPNAME).xml $(DESTDIR)$(CLIXON_DEFAULT_CONFIG) install -d -m 0755 $(DESTDIR)$(datarootdir)/$(APPNAME)/yang install -m 0644 $(YANGSPECS) $(DESTDIR)$(datarootdir)/$(APPNAME)/yang install -d -m 0755 $(DESTDIR)$(libdir)/$(APPNAME)/cli diff --git a/lib/clixon/clixon_yang.h b/lib/clixon/clixon_yang.h index 78906109..5a8c6dd7 100644 --- a/lib/clixon/clixon_yang.h +++ b/lib/clixon/clixon_yang.h @@ -260,6 +260,7 @@ char *yang_find_myprefix(yang_stmt *ys); int yang_order(yang_stmt *y); int yang_print(FILE *f, yang_node *yn); int yang_print_cbuf(cbuf *cb, yang_node *yn, int marginal); +int ys_populate(yang_stmt *ys, void *arg); yang_stmt *yang_parse_file(int fd, const char *name, yang_spec *ysp); int yang_parse(clicon_handle h, const char *filename, const char *module, const char *dir, diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index e8c30ede..25134eed 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -1435,7 +1435,7 @@ ys_populate_feature(clicon_handle h, * See ys_parse_sub for first pass and what can be assumed * After this pass, cv:s are set for LEAFs and LEAF-LISTs */ -static int +int ys_populate(yang_stmt *ys, void *arg) {