diff --git a/src/context.c b/src/context.c
index 2bf5c04d8..d25e99438 100644
--- a/src/context.c
+++ b/src/context.c
@@ -274,7 +274,7 @@ ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx)
struct ly_in *in = NULL;
LY_ERR rc = LY_SUCCESS;
struct lys_glob_unres unres = {0};
- ly_bool no_advanced_builtin = 0;
+ ly_bool no_advanced_builtin;
LY_CHECK_ARG_RET(NULL, new_ctx, LY_EINVAL);
@@ -285,9 +285,7 @@ ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx)
lydict_init(&ctx->dict);
/* plugins */
- if (options & LY_CTX_STORE_INVALID_DATA) {
- no_advanced_builtin = 1;
- }
+ no_advanced_builtin = (options & LY_CTX_BASIC_PLUGINS_ONLY) ? 1 : 0;
LY_CHECK_ERR_GOTO(lyplg_init(no_advanced_builtin), LOGINT(NULL); rc = LY_EINT, cleanup);
if (options & LY_CTX_LEAFREF_LINKING) {
@@ -1089,7 +1087,7 @@ ylib_feature(struct lyd_node *parent, const struct lysp_module *pmod)
continue;
}
- LY_CHECK_RET(lyd_new_term(parent, NULL, "feature", f->name, 0, NULL));
+ LY_CHECK_RET(lyd_new_term(parent, NULL, "feature", f->name, 0, 0, NULL));
}
LY_ARRAY_FOR(pmod->includes, u) {
@@ -1098,7 +1096,7 @@ ylib_feature(struct lyd_node *parent, const struct lysp_module *pmod)
continue;
}
- LY_CHECK_RET(lyd_new_term(parent, NULL, "feature", f->name, 0, NULL));
+ LY_CHECK_RET(lyd_new_term(parent, NULL, "feature", f->name, 0, 0, NULL));
}
}
@@ -1120,9 +1118,9 @@ ylib_deviation(struct lyd_node *parent, const struct lys_module *cur_mod, ly_boo
mod = cur_mod->deviated_by[i];
if (bis) {
- LY_CHECK_RET(lyd_new_term(parent, NULL, "deviation", mod->name, 0, NULL));
+ LY_CHECK_RET(lyd_new_term(parent, NULL, "deviation", mod->name, 0, 0, NULL));
} else {
- LY_CHECK_RET(lyd_new_list(parent, NULL, "deviation", 0, NULL, mod->name,
+ LY_CHECK_RET(lyd_new_list(parent, NULL, "deviation", 0, 0, NULL, mod->name,
(mod->parsed->revs ? mod->parsed->revs[0].date : "")));
}
}
@@ -1144,13 +1142,13 @@ ylib_submodules(struct lyd_node *parent, const struct lysp_module *pmod, ly_bool
submod = pmod->includes[i].submodule;
if (bis) {
- LY_CHECK_RET(lyd_new_list(parent, NULL, "submodule", 0, &cont, submod->name));
+ LY_CHECK_RET(lyd_new_list(parent, NULL, "submodule", 0, 0, &cont, submod->name));
if (submod->revs) {
- LY_CHECK_RET(lyd_new_term(cont, NULL, "revision", submod->revs[0].date, 0, NULL));
+ LY_CHECK_RET(lyd_new_term(cont, NULL, "revision", submod->revs[0].date, 0, 0, NULL));
}
} else {
- LY_CHECK_RET(lyd_new_list(parent, NULL, "submodule", 0, &cont, submod->name,
+ LY_CHECK_RET(lyd_new_list(parent, NULL, "submodule", 0, 0, &cont, submod->name,
(submod->revs ? submod->revs[0].date : "")));
}
@@ -1158,7 +1156,7 @@ ylib_submodules(struct lyd_node *parent, const struct lysp_module *pmod, ly_bool
r = asprintf(&str, "file://%s", submod->filepath);
LY_CHECK_ERR_RET(r == -1, LOGMEM(pmod->mod->ctx), LY_EMEM);
- ret = lyd_new_term(cont, NULL, bis ? "location" : "schema", str, 0, NULL);
+ ret = lyd_new_term(cont, NULL, bis ? "location" : "schema", str, 0, 0, NULL);
free(str);
LY_CHECK_RET(ret);
}
@@ -1197,7 +1195,7 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
if (bis) {
LY_CHECK_GOTO(ret = lyd_new_inner(NULL, mod, "yang-library", 0, &root_bis), error);
- LY_CHECK_GOTO(ret = lyd_new_list(root_bis, NULL, "module-set", 0, &set_bis, "complete"), error);
+ LY_CHECK_GOTO(ret = lyd_new_list(root_bis, NULL, "module-set", 0, 0, &set_bis, "complete"), error);
}
for (i = 0; i < ctx->list.count; ++i) {
@@ -1210,7 +1208,7 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
/*
* deprecated legacy
*/
- LY_CHECK_GOTO(ret = lyd_new_list(root, NULL, "module", 0, &cont, mod->name,
+ LY_CHECK_GOTO(ret = lyd_new_list(root, NULL, "module", 0, 0, &cont, mod->name,
(mod->parsed->revs ? mod->parsed->revs[0].date : "")), error);
/* schema */
@@ -1218,13 +1216,13 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
r = asprintf(&str, "file://%s", mod->filepath);
LY_CHECK_ERR_GOTO(r == -1, LOGMEM(ctx); ret = LY_EMEM, error);
- ret = lyd_new_term(cont, NULL, "schema", str, 0, NULL);
+ ret = lyd_new_term(cont, NULL, "schema", str, 0, 0, NULL);
free(str);
LY_CHECK_GOTO(ret, error);
}
/* namespace */
- LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "namespace", mod->ns, 0, NULL), error);
+ LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "namespace", mod->ns, 0, 0, NULL), error);
/* feature leaf-list */
LY_CHECK_GOTO(ret = ylib_feature(cont, mod->parsed), error);
@@ -1234,7 +1232,7 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
/* conformance-type */
LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "conformance-type", mod->implemented ? "implement" : "import", 0,
- NULL), error);
+ 0, NULL), error);
/* submodule list */
LY_CHECK_GOTO(ret = ylib_submodules(cont, mod->parsed, 0), error);
@@ -1245,25 +1243,25 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
if (bis) {
/* name and revision */
if (mod->implemented) {
- LY_CHECK_GOTO(ret = lyd_new_list(set_bis, NULL, "module", 0, &cont, mod->name), error);
+ LY_CHECK_GOTO(ret = lyd_new_list(set_bis, NULL, "module", 0, 0, &cont, mod->name), error);
if (mod->parsed->revs) {
- LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "revision", mod->parsed->revs[0].date, 0, NULL), error);
+ LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "revision", mod->parsed->revs[0].date, 0, 0, NULL), error);
}
} else {
- LY_CHECK_GOTO(ret = lyd_new_list(set_bis, NULL, "import-only-module", 0, &cont, mod->name,
+ LY_CHECK_GOTO(ret = lyd_new_list(set_bis, NULL, "import-only-module", 0, 0, &cont, mod->name,
(mod->parsed->revs ? mod->parsed->revs[0].date : "")), error);
}
/* namespace */
- LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "namespace", mod->ns, 0, NULL), error);
+ LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "namespace", mod->ns, 0, 0, NULL), error);
/* location */
if (mod->filepath) {
r = asprintf(&str, "file://%s", mod->filepath);
LY_CHECK_ERR_GOTO(r == -1, LOGMEM(ctx); ret = LY_EMEM, error);
- ret = lyd_new_term(cont, NULL, "location", str, 0, NULL);
+ ret = lyd_new_term(cont, NULL, "location", str, 0, 0, NULL);
free(str);
LY_CHECK_GOTO(ret, error);
}
@@ -1284,17 +1282,17 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
r = vasprintf(&str, content_id_format, ap);
va_end(ap);
LY_CHECK_ERR_GOTO(r == -1, LOGMEM(ctx); ret = LY_EMEM, error);
- ret = lyd_new_term(root, NULL, "module-set-id", str, 0, NULL);
+ ret = lyd_new_term(root, NULL, "module-set-id", str, 0, 0, NULL);
LY_CHECK_ERR_GOTO(ret, free(str), error);
if (bis) {
/* create one complete schema */
- LY_CHECK_ERR_GOTO(ret = lyd_new_list(root_bis, NULL, "schema", 0, &cont, "complete"), free(str), error);
+ LY_CHECK_ERR_GOTO(ret = lyd_new_list(root_bis, NULL, "schema", 0, 0, &cont, "complete"), free(str), error);
- LY_CHECK_ERR_GOTO(ret = lyd_new_term(cont, NULL, "module-set", "complete", 0, NULL), free(str), error);
+ LY_CHECK_ERR_GOTO(ret = lyd_new_term(cont, NULL, "module-set", "complete", 0, 0, NULL), free(str), error);
/* content-id */
- LY_CHECK_ERR_GOTO(ret = lyd_new_term(root_bis, NULL, "content-id", str, 0, NULL), free(str), error);
+ LY_CHECK_ERR_GOTO(ret = lyd_new_term(root_bis, NULL, "content-id", str, 0, 0, NULL), free(str), error);
}
free(str);
diff --git a/src/context.h b/src/context.h
index 7a8735bd7..5c638ba9d 100644
--- a/src/context.h
+++ b/src/context.h
@@ -203,13 +203,10 @@ struct ly_ctx;
'require-instance false;'. It also enables usage of
[lyd_leafref_get_links](@ref lyd_leafref_get_links) and
[lyd_leafref_link_node_tree](@ref lyd_leafref_link_node_tree) APIs. */
-#define LY_CTX_STORE_INVALID_DATA 0x0800 /**< By default, storing of value of given data node is subject to build-in validations
- as patterns, length, ranges etc. This option bypass these validations, and allow user
- to validate the values manually by additional calls as lyd_validate.
- It also supresses usage of advanced built-in plugin types (ipv4-address, ipv6-address etc.),
- which expects that value is already valid during storage operation. Instead the value is
- processed by basic plungin (usually string) with all its behavioral implications as hex-string
- comparison becoming case-sensitive.
+#define LY_CTX_BASIC_PLUGINS_ONLY 0x0800 /**< By default, context loads all available built-in plugins. This options prohibits
+ loading of advanced built-in plugin types (ipv4-address, ipv6-address, etc.). Instead the value is
+ processed by basic built-in pluings (usually string) with all its behavioral implications as
+ hex-string comparison becoming case-sensitive.
Change of this flag during the lifetime of context is not fully supported. Once the advanced
plugins are loaded during context creation, they will be used regardless of this flag.
Therefore it is recommended to set this flag during the first context creation. */
diff --git a/src/diff.c b/src/diff.c
index 637ce06ff..00fda9aa0 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -154,7 +154,7 @@ lyd_diff_add_create_nested_userord(struct lyd_node *node)
}
/* create the metadata */
- LY_CHECK_GOTO(rc = lyd_new_meta(NULL, node, NULL, meta_name, meta_val, 0, NULL), cleanup);
+ LY_CHECK_GOTO(rc = lyd_new_meta(NULL, node, NULL, meta_name, meta_val, 0, 1, NULL), cleanup);
cleanup:
free(dyn);
@@ -361,7 +361,7 @@ lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_
}
/* set the none operation */
- LY_CHECK_RET(lyd_new_meta(NULL, elem, NULL, "yang:operation", "none", 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, elem, NULL, "yang:operation", "none", 0, 1, NULL));
}
dup = diff_parent;
@@ -403,12 +403,12 @@ lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_
/* add parent operation, if any */
if (diff_parent && (diff_parent != dup)) {
- LY_CHECK_RET(lyd_new_meta(NULL, diff_parent, NULL, "yang:operation", "none", 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, diff_parent, NULL, "yang:operation", "none", 0, 1, NULL));
}
}
/* add subtree operation */
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:operation", lyd_diff_op2str(op), 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:operation", lyd_diff_op2str(op), 0, 1, NULL));
if (op == LYD_DIFF_OP_CREATE) {
/* all nested user-ordered (leaf-)lists need special metadata for create op */
@@ -422,37 +422,37 @@ lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_
/* orig-default */
if (orig_default) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-default", orig_default, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-default", orig_default, 0, 1, NULL));
}
/* orig-value */
if (orig_value) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-value", orig_value, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-value", orig_value, 0, 1, NULL));
}
/* key */
if (key) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:key", key, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:key", key, 0, 1, NULL));
}
/* value */
if (value) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:value", value, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:value", value, 0, 1, NULL));
}
/* position */
if (position) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:position", position, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:position", position, 0, 1, NULL));
}
/* orig-key */
if (orig_key) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-key", orig_key, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-key", orig_key, 0, 1, NULL));
}
/* orig-position */
if (orig_position) {
- LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-position", orig_position, 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(NULL, dup, NULL, "yang:orig-position", orig_position, 0, 1, NULL));
}
return LY_SUCCESS;
@@ -1439,7 +1439,7 @@ lyd_diff_change_op(struct lyd_node *node, enum lyd_diff_op op)
lyd_diff_del_meta(node, "operation");
if (node->schema) {
- return lyd_new_meta(LYD_CTX(node), node, NULL, "yang:operation", lyd_diff_op2str(op), 0, NULL);
+ return lyd_new_meta(LYD_CTX(node), node, NULL, "yang:operation", lyd_diff_op2str(op), 0, 1, NULL);
} else {
return lyd_new_attr(node, "yang", "operation", lyd_diff_op2str(op), NULL);
}
@@ -1664,7 +1664,7 @@ lyd_diff_merge_create(struct lyd_node **diff_match, struct lyd_node **diff, enum
/* current value is the previous one (meta) */
LY_CHECK_RET(lyd_new_meta(LYD_CTX(src_diff), *diff_match, NULL, "yang:orig-value",
- lyd_get_value(*diff_match), 0, NULL));
+ lyd_get_value(*diff_match), 0, 1, NULL));
/* update the value itself */
LY_CHECK_RET(lyd_change_term(*diff_match, lyd_get_value(src_diff)));
@@ -1678,10 +1678,10 @@ lyd_diff_merge_create(struct lyd_node **diff_match, struct lyd_node **diff, enum
to_free = *diff_match;
*diff_match = src_dup;
- r = lyd_new_meta(ctx, src_dup, NULL, "yang:orig-value", lyd_get_value(to_free), 0, NULL);
+ r = lyd_new_meta(ctx, src_dup, NULL, "yang:orig-value", lyd_get_value(to_free), 0, 1, NULL);
lyd_free_tree(to_free);
LY_CHECK_RET(r);
- LY_CHECK_RET(lyd_new_meta(ctx, src_dup, NULL, "yang:operation", lyd_diff_op2str(LYD_DIFF_OP_REPLACE), 0, NULL));
+ LY_CHECK_RET(lyd_new_meta(ctx, src_dup, NULL, "yang:operation", lyd_diff_op2str(LYD_DIFF_OP_REPLACE), 0, 1, NULL));
}
} else {
/* deleted + created -> operation NONE */
@@ -1692,7 +1692,7 @@ lyd_diff_merge_create(struct lyd_node **diff_match, struct lyd_node **diff, enum
if ((*diff_match)->schema->nodetype & LYD_NODE_TERM) {
/* add orig-dflt metadata */
LY_CHECK_RET(lyd_new_meta(LYD_CTX(src_diff), *diff_match, NULL, "yang:orig-default",
- trg_flags & LYD_DEFAULT ? "true" : "false", 0, NULL));
+ trg_flags & LYD_DEFAULT ? "true" : "false", 0, 1, NULL));
/* update dflt flag itself */
(*diff_match)->flags &= ~LYD_DEFAULT;
@@ -1742,7 +1742,7 @@ lyd_diff_merge_delete(struct lyd_node *diff_match, enum lyd_diff_op cur_op, cons
if (diff_match->schema->nodetype & LYD_NODE_TERM) {
/* add orig-default meta because it is expected */
LY_CHECK_RET(lyd_new_meta(LYD_CTX(src_diff), diff_match, NULL, "yang:orig-default",
- src_diff->flags & LYD_DEFAULT ? "true" : "false", 0, NULL));
+ src_diff->flags & LYD_DEFAULT ? "true" : "false", 0, 1, NULL));
}
break;
case LYD_DIFF_OP_REPLACE:
diff --git a/src/parser_common.c b/src/parser_common.c
index 32152759e..d56c7b637 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -284,8 +284,12 @@ lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, c
{
LY_ERR r;
ly_bool incomplete;
+ ly_bool store_only;
- if ((r = lyd_create_term(schema, value, value_len, 1, dynamic, format, prefix_data, hints, &incomplete, node))) {
+ store_only = (lydctx->parse_opts & LYD_PARSE_ONLY) ? 1 : 0;
+
+ if ((r = lyd_create_term(schema, value, value_len, 1, store_only, dynamic, format, prefix_data,
+ hints, &incomplete, node))) {
if (lydctx->data_ctx->ctx != schema->module->ctx) {
/* move errors to the main context */
ly_err_move(schema->module->ctx, (struct ly_ctx *)lydctx->data_ctx->ctx);
@@ -308,6 +312,7 @@ lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct l
char *dpath = NULL, *path = NULL;
ly_bool incomplete;
struct lyd_meta *first = NULL;
+ ly_bool store_only;
if (meta && *meta) {
/* remember the first metadata */
@@ -323,7 +328,9 @@ lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct l
}
LOG_LOCSET(NULL, NULL, path, NULL);
- LY_CHECK_GOTO(rc = lyd_create_meta(parent, meta, mod, name, name_len, value, value_len, 1, dynamic, format,
+ store_only = (lydctx->parse_opts & LYD_PARSE_ONLY) ? 1 : 0;
+
+ LY_CHECK_GOTO(rc = lyd_create_meta(parent, meta, mod, name, name_len, value, value_len, 1, store_only, dynamic, format,
prefix_data, hints, ctx_node, 0, &incomplete), cleanup);
if (incomplete && !(lydctx->parse_opts & LYD_PARSE_ONLY)) {
diff --git a/src/path.c b/src/path.c
index 73883d754..43e37d83a 100644
--- a/src/path.c
+++ b/src/path.c
@@ -698,8 +698,8 @@ ly_path_compile_predicate(const struct ly_ctx *ctx, const struct lysc_node *cur_
/* store the value */
LOG_LOCSET(key, NULL, NULL, NULL);
- ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaf *)key)->type, val, val_len, 0, NULL,
- format, prefix_data, LYD_HINT_DATA, key, NULL);
+ ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaf *)key)->type, val, val_len, 0, 0,
+ NULL, format, prefix_data, LYD_HINT_DATA, key, NULL);
LOG_LOCBACK(key ? 1 : 0, 0, 0, 0);
LY_CHECK_ERR_GOTO(ret, p->value.realtype = NULL, cleanup);
@@ -762,8 +762,8 @@ ly_path_compile_predicate(const struct ly_ctx *ctx, const struct lysc_node *cur_
/* store the value */
LOG_LOCSET(ctx_node, NULL, NULL, NULL);
- ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaflist *)ctx_node)->type, val, val_len, 0, NULL,
- format, prefix_data, LYD_HINT_DATA, ctx_node, NULL);
+ ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaflist *)ctx_node)->type, val, val_len, 0, 0,
+ NULL, format, prefix_data, LYD_HINT_DATA, ctx_node, NULL);
LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
LY_CHECK_ERR_GOTO(ret, p->value.realtype = NULL, cleanup);
++(*tok_idx);
@@ -1340,7 +1340,7 @@ ly_path_eval_partial(const struct ly_path *path, const struct lyd_node *start, c
case LY_PATH_PREDTYPE_LIST_VAR:
case LY_PATH_PREDTYPE_LIST:
/* we will use hashes to find one list instance */
- LY_CHECK_RET(lyd_create_list(path[u].node, path[u].predicates, vars, &target));
+ LY_CHECK_RET(lyd_create_list(path[u].node, path[u].predicates, vars, 1, &target));
lyd_find_sibling_first(start, target, &node);
lyd_free_tree(target);
break;
diff --git a/src/plugins_exts/schema_mount.c b/src/plugins_exts/schema_mount.c
index 352b29d5a..918880a7e 100644
--- a/src/plugins_exts/schema_mount.c
+++ b/src/plugins_exts/schema_mount.c
@@ -1007,7 +1007,7 @@ schema_mount_validate(struct lysc_ext_instance *ext, struct lyd_node *sibling, c
while (lyd_parent(diff_parent)) {
diff_parent = lyd_parent(diff_parent);
}
- if ((ret = lyd_new_meta(LYD_CTX(diff_parent), diff_parent, NULL, "yang:operation", "none", 0, NULL))) {
+ if ((ret = lyd_new_meta(LYD_CTX(diff_parent), diff_parent, NULL, "yang:operation", "none", 0, 1, NULL))) {
goto cleanup;
}
diff --git a/src/plugins_types.h b/src/plugins_types.h
index e3b954597..a8d4a3643 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -475,6 +475,7 @@ LIBYANG_API_DECL LY_ERR lyplg_type_print_xpath10_value(const struct lyd_value_xp
#define LYPLG_TYPE_STORE_IMPLEMENT 0x02 /**< If a foreign module is needed to be implemented to successfully instantiate
the value, make the module implemented. */
#define LYPLG_TYPE_STORE_IS_UTF8 0x04 /**< The value is guaranteed to be a valid UTF-8 string, if applicable for the type. */
+#define LYPLG_TYPE_STORE_ONLY 0x08 /**< The value is stored only. The validation must be done using [validate](@ref lyplg_type_validate_clb) */
/** @} plugintypestoreopts */
/**
diff --git a/src/plugins_types/binary.c b/src/plugins_types/binary.c
index 542b54b63..b2c824f8c 100644
--- a/src/plugins_types/binary.c
+++ b/src/plugins_types/binary.c
@@ -42,6 +42,8 @@
*/
static const char b64_etable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static LY_ERR lyplg_type_validate_binary(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node), const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err);
+
/**
* @brief Encode binary value into a base64 string value.
*
@@ -165,12 +167,11 @@ binary_base64_decode(const char *value, size_t value_len, void **data, size_t *s
*
* @param[in] value Value to validate.
* @param[in] value_len Length of @p value.
- * @param[in] type type of the value.
* @param[out] err Error information.
* @return LY_ERR value.
*/
static LY_ERR
-binary_base64_validate(const char *value, size_t value_len, const struct lysc_type_bin *type, struct ly_err_item **err)
+binary_base64_validate(const char *value, size_t value_len, struct ly_err_item **err)
{
uint32_t idx, pad;
@@ -204,13 +205,6 @@ binary_base64_validate(const char *value, size_t value_len, const struct lysc_ty
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Base64 encoded value length must be divisible by 4.");
}
- /* length restriction of the binary value */
- if (type->length) {
- const uint32_t octet_count = ((idx + pad) / 4) * 3 - pad;
-
- LY_CHECK_RET(lyplg_type_validate_range(LY_TYPE_BINARY, type->length, octet_count, value, value_len, err));
- }
-
return LY_SUCCESS;
}
@@ -266,7 +260,6 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
struct ly_err_item **err)
{
LY_ERR ret = LY_SUCCESS;
- struct lysc_type_bin *type_bin = (struct lysc_type_bin *)type;
struct lyd_value_binary *val;
/* init storage */
@@ -306,7 +299,7 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
LY_CHECK_GOTO(ret, cleanup);
/* validate */
- ret = binary_base64_validate(value, value_len, type_bin, err);
+ ret = binary_base64_validate(value, value_len, err);
LY_CHECK_GOTO(ret, cleanup);
}
@@ -324,6 +317,12 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
LY_CHECK_GOTO(ret, cleanup);
}
+ if (!(options & LYPLG_TYPE_STORE_ONLY)) {
+ /* validate value */
+ ret = lyplg_type_validate_binary(ctx, type, NULL, NULL, storage, err);
+ LY_CHECK_GOTO(ret, cleanup);
+ }
+
cleanup:
if (options & LYPLG_TYPE_STORE_DYNAMIC) {
free((void *)value);
@@ -335,6 +334,33 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
return ret;
}
+/**
+ * @brief Implementation of ::lyplg_type_validate_clb for the binary type.
+ */
+static LY_ERR
+lyplg_type_validate_binary(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node),
+ const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err)
+{
+ struct lysc_type_bin *type_bin = (struct lysc_type_bin *)type;
+ struct lyd_value_binary *val;
+ const void *value;
+ size_t value_len;
+
+ LY_CHECK_ARG_RET(NULL, type, storage, err, LY_EINVAL);
+
+ val = LYPLG_TYPE_VAL_IS_DYN(val) ? (struct lyd_value_binary *)(storage->dyn_mem) : (struct lyd_value_binary *)(storage->fixed_mem);
+ value = storage->_canonical;
+ value_len = strlen(storage->_canonical);
+ *err = NULL;
+
+ /* length restriction of the binary value */
+ if (type_bin->length) {
+ LY_CHECK_RET(lyplg_type_validate_range(LY_TYPE_BINARY, type_bin->length, val->size, value, value_len, err));
+ }
+
+ return LY_SUCCESS;
+}
+
LIBYANG_API_DEF LY_ERR
lyplg_type_compare_binary(const struct lyd_value *val1, const struct lyd_value *val2)
{
@@ -450,7 +476,7 @@ const struct lyplg_type_record plugins_binary[] = {
.plugin.id = "libyang 2 - binary, version 1",
.plugin.store = lyplg_type_store_binary,
- .plugin.validate = NULL,
+ .plugin.validate = lyplg_type_validate_binary,
.plugin.compare = lyplg_type_compare_binary,
.plugin.sort = NULL,
.plugin.print = lyplg_type_print_binary,
diff --git a/src/plugins_types/decimal64.c b/src/plugins_types/decimal64.c
index a8267e99e..5a292c93c 100644
--- a/src/plugins_types/decimal64.c
+++ b/src/plugins_types/decimal64.c
@@ -142,22 +142,18 @@ lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *typ
LY_CHECK_GOTO(ret, cleanup);
}
- /* preliminary validation */
- ret = lyplg_type_validate_decimal64(ctx, type, NULL, NULL, storage, err);
- if ((ret != LY_SUCCESS) && (ctx->flags & LY_CTX_STORE_INVALID_DATA)) {
- /* preliminary validation failed, just notify the user to validate again */
- if (*err) {
- ly_err_free(*err);
- *err = NULL;
- }
- ret = LY_EINCOMPLETE;
+ if (!(options & LYPLG_TYPE_STORE_ONLY)) {
+ /* validate value */
+ ret = lyplg_type_validate_decimal64(ctx, type, NULL, NULL, storage, err);
+ LY_CHECK_GOTO(ret, cleanup);
}
+
cleanup:
if (options & LYPLG_TYPE_STORE_DYNAMIC) {
free((void *)value);
}
- if (ret && (ret != LY_EINCOMPLETE)) {
+ if (ret) {
lyplg_type_free_simple(ctx, storage);
}
return ret;
diff --git a/src/plugins_types/integer.c b/src/plugins_types/integer.c
index 522dbaa7e..e1b5b9ba7 100644
--- a/src/plugins_types/integer.c
+++ b/src/plugins_types/integer.c
@@ -156,22 +156,18 @@ lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, con
LY_CHECK_GOTO(ret, cleanup);
}
- /* preliminary validation */
- ret = lyplg_type_validate_int(ctx, type, NULL, NULL, storage, err);
- if ((ret != LY_SUCCESS) && (ctx->flags & LY_CTX_STORE_INVALID_DATA)) {
- /* preliminary validation failed, just notify the user to validate again */
- if (*err) {
- ly_err_free(*err);
- *err = NULL;
- }
- ret = LY_EINCOMPLETE;
+ if (!(options & LYPLG_TYPE_STORE_ONLY)) {
+ /* validate value */
+ ret = lyplg_type_validate_int(ctx, type, NULL, NULL, storage, err);
+ LY_CHECK_GOTO(ret, cleanup);
}
+
cleanup:
if (options & LYPLG_TYPE_STORE_DYNAMIC) {
free((void *)value);
}
- if (ret && (ret != LY_EINCOMPLETE)) {
+ if (ret) {
lyplg_type_free_simple(ctx, storage);
}
return ret;
@@ -398,22 +394,18 @@ lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, co
LY_CHECK_GOTO(ret, cleanup);
}
- /* preliminary validation */
- ret = lyplg_type_validate_uint(ctx, type, NULL, NULL, storage, err);
- if ((ret != LY_SUCCESS) && (ctx->flags & LY_CTX_STORE_INVALID_DATA)) {
- /* preliminary validation failed, just notify the user to validate again */
- if (*err) {
- ly_err_free(*err);
- *err = NULL;
- }
- ret = LY_EINCOMPLETE;
+ if (!(options & LYPLG_TYPE_STORE_ONLY)) {
+ /* validate value */
+ ret = lyplg_type_validate_uint(ctx, type, NULL, NULL, storage, err);
+ LY_CHECK_GOTO(ret, cleanup);
}
+
cleanup:
if (options & LYPLG_TYPE_STORE_DYNAMIC) {
free((void *)value);
}
- if (ret && (ret != LY_EINCOMPLETE)) {
+ if (ret) {
lyplg_type_free_simple(ctx, storage);
}
return ret;
diff --git a/src/plugins_types/string.c b/src/plugins_types/string.c
index 0b04f2631..a31c65cc9 100644
--- a/src/plugins_types/string.c
+++ b/src/plugins_types/string.c
@@ -91,22 +91,18 @@ lyplg_type_store_string(const struct ly_ctx *ctx, const struct lysc_type *type,
LY_CHECK_GOTO(ret, cleanup);
}
- /* preliminary validation */
- ret = lyplg_type_validate_string(ctx, type, NULL, NULL, storage, err);
- if ((ret != LY_SUCCESS) && (ctx->flags & LY_CTX_STORE_INVALID_DATA)) {
- /* preliminary validation failed, just notify the user to validate again */
- if (*err) {
- ly_err_free(*err);
- *err = NULL;
- }
- ret = LY_EINCOMPLETE;
+ if (!(options & LYPLG_TYPE_STORE_ONLY)) {
+ /* validate value */
+ ret = lyplg_type_validate_string(ctx, type, NULL, NULL, storage, err);
+ LY_CHECK_GOTO(ret, cleanup);
}
+
cleanup:
if (options & LYPLG_TYPE_STORE_DYNAMIC) {
free((void *)value);
}
- if (ret && (ret != LY_EINCOMPLETE)) {
+ if (ret) {
lyplg_type_free_simple(ctx, storage);
}
return ret;
diff --git a/src/plugins_types/union.c b/src/plugins_types/union.c
index 03571b0e3..8201bf35a 100644
--- a/src/plugins_types/union.c
+++ b/src/plugins_types/union.c
@@ -156,6 +156,7 @@ lyb_parse_union(const void *lyb_data, size_t lyb_data_len, uint32_t *type_idx, c
* @param[in] ctx libyang context.
* @param[in] type Specific union type to use for storing.
* @param[in] subvalue Union subvalue structure.
+ * @param[in] options The store options.
* @param[in] resolve Whether the value needs to be resolved (validated by a callback).
* @param[in] ctx_node Context node for prefix resolution.
* @param[in] tree Data tree for resolving (validation).
@@ -164,13 +165,14 @@ lyb_parse_union(const void *lyb_data, size_t lyb_data_len, uint32_t *type_idx, c
* @return LY_ERR value.
*/
static LY_ERR
-union_store_type(const struct ly_ctx *ctx, struct lysc_type *type, struct lyd_value_union *subvalue,
+union_store_type(const struct ly_ctx *ctx, struct lysc_type *type, struct lyd_value_union *subvalue, uint32_t options,
ly_bool resolve, const struct lyd_node *ctx_node, const struct lyd_node *tree, struct lys_glob_unres *unres,
struct ly_err_item **err)
{
LY_ERR ret;
const void *value = NULL;
size_t value_len = 0;
+ uint32_t opts;
*err = NULL;
@@ -181,7 +183,8 @@ union_store_type(const struct ly_ctx *ctx, struct lysc_type *type, struct lyd_va
value_len = subvalue->orig_len;
}
- ret = type->plugin->store(ctx, type, value, value_len, 0, subvalue->format, subvalue->prefix_data, subvalue->hints,
+ opts = (options & LYPLG_TYPE_STORE_ONLY) ? LYPLG_TYPE_STORE_ONLY : 0;
+ ret = type->plugin->store(ctx, type, value, value_len, opts, subvalue->format, subvalue->prefix_data, subvalue->hints,
subvalue->ctx_node, &subvalue->value, unres, err);
if ((ret != LY_SUCCESS) && (ret != LY_EINCOMPLETE)) {
/* clear any leftover/freed garbage */
@@ -207,6 +210,7 @@ union_store_type(const struct ly_ctx *ctx, struct lysc_type *type, struct lyd_va
* @param[in] ctx libyang context.
* @param[in] types Sized array of union types.
* @param[in] subvalue Union subvalue structure.
+ * @param[in] options The store options.
* @param[in] resolve Whether the value needs to be resolved (validated by a callback).
* @param[in] ctx_node Context node for prefix resolution.
* @param[in] tree Data tree for resolving (validation).
@@ -217,8 +221,8 @@ union_store_type(const struct ly_ctx *ctx, struct lysc_type *type, struct lyd_va
*/
static LY_ERR
union_find_type(const struct ly_ctx *ctx, struct lysc_type **types, struct lyd_value_union *subvalue,
- ly_bool resolve, const struct lyd_node *ctx_node, const struct lyd_node *tree, uint32_t *type_idx,
- struct lys_glob_unres *unres, struct ly_err_item **err)
+ uint32_t options, ly_bool resolve, const struct lyd_node *ctx_node, const struct lyd_node *tree,
+ uint32_t *type_idx, struct lys_glob_unres *unres, struct ly_err_item **err)
{
LY_ERR ret = LY_SUCCESS;
LY_ARRAY_COUNT_TYPE u;
@@ -242,7 +246,7 @@ union_find_type(const struct ly_ctx *ctx, struct lysc_type **types, struct lyd_v
/* use the first usable subtype to store the value */
for (u = 0; u < LY_ARRAY_COUNT(types); ++u) {
- ret = union_store_type(ctx, types[u], subvalue, resolve, ctx_node, tree, unres, &e);
+ ret = union_store_type(ctx, types[u], subvalue, options, resolve, ctx_node, tree, unres, &e);
if ((ret == LY_SUCCESS) || (ret == LY_EINCOMPLETE)) {
break;
}
@@ -330,7 +334,7 @@ lyb_fill_subvalue(const struct ly_ctx *ctx, struct lysc_type_union *type_u, cons
}
/* use the specific type to store the value */
- ret = union_store_type(ctx, type_u->types[type_idx], subvalue, 0, NULL, NULL, unres, err);
+ ret = union_store_type(ctx, type_u->types[type_idx], subvalue, *options, 0, NULL, NULL, unres, err);
return ret;
}
@@ -368,7 +372,7 @@ lyplg_type_store_union(const struct ly_ctx *ctx, const struct lysc_type *type, c
LY_CHECK_GOTO(ret, cleanup);
/* use the first usable subtype to store the value */
- ret = union_find_type(ctx, type_u->types, subvalue, 0, NULL, NULL, NULL, unres, err);
+ ret = union_find_type(ctx, type_u->types, subvalue, options, 0, NULL, NULL, NULL, unres, err);
LY_CHECK_GOTO((ret != LY_SUCCESS) && (ret != LY_EINCOMPLETE), cleanup);
}
@@ -406,11 +410,11 @@ lyplg_type_validate_union(const struct ly_ctx *ctx, const struct lysc_type *type
if (subvalue->format == LY_VALUE_LYB) {
/* use the specific type to store the value */
lyb_parse_union(subvalue->original, 0, &type_idx, NULL, NULL);
- ret = union_store_type(ctx, type_u->types[type_idx], subvalue, 1, ctx_node, tree, NULL, err);
+ ret = union_store_type(ctx, type_u->types[type_idx], subvalue, 0, 1, ctx_node, tree, NULL, err);
LY_CHECK_RET(ret);
} else {
/* use the first usable subtype to store the value */
- ret = union_find_type(ctx, type_u->types, subvalue, 1, ctx_node, tree, NULL, NULL, err);
+ ret = union_find_type(ctx, type_u->types, subvalue, 0, 1, ctx_node, tree, NULL, NULL, err);
LY_CHECK_RET(ret);
}
@@ -463,7 +467,7 @@ lyb_union_print(const struct ly_ctx *ctx, struct lysc_type_union *type_u, struct
ctx = subvalue->ctx_node->module->ctx;
}
subvalue->value.realtype->plugin->free(ctx, &subvalue->value);
- r = union_find_type(ctx, type_u->types, subvalue, 0, NULL, NULL, &type_idx, NULL, &err);
+ r = union_find_type(ctx, type_u->types, subvalue, 0, 0, NULL, NULL, &type_idx, NULL, &err);
ly_err_free(err);
LY_CHECK_RET((r != LY_SUCCESS) && (r != LY_EINCOMPLETE), NULL);
diff --git a/src/schema_compile.c b/src/schema_compile.c
index d7c4eeb3f..69a7b2a23 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -942,24 +942,8 @@ lys_compile_unres_dflt(struct lysc_ctx *ctx, struct lysc_node *node, struct lysc
/* fine, but we need to recompile */
return LY_ERECOMPILE;
} else if (ret == LY_EINCOMPLETE) {
- switch (type->basetype) {
- case LY_TYPE_INT8:
- case LY_TYPE_INT16:
- case LY_TYPE_INT32:
- case LY_TYPE_INT64:
- case LY_TYPE_UINT8:
- case LY_TYPE_UINT16:
- case LY_TYPE_UINT32:
- case LY_TYPE_UINT64:
- case LY_TYPE_STRING:
- case LY_TYPE_DEC64:
- /* we have all data needed for validation */
- ret = type->plugin->validate(ctx->ctx, type, NULL, NULL, storage, &err);
- break;
- default:
- /* we have no data so we will not be resolving it */
- ret = LY_SUCCESS;
- }
+ /* we have no data so we will not be resolving it */
+ ret = LY_SUCCESS;
}
if (ret) {
diff --git a/src/tree_data.c b/src/tree_data.c
index 17ba9c1a5..dd8b72239 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1018,8 +1018,9 @@ lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool clear_df
LY_ERR
lyd_create_meta(struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod, const char *name,
- size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format,
- void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt, ly_bool *incomplete)
+ size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic,
+ LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt,
+ ly_bool *incomplete)
{
LY_ERR ret = LY_SUCCESS;
struct lysc_ext_instance *ant = NULL;
@@ -1050,7 +1051,7 @@ lyd_create_meta(struct lyd_node *parent, struct lyd_meta **meta, const struct ly
mt->parent = parent;
mt->annotation = ant;
lyplg_ext_get_storage(ant, LY_STMT_TYPE, sizeof ant_type, (const void **)&ant_type);
- ret = lyd_value_store(mod->ctx, &mt->value, ant_type, value, value_len, is_utf8, dynamic, format, prefix_data, hints,
+ ret = lyd_value_store(mod->ctx, &mt->value, ant_type, value, value_len, is_utf8, store_only, dynamic, format, prefix_data, hints,
ctx_node, incomplete);
LY_CHECK_ERR_GOTO(ret, free(mt), cleanup);
ret = lydict_insert(mod->ctx, name, name_len, &mt->name);
@@ -1828,7 +1829,7 @@ lyd_dup_r(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_
/* store canonical value in the target context */
val_can = lyd_get_value(node);
type = ((struct lysc_node_leaf *)term->schema)->type;
- ret = lyd_value_store(trg_ctx, &term->value, type, val_can, strlen(val_can), 1, NULL, LY_VALUE_CANON, NULL,
+ ret = lyd_value_store(trg_ctx, &term->value, type, val_can, strlen(val_can), 1, 1, NULL, LY_VALUE_CANON, NULL,
LYD_HINT_DATA, term->schema, NULL);
LY_CHECK_GOTO(ret, error);
}
@@ -2766,11 +2767,11 @@ lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *sc
/* create a data node and find the instance */
if (schema->nodetype == LYS_LEAFLIST) {
/* target used attributes: schema, hash, value */
- rc = lyd_create_term(schema, key_or_value, val_len, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, NULL, &target);
+ rc = lyd_create_term(schema, key_or_value, val_len, 0, 1, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, NULL, &target);
LY_CHECK_RET(rc);
} else {
/* target used attributes: schema, hash, child (all keys) */
- LY_CHECK_RET(lyd_create_list2(schema, key_or_value, val_len, &target));
+ LY_CHECK_RET(lyd_create_list2(schema, key_or_value, val_len, 1, &target));
}
/* find it */
diff --git a/src/tree_data.h b/src/tree_data.h
index 745496dda..505cddbd5 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -1198,6 +1198,7 @@ LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, c
* @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @param[in] ... Ordered key values of the new list instance, all must be set. In case of an instance-identifier
* or identityref value, the JSON format is expected (module names instead of prefixes). No keys are expected for
@@ -1205,7 +1206,7 @@ LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, c
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
- ly_bool output, struct lyd_node **node, ...);
+ ly_bool output, ly_bool store_only, struct lyd_node **node, ...);
/**
* @brief Create a new list node in the data tree.
@@ -1215,13 +1216,14 @@ LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_m
* @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @param[in] ... Ordered binary key values of the new list instance, all must be set. Every key value must be followed
* by its length. No keys are expected for key-less lists.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
- ly_bool output, struct lyd_node **node, ...);
+ ly_bool output, ly_bool store_only, struct lyd_node **node, ...);
/**
* @brief Create a new list node in the data tree.
@@ -1231,13 +1233,14 @@ LIBYANG_API_DECL LY_ERR lyd_new_list_bin(struct lyd_node *parent, const struct l
* @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @param[in] ... Ordered canonical key values of the new list instance, all must be set. No keys are expected for
* key-less lists.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
- ly_bool output, struct lyd_node **node, ...);
+ ly_bool output, ly_bool store_only, struct lyd_node **node, ...);
/**
* @brief Create a new top-level list node defined in the given extension instance.
@@ -1247,13 +1250,15 @@ LIBYANG_API_DECL LY_ERR lyd_new_list_canon(struct lyd_node *parent, const struct
*
* @param[in] ext Extension instance where the list node being created is defined.
* @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node The created node.
* @param[in] ... Ordered key values of the new list instance, all must be set. In case of an instance-identifier
* or identityref value, the JSON format is expected (module names instead of prefixes). No keys are expected for
* key-less lists.
* @return LY_ERR value.
*/
-LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...);
+LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, ly_bool store_only,
+ struct lyd_node **node, ...);
/**
* @brief Create a new list node in the data tree.
@@ -1266,11 +1271,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, co
* Use NULL or string of length 0 in case of key-less list.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char *keys, ly_bool output, struct lyd_node **node);
+ const char *keys, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new list node in the data tree.
@@ -1283,11 +1289,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_
* @param[in] value_lengths Array of lengths of each @p key_values, may be NULL if @p key_values are 0-terminated strings.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char **key_values, uint32_t *value_lengths, ly_bool output, struct lyd_node **node);
+ const char **key_values, uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new list node in the data tree.
@@ -1300,11 +1307,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_
* @param[in] value_lengths Array of lengths of each @p key_values.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list3_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const void **key_values, uint32_t *value_lengths, ly_bool output, struct lyd_node **node);
+ const void **key_values, uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new list node in the data tree.
@@ -1317,11 +1325,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_list3_bin(struct lyd_node *parent, const struct
* @param[in] value_lengths Array of lengths of each @p key_values, may be NULL if @p key_values are 0-terminated strings.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_list3_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char **key_values, uint32_t *value_lengths, ly_bool output, struct lyd_node **node);
+ const char **key_values, uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new term node in the data tree.
@@ -1334,11 +1343,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_list3_canon(struct lyd_node *parent, const struc
* @param[in] val_str String value of the node. If it varies based on the format, ::LY_VALUE_JSON is expected.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char *val_str, ly_bool output, struct lyd_node **node);
+ const char *val_str, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new term node in the data tree.
@@ -1350,11 +1360,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_m
* @param[in] value_len Length of @p value.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const void *value, size_t value_len, ly_bool output, struct lyd_node **node);
+ const void *value, size_t value_len, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new term node in the data tree.
@@ -1365,11 +1376,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct l
* @param[in] val_str Canonical string value of the node. If it is not, it may lead to unexpected behavior.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char *val_str, ly_bool output, struct lyd_node **node);
+ const char *val_str, ly_bool output, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new top-level term node defined in the given extension instance.
@@ -1381,11 +1393,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_term_canon(struct lyd_node *parent, const struct
* @param[in] name Schema node name of the new data node. The node can be #LYS_LEAF or #LYS_LEAFLIST.
* @param[in] val_str String form of the value of the node being created. In case of an instance-identifier or identityref
* value, the JSON format is expected (module names instead of prefixes).
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node The created node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str,
- struct lyd_node **node);
+ ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a new any node in the data tree.
@@ -1434,11 +1447,12 @@ LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, con
* @param[in] val_str String form of the value of the metadata. In case of an instance-identifier or identityref
* value, the JSON format is expected (module names instead of prefixes).
* @param[in] clear_dflt Whether to clear the default flag starting from @p parent, recursively all NP containers.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] meta Optional created metadata. Must be set if @p parent is NULL.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
- const char *name, const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta);
+ const char *name, const char *val_str, ly_bool clear_dflt, ly_bool store_only, struct lyd_meta **meta);
/**
* @brief Create new metadata from an opaque node attribute if possible.
@@ -1447,13 +1461,14 @@ LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *
* @param[in] parent Optional parent node for the metadata being created. Must be set if @p meta is NULL.
* @param[in] clear_dflt Whether to clear the default flag starting from @p parent, recursively all NP containers.
* @param[in] attr Opaque node attribute to parse into metadata.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] meta Optional created metadata. Must be set if @p parent is NULL.
* @return LY_SUCCESS on success.
* @return LY_ENOT if the attribute could not be parsed into any metadata.
* @return LY_ERR on error.
*/
LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt,
- const struct lyd_attr *attr, struct lyd_meta **meta);
+ const struct lyd_attr *attr, ly_bool store_only, struct lyd_meta **meta);
/**
* @brief Create a new JSON opaque node in the data tree. To create an XML opaque node, use ::lyd_new_opaq2().
@@ -1544,6 +1559,7 @@ LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *modul
(or JSON if no defined) ::LY_VALUE_CANON format. If it is not, it may lead
to unexpected behavior. */
#define LYD_NEW_PATH_WITH_OPAQ 0x20 /**< Consider opaque nodes normally when searching for existing nodes. */
+#define LYD_NEW_PATH_STORE_ONLY 0x40 /**< Perform storing operation only, no validation */
/** @} pathoptions */
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index 672f720ac..62e90fc43 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -476,8 +476,8 @@ lyd_data_next_module(struct lyd_node **next, struct lyd_node **first)
LY_ERR
lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
- size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
- const struct lysc_node *ctx_node, ly_bool *incomplete)
+ size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data,
+ uint32_t hints, const struct lysc_node *ctx_node, ly_bool *incomplete)
{
LY_ERR ret;
struct ly_err_item *err = NULL;
@@ -496,6 +496,9 @@ lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct ly
if (is_utf8) {
options |= LYPLG_TYPE_STORE_IS_UTF8;
}
+ if (store_only) {
+ options |= LYPLG_TYPE_STORE_ONLY;
+ }
ret = type->plugin->store(ctx, type, value, value_len, options, format, prefix_data, hints, ctx_node, val, NULL, &err);
if (dynamic) {
@@ -683,7 +686,7 @@ lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t va
/* store the value */
LOG_LOCSET(node->schema, &node->node, NULL, NULL);
- ret = lyd_value_store(ctx, &val, type, value, value_len, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
+ ret = lyd_value_store(ctx, &val, type, value, value_len, 0, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
LOG_LOCBACK(1, 1, 0, 0);
LY_CHECK_RET(ret);
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 4df6d60e2..cdadc6ff6 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -225,6 +225,7 @@ const char *ly_format2str(LY_VALUE_FORMAT format);
* @param[in] value String value to be parsed.
* @param[in] value_len Length of @p value, must be set correctly.
* @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -236,8 +237,8 @@ const char *ly_format2str(LY_VALUE_FORMAT format);
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool is_utf8,
- ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete,
- struct lyd_node **node);
+ ly_bool store_only, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
+ ly_bool *incomplete, struct lyd_node **node);
/**
* @brief Create a term (leaf/leaf-list) node from a parsed value by duplicating it.
@@ -274,12 +275,13 @@ LY_ERR lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node);
* @param[in] schema Schema node of the new data node.
* @param[in] predicates Compiled key list predicates.
* @param[in] vars Array of defined variables to use in predicates, may be NULL.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates,
- const struct lyxp_var *vars, struct lyd_node **node);
+ const struct lyxp_var *vars, ly_bool store_only, struct lyd_node **node);
/**
* @brief Create a list with all its keys (cannot be used for key-less list).
@@ -289,11 +291,13 @@ LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_pred
* @param[in] schema Schema node of the new data node.
* @param[in] keys Key list predicates.
* @param[in] keys_len Length of @p keys.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, struct lyd_node **node);
+LY_ERR lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, ly_bool store_only,
+ struct lyd_node **node);
/**
* @brief Create an anyxml/anydata node.
@@ -424,6 +428,7 @@ void lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool cle
* @param[in] value String value to be parsed.
* @param[in] value_len Length of @p value, must be set correctly.
* @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -436,8 +441,9 @@ void lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool cle
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_meta(struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod, const char *name,
- size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format,
- void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt, ly_bool *incomplete);
+ size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic,
+ LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt,
+ ly_bool *incomplete);
/**
* @brief Insert an attribute (last) into a parent
@@ -481,6 +487,7 @@ LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const st
* @param[in] value Value to be parsed, must not be NULL.
* @param[in] value_len Length of the give @p value, must be set correctly.
* @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -491,8 +498,8 @@ LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const st
* @return LY_ERR value on error.
*/
LY_ERR lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
- size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
- const struct lysc_node *ctx_node, ly_bool *incomplete);
+ size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data,
+ uint32_t hints, const struct lysc_node *ctx_node, ly_bool *incomplete);
/**
* @brief Validate previously incompletely stored value.
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
index 9a257bf1f..ee36f980e 100644
--- a/src/tree_data_new.c
+++ b/src/tree_data_new.c
@@ -51,8 +51,8 @@
#include "xpath.h"
LY_ERR
-lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool is_utf8, ly_bool *dynamic,
- LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete, struct lyd_node **node)
+lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool is_utf8, ly_bool store_only,
+ ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete, struct lyd_node **node)
{
LY_ERR ret;
struct lyd_node_term *term;
@@ -68,7 +68,7 @@ lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_
LOG_LOCSET(schema, NULL, NULL, NULL);
ret = lyd_value_store(schema->module->ctx, &term->value, ((struct lysc_node_leaf *)term->schema)->type, value,
- value_len, is_utf8, dynamic, format, prefix_data, hints, schema, incomplete);
+ value_len, is_utf8, store_only, dynamic, format, prefix_data, hints, schema, incomplete);
LOG_LOCBACK(1, 0, 0, 0);
LY_CHECK_ERR_RET(ret, free(term), ret);
lyd_hash(&term->node);
@@ -135,7 +135,7 @@ lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node)
LY_ERR
lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates, const struct lyxp_var *vars,
- struct lyd_node **node)
+ ly_bool store_only, struct lyd_node **node)
{
LY_ERR ret = LY_SUCCESS;
struct lyd_node *list = NULL, *key;
@@ -162,7 +162,7 @@ lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *
/* store the value */
LOG_LOCSET(predicates[u].key, NULL, NULL, NULL);
ret = lyd_value_store(schema->module->ctx, &val, ((struct lysc_node_leaf *)predicates[u].key)->type,
- var->value, strlen(var->value), 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, predicates[u].key, NULL);
+ var->value, strlen(var->value), 0, store_only, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, predicates[u].key, NULL);
LOG_LOCBACK(1, 0, 0, 0);
LY_CHECK_GOTO(ret, cleanup);
@@ -195,7 +195,7 @@ lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *
}
LY_ERR
-lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, struct lyd_node **node)
+lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, ly_bool store_only, struct lyd_node **node)
{
LY_ERR ret = LY_SUCCESS;
struct lyxp_expr *expr = NULL;
@@ -213,7 +213,7 @@ lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_l
NULL, &predicates), cleanup);
/* create the list node */
- LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, NULL, node), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, NULL, store_only, node), cleanup);
cleanup:
LOG_LOCBACK(1, 0, 0, 0);
@@ -591,6 +591,7 @@ _lyd_new_list_node(const struct ly_ctx *ctx, const struct lyd_node *parent, cons
* @param[in] format Format of key values.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @param[in] ap Ordered key values of the new list instance, all must be set. For ::LY_VALUE_LYB, every value must
* be followed by the value length.
@@ -598,7 +599,7 @@ _lyd_new_list_node(const struct ly_ctx *ctx, const struct lyd_node *parent, cons
*/
static LY_ERR
_lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, LY_VALUE_FORMAT format,
- ly_bool output, struct lyd_node **node, va_list ap)
+ ly_bool output, ly_bool store_only, struct lyd_node **node, va_list ap)
{
struct lyd_node *ret = NULL, *key;
const struct lysc_node *key_s;
@@ -623,7 +624,7 @@ _lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const ch
key_len = key_val ? strlen((char *)key_val) : 0;
}
- rc = lyd_create_term(key_s, key_val, key_len, 0, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
+ rc = lyd_create_term(key_s, key_val, key_len, 0, store_only, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
LY_CHECK_GOTO(rc, cleanup);
lyd_insert_node(ret, NULL, key, 1);
}
@@ -644,14 +645,14 @@ _lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const ch
LIBYANG_API_DEF LY_ERR
lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
- struct lyd_node **node, ...)
+ ly_bool store_only, struct lyd_node **node, ...)
{
LY_ERR rc;
va_list ap;
va_start(ap, node);
- rc = _lyd_new_list(parent, module, name, LY_VALUE_JSON, output, node, ap);
+ rc = _lyd_new_list(parent, module, name, LY_VALUE_JSON, output, store_only, node, ap);
va_end(ap);
return rc;
@@ -659,14 +660,14 @@ lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const cha
LIBYANG_API_DEF LY_ERR
lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
- struct lyd_node **node, ...)
+ ly_bool store_only, struct lyd_node **node, ...)
{
LY_ERR rc;
va_list ap;
va_start(ap, node);
- rc = _lyd_new_list(parent, module, name, LY_VALUE_LYB, output, node, ap);
+ rc = _lyd_new_list(parent, module, name, LY_VALUE_LYB, output, store_only, node, ap);
va_end(ap);
return rc;
@@ -674,21 +675,21 @@ lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const
LIBYANG_API_DEF LY_ERR
lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
- struct lyd_node **node, ...)
+ ly_bool store_only, struct lyd_node **node, ...)
{
LY_ERR rc;
va_list ap;
va_start(ap, node);
- rc = _lyd_new_list(parent, module, name, LY_VALUE_CANON, output, node, ap);
+ rc = _lyd_new_list(parent, module, name, LY_VALUE_CANON, output, store_only, node, ap);
va_end(ap);
return rc;
}
LIBYANG_API_DEF LY_ERR
-lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...)
+lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, ly_bool store_only, struct lyd_node **node, ...)
{
struct lyd_node *ret = NULL, *key;
const struct lysc_node *schema, *key_s;
@@ -718,7 +719,7 @@ lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct l
for (key_s = lysc_node_child(schema); key_s && (key_s->flags & LYS_KEY); key_s = key_s->next) {
key_val = va_arg(ap, const char *);
- rc = lyd_create_term(key_s, key_val, key_val ? strlen(key_val) : 0, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
+ rc = lyd_create_term(key_s, key_val, key_val ? strlen(key_val) : 0, 0, store_only, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
NULL, &key);
LY_CHECK_GOTO(rc, cleanup);
lyd_insert_node(ret, NULL, key, 1);
@@ -736,7 +737,7 @@ lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct l
LIBYANG_API_DEF LY_ERR
lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys,
- ly_bool output, struct lyd_node **node)
+ ly_bool output, ly_bool store_only, struct lyd_node **node)
{
LY_ERR r;
struct lyd_node *ret = NULL;
@@ -768,7 +769,7 @@ lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const ch
LY_CHECK_RET(lyd_create_inner(schema, &ret));
} else {
/* create the list node */
- LY_CHECK_RET(lyd_create_list2(schema, keys, strlen(keys), &ret));
+ LY_CHECK_RET(lyd_create_list2(schema, keys, strlen(keys), store_only, &ret));
}
if (ext) {
ret->flags |= LYD_EXT;
@@ -794,12 +795,13 @@ lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const ch
* @param[in] value_lengths Lengths of @p key_values, required for ::LY_VALUE_LYB, optional otherwise.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[out] node Optional created node.
* @return LY_ERR value.
*/
static LY_ERR
_lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, LY_VALUE_FORMAT format,
- const void **key_values, uint32_t *value_lengths, ly_bool output, struct lyd_node **node)
+ const void **key_values, uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
struct lyd_node *ret = NULL, *key;
const struct lysc_node *key_s;
@@ -826,7 +828,7 @@ _lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const c
key_val = key_values[i] ? key_values[i] : "";
key_len = value_lengths ? value_lengths[i] : strlen(key_val);
- rc = lyd_create_term(key_s, key_val, key_len, 0, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
+ rc = lyd_create_term(key_s, key_val, key_len, 0, store_only, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
LY_CHECK_GOTO(rc, cleanup);
lyd_insert_node(ret, NULL, key, 1);
}
@@ -847,23 +849,24 @@ _lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const c
LIBYANG_API_DEF LY_ERR
lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, const char **key_values,
- uint32_t *value_lengths, ly_bool output, struct lyd_node **node)
+ uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_list3(parent, module, name, LY_VALUE_JSON, (const void **)key_values, value_lengths, output, node);
+ return _lyd_new_list3(parent, module, name, LY_VALUE_JSON, (const void **)key_values, value_lengths, output, store_only, node);
}
LIBYANG_API_DEF LY_ERR
lyd_new_list3_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void **key_values,
- uint32_t *value_lengths, ly_bool output, struct lyd_node **node)
+ uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_list3(parent, module, name, LY_VALUE_LYB, key_values, value_lengths, output, node);
+ return _lyd_new_list3(parent, module, name, LY_VALUE_LYB, key_values, value_lengths, output, store_only, node);
}
LIBYANG_API_DEF LY_ERR
lyd_new_list3_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const char **key_values,
- uint32_t *value_lengths, ly_bool output, struct lyd_node **node)
+ uint32_t *value_lengths, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_list3(parent, module, name, LY_VALUE_CANON, (const void **)key_values, value_lengths, output, node);
+ return _lyd_new_list3(parent, module, name, LY_VALUE_CANON, (const void **)key_values, value_lengths, output,
+ store_only, node);
}
/**
@@ -875,6 +878,7 @@ lyd_new_list3_canon(struct lyd_node *parent, const struct lys_module *module, co
* @param[in] value Value of the node being created.
* @param[in] value_len Length of @p value.
* @param[in] format Format of @p value.
+ * @param[in] store_only Whether to perform storing operation only.
* @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
* taken into consideration. Otherwise, the output's data node is going to be created.
* @param[out] node Optional created node.
@@ -882,7 +886,7 @@ lyd_new_list3_canon(struct lyd_node *parent, const struct lys_module *module, co
*/
static LY_ERR
_lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
- size_t value_len, LY_VALUE_FORMAT format, ly_bool output, struct lyd_node **node)
+ size_t value_len, LY_VALUE_FORMAT format, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
LY_ERR r;
struct lyd_node *ret = NULL;
@@ -905,7 +909,7 @@ _lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const ch
}
LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found.", name), LY_ENOTFOUND);
- LY_CHECK_RET(lyd_create_term(schema, value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret));
+ LY_CHECK_RET(lyd_create_term(schema, value, value_len, 0, store_only, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret));
if (ext) {
ret->flags |= LYD_EXT;
}
@@ -921,27 +925,28 @@ _lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const ch
LIBYANG_API_DEF LY_ERR
lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
- ly_bool output, struct lyd_node **node)
+ ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON, output, node);
+ return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON, output, store_only, node);
}
LIBYANG_API_DEF LY_ERR
lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
- size_t value_len, ly_bool output, struct lyd_node **node)
+ size_t value_len, ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_term(parent, module, name, value, value_len, LY_VALUE_LYB, output, node);
+ return _lyd_new_term(parent, module, name, value, value_len, LY_VALUE_LYB, output, store_only, node);
}
LIBYANG_API_DEF LY_ERR
lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
- ly_bool output, struct lyd_node **node)
+ ly_bool output, ly_bool store_only, struct lyd_node **node)
{
- return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON, output, node);
+ return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON, output, store_only, node);
}
LIBYANG_API_DEF LY_ERR
-lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str, struct lyd_node **node)
+lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str, ly_bool store_only,
+ struct lyd_node **node)
{
LY_ERR rc;
struct lyd_node *ret = NULL;
@@ -960,7 +965,7 @@ lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const ch
}
return LY_ENOTFOUND;
}
- rc = lyd_create_term(schema, val_str, val_str ? strlen(val_str) : 0, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
+ rc = lyd_create_term(schema, val_str, val_str ? strlen(val_str) : 0, 0, store_only, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
NULL, &ret);
LY_CHECK_RET(rc);
@@ -1038,7 +1043,7 @@ lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const voi
LIBYANG_API_DEF LY_ERR
lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name,
- const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta)
+ const char *val_str, ly_bool clear_dflt, ly_bool store_only, struct lyd_meta **meta)
{
const char *prefix, *tmp;
size_t pref_len, name_len;
@@ -1075,13 +1080,13 @@ lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys
val_str = "";
}
- return lyd_create_meta(parent, meta, module, name, name_len, val_str, strlen(val_str), 0, NULL, LY_VALUE_JSON,
+ return lyd_create_meta(parent, meta, module, name, name_len, val_str, strlen(val_str), 0, store_only, NULL, LY_VALUE_JSON,
NULL, LYD_HINT_DATA, parent ? parent->schema : NULL, clear_dflt, NULL);
}
LIBYANG_API_DEF LY_ERR
lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt, const struct lyd_attr *attr,
- struct lyd_meta **meta)
+ ly_bool store_only, struct lyd_meta **meta)
{
const struct lys_module *mod;
@@ -1117,7 +1122,7 @@ lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_d
}
return lyd_create_meta(parent, meta, mod, attr->name.name, strlen(attr->name.name), attr->value, strlen(attr->value),
- 0, NULL, attr->format, attr->val_prefix_data, attr->hints, parent ? parent->schema : NULL, clear_dflt, NULL);
+ 0, store_only, NULL, attr->format, attr->val_prefix_data, attr->hints, parent ? parent->schema : NULL, clear_dflt, NULL);
}
LIBYANG_API_DEF LY_ERR
@@ -1303,7 +1308,7 @@ _lyd_change_term(struct lyd_node *term, const void *value, size_t value_len, LY_
/* parse the new value */
LOG_LOCSET(term->schema, term, NULL, NULL);
- ret = lyd_value_store(LYD_CTX(term), &val, type, value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA,
+ ret = lyd_value_store(LYD_CTX(term), &val, type, value, value_len, 0, 0, NULL, format, NULL, LYD_HINT_DATA,
term->schema, NULL);
LOG_LOCBACK(term->schema ? 1 : 0, 1, 0, 0);
LY_CHECK_GOTO(ret, cleanup);
@@ -1410,7 +1415,7 @@ lyd_change_meta(struct lyd_meta *meta, const char *val_str)
/* parse the new value into a new meta structure */
ret = lyd_create_meta(NULL, &m2, meta->annotation->module, meta->name, strlen(meta->name), val_str, strlen(val_str),
- 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, meta->parent ? meta->parent->schema : NULL, 0, NULL);
+ 0, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, meta->parent ? meta->parent->schema : NULL, 0, NULL);
LY_CHECK_GOTO(ret, cleanup);
/* compare original and new value */
@@ -1565,7 +1570,7 @@ lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const
if (!r) {
/* try to store the value */
LY_CHECK_RET(lyd_value_store(schema->module->ctx, &val, ((struct lysc_node_leaflist *)schema)->type,
- value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA, schema, NULL));
+ value, value_len, 0, 0, NULL, format, NULL, LYD_HINT_DATA, schema, NULL));
++((struct lysc_type *)val.realtype)->refcount;
/* store the new predicate so that it is used when searching for this instance */
@@ -1716,7 +1721,8 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
LYD_NODEHINT_LIST, &node), cleanup);
} else {
/* create standard list instance */
- LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, NULL, &node), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, NULL, (options & LYD_NEW_PATH_STORE_ONLY),
+ &node), cleanup);
}
break;
case LYS_CONTAINER:
@@ -1752,8 +1758,8 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
if (val) {
LY_CHECK_GOTO(ret = lyd_create_term2(schema, val, &node), cleanup);
} else {
- LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA,
- NULL, &node), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, 0, (options & LYD_NEW_PATH_STORE_ONLY),
+ NULL, format, NULL, LYD_HINT_DATA, NULL, &node), cleanup);
}
break;
case LYS_LEAF:
@@ -1782,8 +1788,8 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
}
/* create a leaf instance */
- LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA, NULL,
- &node), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, 0, (options & LYD_NEW_PATH_STORE_ONLY), NULL,
+ format, NULL, LYD_HINT_DATA, NULL, &node), cleanup);
break;
case LYS_ANYDATA:
case LYS_ANYXML:
diff --git a/src/xpath.c b/src/xpath.c
index 139cd0f7a..9e27801c7 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -6218,7 +6218,7 @@ moveto_node_hash_child(struct lyxp_set *set, const struct lysc_node *scnode, con
/* create specific data instance if needed */
if (scnode->nodetype == LYS_LIST) {
- LY_CHECK_GOTO(ret = lyd_create_list(scnode, predicates, NULL, &inst), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_list(scnode, predicates, NULL, 1, &inst), cleanup);
} else if (scnode->nodetype == LYS_LEAFLIST) {
LY_CHECK_GOTO(ret = lyd_create_term2(scnode, &predicates[0].value, &inst), cleanup);
}
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index 9a6f45185..ced88973d 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -230,10 +230,10 @@ test_options(void **state)
assert_int_equal(LY_SUCCESS, ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_LEAFREF_LINKING));
assert_int_equal(0, UTEST_LYCTX->flags & LY_CTX_LEAFREF_LINKING);
- /* LY_CTX_STORE_INVALID_DATA */
- assert_int_not_equal(0, UTEST_LYCTX->flags & LY_CTX_STORE_INVALID_DATA);
- assert_int_equal(LY_SUCCESS, ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA));
- assert_int_equal(0, UTEST_LYCTX->flags & LY_CTX_STORE_INVALID_DATA);
+ /* LY_CTX_BASIC_PLUGINS_ONLY */
+ assert_int_not_equal(0, UTEST_LYCTX->flags & LY_CTX_BASIC_PLUGINS_ONLY);
+ assert_int_equal(LY_SUCCESS, ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_BASIC_PLUGINS_ONLY));
+ assert_int_equal(0, UTEST_LYCTX->flags & LY_CTX_BASIC_PLUGINS_ONLY);
assert_int_equal(UTEST_LYCTX->flags, ly_ctx_get_options(UTEST_LYCTX));
@@ -266,9 +266,9 @@ test_options(void **state)
assert_int_equal(LY_SUCCESS, ly_ctx_set_options(UTEST_LYCTX, LY_CTX_LEAFREF_LINKING));
assert_int_not_equal(0, UTEST_LYCTX->flags & LY_CTX_LEAFREF_LINKING);
- /* LY_CTX_STORE_INVALID_DATA */
- assert_int_equal(LY_SUCCESS, ly_ctx_set_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA));
- assert_int_not_equal(0, UTEST_LYCTX->flags & LY_CTX_STORE_INVALID_DATA);
+ /* LY_CTX_BASIC_PLUGINS_ONLY */
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_options(UTEST_LYCTX, LY_CTX_BASIC_PLUGINS_ONLY));
+ assert_int_not_equal(0, UTEST_LYCTX->flags & LY_CTX_BASIC_PLUGINS_ONLY);
assert_int_equal(UTEST_LYCTX->flags, ly_ctx_get_options(UTEST_LYCTX));
}
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 5cee9032e..8e11c8243 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -102,55 +102,55 @@ test_top_level(void **state)
UTEST_ADD_MODULE(schema_a, LYS_IN_YANG, NULL, &mod);
/* list */
- assert_int_equal(lyd_new_list(NULL, mod, "l1", 0, &node, "val_a", "val_b"), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(NULL, mod, "l1", 0, 0, &node, "val_a", "val_b"), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[]", 0, &node), LY_EVALID);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[]", 0, 0, &node), LY_EVALID);
CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", "Schema location \"/a:l1\".");
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[key1='a'][key2='b']", 0, &node), LY_ENOTFOUND);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[key1='a'][key2='b']", 0, 0, &node), LY_ENOTFOUND);
CHECK_LOG_CTX("Not found node \"key1\" in path.", "Schema location \"/a:l1\".");
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b'][c='c']", 0, &node), LY_EVALID);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b'][c='c']", 0, 0, &node), LY_EVALID);
CHECK_LOG_CTX("Key expected instead of leaf \"c\" in path.", "Schema location \"/a:l1\".");
- assert_int_equal(lyd_new_list2(NULL, mod, "c", "[a='a'][b='b']", 0, &node), LY_ENOTFOUND);
+ assert_int_equal(lyd_new_list2(NULL, mod, "c", "[a='a'][b='b']", 0, 0, &node), LY_ENOTFOUND);
CHECK_LOG_CTX("List node \"c\" not found.", NULL);
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b']", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b']", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a=''][b='']", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a=''][b='']", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a:a='a'][a:b='b']", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a:a='a'][a:b='b']", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a= 'a']\n[b =\t'b']", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a= 'a']\n[b =\t'b']", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
const char *key_vals[] = {"a", "b"};
- assert_int_equal(lyd_new_list3(NULL, mod, "l1", key_vals, NULL, 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list3(NULL, mod, "l1", key_vals, NULL, 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
uint32_t val_lens[] = {1, 1};
- assert_int_equal(lyd_new_list3_bin(NULL, mod, "l1", (const void **)key_vals, val_lens, 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list3_bin(NULL, mod, "l1", (const void **)key_vals, val_lens, 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
/* leaf */
- assert_int_equal(lyd_new_term(NULL, mod, "foo", "[a='a'][b='b'][c='c']", 0, &node), LY_EVALID);
+ assert_int_equal(lyd_new_term(NULL, mod, "foo", "[a='a'][b='b'][c='c']", 0, 0, &node), LY_EVALID);
CHECK_LOG_CTX("Invalid type uint16 value \"[a='a'][b='b'][c='c']\".", "Schema location \"/a:foo\".");
- assert_int_equal(lyd_new_term(NULL, mod, "c", "value", 0, &node), LY_ENOTFOUND);
+ assert_int_equal(lyd_new_term(NULL, mod, "c", "value", 0, 0, &node), LY_ENOTFOUND);
CHECK_LOG_CTX("Term node \"c\" not found.", NULL);
- assert_int_equal(lyd_new_term(NULL, mod, "foo", "256", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(NULL, mod, "foo", "256", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
/* leaf-list */
- assert_int_equal(lyd_new_term(NULL, mod, "ll", "ahoy", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(NULL, mod, "ll", "ahoy", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
/* container */
@@ -170,23 +170,23 @@ test_top_level(void **state)
lyd_free_tree(node);
/* key-less list */
- assert_int_equal(lyd_new_list2(NULL, mod, "l2", "[a='a'][b='b']", 0, &node), LY_EVALID);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l2", "[a='a'][b='b']", 0, 0, &node), LY_EVALID);
CHECK_LOG_CTX("List predicate defined for keyless list \"l2\" in path.", "Schema location \"/a:l2\".");
- assert_int_equal(lyd_new_list2(NULL, mod, "l2", "", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l2", "", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list2(NULL, mod, "l2", NULL, 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list2(NULL, mod, "l2", NULL, 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
- assert_int_equal(lyd_new_list(NULL, mod, "l2", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(NULL, mod, "l2", 0, 0, &node), LY_SUCCESS);
lyd_free_tree(node);
/* RPC */
assert_int_equal(lyd_new_inner(NULL, mod, "oper", 0, &rpc), LY_SUCCESS);
- assert_int_equal(lyd_new_term(rpc, mod, "param", "22", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(rpc, mod, "param", "22", 0, 0, &node), LY_SUCCESS);
assert_int_equal(LY_TYPE_STRING, ((struct lysc_node_leaf *)node->schema)->type->basetype);
- assert_int_equal(lyd_new_term(rpc, mod, "param", "22", 1, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(rpc, mod, "param", "22", 1, 0, &node), LY_SUCCESS);
assert_int_equal(LY_TYPE_INT8, ((struct lysc_node_leaf *)node->schema)->type->basetype);
lyd_free_tree(rpc);
}
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index d0dcae599..4c8ddaaa0 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -907,7 +907,7 @@ test_defaults(void **state)
lyd_free_all(diff);
/* create another explicit case and validate */
- assert_int_equal(lyd_new_term(NULL, mod, "l", "value", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(NULL, mod, "l", "value", 0, 0, &node), LY_SUCCESS);
assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
@@ -936,9 +936,9 @@ test_defaults(void **state)
lyd_free_all(diff);
/* create explicit leaf-list and leaf and validate */
- assert_int_equal(lyd_new_term(NULL, mod, "d", "15", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(NULL, mod, "d", "15", 0, 0, &node), LY_SUCCESS);
assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
- assert_int_equal(lyd_new_term(NULL, mod, "ll2", "dflt2", 0, &node), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(NULL, mod, "ll2", "dflt2", 0, 0, &node), LY_SUCCESS);
assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
@@ -1010,9 +1010,9 @@ test_defaults(void **state)
assert_null(diff);
/* similar changes for nested defaults */
- assert_int_equal(lyd_new_term(tree->prev, NULL, "ll1", "def3", 0, NULL), LY_SUCCESS);
- assert_int_equal(lyd_new_term(tree->prev, NULL, "d", "5", 0, NULL), LY_SUCCESS);
- assert_int_equal(lyd_new_term(tree->prev, NULL, "ll2", "non-dflt", 0, NULL), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(tree->prev, NULL, "ll1", "def3", 0, 0, NULL), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(tree->prev, NULL, "d", "5", 0, 0, NULL), LY_SUCCESS);
+ assert_int_equal(lyd_new_term(tree->prev, NULL, "ll2", "non-dflt", 0, 0, NULL), LY_SUCCESS);
assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
@@ -1378,9 +1378,8 @@ test_rpc(void **state)
" 123\n"
"";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
- assert_int_equal(LY_EVALID, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree, NULL));
- CHECK_LOG_CTX("Unsatisfied length - string \"123\" length is not allowed.",
- "Data location \"/val-str:modify-user-password/new-password\", line number 3.");
+ assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree, NULL));
+ lyd_free_all(tree);
ly_in_free(in, 0);
}
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index 17a4c94a4..40586aded 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -1513,21 +1513,21 @@ test_new(void **state)
mod = ly_ctx_get_module_implemented(UTEST_LYCTX, "ietf-interfaces");
assert_non_null(mod);
assert_int_equal(LY_SUCCESS, lyd_new_inner(data, mod, "interfaces", 0, &node));
- assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, &node, "bu"));
- assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, 0, &node, "bu"));
+ assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, 0, NULL));
mod = ly_ctx_get_module_implemented(LYD_CTX(node), "ietf-ip");
assert_non_null(mod);
assert_int_equal(LY_SUCCESS, lyd_new_inner(node, mod, "ipv4", 0, &node));
- assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "enabled", "false", 0, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "enabled", "false", 0, 0, NULL));
mod = ly_ctx_get_module_implemented(UTEST_LYCTX, "ietf-interfaces");
assert_non_null(mod);
assert_int_equal(LY_SUCCESS, lyd_new_inner(data, mod, "interfaces-state", 0, &node));
- assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, &node, "bu"));
- assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, NULL));
- assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "oper-status", "not-present", 0, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, 0, &node, "bu"));
+ assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, 0, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "oper-status", "not-present", 0, 0, NULL));
assert_int_equal(LY_SUCCESS, lyd_new_inner(node, NULL, "statistics", 0, &node));
- assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "discontinuity-time", "2022-01-01T10:00:00-00:00", 0, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "discontinuity-time", "2022-01-01T10:00:00-00:00", 0, 0, NULL));
CHECK_LYD_STRING_PARAM(data, xml, LYD_XML, LYD_PRINT_WITHSIBLINGS);
lyd_free_siblings(data);
diff --git a/tests/utests/types/binary.c b/tests/utests/types/binary.c
index 4f3ea663f..538b93599 100644
--- a/tests/utests/types/binary.c
+++ b/tests/utests/types/binary.c
@@ -232,6 +232,15 @@ test_plugin_store(void **state)
assert_int_equal(LY_EVALID, ly_ret);
assert_string_equal(err->msg, "Unsatisfied length - string \"MTIz\" length is not allowed.");
ly_err_free(err);
+
+ /* LYPLG_TYPE_STORE_ONLY test */
+ val = "MTIz";
+ err = NULL;
+ ly_ret = type->store(UTEST_LYCTX, lysc_type2, val, strlen(val),
+ LYPLG_TYPE_STORE_ONLY, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &value, NULL, &err);
+ assert_int_equal(LY_SUCCESS, ly_ret);
+ type->free(UTEST_LYCTX, &value);
+ ly_err_free(err);
}
static void
diff --git a/tests/utests/types/decimal64.c b/tests/utests/types/decimal64.c
index d002a7d06..5c9b411d4 100644
--- a/tests/utests/types/decimal64.c
+++ b/tests/utests/types/decimal64.c
@@ -68,14 +68,6 @@
lyd_free_all(tree); \
}
-#define TEST_ERROR_PARSE_ONLY_XML(MOD_NAME, NODE_NAME, DATA) \
- {\
- struct lyd_node *tree; \
- const char *data = "<" NODE_NAME " xmlns=\"urn:tests:" MOD_NAME "\">" DATA "" NODE_NAME ">"; \
- CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY, LYD_VALIDATE_PRESENT, LY_EVALID, tree); \
- assert_null(tree); \
- }
-
static void
test_data_xml(void **state)
{
@@ -117,11 +109,7 @@ test_data_xml(void **state)
CHECK_LOG_CTX("Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits.",
"Schema location \"/defs:l1\", line number 1.");
- /* LY_CTX_STORE_INVALID_DATA test */
- TEST_ERROR_PARSE_ONLY_XML("defs", "l1", "\n 15 \t\n ");
- CHECK_LOG_CTX("Unsatisfied range - value \"15.0\" is out of the allowed range.",
- "Schema location \"/defs:l1\", line number 3.");
- ly_ctx_set_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA);
+ /* LYPLG_TYPE_STORE_ONLY test */
TEST_SUCCESS_PARSE_ONLY_XML("defs", "l1", "\n 15 \t\n ");
}
diff --git a/tests/utests/types/inet_types.c b/tests/utests/types/inet_types.c
index 5517f5c76..58a4819ed 100644
--- a/tests/utests/types/inet_types.c
+++ b/tests/utests/types/inet_types.c
@@ -139,7 +139,7 @@ test_data_xml(void **state)
}
static void
-test_data_store_invalid_xml(void **state)
+test_data_basic_plugins_only_xml(void **state)
{
const char *schema;
@@ -153,7 +153,7 @@ test_data_store_invalid_xml(void **state)
/* Recreate context to get rid of all plugins */
ly_ctx_destroy(UTEST_LYCTX);
- assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_STORE_INVALID_DATA, &UTEST_LYCTX));
+ assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_BASIC_PLUGINS_ONLY, &UTEST_LYCTX));
UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
/* Stored via string plugin */
@@ -162,7 +162,7 @@ test_data_store_invalid_xml(void **state)
CHECK_LOG_CTX("Unsatisfied pattern - \"192.168.0.333\" does not conform to \""
"(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9]"
"[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\\p{N}\\p{L}]+)?\".",
- "Data location \"/a:l\".");
+ "Schema location \"/a:l\", line number 1.");
TEST_SUCCESS_PARSE_ONLY_XML("a", "l", "192.168.0.333", STRING, "192.168.0.333");
}
@@ -196,7 +196,7 @@ main(void)
const struct CMUnitTest tests[] = {
UTEST(test_data_xml),
UTEST(test_data_lyb),
- UTEST(test_data_store_invalid_xml),
+ UTEST(test_data_basic_plugins_only_xml),
};
return cmocka_run_group_tests(tests, NULL, NULL);
diff --git a/tests/utests/types/int8.c b/tests/utests/types/int8.c
index e224108a4..41dd4c6bb 100644
--- a/tests/utests/types/int8.c
+++ b/tests/utests/types/int8.c
@@ -1549,13 +1549,13 @@ test_plugin_store(void **state)
assert_int_equal(LY_EVALID, ly_ret);
ly_err_free(err);
- /* LY_CTX_STORE_INVALID_DATA test */
- ly_ctx_set_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA);
+ /* LYPLG_TYPE_STORE_ONLY test */
val_text = "-60";
err = NULL;
ly_ret = type->store(UTEST_LYCTX, lysc_type, val_text, strlen(val_text),
- 0, LY_VALUE_XML, NULL, LYD_VALHINT_DECNUM, NULL, &value, NULL, &err);
- assert_int_equal(LY_EINCOMPLETE, ly_ret);
+ LYPLG_TYPE_STORE_ONLY, LY_VALUE_XML, NULL, LYD_VALHINT_DECNUM, NULL,
+ &value, NULL, &err);
+ assert_int_equal(LY_SUCCESS, ly_ret);
type->free(UTEST_LYCTX, &value);
ly_err_free(err);
diff --git a/tests/utests/types/string.c b/tests/utests/types/string.c
index 216303099..20211627e 100644
--- a/tests/utests/types/string.c
+++ b/tests/utests/types/string.c
@@ -1198,13 +1198,13 @@ test_plugin_store(void **state)
assert_int_equal(LY_EVALID, ly_ret);
ly_err_free(err);
- /* LY_CTX_STORE_INVALID_DATA test */
- ly_ctx_set_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA);
+ /* LYPLG_TYPE_STORE_ONLY test */
val_text = "10 \"| bcdei";
err = NULL;
ly_ret = type->store(UTEST_LYCTX, lysc_type, val_text, strlen(val_text),
- 0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &value, NULL, &err);
- assert_int_equal(LY_EINCOMPLETE, ly_ret);
+ LYPLG_TYPE_STORE_ONLY, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL,
+ &value, NULL, &err);
+ assert_int_equal(LY_SUCCESS, ly_ret);
type->free(UTEST_LYCTX, &value);
ly_err_free(err);
}
diff --git a/tests/utests/types/uint8.c b/tests/utests/types/uint8.c
index a1ec92aef..a4def3660 100644
--- a/tests/utests/types/uint8.c
+++ b/tests/utests/types/uint8.c
@@ -58,14 +58,6 @@
lyd_free_all(tree); \
}
-#define TEST_ERROR_PARSE_ONLY_XML(MOD_NAME, DATA) \
- {\
- struct lyd_node *tree; \
- const char *data = "" DATA ""; \
- CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY, LYD_VALIDATE_PRESENT, LY_EVALID, tree); \
- assert_null(tree); \
- }
-
static void
test_data_xml(void **state)
{
@@ -81,11 +73,7 @@ test_data_xml(void **state)
CHECK_LOG_CTX("Unsatisfied range - value \"15\" is out of the allowed range.",
"Schema location \"/defs:port\", line number 3.");
- /* LY_CTX_STORE_INVALID_DATA test */
- TEST_ERROR_PARSE_ONLY_XML("defs", "\n 15 \t\n ");
- CHECK_LOG_CTX("Unsatisfied range - value \"15\" is out of the allowed range.",
- "Schema location \"/defs:port\", line number 3.");
- ly_ctx_set_options(UTEST_LYCTX, LY_CTX_STORE_INVALID_DATA);
+ /* LYPLG_TYPE_STORE_ONLY test */
TEST_SUCCESS_PARSE_ONLY_XML("defs", "\n 15 \t\n ");
}