Merge branch 'develop' of https://github.com/clicon/clixon into develop

This commit is contained in:
Olof hagsand 2017-12-09 22:19:17 +01:00
commit 662495fff0
9 changed files with 91 additions and 39 deletions

View file

@ -15,11 +15,15 @@
* Changed XML creation and parse API for more coherency and closer YANG/XML integration. A new yang spec parameter has been added (default NULL) and functions have been removed and renamed. You may need to change the XML calls as follows. * Changed XML creation and parse API for more coherency and closer YANG/XML integration. A new yang spec parameter has been added (default NULL) and functions have been removed and renamed. You may need to change the XML calls as follows.
* xml_new(name, parent) --> xml_new(name, xn_parent, yspec) * xml_new(name, parent) --> xml_new(name, xn_parent, yspec)
* xml_new_spec(name, parent, spec) --> xml_new(name, parent, spec) * xml_new_spec(name, parent, spec) --> xml_new(name, parent, spec)
* clicon_xml_parse(&xt, format, ...) --> xml_parse_va(&xt, yspec, format, ...)
* clicon_xml_parse_file(fd, &xt, endtag) --> xml_parse_file(fd, endtag, yspec, &xt) * clicon_xml_parse_file(fd, &xt, endtag) --> xml_parse_file(fd, endtag, yspec, &xt)
* clicon_xml_parse_string(&str, &xt) --> xml_parse_string(str, yspec, &xt) * clicon_xml_parse_string(&str, &xt) --> xml_parse_string(str, yspec, &xt)
* xml_parse(str, xt) --> xml_parse_string(str, yspec, &xt)
* clicon_xml_parse(&xt, format, ...) --> xml_parse_va(&xt, yspec, format, ...)
* clicon_xml_parse_str(str, &xt) --> xml_parse_string(str, yspec, &xt) * clicon_xml_parse_str(str, &xt) --> xml_parse_string(str, yspec, &xt)
* xml_parse(str, xt) --> xml_parse_string(str, yspec, &xt)
* Backward compatibility is enabled by (will be removed in 3.5.0:
```
configure --with-xml-compat
```
## 3.3.3 (25 November 2017) ## 3.3.3 (25 November 2017)

View file

@ -209,8 +209,7 @@ expand_dbvar(void *h,
else else
bodystr = xml_body(x); bodystr = xml_body(x);
if (bodystr == NULL){ if (bodystr == NULL){
clicon_err(OE_CFG, 0, "No xml body"); continue; /* no body, cornercase */
goto done;
} }
/* detect duplicates */ /* detect duplicates */
for (k=0; k<j; k++){ for (k=0; k<j; k++){

38
configure vendored
View file

@ -632,6 +632,7 @@ CPP
OBJEXT OBJEXT
EXEEXT EXEEXT
ac_ct_CC ac_ct_CC
with_xml_compat
with_config_compat with_config_compat
with_startup_compat with_startup_compat
with_keyvalue with_keyvalue
@ -713,6 +714,7 @@ with_keyvalue
with_qdbm with_qdbm
with_startup_compat with_startup_compat
with_config_compat with_config_compat
with_xml_compat
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
host_alias host_alias
@ -1352,7 +1354,8 @@ Optional Packages:
--with-keyvalue enable support for key-value xmldb datastore --with-keyvalue enable support for key-value xmldb datastore
--with-qdbm=dir Use QDBM here, if keyvalue --with-qdbm=dir Use QDBM here, if keyvalue
--with-startup-compat Backward compatibility of backend startup commands --with-startup-compat Backward compatibility of backend startup commands
--with-config-compat Backward compatibility of ocnfiguration file --with-config-compat Backward compatibility of configuration file
--with-xml-compat Backward compatibility of XML API
Some influential environment variables: Some influential environment variables:
CC C compiler command CC C compiler command
@ -2353,8 +2356,12 @@ test -n "$target_alias" &&
# If yes, compile apps/restconf # If yes, compile apps/restconf
# If yes, compile datastore/keyvalue # If yes, compile datastore/keyvalue
# If yes, backward compatible backend startup # If yes, backward compatible with 3.3.2 backend startup
# If yes, backward compatible .conf configuration
# If yes, backward compatible with 3.3.2 .conf configuration
# If yes, backward compatible with 3.3.3 XML api new and parse functions
# #
ac_ext=c ac_ext=c
@ -3973,7 +3980,6 @@ fi
echo "Using QDBM here: ${with_qdbm}" echo "Using QDBM here: ${with_qdbm}"
CPPFLAGS="-I${with_qdbm}/include ${CPPFLAGS}" CPPFLAGS="-I${with_qdbm}/include ${CPPFLAGS}"
LDFLAGS="-L${with_qdbm}/lib ${LDFLAGS}" LDFLAGS="-L${with_qdbm}/lib ${LDFLAGS}"
fi fi
# Problem: depot.h may be in qdbm/depot.h. # Problem: depot.h may be in qdbm/depot.h.
for ac_header in depot.h for ac_header in depot.h
@ -4054,7 +4060,8 @@ fi
fi fi
# This is for backward compatibility of backend startup commands # This is for backward compatibility of backend startup commands in 3.3.3
# Will be removed in 3.4.0
# Check whether --with-startup_compat was given. # Check whether --with-startup_compat was given.
if test "${with_startup_compat+set}" = set; then : if test "${with_startup_compat+set}" = set; then :
@ -4071,7 +4078,8 @@ _ACEOF
fi fi
# This is for backward compatibility of .conf configuration file # This is for backward compatibility of .conf configuration file in 3.3.3
# Will be removed in 3.4.0
# Check whether --with-config_compat was given. # Check whether --with-config_compat was given.
if test "${with_config_compat+set}" = set; then : if test "${with_config_compat+set}" = set; then :
@ -4088,6 +4096,24 @@ _ACEOF
fi fi
# This is for backward compatibility of XML create and parse API in 3.4.0
# Will be removed in 3.5.0
# Check whether --with-xml_compat was given.
if test "${with_xml_compat+set}" = set; then :
withval=$with_xml_compat;
else
with_xml_compat=no
fi
if test "x${with_xml_compat}" == xyes; then
cat >>confdefs.h <<_ACEOF
#define XML_COMPAT $with_xml_compat
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5
$as_echo_n "checking for crypt in -lcrypt... " >&6; } $as_echo_n "checking for crypt in -lcrypt... " >&6; }
if ${ac_cv_lib_crypt_crypt+:} false; then : if ${ac_cv_lib_crypt_crypt+:} false; then :

View file

@ -86,8 +86,12 @@ AC_SUBST(AR)
AC_SUBST(RANLIB) AC_SUBST(RANLIB)
AC_SUBST(with_restconf) # If yes, compile apps/restconf AC_SUBST(with_restconf) # If yes, compile apps/restconf
AC_SUBST(with_keyvalue) # If yes, compile datastore/keyvalue AC_SUBST(with_keyvalue) # If yes, compile datastore/keyvalue
AC_SUBST(with_startup_compat) # If yes, backward compatible backend startup # If yes, backward compatible with 3.3.2 backend startup
AC_SUBST(with_config_compat) # If yes, backward compatible .conf configuration AC_SUBST(with_startup_compat)
# If yes, backward compatible with 3.3.2 .conf configuration
AC_SUBST(with_config_compat)
# If yes, backward compatible with 3.3.3 XML api new and parse functions
AC_SUBST(with_xml_compat)
# #
AC_PROG_CC() AC_PROG_CC()
@ -164,7 +168,8 @@ if test "x${with_keyvalue}" == xyes; then
AC_CONFIG_FILES(datastore/keyvalue/Makefile) AC_CONFIG_FILES(datastore/keyvalue/Makefile)
fi fi
# This is for backward compatibility of backend startup commands # This is for backward compatibility of backend startup commands in 3.3.3
# Will be removed in 3.4.0
AC_ARG_WITH([startup_compat], AC_ARG_WITH([startup_compat],
[AS_HELP_STRING([--with-startup-compat],[Backward compatibility of backend startup commands])], [AS_HELP_STRING([--with-startup-compat],[Backward compatibility of backend startup commands])],
[], [],
@ -173,15 +178,27 @@ if test "x${with_startup_compat}" == xyes; then
AC_DEFINE_UNQUOTED(BACKEND_STARTUP_COMPAT, $with_startup_compat, [Backward compatible backend startup command-line options]) AC_DEFINE_UNQUOTED(BACKEND_STARTUP_COMPAT, $with_startup_compat, [Backward compatible backend startup command-line options])
fi fi
# This is for backward compatibility of .conf configuration file # This is for backward compatibility of .conf configuration file in 3.3.3
# Will be removed in 3.4.0
AC_ARG_WITH([config_compat], AC_ARG_WITH([config_compat],
[AS_HELP_STRING([--with-config-compat],[Backward compatibility of ocnfiguration file])], [AS_HELP_STRING([--with-config-compat],[Backward compatibility of configuration file])],
[], [],
[with_config_compat=no]) [with_config_compat=no])
if test "x${with_config_compat}" == xyes; then if test "x${with_config_compat}" == xyes; then
AC_DEFINE_UNQUOTED(CONFIG_COMPAT, $with_config_compat, [Backward compatible of .conf configuration files]) AC_DEFINE_UNQUOTED(CONFIG_COMPAT, $with_config_compat, [Backward compatible of .conf configuration files])
fi fi
# Clixon 3.4.0 changes XML creation and parse API
# Set this for backward compat and migration.
# Will be removed in 3.5.0
AC_ARG_WITH([xml_compat],
[AS_HELP_STRING([--with-xml-compat],[Backward compatibility of XML API])],
[],
[with_xml_compat=no])
if test "x${with_xml_compat}" == xyes; then
AC_DEFINE_UNQUOTED(XML_COMPAT, $with_xml_compat, [Backward compatible of XML API])
fi
AC_CHECK_LIB(crypt, crypt) AC_CHECK_LIB(crypt, crypt)
AC_CHECK_HEADERS(crypt.h) AC_CHECK_HEADERS(crypt.h)

View file

@ -138,6 +138,9 @@
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS
/* Backward compatible of XML API */
#undef XML_COMPAT
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */ `char[]'. */
#undef YYTEXT_POINTER #undef YYTEXT_POINTER

View file

@ -56,6 +56,8 @@
#undef CLIXON_VERSION_MINOR #undef CLIXON_VERSION_MINOR
#undef CLIXON_VERSION_PATCH #undef CLIXON_VERSION_PATCH
#undef XML_COMPAT
/* /*
* Use this constant to disable some prototypes that should not be visible outside the lib. * Use this constant to disable some prototypes that should not be visible outside the lib.
* This is an alternative to use separate internal include files. * This is an alternative to use separate internal include files.

View file

@ -38,6 +38,10 @@
#ifndef _CLIXON_XML_H #ifndef _CLIXON_XML_H
#define _CLIXON_XML_H #define _CLIXON_XML_H
/*
* Constants
*/
/* /*
* Types * Types
*/ */
@ -113,12 +117,6 @@ cxobj *xml_child_each(cxobj *xparent, cxobj *xprev, enum cxobj_type type);
cxobj **xml_childvec_get(cxobj *x); cxobj **xml_childvec_get(cxobj *x);
int xml_childvec_set(cxobj *x, int len); int xml_childvec_set(cxobj *x, int len);
#ifdef OBSOLETE /* Changed in 3.3.3, see CHANGELOG */
/* Changed: */
cxobj *xml_new(char *name, cxobj *xn_parent);
/* Removed: */
cxobj *xml_new_spec(char *name, cxobj *xn_parent, void *spec);
#endif
cxobj *xml_new(char *name, cxobj *xn_parent, yang_stmt *spec); cxobj *xml_new(char *name, cxobj *xn_parent, yang_stmt *spec);
yang_stmt *xml_spec(cxobj *x); yang_stmt *xml_spec(cxobj *x);
int xml_spec_set(cxobj *x, yang_stmt *spec); int xml_spec_set(cxobj *x, yang_stmt *spec);
@ -142,15 +140,6 @@ int xml_free(cxobj *xn);
int xml_print(FILE *f, cxobj *xn); int xml_print(FILE *f, cxobj *xn);
int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint); int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint);
int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint); int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint);
#ifdef OBSOLETE /* Changed in 3.3.3, see CHANGELOG */
/* Changed: */
int clicon_xml_parse(cxobj **cxtop, char *format, ...);
int clicon_xml_parse_file(int fd, cxobj **xml_top, char *endtag);
int clicon_xml_parse_str(char *str, cxobj **xml_top);
/* Removed: */
int xml_parse(char *str, yang_spec *yspec, cxobj *xt);
int clicon_xml_parse_string(char **str, cxobj **xml_top);
#endif
int xml_parse_file(int fd, char *endtag, yang_spec *yspec, cxobj **xt); int xml_parse_file(int fd, char *endtag, yang_spec *yspec, cxobj **xt);
int xml_parse_string(const char *str, yang_spec *yspec, cxobj **xml_top); int xml_parse_string(const char *str, yang_spec *yspec, cxobj **xml_top);
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...); int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...);
@ -180,4 +169,16 @@ int xml_hash_add(cxobj *x);
int xml_hash_rm_only(cxobj *x); int xml_hash_rm_only(cxobj *x);
int xml_hash_rm_entry(cxobj *x); int xml_hash_rm_entry(cxobj *x);
#ifdef XML_COMPAT /* See CHANGELOG */
/* MANUAL CHANGE: xml_new(name, parent) --> xml_new(name, parent, NULL) */
#define xml_new_spec(name, parent) xml_new(name, parent, NULL)
#define clicon_xml_parse(xt, fmt, ...) xml_parse_va(xt, NULL, fmt, __VA_ARGS__)
#define clicon_xml_parse_file(fd, xt, etag) xml_parse_file(fd, etag, NULL, xt)
#define clicon_xml_parse_string(strp, xt) xml_parse_string(*strp, NULL, xt)
#define clicon_xml_parse_str(str, xt) xml_parse_string(str, NULL, xt)
#define xml_parse(str, xt) xml_parse_string(str, NULL, &xt)
#endif
#endif /* _CLIXON_XML_H */ #endif /* _CLIXON_XML_H */

View file

@ -955,11 +955,13 @@ clicon_xml2file(FILE *f,
cxobj *xc; cxobj *xc;
int hasbody; int hasbody;
int haselement; int haselement;
char *val;
name = xml_name(x); name = xml_name(x);
namespace = xml_namespace(x); namespace = xml_namespace(x);
switch(xml_type(x)){ switch(xml_type(x)){
case CX_BODY: case CX_BODY:
if ((val = xml_value(x)) != NULL) /* incomplete tree */
fprintf(f, "%s", xml_value(x)); fprintf(f, "%s", xml_value(x));
break; break;
case CX_ATTR: case CX_ATTR:
@ -1191,7 +1193,7 @@ xmltree2cbuf(cbuf *cb,
* @see xml_parse_va * @see xml_parse_va
*/ */
static int static int
xml_parse(const char *str, _xml_parse(const char *str,
yang_spec *yspec, yang_spec *yspec,
cxobj *xt) cxobj *xt)
{ {
@ -1297,7 +1299,7 @@ xml_parse_file(int fd,
if (*xt == NULL) if (*xt == NULL)
if ((*xt = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL) if ((*xt = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
goto done; goto done;
if (xml_parse(ptr, yspec, *xt) < 0) if (_xml_parse(ptr, yspec, *xt) < 0)
goto done; goto done;
break; break;
} }
@ -1349,7 +1351,7 @@ xml_parse_string(const char *str,
if (*xtop == NULL) if (*xtop == NULL)
if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL) if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
return -1; return -1;
return xml_parse(str, yspec, *xtop); return _xml_parse(str, yspec, *xtop);
} }
/*! Read XML from var-arg list and parse it into xml tree /*! Read XML from var-arg list and parse it into xml tree
@ -1397,7 +1399,7 @@ xml_parse_va(cxobj **xtop,
if (*xtop == NULL) if (*xtop == NULL)
if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL) if ((*xtop = xml_new(XML_TOP_SYMBOL, NULL, NULL)) == NULL)
goto done; goto done;
if (xml_parse(str, yspec, *xtop) < 0) if (_xml_parse(str, yspec, *xtop) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: done:

View file

@ -680,10 +680,8 @@ match_base_child(cxobj *x0,
cvi = NULL; i = 0; cvi = NULL; i = 0;
while ((cvi = cvec_each(cvk, cvi)) != NULL) { while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi); keyname = cv_string_get(cvi);
if ((b1 = xml_find_body(x1c, keyname)) == NULL){ if ((b1 = xml_find_body(x1c, keyname)) == NULL)
clicon_err(OE_UNIX, errno, "key %s not found", keyname); goto ok; /* not found */
goto done;
}
b1vec[i++] = b1; b1vec[i++] = b1;
} }
/* Iterate over x0 tree to (1) find a child that matches name /* Iterate over x0 tree to (1) find a child that matches name