From 46552066d1472cb15832246576a988b638f8b8e5 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 2 Dec 2019 20:55:28 +0100 Subject: [PATCH] Added nsc parameter to `xmldb_get()` --- CHANGELOG.md | 4 +++- apps/backend/backend_startup.c | 2 +- lib/clixon/clixon_datastore.h | 4 ++-- lib/src/clixon_datastore_read.c | 6 ++++-- util/clixon_util_datastore.c | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8baf5c7..d174d542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ * Fixed multi-namespace for augmented state which was not covered in 4.2.0. ### API changes on existing features (you may need to change your code) -* C-API: Added clicon_handle as parameter to all `clicon_connect_` functions to get better error message +* C-API + * Added clicon_handle as parameter to all `clicon_connect_` functions to get better error message + * Added nsc parameter to `xmldb_get()` * Yang files reorganized into three classes: clixon, mandatory, optional (previous "standard" split into mandatory and optional). * Clixon and mandatory yang spec are always installed * Optional yang files are loaded only if configured with `--enable-optyangs` (flipped logic and changed from `disable-stdyangs`). NOTE: you must do this to run examples and tests. diff --git a/apps/backend/backend_startup.c b/apps/backend/backend_startup.c index 96f35baa..9314968c 100644 --- a/apps/backend/backend_startup.c +++ b/apps/backend/backend_startup.c @@ -241,7 +241,7 @@ startup_extraxml(clicon_handle h, * It should be empty if extra-xml is null and reset plugins did nothing * then skip validation. */ - if (xmldb_get(h, tmp_db, NULL, &xt0) < 0) + if (xmldb_get(h, tmp_db, NULL, NULL, &xt0) < 0) goto done; if (xt0==NULL || xml_child_nr(xt0)==0) goto ok; diff --git a/lib/clixon/clixon_datastore.h b/lib/clixon/clixon_datastore.h index bb4e5e24..ba0cf9af 100644 --- a/lib/clixon/clixon_datastore.h +++ b/lib/clixon/clixon_datastore.h @@ -49,9 +49,9 @@ int xmldb_validate_db(const char *db); int xmldb_connect(clicon_handle h); int xmldb_disconnect(clicon_handle h); /* in clixon_datastore_read.[ch] */ -int xmldb_get(clicon_handle h, const char *db, char *xpath, cxobj **xtop); +int xmldb_get(clicon_handle h, const char *db, cvec *nsc, char *xpath, cxobj **xtop); int xmldb_get0(clicon_handle h, const char *db, - cvec *nc, char *xpath, + cvec *nsc, char *xpath, int copy, cxobj **xtop, modstate_diff_t *msd); int xmldb_get0_clear(clicon_handle h, cxobj *x); int xmldb_get0_free(clicon_handle h, cxobj **xp); diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index 62921c6b..07fb53d4 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -647,12 +647,13 @@ xmldb_get_zerocopy(clicon_handle h, /*! Get content of datastore and return a copy of the XML tree * @param[in] h Clicon handle * @param[in] db Name of database to search in (filename including dir path + * @param[in] nsc XML namespace context for XPATH * @param[in] xpath String with XPATH syntax. or NULL for all * @param[out] xret Single return XML tree. Free with xml_free() * @retval 0 OK * @retval -1 Error * @code - * if (xmldb_get(xh, "running", "/interfaces/interface[name="eth"]", &xt) < 0) + * if (xmldb_get(xh, "running", NULL, "/interfaces/interface[name="eth"]", &xt) < 0) * err; * xml_free(xt); * @endcode @@ -661,10 +662,11 @@ xmldb_get_zerocopy(clicon_handle h, int xmldb_get(clicon_handle h, const char *db, + cvec *nsc, char *xpath, cxobj **xret) { - return xmldb_get0(h, db, NULL, xpath, 1, xret, NULL); + return xmldb_get0(h, db, nsc, xpath, 1, xret, NULL); } /*! Zero-copy variant of get content of database diff --git a/util/clixon_util_datastore.c b/util/clixon_util_datastore.c index 099e8446..ec069a34 100644 --- a/util/clixon_util_datastore.c +++ b/util/clixon_util_datastore.c @@ -198,7 +198,7 @@ main(int argc, char **argv) xpath = argv[1]; else xpath = "/"; - if (xmldb_get(h, db, xpath, &xt) < 0) + if (xmldb_get(h, db, NULL, xpath, &xt) < 0) goto done; clicon_xml2file(stdout, xt, 0, 0); fprintf(stdout, "\n"); @@ -217,7 +217,7 @@ main(int argc, char **argv) else xpath = "/"; for (i=0;i