* C-API: Added xpath_first_localonly() as an xpath function that skips prefix and namespace checks.

* Added experimental code for optizing XPath search using binary search.
  * Enable with XPATH_LIST_OPTIMIZE
* Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)`
This commit is contained in:
Olof hagsand 2019-12-20 18:21:46 +01:00
parent ab46ce9820
commit 7ad16bd84b
56 changed files with 602 additions and 227 deletions

View file

@ -58,7 +58,6 @@
#include <sys/param.h>
#include <sys/mount.h>
#include <pwd.h>
#include <assert.h>
/* cligen */
#include <cligen/cligen.h>
@ -70,7 +69,6 @@
#include "cli_common.h"
/*! Register log notification stream
* @param[in] h Clicon handle
* @param[in] stream Event stream. CLICON is predefined, others are application-defined
@ -715,13 +713,13 @@ compare_dbs(clicon_handle h,
if (clicon_rpc_get_config(h, NULL, "running", "/", NULL, &xc1) < 0)
goto done;
if ((xerr = xpath_first(xc1, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
if (clicon_rpc_get_config(h, NULL, "candidate", "/", NULL, &xc2) < 0)
goto done;
if ((xerr = xpath_first(xc2, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
if (compare_xmls(xc1, xc2, astext) < 0) /* astext? */
@ -885,7 +883,7 @@ save_config_file(clicon_handle h,
goto done;
}
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
/* get-config returns a <data> tree. Save as <config> tree so it can be used
@ -1225,7 +1223,7 @@ cli_copy_config(clicon_handle h,
if (clicon_rpc_get_config(h, NULL, db, cbuf_get(cb), nsc, &x1) < 0)
goto done;
if ((xerr = xpath_first(x1, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}

View file

@ -48,7 +48,6 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <fcntl.h>
#include <syslog.h>
#include <sys/param.h>
@ -76,6 +75,8 @@
This is an example yang module:
module m {
container x {
namespace "urn:example:m";
prefix m;
list m1 {
key "a";
leaf a {
@ -88,12 +89,11 @@ module m {
}
}
You can see which CLISPEC it generates via clixon_cli -D 1:
Jan 2 11:17:58: yang2cli: buf
} x,cli_set("/x");{
m1 (<a:string>|<a:string expand_dbvar("candidate /x/m1/%s/a")>),cli_set("/x/m1/%s");
You can see which CLISPEC it generates via clixon_cli -D 2:
x,cli_set("/example:x");{
m1 a (<a:string>|<a:string expand_dbvar("candidate","/example:x/m1=%s/a")>),overwrite_me("/example:x/m1=%s/");
{
b (<b:string>|<b:string expand_dbvar("candidate /x/m1/%s/b")>),cli_set("/x/m1/%s/b");
b (<b:string>|<b:string expand_dbvar("candidate","/example:x/m1=%s/b")>),overwrite_me("/example:x/m1=%s/b");
}
}
*/

View file

@ -53,7 +53,6 @@
#include <sys/param.h>
#include <netinet/in.h>
#include <pwd.h>
#include <assert.h>
#include <libgen.h>
#include <wordexp.h>

View file

@ -464,7 +464,6 @@ cli_handler_err(FILE *f)
return 0;
}
/*! Evaluate a matched command
* @param[in] h Clicon handle
* @param[in] cmd The command string

View file

@ -59,7 +59,6 @@
#include <sys/param.h>
#include <sys/mount.h>
#include <pwd.h>
#include <assert.h>
/* cligen */
#include <cligen/cligen.h>
@ -158,7 +157,7 @@ expand_dbvar(void *h,
if (clicon_rpc_get_config(h, NULL, dbstr, xpath, nsc, &xt) < 0) /* XXX */
goto done;
if ((xe = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xe);
clicon_rpc_generate_error(xe, "Get configuration", NULL);
goto ok;
}
xcur = xt; /* default top-of-tree */
@ -175,7 +174,7 @@ expand_dbvar(void *h,
if ((ret = api_path2xml(api_path, yspec, xtop, YC_DATANODE, 0, &xbot, &y, &xerr)) < 0)
goto done;
if (ret == 0){
clicon_rpc_generate_error("Expand datastore symbol", xerr);
clicon_rpc_generate_error(xerr, "Expand datastore symbol", NULL);
goto done;
}
}
@ -487,7 +486,7 @@ cli_show_config1(clicon_handle h,
goto done;
}
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
if ((yspec = clicon_dbspec_yang(h)) == NULL){
@ -635,7 +634,7 @@ show_conf_xpath(clicon_handle h,
if (clicon_rpc_get_config(h, NULL, str, xpath, nsc, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
@ -738,7 +737,7 @@ cli_show_auto1(clicon_handle h,
}
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clicon_rpc_generate_error("Get configuration", xerr);
clicon_rpc_generate_error(xerr, "Get configuration", NULL);
goto done;
}
if ((xp = xpath_first(xt, nsc, "%s", xpath)) != NULL)