libyang UPDATE optional value validation and context type plugins (#2171)
This patch separates the build-in type validations from store
operations to allow storing a node even if the value doesn't pass the
validations. To do multiple changes were done:
- introduces LY_CTX_BASIC_PLUGINS_ONLY flag, which prevents loading of
any advanced plugins
- introduces LYPLG_TYPE_STORE_ONLY flag, which skip validation and
perform just storing
- introduces LYD_PARSE_STORE_ONLY flag, which implies usage of LYPLG_TYPE_STORE_ONLY
- introduces options for lyd_new_* API
- removes lyd_new_(term|list)_(bin|canon) API
- added sanity checks within lyd_new_(term|list) APIs for proper
combinations of options
- refactored lyd_new_* APIs to use common flags to use common options attributes
diff --git a/src/context.c b/src/context.c
index a7902e9..97ba672 100644
--- a/src/context.c
+++ b/src/context.c
@@ -283,6 +283,7 @@
struct ly_in *in = NULL;
LY_ERR rc = LY_SUCCESS;
struct lys_glob_unres unres = {0};
+ ly_bool builtin_plugins_only;
LY_CHECK_ARG_RET(NULL, new_ctx, LY_EINVAL);
@@ -293,7 +294,8 @@
lydict_init(&ctx->dict);
/* plugins */
- LY_CHECK_ERR_GOTO(lyplg_init(), LOGINT(NULL); rc = LY_EINT, cleanup);
+ builtin_plugins_only = (options & LY_CTX_BUILTIN_PLUGINS_ONLY) ? 1 : 0;
+ LY_CHECK_ERR_GOTO(lyplg_init(builtin_plugins_only), LOGINT(NULL); rc = LY_EINT, cleanup);
if (options & LY_CTX_LEAFREF_LINKING) {
ctx->leafref_links_ht = lyht_new(1, sizeof(struct lyd_leafref_links_rec), ly_ctx_ht_leafref_links_equal_cb, NULL, 1);
@@ -1234,8 +1236,7 @@
LY_CHECK_GOTO(ret = ylib_deviation(cont, mod, 0), error);
/* conformance-type */
- LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "conformance-type", mod->implemented ? "implement" : "import", 0,
- NULL), error);
+ LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "conformance-type", mod->implemented ? "implement" : "import", 0, NULL), error);
/* submodule list */
LY_CHECK_GOTO(ret = ylib_submodules(cont, mod->parsed, 0), error);