Added --with-libxml2 to configure

This commit is contained in:
Olof hagsand 2019-05-24 10:04:29 +02:00
parent e55a27bcac
commit 5b39b63698
8 changed files with 36 additions and 38 deletions

View file

@ -141,14 +141,14 @@
### Minor changes
* Regexp improvements
* Added libxml2 XSD regexp mode as alternative to posix translation
* Regexp improvements: Added libxml2 XSD regexp mode as alternative to posix translation
* Configure with: `./configure --with-libxml2`
* Set `CLICON_YANG_REGEXP` to libxml2 (default is posix)
* Better compliance with XSD regexps (when transforming to Posix regexps)
* Added `\p{L}` and `\p{N}`
* Added escaping of `$`
* Added `CLICON_YANG_REGEXP`option with possible values libxml2 and posix
* Added clixon_util_regexp utility function
* Added regexp test [test/test_pattern.sh]
* Added regexp test [test/test_pattern.sh] for both posix and libxml2
* Yang state get improvements
* Integrated state and config into same tree on retrieval, not separate trees
* Added cli functions `cli_show_config_state()` and `cli_show_auto_state()` for showing combined config and state info.

View file

@ -497,9 +497,9 @@ main(int argc,
if (help)
usage(h, argv[0]);
#ifndef HAVE_LIBXML_XMLREGEXP_H
#ifndef HAVE_LIBXML2
if (strcmp(clicon_yang_regexp(h), "libxml2")==0){
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXM_XMLREGEXP_H not set (Either change CLICON_YANG_REGEXP to posix, or configure with libxml2?))");
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML2 not set (Either change CLICON_YANG_REGEXP to posix, or run: configure --with-libxml2))");
goto done;
}
#endif

View file

@ -447,11 +447,11 @@ main(int argc, char **argv)
usage(h, argv[0]);
if (strcmp(clicon_yang_regexp(h), "libxml2")==0){
#ifdef HAVE_LIBXML_XMLREGEXP_H
/* Enable XSD libxml2 */
cligen_regex_set(cli_cligen(h), 1);
#ifdef HAVE_LIBXML2
/* Enable XSD libxml2 regex engine */
cligen_regex_xsd_set(cli_cligen(h), 1);
#else
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML_XMLREGEXP_H not set (Either change CLICON_YANG_REGEXP to posix, or configure with libxml2))");
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML2 not set (Either change CLICON_YANG_REGEXP to posix, or run: configure --with-libxml2))");
goto done;
#endif
}

29
configure vendored
View file

@ -717,6 +717,7 @@ enable_publish
with_restconf
with_wwwuser
with_configfile
with_libxml2
'
ac_precious_vars='build_alias
host_alias
@ -1365,6 +1366,7 @@ Optional Packages:
--without-restconf disable support for restconf
--with-wwwuser=<user> Set www user different from www-data
--with-configfile=FILE set default path to config file
--with-libxml2 use gnome/libxml2 regex engine
Some influential environment variables:
CC C compiler command
@ -4417,7 +4419,17 @@ _ACEOF
fi
# This is for libxml2 code which we can use for XSD regexp
# This is for libxml2 XSD regex engine
# Note this only enables the compiling of the code. In order to actually
# use it you need to set Clixon config option CLICON_YANG_REGEXP to libxml2
# Check whether --with-libxml2 was given.
if test "${with_libxml2+set}" = set; then :
withval=$with_libxml2;
fi
if test "${with_libxml2}"; then
# Find libxml2 lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlRegexpCompile in -lxml2" >&5
$as_echo_n "checking for xmlRegexpCompile in -lxml2... " >&6; }
if ${ac_cv_lib_xml2_xmlRegexpCompile+:} false; then :
@ -4463,23 +4475,8 @@ _ACEOF
fi
# Libxml2 may hide its include files under /usr/include/libxml2/libxml
# You may need to prepend CFLAGS="-I/usr/include/libxml2 to configure
for ac_header in libxml/xmlregexp.h
do :
ac_fn_c_check_header_compile "$LINENO" "libxml/xmlregexp.h" "ac_cv_header_libxml_xmlregexp_h" "#include \"libxml/xmlversion.h\"
"
if test "x$ac_cv_header_libxml_xmlregexp_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBXML_XMLREGEXP_H 1
_ACEOF
fi
done
#
for ac_func in inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort
do :

View file

@ -220,12 +220,14 @@ AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, xdr_char)
AC_CHECK_LIB(dl, dlopen)
# This is for libxml2 code which we can use for XSD regexp
# This is for libxml2 XSD regex engine
# Note this only enables the compiling of the code. In order to actually
# use it you need to set Clixon config option CLICON_YANG_REGEXP to libxml2
AC_ARG_WITH(libxml2, [ --with-libxml2 use gnome/libxml2 regex engine ] )
if test "${with_libxml2}"; then
# Find libxml2 lib
AC_CHECK_LIB(xml2, xmlRegexpCompile)
# Libxml2 may hide its include files under /usr/include/libxml2/libxml
# You may need to prepend CFLAGS="-I/usr/include/libxml2 to configure
AC_CHECK_HEADERS([libxml/xmlregexp.h], [], [], [#include "libxml/xmlversion.h"])
fi
#
AC_CHECK_FUNCS(inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort)

View file

@ -60,9 +60,6 @@
/* Define to 1 if you have the `xml2' library (-lxml2). */
#undef HAVE_LIBXML2
/* Define to 1 if you have the <libxml/xmlregexp.h> header file. */
#undef HAVE_LIBXML_XMLREGEXP_H
/* Define to 1 if you have the <linux/if_vlan.h> header file. */
#undef HAVE_LINUX_IF_VLAN_H

View file

@ -76,9 +76,11 @@ expectfn "$clixon_cli -1 -f $cfg set interfaces interface fddi&< type ianaift:et
new "cli failed validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Validate failed. Edit and try again or discard changes: application missing-element Mandatory variable <bad-element>type</bad-element>"
new "cli configure more"
new "cli configure ip addr"
expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 ipv4 address 1.2.3.4 prefix-length 24" 0 "^$"
new "cli configure ip descr"
expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 description mydesc" 0 "^$"
new "cli configure ip type"
expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 type ex:eth" 0 "^$"
new "cli show xpath description"

View file

@ -99,7 +99,7 @@ regex_posix(char *regexp,
int retval = -1;
char *posix = NULL;
char pattern[1024];
int status;
int status = 0;
regex_t re;
char errbuf[1024];
int len0;