* Made a separate Clixon datastore XML/JSON top-level symbol

* Replaces the hardcoded "config" keyword.
  * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
* Tests: added endtest to all tests. Removed all premature exits if BE=0
This commit is contained in:
Olof hagsand 2021-03-05 14:15:15 +01:00
parent 2ab90d847b
commit b7991d9b39
132 changed files with 939 additions and 628 deletions

View file

@ -102,6 +102,7 @@ usage(char *argv0)
int
main(int argc, char **argv)
{
int retval = -1;
int c;
clicon_handle h;
char *argv0;
@ -119,6 +120,7 @@ main(int argc, char **argv)
char *xpath;
cbuf *cbret = NULL;
int dbg = 0;
cxobj *xerr = NULL;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
@ -259,16 +261,21 @@ main(int argc, char **argv)
goto done;
fclose(fp);
}
else
if (clixon_xml_parse_string(argv[2], YB_MODULE, yspec, &xt, NULL) < 0)
else{
if ((ret = clixon_xml_parse_string(argv[2], YB_MODULE, yspec, &xt, &xerr)) < 0)
goto done;
if (xml_rootchild(xt, 0, &xt) < 0)
if (ret == 0){
xml_print(stderr, xerr);
goto done;
}
}
if (xml_name_set(xt, NETCONF_INPUT_CONFIG) < 0)
goto done;
if ((cbret = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if (xmldb_put(h, db, op, xt, NULL, cbret) < 1)
if ((ret = xmldb_put(h, db, op, xt, NULL, cbret)) < 0)
goto done;
}
else if (strcmp(cmd, "copy")==0){
@ -329,6 +336,7 @@ main(int argc, char **argv)
}
if (xmldb_disconnect(h) < 0)
goto done;
retval = 0;
done:
if (cbret)
cbuf_free(cbret);
@ -338,6 +346,6 @@ main(int argc, char **argv)
clicon_handle_exit(h);
if (yspec)
yspec_free(yspec);
return 0;
return retval;
}

View file

@ -33,7 +33,10 @@
***** END LICENSE BLOCK *****
*
* HTTP2 + OPENSSL client integrated with clixon events
* Ubuntu package:
* apt install libnghttp2-dev
* Example run: clixon_util_ssl -H nghttp2.org
*/
@ -122,9 +125,8 @@ send_callback(nghttp2_session *session,
{
session_data *sd = (session_data*)user_data;
int ret;
clicon_debug(1, "%s %d:", __FUNCTION__, length);
clicon_debug(1, "%s %zu:", __FUNCTION__, length);
#if 0
{
int i;
@ -475,6 +477,7 @@ main(int argc,
int ret;
nghttp2_session *session = NULL;
session_data *sd = NULL;
int dbg = 0;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
@ -487,7 +490,7 @@ main(int argc,
usage(argv[0]);
break;
case 'D':
if (sscanf(optarg, "%d", &debug) != 1)
if (sscanf(optarg, "%d", &dbg) != 1)
usage(argv[0]);
break;
case 'H': /* hostname */
@ -501,6 +504,7 @@ main(int argc,
fprintf(stderr, "-H <hostname> is mandatory\n");
usage(argv[0]);
}
clicon_debug_init(dbg, NULL);
SSL_library_init();
if ((ctx = InitCTX()) == NULL)
goto done;