diff --git a/CHANGELOG.md b/CHANGELOG.md index b2626d1f..a95f4535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ ### Minor changes: * Added systemd example files under example/systemd * Changed `plugin_init()` backend return semantics: If returns NULL, _without_ calling clicon_err(), the module is disabled. -* Dedicated standalone xml,json,yang and xpath parser utility test programs added under lib/src/. +* Added util subdir, with dedicated standalone xml,json,yang and xpath parser utility test programs. * CDATA xml support (patch by David Cornejo, Netgate) * Encode and decode (parsing) support * Validation of yang bits type space-separated list value diff --git a/Makefile.in b/Makefile.in index 04c72ab5..9c914381 100644 --- a/Makefile.in +++ b/Makefile.in @@ -52,7 +52,7 @@ INSTALL = @INSTALL@ INCLUDES = -I. -I@srcdir@ @INCLUDES@ SHELL = /bin/sh -SUBDIRS = lib apps include etc datastore yang +SUBDIRS = lib apps include etc datastore util yang .PHONY: doc all clean depend $(SUBDIRS) install loc TAGS .config.status docker diff --git a/configure b/configure index 88710c13..3312a01a 100755 --- a/configure +++ b/configure @@ -4325,7 +4325,7 @@ _ACEOF -ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/docker/Makefile extras/rpm/Makefile docker/Makefile docker/cli/Makefile docker/cli/Dockerfile docker/backend/Makefile docker/backend/Dockerfile docker/netconf/Makefile docker/netconf/Dockerfile datastore/Makefile datastore/text/Makefile yang/Makefile doc/Makefile" +ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/docker/Makefile extras/rpm/Makefile docker/Makefile docker/cli/Makefile docker/cli/Dockerfile docker/backend/Makefile docker/backend/Dockerfile docker/netconf/Makefile docker/netconf/Dockerfile datastore/Makefile datastore/text/Makefile util/Makefile yang/Makefile doc/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5043,6 +5043,7 @@ do "docker/netconf/Dockerfile") CONFIG_FILES="$CONFIG_FILES docker/netconf/Dockerfile" ;; "datastore/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/Makefile" ;; "datastore/text/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/text/Makefile" ;; + "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;; "yang/Makefile") CONFIG_FILES="$CONFIG_FILES yang/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; diff --git a/configure.ac b/configure.ac index 6c122768..44614911 100644 --- a/configure.ac +++ b/configure.ac @@ -211,7 +211,8 @@ AC_OUTPUT(Makefile docker/netconf/Dockerfile datastore/Makefile datastore/text/Makefile + util/Makefile yang/Makefile - doc/Makefile + doc/Makefile ) diff --git a/lib/src/Makefile.in b/lib/src/Makefile.in index 931bd41d..a37680c9 100644 --- a/lib/src/Makefile.in +++ b/lib/src/Makefile.in @@ -80,14 +80,6 @@ YACCOBJS := lex.clixon_xml_parse.o clixon_xml_parse.tab.o \ lex.clixon_json_parse.o clixon_json_parse.tab.o \ lex.clixon_xpath_parse.o clixon_xpath_parse.tab.o -# Extra applications. Utilities, unit testings. Not installed. -APPSRC = clixon_util_xml.c -APPSRC += clixon_util_json.c -APPSRC += clixon_util_yang.c -APPSRC += clixon_util_xpath.c - -APPS = $(APPSRC:.c=) - # Generated src GENSRC = build.c @@ -101,10 +93,10 @@ MYLIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = libclixon$(SH_SUFFIX) -all: $(MYLIB) $(MYLIBLINK) $(APPS) +all: $(MYLIB) $(MYLIBLINK) clean: - rm -f $(OBJS) $(MYLIB) $(APPS) $(MYLIBLINK) $(GENOBJS) $(GENSRC) *.core + rm -f $(OBJS) $(MYLIB) $(MYLIBLINK) $(GENOBJS) $(GENSRC) *.core rm -f clixon_xml_parse.tab.[ch] clixon_xml_parse.yy.[co] rm -f clixon_yang_parse.tab.[ch] clixon_yang_parse.[co] rm -f clixon_json_parse.tab.[ch] clixon_json_parse.[co] @@ -174,19 +166,6 @@ clixon_xpath_parse.tab.c clixon_xpath_parse.tab.h: clixon_xpath_parse.y lex.clixon_xpath_parse.o : lex.clixon_xpath_parse.c clixon_xpath_parse.tab.h $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -Wno-error -c $< -# APPS -clixon_util_xml: clixon_util_xml.c $(MYLIB) - $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $^ $(LIBS) -o $@ - -clixon_util_json: clixon_util_json.c $(MYLIB) - $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $^ $(LIBS) -o $@ - -clixon_util_yang: clixon_util_yang.c $(MYLIB) - $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $^ $(LIBS) -o $@ - -clixon_util_xpath: clixon_util_xpath.c $(MYLIB) - $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $^ $(LIBS) -o $@ - distclean: clean rm -f Makefile *~ .depend diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 34633e8a..05fbf56e 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -697,7 +697,7 @@ xp_relop(xp_ctx *xc1, case XT_BOOL: /* comparison on the boolean and the result of converting the node-set to a boolean using the boolean function is true. */ - b = ctx2boolean(xc); + b = ctx2boolean(xc1); switch(op){ case XO_EQ: xr->xc_bool = (b == xc2->xc_bool); diff --git a/test/test_json.sh b/test/test_json.sh index 63543abd..5c33ccd3 100755 --- a/test/test_json.sh +++ b/test/test_json.sh @@ -1,6 +1,6 @@ #!/bin/bash # Test: JSON parser tests -PROG=../lib/src/clixon_util_json +PROG=../util/clixon_util_json # include err() and new() functions and creates $dir . ./lib.sh diff --git a/test/test_xml.sh b/test/test_xml.sh index 4dd63631..9e4e8c70 100755 --- a/test/test_xml.sh +++ b/test/test_xml.sh @@ -1,6 +1,6 @@ #!/bin/bash # Test: XML parser tests -PROG=../lib/src/clixon_util_xml +PROG=../util/clixon_util_xml # include err() and new() functions and creates $dir . ./lib.sh diff --git a/test/test_xpath.sh b/test/test_xpath.sh index 4d23996a..b0b53a1c 100755 --- a/test/test_xpath.sh +++ b/test/test_xpath.sh @@ -1,6 +1,6 @@ #!/bin/bash # Test: XPATH tests -PROG=../lib/src/clixon_util_xpath +PROG=../util/clixon_util_xpath # include err() and new() functions and creates $dir . ./lib.sh diff --git a/test/test_yang_parse.sh b/test/test_yang_parse.sh index 1a80c89d..c98546ca 100755 --- a/test/test_yang_parse.sh +++ b/test/test_yang_parse.sh @@ -1,6 +1,6 @@ #!/bin/bash # Test: XML parser tests -PROG=../lib/src/clixon_util_yang +PROG=../util/clixon_util_yang # include err() and new() functions and creates $dir . ./lib.sh diff --git a/util/Makefile.in b/util/Makefile.in new file mode 100644 index 00000000..24379f48 --- /dev/null +++ b/util/Makefile.in @@ -0,0 +1,112 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# +# Copyright (C) 2009-2018 Olof Hagsand and Benny Holmgren +# +# This file is part of CLIXON +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 3 or later (the "GPL"), +# in which case the provisions of the GPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of the GPL, and not to allow others to +# use your version of this file under the terms of Apache License version 2, +# indicate your decision by deleting the provisions above and replace them with +# the notice and other provisions required by the GPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the Apache License version 2 or the GPL. +# +# ***** END LICENSE BLOCK ***** +# +prefix = @prefix@ +datarootdir = @datarootdir@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +dbdir = @prefix@/db +mandir = @mandir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +sysconfdir = @sysconfdir@ +HOST_VENDOR = @host_vendor@ + +SH_SUFFIX = @SH_SUFFIX@ + +CLIXON_VERSION = @CLIXON_VERSION@ +CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ +CLIXON_MINOR = @CLIXON_VERSION_MINOR@ + +VPATH = @srcdir@ +CC = @CC@ +CFLAGS = @CFLAGS@ +INSTALL = @INSTALL@ +INSTALL_LIB = @INSTALL@ +INSTALLFLAGS = @INSTALLFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ + +CPPFLAGS = @CPPFLAGS@ + +INCLUDES = -I. @INCLUDES@ -I$(top_srcdir)/lib/clixon -I$(top_srcdir)/include -I$(top_srcdir) + +MYLIB = ../lib/src/libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) + +# Utilities, unit testings. Not installed. +APPSRC = clixon_util_xml.c +APPSRC += clixon_util_json.c +APPSRC += clixon_util_yang.c +APPSRC += clixon_util_xpath.c + +APPS = $(APPSRC:.c=) + +all: $(APPS) + +clean: + rm -f $(APPS) *.core + +# APPS +clixon_util_xml: clixon_util_xml.c $(MYLIB) + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $^ $(LIBS) -o $@ + +clixon_util_json: clixon_util_json.c $(MYLIB) + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $^ $(LIBS) -o $@ + +clixon_util_yang: clixon_util_yang.c $(MYLIB) + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $^ $(LIBS) -o $@ + +clixon_util_xpath: clixon_util_xpath.c $(MYLIB) + $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $^ $(LIBS) -o $@ + +distclean: clean + rm -f Makefile *~ .depend + +install: + +install-include: + +install-lib: + +uninstall: + +TAGS: + find . -name '*.[ch]' -print | etags - + +depend: + $(CC) $(DEPENDFLAGS) @DEFS@ $(INCLUDES) $(CFLAGS) -MM $(APPSRC) > .depend + +#include .depend + diff --git a/util/README.md b/util/README.md new file mode 100644 index 00000000..542cb620 --- /dev/null +++ b/util/README.md @@ -0,0 +1,5 @@ +# Clixon utils + +This directory contains Clixon utility programs, ie, programs that are +good to have for testing, analysis, etc, but not an actual part of +delivered code. \ No newline at end of file diff --git a/lib/src/clixon_util_json.c b/util/clixon_util_json.c similarity index 100% rename from lib/src/clixon_util_json.c rename to util/clixon_util_json.c diff --git a/lib/src/clixon_util_xml.c b/util/clixon_util_xml.c similarity index 100% rename from lib/src/clixon_util_xml.c rename to util/clixon_util_xml.c diff --git a/lib/src/clixon_util_xpath.c b/util/clixon_util_xpath.c similarity index 100% rename from lib/src/clixon_util_xpath.c rename to util/clixon_util_xpath.c diff --git a/lib/src/clixon_util_yang.c b/util/clixon_util_yang.c similarity index 100% rename from lib/src/clixon_util_yang.c rename to util/clixon_util_yang.c