schema tree BUGFIX use all_implemented context flag in all cases
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 324f3f2..5e74ebc 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1045,7 +1045,7 @@
}
LY_ERR
-lys_create_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool implement,
+lys_create_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool need_implemented,
LY_ERR (*custom_check)(const struct ly_ctx *ctx, struct lysp_module *mod, struct lysp_submodule *submod, void *data),
void *check_data, const char **features, struct lys_glob_unres *unres, struct lys_module **module)
{
@@ -1058,13 +1058,20 @@
struct lys_parser_ctx *pctx = NULL;
char *filename, *rev, *dot;
size_t len;
+ ly_bool implement;
- assert(ctx && in && (!features || implement) && unres);
+ assert(ctx && in && (!features || need_implemented) && unres);
if (module) {
*module = NULL;
}
+ if (ctx->flags & LY_CTX_ALL_IMPLEMENTED) {
+ implement = 1;
+ } else {
+ implement = need_implemented;
+ }
+
mod = calloc(1, sizeof *mod);
LY_CHECK_ERR_RET(!mod, LOGMEM(ctx), LY_EMEM);
mod->ctx = ctx;
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 7d3feec..7ecf7d7 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -705,9 +705,9 @@
}
LY_ERR
-lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, const char **features, ly_bool implement,
- struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required, struct lys_glob_unres *unres,
- void **result)
+lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, const char **features,
+ ly_bool need_implemented, struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required,
+ struct lys_glob_unres *unres, void **result)
{
struct ly_in *in;
char *filepath = NULL;
@@ -739,7 +739,7 @@
ret = lys_parse_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data,
(struct lysp_submodule **)&mod);
} else {
- ret = lys_create_module(ctx, in, format, implement, lysp_load_module_check, &check_data, features, unres,
+ ret = lys_create_module(ctx, in, format, need_implemented, lysp_load_module_check, &check_data, features, unres,
(struct lys_module **)&mod);
}
@@ -756,8 +756,8 @@
}
LY_ERR
-lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement, const char **features,
- struct lys_glob_unres *unres, struct lys_module **mod)
+lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool need_implemented,
+ const char **features, struct lys_glob_unres *unres, struct lys_module **mod)
{
const char *module_data = NULL;
LYS_INFORMAT format = LYS_IN_UNKNOWN;
@@ -767,11 +767,14 @@
struct lys_module *ctx_latest = NULL, *m;
struct ly_in *in;
LY_ERR ret;
+ ly_bool implement;
assert(mod && unres);
if (ctx->flags & LY_CTX_ALL_IMPLEMENTED) {
implement = 1;
+ } else {
+ implement = need_implemented;
}
/*
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 5a2097b..7fccb76 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -284,15 +284,15 @@
* @param[in] ctx libyang context.
* @param[in] name Name of the module to load.
* @param[in] revison Optional revision of the module to load. If NULL, the newest revision is loaded.
- * @param[in] implement Flag if the loaded module is supposed to be marked as implemented. If revision is NULL and implement flag set,
- * the implemented module in the context is returned despite it might not be of the latest revision, because in this case the module
- * of the latest revision can not be made implemented.
+ * @param[in] need_implemented Whether the module should be implemented. If revision is NULL and this flag is set,
+ * the implemented module in the context is returned despite it might not be of the latest revision, because in this
+ * case the module of the latest revision can not be made implemented.
* @param[in] features All the features to enable if implementing the module.
* @param[in] unres Global unres structure for all newly implemented modules.
* @param[out] mod Parsed module structure.
* @return LY_ERR value.
*/
-LY_ERR lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement,
+LY_ERR lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool need_implemented,
const char **features, struct lys_glob_unres *unres, struct lys_module **mod);
/**
@@ -458,7 +458,7 @@
* @param[in] ctx libyang context where to process the data model.
* @param[in] in Input structure.
* @param[in] format Format of the input data (YANG or YIN).
- * @param[in] implement Flag if the schema is supposed to be marked as implemented and compiled.
+ * @param[in] need_implemented Whether module needs to be implemented and compiled.
* @param[in] custom_check Callback to check the parsed schema before it is accepted.
* @param[in] check_data Caller's data to pass to the custom_check callback.
* @param[in] features Array of features to enable ended with NULL. NULL for all features disabled and '*' for all enabled.
@@ -466,7 +466,7 @@
* @param[out] module Created module.
* @return LY_ERR value.
*/
-LY_ERR lys_create_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool implement,
+LY_ERR lys_create_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool need_implemented,
lys_custom_check custom_check, void *check_data, const char **features, struct lys_glob_unres *unres,
struct lys_module **module);
@@ -508,7 +508,7 @@
* @param[in] name Name of the (sub)module to load.
* @param[in] revision Optional revision of the (sub)module to load, if NULL the newest revision is being loaded.
* @param[in] features Array of enabled features ended with NULL.
- * @param[in] implement Flag if the (sub)module is supposed to be marked as implemented.
+ * @param[in] need_implemented Whether the (sub)module is needed implemented or not.
* @param[in] main_ctx Parser context of the main module in case of loading submodule.
* @param[in] main_name Main module name in case of loading submodule.
* @param[in] required Module is required so error (even if the input file not found) are important. If 0, there is some
@@ -519,7 +519,7 @@
* @return LY_ERR value, in case of LY_SUCCESS, the \arg result is always provided.
*/
LY_ERR lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, const char **features,
- ly_bool implement, struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required,
+ ly_bool need_implemented, struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required,
struct lys_glob_unres *unres, void **result);
/**