diff --git a/README.md b/README.md index 04c8e22b..c97e2abc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
- +
[![Build Status](https://travis-ci.org/clicon/clixon.png)](https://travis-ci.org/clicon/clixon) [![Documentation Status](https://readthedocs.org/projects/clixon-docs/badge/?version=latest)](https://clixon-docs.readthedocs.io/en/latest/?badge=latest) diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 8967af92..aee9336f 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -847,3 +847,54 @@ cli_show_auto_state(clicon_handle h, return cli_show_auto1(h, 1, cvv, argv); } +/*! Show clixon configuration options as loaded + */ +int +cli_show_options(clicon_handle h, + cvec *cvv, + cvec *argv) +{ + int retval = -1; + clicon_hash_t *hash = clicon_options(h); + int i; + char **keys = NULL; + void *val; + size_t klen; + size_t vlen; + cxobj *x = NULL; + + if (clicon_hash_keys(hash, &keys, &klen) < 0) + goto done; + for(i = 0; i < klen; i++) { + val = clicon_hash_value(hash, keys[i], &vlen); + if (vlen){ + if (((char*)val)[vlen-1]=='\0') /* assume string */ + fprintf(stdout, "%s: \"%s\"\n", keys[i], (char*)val); + else + fprintf(stdout, "%s: 0x%p , length %zu\n", keys[i], val, vlen); + } + else + fprintf(stdout, "%s: NULL", keys[i]); + } + /* Next print CLICON_FEATURE and CLICON_YANG_DIR from config tree + * Since they are lists they are placed in the config tree. + */ + x = NULL; + while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) { + if (strcmp(xml_name(x), "CLICON_YANG_DIR") != 0) + continue; + fprintf(stdout, "%s: \"%s\"", xml_name(x), xml_body(x)); + } + x = NULL; + while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) { + if (strcmp(xml_name(x), "CLICON_FEATURE") != 0) + continue; + fprintf(stdout, "%s: \"%s\"\n", xml_name(x), xml_body(x)); + } + retval = 0; + done: + if (keys) + free(keys); + return retval; +} + diff --git a/apps/cli/clixon_cli_api.h b/apps/cli/clixon_cli_api.h index e35d042c..971c9a97 100644 --- a/apps/cli/clixon_cli_api.h +++ b/apps/cli/clixon_cli_api.h @@ -133,6 +133,8 @@ int cli_show_config_state(clicon_handle h, cvec *cvv, cvec *argv); int cli_show_auto(clicon_handle h, cvec *cvv, cvec *argv); -int cli_show_state_auto(clicon_handle h, cvec *cvv, cvec *argv); +int cli_show_auto_state(clicon_handle h, cvec *cvv, cvec *argv); + +int cli_show_options(clicon_handle h, cvec *cvv, cvec *argv); #endif /* _CLIXON_CLI_API_H_ */ diff --git a/example/main/example_cli.cli b/example/main/example_cli.cli index 52669576..6bef7e9f 100644 --- a/example/main/example_cli.cli +++ b/example/main/example_cli.cli @@ -62,6 +62,7 @@ compare("Compare running and candidate"), compare_dbs((int32)1); show("Show a particular state of the system"){ xpath("Show configuration") ("XPATH expression") ("Namespace"), show_conf_xpath("candidate"); version("Show version"), cli_show_version("candidate", "text", "/"); + options("Show clixon options"), cli_show_options(); compare("Compare candidate and running databases"), compare_dbs((int32)0);{ xml("Show comparison in xml"), compare_dbs((int32)0); text("Show comparison in text"), compare_dbs((int32)1); diff --git a/lib/clixon/clixon_xml_nsctx.h b/lib/clixon/clixon_xml_nsctx.h index a13f766a..5c815f25 100644 --- a/lib/clixon/clixon_xml_nsctx.h +++ b/lib/clixon/clixon_xml_nsctx.h @@ -2,7 +2,9 @@ * ***** BEGIN LICENSE BLOCK ***** - Copyright (C) 2009-2019 Olof Hagsand + Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren + Copyright (C) 2017-2019 Olof Hagsand + Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate) This file is part of CLIXON. diff --git a/lib/src/clixon_proto.c b/lib/src/clixon_proto.c index 71aceb63..930fdf61 100644 --- a/lib/src/clixon_proto.c +++ b/lib/src/clixon_proto.c @@ -293,8 +293,8 @@ static int msg_dump(struct clicon_msg *msg) { int i; - char buf[9*8]; - char buf2[9*8]; + char buf[9*8+1]; + char buf2[9*8+1]; memset(buf2, 0, sizeof(buf2)); snprintf(buf2, sizeof(buf2), "%s:", __FUNCTION__); diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 2a6f7c23..3b92492d 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -881,7 +881,7 @@ xml_child_order(cxobj *xp, * Further, never manipulate the child-list during operation or using the * same object recursively, the function uses an internal field to remember the * index used. It works as long as the same object is not iterated concurrently. - * If you need to delete a node you can do somethjing like: + * If you need to delete a node you can do somethhing like: * @code * cxobj *xprev = NULL; * cxobj *x = NULL; @@ -892,6 +892,7 @@ xml_child_order(cxobj *xp, * x = xprev; * continue; * } + * xprev = x; * } * @endcode #ifdef XML_EXPLICIT_INDEX diff --git a/lib/src/clixon_xml_nsctx.c b/lib/src/clixon_xml_nsctx.c index eac9f8d3..58c84eb6 100644 --- a/lib/src/clixon_xml_nsctx.c +++ b/lib/src/clixon_xml_nsctx.c @@ -310,6 +310,7 @@ xml_nsctx_node(cxobj *xn, * xml_nsctx_free(nsc) * @endcode * @see RFC7950 Sections 6.4.1 (and 9.9.2?) + * @note Assume yn is in a yang structure (eg has parents and belongs to a (sub)module) */ int xml_nsctx_yang(yang_stmt *yn,