parser json FEATURE support for nested ext instances with data
... such as schema-mount.
diff --git a/src/context.h b/src/context.h
index 8752e56..71cc590 100644
--- a/src/context.h
+++ b/src/context.h
@@ -415,13 +415,35 @@
*
* @param[in] ctx Context that will use this callback.
* @param[in] clb Callback responsible for returning the missing model.
- * @param[in] user_data Arbitrary data that will always be passed to the callback \p clb.
+ * @param[in] user_data Arbitrary data that will always be passed to the callback @p clb.
*/
LIBYANG_API_DECL void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data);
+/**
+ * @brief Callback for getting arbitrary run-time data required by an extension instance.
+ *
+ * @param[in] ext Compiled extension instance.
+ * @param[in] user_data User-supplied callback data.
+ * @param[out] ext_data Provided extension instance data.
+ * @param[out] ext_data_free Whether the extension instance should free @p ext_data or not.
+ * @return LY_ERR value.
+ */
typedef LY_ERR (*ly_ext_data_clb)(const struct lysc_ext_instance *ext, void *user_data, void **ext_data,
ly_bool *ext_data_free);
+/**
+ * @brief Set callback providing run-time extension instance data. The expected data depend on the extension.
+ * Data expected by internal extensions:
+ *
+ * - *ietf-yang-schema-mount:mount-point* (struct lyd_node \*\*ext_data)\n
+ * Operational data tree with at least `ietf-yang-library` data describing the mounted schema and
+ * `ietf-yang-schema-mount` **validated** data describing the specific mount point
+ * ([ref](https://datatracker.ietf.org/doc/html/rfc8528#section-3.3)).
+ *
+ * @param[in] ctx Context that will use this callback.
+ * @param[in] clb Callback responsible for returning the extension instance data.
+ * @param[in] user_data Arbitrary data that will always be passed to the callback @p clb.
+ */
LIBYANG_API_DECL ly_ext_data_clb ly_ctx_set_ext_data_clb(struct ly_ctx *ctx, ly_ext_data_clb clb, void *user_data);
/**
@@ -509,7 +531,8 @@
* @param[in] revision Revision of the submodule to find, NULL for a submodule without a revision.
* @return Found submodule, NULL if there is none.
*/
-LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *submodule, const char *revision);
+LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *submodule,
+ const char *revision);
/**
* @brief Get the latests revision of a submodule from context. If its belongs-to module is known,
@@ -540,7 +563,8 @@
* @param[in] submodule Submodule name to find.
* @return Found submodule, NULL if there is none.
*/
-LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2_latest(const struct lys_module *module, const char *submodule);
+LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2_latest(const struct lys_module *module,
+ const char *submodule);
/**
* @brief Reset cached latest revision information of the schemas in the context.
@@ -589,7 +613,8 @@
* with the current features settings in case the module is already present in the context.
* @return Pointer to the data model structure, NULL if not found or some error occurred.
*/
-LIBYANG_API_DECL struct lys_module *ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision, const char **features);
+LIBYANG_API_DECL struct lys_module *ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision,
+ const char **features);
/**
* @brief Get data of the internal ietf-yang-library module with information about all the loaded modules.
@@ -611,7 +636,8 @@
* @param[in] ... Parameters for @p content_id_format.
* @return LY_ERR value
*/
-LIBYANG_API_DECL LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root, const char *content_id_format, ...);
+LIBYANG_API_DECL LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root,
+ const char *content_id_format, ...);
/**
* @brief Free all internal structures of the specified context.
diff --git a/src/json.c b/src/json.c
index 85368cb..cbe38e9 100644
--- a/src/json.c
+++ b/src/json.c
@@ -24,12 +24,6 @@
#include "json.h"
#include "tree_schema_internal.h"
-#define JSON_PUSH_STATUS_RET(CTX, STATUS) \
- LY_CHECK_RET(ly_set_add(&CTX->status, (void *)(uintptr_t)(STATUS), 1, NULL))
-
-#define JSON_POP_STATUS_RET(CTX) \
- assert(CTX->status.count); CTX->status.count--;
-
const char *
lyjson_token2str(enum LYJSON_PARSER_STATUS status)
{
@@ -78,7 +72,7 @@
ly_in_skip(jsonctx->in, 1);
}
if (*jsonctx->in->current == '\0') {
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_END);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_END);
}
return LY_SUCCESS;
@@ -318,7 +312,7 @@
{
LY_CHECK_RET(lyjson_string_(jsonctx));
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_STRING);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_STRING);
LY_CHECK_RET(lyjson_check_next(jsonctx));
return LY_SUCCESS;
@@ -718,7 +712,7 @@
}
ly_in_skip(jsonctx->in, offset);
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_NUMBER);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_NUMBER);
LY_CHECK_RET(lyjson_check_next(jsonctx));
return LY_SUCCESS;
@@ -758,23 +752,21 @@
/* empty object */
ly_in_skip(jsonctx->in, 1);
lyjson_ctx_set_value(jsonctx, NULL, 0, 0);
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_OBJECT_EMPTY);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_OBJECT_EMPTY);
return LY_SUCCESS;
}
LY_CHECK_RET(lyjson_object_name(jsonctx));
/* output data are set by lyjson_string_() */
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_OBJECT);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_OBJECT);
return LY_SUCCESS;
}
-/*
+/**
* @brief Process JSON array envelope
*
- *
- *
* @param[in] jsonctx JSON parser context
* @return LY_SUCCESS or LY_EMEM
*/
@@ -786,9 +778,9 @@
if (*jsonctx->in->current == ']') {
/* empty array */
ly_in_skip(jsonctx->in, 1);
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_ARRAY_EMPTY);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_ARRAY_EMPTY);
} else {
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_ARRAY);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_ARRAY);
}
/* erase previous values, array has no value on its own */
@@ -808,21 +800,21 @@
/* false */
lyjson_ctx_set_value(jsonctx, jsonctx->in->current, ly_strlen_const("false"), 0);
ly_in_skip(jsonctx->in, ly_strlen_const("false"));
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_FALSE);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_FALSE);
LY_CHECK_RET(lyjson_check_next(jsonctx));
} else if ((*jsonctx->in->current == 't') && !strncmp(jsonctx->in->current, "true", ly_strlen_const("true"))) {
/* true */
lyjson_ctx_set_value(jsonctx, jsonctx->in->current, ly_strlen_const("true"), 0);
ly_in_skip(jsonctx->in, ly_strlen_const("true"));
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_TRUE);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_TRUE);
LY_CHECK_RET(lyjson_check_next(jsonctx));
} else if ((*jsonctx->in->current == 'n') && !strncmp(jsonctx->in->current, "null", ly_strlen_const("null"))) {
/* none */
lyjson_ctx_set_value(jsonctx, "", 0, 0);
ly_in_skip(jsonctx->in, ly_strlen_const("null"));
- JSON_PUSH_STATUS_RET(jsonctx, LYJSON_NULL);
+ LYJSON_STATUS_PUSH_RET(jsonctx, LYJSON_NULL);
LY_CHECK_RET(lyjson_check_next(jsonctx));
} else if (*jsonctx->in->current == '"') {
@@ -861,7 +853,7 @@
}
LY_ERR
-lyjson_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, struct lyjson_ctx **jsonctx_p)
+lyjson_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, ly_bool subtree, struct lyjson_ctx **jsonctx_p)
{
LY_ERR ret = LY_SUCCESS;
struct lyjson_ctx *jsonctx;
@@ -885,8 +877,12 @@
goto cleanup;
}
- ret = lyjson_value(jsonctx);
-
+ if (subtree) {
+ ret = lyjson_object(jsonctx);
+ jsonctx->depth++;
+ } else {
+ ret = lyjson_value(jsonctx);
+ }
if ((jsonctx->status.count > 1) && (lyjson_ctx_status(jsonctx, 0) == LYJSON_END)) {
LOGVAL(jsonctx->ctx, LY_VCODE_EOF);
ret = LY_EVALID;
@@ -950,7 +946,7 @@
goto result;
} else {
/* the previous token is closed and should be completely processed */
- JSON_POP_STATUS_RET(jsonctx);
+ LYJSON_STATUS_POP_RET(jsonctx);
prev = lyjson_ctx_status(jsonctx, 0);
}
@@ -985,14 +981,15 @@
/* ... array - get another complete value */
ret = lyjson_value(jsonctx);
}
- } else if (((prev == LYJSON_OBJECT) && (*jsonctx->in->current == '}')) || ((prev == LYJSON_ARRAY) && (*jsonctx->in->current == ']'))) {
+ } else if (((prev == LYJSON_OBJECT) && (*jsonctx->in->current == '}')) ||
+ ((prev == LYJSON_ARRAY) && (*jsonctx->in->current == ']'))) {
if (*jsonctx->in->current == '}') {
assert(jsonctx->depth);
jsonctx->depth--;
}
ly_in_skip(jsonctx->in, 1);
- JSON_POP_STATUS_RET(jsonctx);
- JSON_PUSH_STATUS_RET(jsonctx, prev + 1);
+ LYJSON_STATUS_POP_RET(jsonctx);
+ LYJSON_STATUS_PUSH_RET(jsonctx, prev + 1);
} else {
/* unexpected value */
LOGVAL(jsonctx->ctx, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(jsonctx->in->current), jsonctx->in->current,
diff --git a/src/json.h b/src/json.h
index 96504c5..c0d6ab6 100644
--- a/src/json.h
+++ b/src/json.h
@@ -30,6 +30,14 @@
/* Macro to test if character is valid string character */
#define is_jsonstrchar(c) (c == 0x20 || c == 0x21 || (c >= 0x23 && c <= 0x5b) || (c >= 0x5d && c <= 0x10ffff))
+/* Macro to push JSON parser status */
+#define LYJSON_STATUS_PUSH_RET(CTX, STATUS) \
+ LY_CHECK_RET(ly_set_add(&CTX->status, (void *)(uintptr_t)(STATUS), 1, NULL))
+
+/* Macro to pop JSON parser status */
+#define LYJSON_STATUS_POP_RET(CTX) \
+ assert(CTX->status.count); CTX->status.count--;
+
/**
* @brief Status of the parser providing information what is expected next (which function is supposed to be called).
*/
@@ -77,10 +85,11 @@
*
* @param[in] ctx libyang context.
* @param[in] in JSON string data to parse.
+ * @param[in] subtree Whether this is a special case of parsing a subtree (starting with object name).
* @param[out] jsonctx New JSON context with status referring the parsed value.
* @return LY_ERR value.
*/
-LY_ERR lyjson_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, struct lyjson_ctx **jsonctx);
+LY_ERR lyjson_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, ly_bool subtree, struct lyjson_ctx **jsonctx);
/**
* @brief Get status of the parser as the last/previous parsed token
diff --git a/src/parser_json.c b/src/parser_json.c
index e1dd7fe..49fd941 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1,9 +1,10 @@
/**
* @file parser_json.c
* @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
* @brief JSON data parser for libyang
*
- * Copyright (c) 2020 CESNET, z.s.p.o.
+ * Copyright (c) 2020 - 2022 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@
#include "log.h"
#include "parser_data.h"
#include "parser_internal.h"
+#include "plugins_exts.h"
#include "set.h"
#include "tree.h"
#include "tree_data.h"
@@ -54,15 +56,14 @@
}
/**
- * @brief Submit the responsibility for releasing the dynamic values to @p dst.
+ * @brief Pass the responsibility for releasing the dynamic values to @p dst.
*
* @param[in] jsonctx JSON context which contains the dynamic value.
* @param[in,out] dst Pointer to which the responsibility will be submited.
- * If the pointer is already pointing to some allocated memory,
- * it is released beforehand.
+ * If the pointer is already pointing to some allocated memory, it is released beforehand.
*/
static void
-lyjson_ctx_submit_dynamic_value(struct lyjson_ctx *jsonctx, char **dst)
+lyjson_ctx_give_dynamic_value(struct lyjson_ctx *jsonctx, char **dst)
{
assert(jsonctx && dst);
@@ -75,10 +76,10 @@
}
*dst = NULL;
- /* Submit the dynamic value. */
+ /* give the dynamic value */
*dst = (char *)jsonctx->value;
- /* Responsibility for the release is now passed to @p dst. */
+ /* responsibility for the release is now passed to dst */
jsonctx->dynamic = 0;
}
@@ -182,95 +183,73 @@
}
/**
- * @brief Get schema node corresponding to the input parameters.
+ * @brief Try to parse data with a parent based on an extension instance.
*
* @param[in] lydctx JSON data parser context.
- * @param[in] is_attr Flag if the reference to the node is an attribute, for logging only.
- * @param[in] prefix Requested node's prefix (module name).
- * @param[in] prefix_len Length of the @p prefix.
- * @param[in] name Requested node's name.
- * @param[in] name_len Length of the @p name.
- * @param[in] parent Parent of the node being processed, can be NULL in case of top-level.
- * @param[out] snode_p Pointer to the found schema node corresponding to the input parameters.
- * @return LY_SUCCES on success, note that even in this case the returned value of @p snode_p can be NULL, so the data are expected to be parsed as opaq.
- * @return LY_EVALID on failure, error message is logged
- * @return LY_ENOT in case the input data are expected to be skipped
+ * @param[in,out] parent Parent node where the children are inserted.
+ * @return LY_SUCCESS on success;
+ * @return LY_ENOT if no extension instance parsed the data;
+ * @return LY_ERR on error.
*/
static LY_ERR
-lydjson_get_snode(const struct lyd_json_ctx *lydctx, ly_bool is_attr, const char *prefix, size_t prefix_len, const char *name,
- size_t name_len, const struct lyd_node_inner *parent, const struct lysc_node **snode_p)
+lydjson_nested_ext(struct lyd_json_ctx *lydctx, struct lyd_node *parent)
{
- LY_ERR ret = LY_SUCCESS;
- struct lys_module *mod = NULL;
- uint32_t getnext_opts = lydctx->int_opts & LYD_INTOPT_REPLY ? LYS_GETNEXT_OUTPUT : 0;
+ LY_ERR r;
+ struct ly_in in_bck, in_start, in_ext;
+ LY_ARRAY_COUNT_TYPE u;
+ struct lysc_ext_instance *nested_exts = NULL;
+ lyplg_ext_data_parse_clb ext_parse_cb;
+ struct lyd_ctx_ext_val *ext_val;
+ uint32_t quot_count;
- /* init return value */
- *snode_p = NULL;
+ /* backup current input */
+ in_bck = *lydctx->jsonctx->in;
- LOG_LOCSET(NULL, parent ? &parent->node : NULL, NULL, NULL);
-
- /* get the element module */
- if (prefix_len) {
- mod = ly_ctx_get_module_implemented2(lydctx->jsonctx->ctx, prefix, prefix_len);
- } else if (parent) {
- if (parent->schema) {
- mod = parent->schema->module;
+ /* go back in the input for extension parsing */
+ in_start = *lydctx->jsonctx->in;
+ assert(lyjson_ctx_status(lydctx->jsonctx, 0) == LYJSON_OBJECT);
+ quot_count = 0;
+ do {
+ --in_start.current;
+ if ((in_start.current[0] == '\"') && (in_start.current[-1] != '\\')) {
+ ++quot_count;
}
- } else {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_SYNTAX_JSON, "Top-level JSON object member \"%.*s\" must be namespace-qualified.",
- (int)(is_attr ? name_len + 1 : name_len), is_attr ? name - 1 : name);
- ret = LY_EVALID;
- goto cleanup;
+ } while (quot_count < 2);
+
+ /* check if there are any nested extension instances */
+ if (parent && parent->schema) {
+ nested_exts = parent->schema->exts;
}
- if (!mod) {
- if (lydctx->parse_opts & LYD_PARSE_STRICT) {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "No module named \"%.*s\" in the context.", (int)prefix_len, prefix);
- ret = LY_EVALID;
- goto cleanup;
- }
- if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
- ret = LY_ENOT;
- goto cleanup;
- }
- }
-
- /* get the schema node */
- if (mod && (!parent || parent->schema)) {
- if (!parent && lydctx->ext) {
- *snode_p = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
- } else {
- *snode_p = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
- }
- if (!*snode_p) {
- if (lydctx->parse_opts & LYD_PARSE_STRICT) {
- if (lydctx->ext) {
- if (lydctx->ext->argument) {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" %s extension instance.",
- (int)name_len, name, lydctx->ext->argument, lydctx->ext->def->name);
- } else {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the %s extension instance.",
- (int)name_len, name, lydctx->ext->def->name);
- }
- } else {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" module.",
- (int)name_len, name, mod->name);
- }
- ret = LY_EVALID;
- goto cleanup;
- } else if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
- /* skip element with children */
- ret = LY_ENOT;
- goto cleanup;
+ LY_ARRAY_FOR(nested_exts, u) {
+ /* prepare the input and try to parse this extension data */
+ in_ext = in_start;
+ ext_parse_cb = nested_exts[u].def->plugin->parse;
+ r = ext_parse_cb(&in_ext, LYD_JSON, &nested_exts[u], parent, lydctx->parse_opts | LYD_PARSE_ONLY);
+ if (!r) {
+ /* data successfully parsed, remember for validation */
+ if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+ ext_val = malloc(sizeof *ext_val);
+ LY_CHECK_ERR_RET(!ext_val, LOGMEM(lydctx->jsonctx->ctx), LY_EMEM);
+ ext_val->ext = &nested_exts[u];
+ ext_val->sibling = lyd_child_no_keys(parent);
+ LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
}
- } else {
- /* check that schema node is valid and can be used */
- ret = lyd_parser_check_schema((struct lyd_ctx *)lydctx, *snode_p);
+
+ /* adjust the jsonctx accordingly */
+ *lydctx->jsonctx->in = in_ext;
+ LYJSON_STATUS_PUSH_RET(lydctx->jsonctx, LYJSON_OBJECT_CLOSED);
+ LY_CHECK_RET(lyjson_ctx_next(lydctx->jsonctx, NULL));
+ return LY_SUCCESS;
+ } else if (r != LY_ENOT) {
+ /* fatal error */
+ return r;
}
+ /* data was not from this module, continue */
}
-cleanup:
- LOG_LOCBACK(0, parent ? 1 : 0, 0, 0);
- return ret;
+ /* no extensions or none matched, restore input */
+ *lydctx->jsonctx->in = in_bck;
+ return LY_ENOT;
}
/**
@@ -311,6 +290,135 @@
}
/**
+ * @brief Get schema node corresponding to the input parameters.
+ *
+ * @param[in] lydctx JSON data parser context.
+ * @param[in] is_attr Flag if the reference to the node is an attribute, for logging only.
+ * @param[in] prefix Requested node's prefix (module name).
+ * @param[in] prefix_len Length of the @p prefix.
+ * @param[in] name Requested node's name.
+ * @param[in] name_len Length of the @p name.
+ * @param[in] parent Parent of the node being processed, can be NULL in case of top-level.
+ * @param[out] snode_p Found schema node corresponding to the input parameters. If NULL, parse as an opaque node.
+ * @return LY_SUCCES on success.
+ * @return LY_ENOT if the whole object was parsed (skipped or as an extension).
+ * @return LY_ERR on error.
+ */
+static LY_ERR
+lydjson_get_snode(struct lyd_json_ctx *lydctx, ly_bool is_attr, const char *prefix, size_t prefix_len, const char *name,
+ size_t name_len, struct lyd_node *parent, const struct lysc_node **snode_p)
+{
+ LY_ERR ret = LY_SUCCESS, r;
+ struct lys_module *mod = NULL;
+ uint32_t getnext_opts = lydctx->int_opts & LYD_INTOPT_REPLY ? LYS_GETNEXT_OUTPUT : 0;
+
+ /* init return value */
+ *snode_p = NULL;
+
+ LOG_LOCSET(NULL, parent, NULL, NULL);
+
+ /* get the element module */
+ if (prefix_len) {
+ mod = ly_ctx_get_module_implemented2(lydctx->jsonctx->ctx, prefix, prefix_len);
+ } else if (parent) {
+ if (parent->schema) {
+ mod = parent->schema->module;
+ }
+ } else {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_SYNTAX_JSON, "Top-level JSON object member \"%.*s\" must be namespace-qualified.",
+ (int)(is_attr ? name_len + 1 : name_len), is_attr ? name - 1 : name);
+ ret = LY_EVALID;
+ goto cleanup;
+ }
+ if (!mod) {
+ /* check for extension data */
+ r = lydjson_nested_ext(lydctx, parent);
+ if (!r) {
+ /* successfully parsed */
+ ret = LY_ENOT;
+ goto cleanup;
+ } else if (r != LY_ENOT) {
+ /* error */
+ ret = r;
+ goto cleanup;
+ }
+
+ /* unknown module */
+ if (lydctx->parse_opts & LYD_PARSE_STRICT) {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "No module named \"%.*s\" in the context.", (int)prefix_len, prefix);
+ ret = LY_EVALID;
+ goto cleanup;
+ }
+ if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
+ /* skip element with children */
+ ret = lydjson_data_skip(lydctx->jsonctx);
+ LY_CHECK_GOTO(ret, cleanup);
+
+ ret = LY_ENOT;
+ goto cleanup;
+ }
+ }
+
+ /* get the schema node */
+ if (mod && (!parent || parent->schema)) {
+ if (!parent && lydctx->ext) {
+ *snode_p = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
+ } else {
+ *snode_p = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
+ }
+ if (!*snode_p) {
+ /* check for extension data */
+ r = lydjson_nested_ext(lydctx, parent);
+ if (!r) {
+ /* successfully parsed */
+ ret = LY_ENOT;
+ goto cleanup;
+ } else if (r != LY_ENOT) {
+ /* error */
+ ret = r;
+ goto cleanup;
+ }
+
+ /* unknown data node */
+ if (lydctx->parse_opts & LYD_PARSE_STRICT) {
+ if (parent) {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found as a child of \"%s\" node.",
+ (int)name_len, name, LYD_NAME(parent));
+ } else if (lydctx->ext) {
+ if (lydctx->ext->argument) {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE,
+ "Node \"%.*s\" not found in the \"%s\" %s extension instance.",
+ (int)name_len, name, lydctx->ext->argument, lydctx->ext->def->name);
+ } else {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the %s extension instance.",
+ (int)name_len, name, lydctx->ext->def->name);
+ }
+ } else {
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" module.",
+ (int)name_len, name, mod->name);
+ }
+ ret = LY_EVALID;
+ goto cleanup;
+ } else if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
+ /* skip element with children */
+ ret = lydjson_data_skip(lydctx->jsonctx);
+ LY_CHECK_GOTO(ret, cleanup);
+
+ ret = LY_ENOT;
+ goto cleanup;
+ }
+ } else {
+ /* check that schema node is valid and can be used */
+ ret = lyd_parser_check_schema((struct lyd_ctx *)lydctx, *snode_p);
+ }
+ }
+
+cleanup:
+ LOG_LOCBACK(0, parent ? 1 : 0, 0, 0);
+ return ret;
+}
+
+/**
* @brief Check that the input data are parseable as the @p list.
*
* Checks for all the list's keys. Function does not revert the context state.
@@ -592,7 +700,7 @@
lydjson_parse_name(meta_container->name.name, strlen(meta_container->name.name), &name, &name_len,
&prefix, &prefix_len, &is_attr);
assert(is_attr);
- ret = lydjson_get_snode(lydctx, is_attr, prefix, prefix_len, name, name_len, (*first_p)->parent, &snode);
+ ret = lydjson_get_snode(lydctx, is_attr, prefix, prefix_len, name, name_len, lyd_parent(*first_p), &snode);
assert(ret == LY_SUCCESS);
if (snode != node->schema) {
@@ -641,7 +749,8 @@
if (match != instance) {
/* there is no corresponding data node for the metadata */
if (instance > 1) {
- LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Missing JSON data instance #%" PRIu64 " to be coupled with %s metadata.",
+ LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE,
+ "Missing JSON data instance #%" PRIu64 " to be coupled with %s metadata.",
instance, meta_container->name.name);
} else {
LOGVAL(lydctx->jsonctx->ctx, LYVE_REFERENCE, "Missing JSON data instance to be coupled with %s metadata.",
@@ -766,7 +875,7 @@
while (status != LYJSON_OBJECT_CLOSED) {
lydjson_parse_name(lydctx->jsonctx->value, lydctx->jsonctx->value_len, &name, &name_len, &prefix, &prefix_len, &is_attr);
- lyjson_ctx_submit_dynamic_value(lydctx->jsonctx, &dynamic_prefname);
+ lyjson_ctx_give_dynamic_value(lydctx->jsonctx, &dynamic_prefname);
if (!name_len) {
LOGVAL(ctx, LYVE_SYNTAX_JSON, "Metadata in JSON found with an empty name, followed by: %.10s", name);
@@ -844,10 +953,6 @@
goto next_entry;
}
- /* move after the metadata */
- ret = lyjson_ctx_next(lydctx->jsonctx, NULL);
- LY_CHECK_GOTO(ret, cleanup);
-
/* success */
goto cleanup;
@@ -875,14 +980,14 @@
* @param[in] last If set, always insert at the end.
*/
static void
-lydjson_maintain_children(struct lyd_node_inner *parent, struct lyd_node **first_p, struct lyd_node **node_p, ly_bool last)
+lydjson_maintain_children(struct lyd_node *parent, struct lyd_node **first_p, struct lyd_node **node_p, ly_bool last)
{
if (*node_p) {
/* insert, keep first pointer correct */
- lyd_insert_node(parent ? &parent->node : NULL, first_p, *node_p, last);
+ lyd_insert_node(parent, first_p, *node_p, last);
if (first_p) {
if (parent) {
- *first_p = parent->child;
+ *first_p = lyd_child(parent);
} else {
while ((*first_p)->prev->next) {
*first_p = (*first_p)->prev;
@@ -910,7 +1015,7 @@
*/
static LY_ERR
lydjson_create_opaq(struct lyd_json_ctx *lydctx, const char *name, size_t name_len, const char *prefix, size_t prefix_len,
- struct lyd_node_inner *parent, enum LYJSON_PARSER_STATUS *status_inner_p, struct lyd_node **node_p)
+ struct lyd_node *parent, enum LYJSON_PARSER_STATUS *status_inner_p, struct lyd_node **node_p)
{
LY_ERR ret = LY_SUCCESS;
const char *value = NULL, *module_name;
@@ -929,7 +1034,7 @@
}
/* create node */
- lydjson_get_node_prefix(parent ? &parent->node : NULL, prefix, prefix_len, &module_name, &module_name_len);
+ lydjson_get_node_prefix(parent, prefix, prefix_len, &module_name, &module_name_len);
ret = lyd_create_opaq(lydctx->jsonctx->ctx, name, name_len, prefix, prefix_len, module_name, module_name_len, value,
value_len, &dynamic, LY_VALUE_JSON, NULL, type_hint, node_p);
if (dynamic) {
@@ -964,13 +1069,10 @@
*/
static LY_ERR
lydjson_parse_opaq(struct lyd_json_ctx *lydctx, const char *name, size_t name_len, const char *prefix, size_t prefix_len,
- struct lyd_node_inner *parent, enum LYJSON_PARSER_STATUS *status_p,
- enum LYJSON_PARSER_STATUS *status_inner_p, struct lyd_node **first_p, struct lyd_node **node_p)
+ struct lyd_node *parent, enum LYJSON_PARSER_STATUS *status_p, enum LYJSON_PARSER_STATUS *status_inner_p,
+ struct lyd_node **first_p, struct lyd_node **node_p)
{
- LY_ERR ret = LY_SUCCESS;
-
- ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p);
- LY_CHECK_RET(ret);
+ LY_CHECK_RET(lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p));
if ((*status_p == LYJSON_ARRAY) && (*status_inner_p == LYJSON_NULL)) {
/* special array null value */
@@ -1011,8 +1113,7 @@
/* continue with the next instance */
assert(node_p);
lydjson_maintain_children(parent, first_p, node_p, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
- ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p);
- LY_CHECK_RET(ret);
+ LY_CHECK_RET(lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p));
}
if ((*status_p == LYJSON_OBJECT) || (*status_p == LYJSON_OBJECT_EMPTY)) {
@@ -1025,10 +1126,7 @@
finish:
/* finish linking metadata */
- LY_CHECK_RET(lydjson_metadata_finish(lydctx, lyd_node_child_p(*node_p)));
-
- /* move after the item */
- return lyjson_ctx_next(lydctx->jsonctx, status_p);
+ return lydjson_metadata_finish(lydctx, lyd_node_child_p(*node_p));
}
/**
@@ -1053,7 +1151,7 @@
*/
static LY_ERR
lydjson_ctx_next_parse_opaq(struct lyd_json_ctx *lydctx, const char *name, size_t name_len,
- const char *prefix, size_t prefix_len, struct lyd_node_inner *parent, enum LYJSON_PARSER_STATUS *status_p,
+ const char *prefix, size_t prefix_len, struct lyd_node *parent, enum LYJSON_PARSER_STATUS *status_p,
struct lyd_node **first_p, struct lyd_node **node_p)
{
enum LYJSON_PARSER_STATUS status_inner = 0;
@@ -1074,7 +1172,8 @@
}
/* parse opaq node from the input */
- LY_CHECK_RET(lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_p, &status_inner, first_p, node_p));
+ LY_CHECK_RET(lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_p, &status_inner,
+ first_p, node_p));
return LY_SUCCESS;
}
@@ -1102,7 +1201,9 @@
const char *name, size_t name_len, const char *prefix, size_t prefix_len, struct lyd_node *parent,
enum LYJSON_PARSER_STATUS *status_p, struct lyd_node **first_p, struct lyd_node **node_p)
{
- LY_ERR ret = LY_SUCCESS;
+ LY_ERR r;
+ const char *opaq_name;
+ size_t opaq_name_len;
/* parse as an attribute to a node */
if (!attr_node && snode) {
@@ -1125,16 +1226,18 @@
lydctx->parse_opts &= ~LYD_PARSE_STRICT;
lydctx->parse_opts |= LYD_PARSE_OPAQ;
- ret = lydjson_ctx_next_parse_opaq(lydctx, prefix ? prefix - 1 : name - 1, prefix ? prefix_len + name_len + 2 : name_len + 1,
- NULL, 0, (struct lyd_node_inner *)parent, status_p, first_p, node_p);
+ opaq_name = prefix ? prefix - 1 : name - 1;
+ opaq_name_len = prefix ? prefix_len + name_len + 2 : name_len + 1;
+ r = lydjson_ctx_next_parse_opaq(lydctx, opaq_name, opaq_name_len, NULL, 0, parent, status_p, first_p, node_p);
/* restore the parser options */
lydctx->parse_opts = prev_opts;
+ LY_CHECK_RET(r);
} else {
- ret = lydjson_metadata(lydctx, snode, attr_node);
+ LY_CHECK_RET(lydjson_metadata(lydctx, snode, attr_node));
}
- return ret;
+ return LY_SUCCESS;
}
/**
@@ -1152,11 +1255,11 @@
* @param[in,out] status JSON parser status, is updated.
* @param[out] node Parsed data (or opaque) node.
* @return LY_SUCCESS if a node was successfully parsed,
- * @return LY_EINVAL in case of invalid JSON encoding,
+ * @return LY_ENOT in case of invalid JSON encoding,
* @return LY_ERR on other errors.
*/
static LY_ERR
-lydjson_parse_instance(struct lyd_json_ctx *lydctx, struct lyd_node_inner *parent, struct lyd_node **first_p,
+lydjson_parse_instance(struct lyd_json_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p,
const struct lysc_node *snode, const char *name, size_t name_len, const char *prefix, size_t prefix_len,
enum LYJSON_PARSER_STATUS *status, struct lyd_node **node)
{
@@ -1170,7 +1273,7 @@
assert(snode->nodetype & (LYD_NODE_TERM | LYD_NODE_INNER | LYD_NODE_ANY));
if (snode->nodetype & LYD_NODE_TERM) {
LY_CHECK_RET((*status != LYJSON_ARRAY) && (*status != LYJSON_NUMBER) && (*status != LYJSON_STRING) &&
- (*status != LYJSON_FALSE) && (*status != LYJSON_TRUE) && (*status != LYJSON_NULL), LY_EINVAL);
+ (*status != LYJSON_FALSE) && (*status != LYJSON_TRUE) && (*status != LYJSON_NULL), LY_ENOT);
/* create terminal node */
ret = lyd_parser_create_term((struct lyd_ctx *)lydctx, snode, lydctx->jsonctx->value,
@@ -1187,7 +1290,7 @@
assert(*status == LYJSON_ARRAY_CLOSED);
}
} else if (snode->nodetype == LYS_ANYXML) {
- LY_CHECK_RET((*status != LYJSON_STRING) && (*status != LYJSON_NULL), LY_EINVAL);
+ LY_CHECK_RET((*status != LYJSON_STRING) && (*status != LYJSON_NULL), LY_ENOT);
/* create anyxml node */
if (*status == LYJSON_NULL) {
@@ -1208,7 +1311,7 @@
}
} else if (snode->nodetype & LYD_NODE_INNER) {
/* create inner node */
- LY_CHECK_RET((*status != LYJSON_OBJECT) && (*status != LYJSON_OBJECT_EMPTY), LY_EINVAL);
+ LY_CHECK_RET((*status != LYJSON_OBJECT) && (*status != LYJSON_OBJECT_EMPTY), LY_ENOT);
ret = lyd_create_inner(snode, node);
LY_CHECK_RET(ret);
@@ -1246,7 +1349,7 @@
LOG_LOCBACK(1, 1, 0, 0);
} else if (snode->nodetype == LYS_ANYDATA) {
/* create any node */
- LY_CHECK_RET((*status != LYJSON_OBJECT) && (*status != LYJSON_OBJECT_EMPTY), LY_EINVAL);
+ LY_CHECK_RET((*status != LYJSON_OBJECT) && (*status != LYJSON_OBJECT_EMPTY), LY_ENOT);
/* parse any data tree with correct options */
/* first backup the current options and then make the parser to process data as opaq nodes */
@@ -1275,15 +1378,11 @@
LY_CHECK_RET(ret);
}
- /* move JSON parser */
- LY_CHECK_RET(lyjson_ctx_next(lydctx->jsonctx, status));
-
/* add/correct flags */
lyd_parse_set_data_flags(*node, &lydctx->node_when, &(*node)->meta, lydctx->parse_opts);
} else if (ret == LY_ENOT) {
/* parse it again as an opaq node */
- ret = lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent,
- status, status, first_p, node);
+ ret = lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status, status, first_p, node);
LY_CHECK_RET(ret);
if (snode->nodetype == LYS_LIST) {
@@ -1293,7 +1392,7 @@
}
}
- return ret;
+ return LY_SUCCESS;
}
/**
@@ -1308,11 +1407,11 @@
static LY_ERR
lydjson_subtree_r(struct lyd_json_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p, struct ly_set *parsed)
{
- LY_ERR ret = LY_SUCCESS;
+ LY_ERR ret = LY_SUCCESS, r;
enum LYJSON_PARSER_STATUS status = lyjson_ctx_status(lydctx->jsonctx, 0);
const char *name, *prefix = NULL, *expected = NULL;
size_t name_len, prefix_len = 0;
- ly_bool is_meta = 0;
+ ly_bool is_meta = 0, parse_subtree;
const struct lysc_node *snode = NULL;
struct lyd_node *node = NULL, *attr_node = NULL;
const struct ly_ctx *ctx = lydctx->jsonctx->ctx;
@@ -1321,22 +1420,22 @@
assert(parent || first_p);
assert(status == LYJSON_OBJECT);
+ parse_subtree = lydctx->parse_opts & LYD_PARSE_SUBTREE ? 1 : 0;
+ /* all descendants should be parsed */
+ lydctx->parse_opts &= ~LYD_PARSE_SUBTREE;
+
/* process the node name */
lydjson_parse_name(lydctx->jsonctx->value, lydctx->jsonctx->value_len, &name, &name_len, &prefix, &prefix_len, &is_meta);
- lyjson_ctx_submit_dynamic_value(lydctx->jsonctx, &value);
+ lyjson_ctx_give_dynamic_value(lydctx->jsonctx, &value);
if (!is_meta || name_len || prefix_len) {
/* get the schema node */
- ret = lydjson_get_snode(lydctx, is_meta, prefix, prefix_len, name, name_len, (struct lyd_node_inner *)parent, &snode);
- if (ret == LY_ENOT) {
- /* skip element with children */
- ret = lydjson_data_skip(lydctx->jsonctx);
- LY_CHECK_GOTO(ret, cleanup);
- status = lyjson_ctx_status(lydctx->jsonctx, 0);
- /* nothing for now, continue with another call of lydjson_subtree_r() */
+ r = lydjson_get_snode(lydctx, is_meta, prefix, prefix_len, name, name_len, parent, &snode);
+ if (r == LY_ENOT) {
+ /* data parsed */
goto cleanup;
}
- LY_CHECK_GOTO(ret, cleanup);
+ LY_CHECK_ERR_GOTO(r, ret = r, cleanup);
if (!snode) {
/* we will not be parsing it as metadata */
@@ -1372,15 +1471,13 @@
}
/* move to the second item in the name/X pair and parse opaq */
- ret = lydjson_ctx_next_parse_opaq(lydctx, name, name_len, prefix, prefix_len,
- (struct lyd_node_inner *)parent, &status, first_p, &node);
+ ret = lydjson_ctx_next_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, &status, first_p, &node);
LY_CHECK_GOTO(ret, cleanup);
} else {
/* parse as a standard lyd_node but it can still turn out to be an opaque node */
/* move to the second item in the name/X pair */
- ret = lyjson_ctx_next(lydctx->jsonctx, &status);
- LY_CHECK_GOTO(ret, cleanup);
+ LY_CHECK_GOTO(ret = lyjson_ctx_next(lydctx->jsonctx, &status), cleanup);
/* first check the expected representation according to the nodetype and then continue with the content */
switch (snode->nodetype) {
@@ -1400,21 +1497,19 @@
/* process all the values/objects */
do {
- lydjson_maintain_children((struct lyd_node_inner *)parent, first_p, &node,
- lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+ lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
- ret = lydjson_parse_instance(lydctx, (struct lyd_node_inner *)parent, first_p, snode, name, name_len,
- prefix, prefix_len, &status, &node);
- if (ret == LY_EINVAL) {
+ ret = lydjson_parse_instance(lydctx, parent, first_p, snode, name, name_len, prefix, prefix_len,
+ &status, &node);
+ if (ret == LY_ENOT) {
goto representation_error;
} else if (ret) {
goto cleanup;
}
- } while (status != LYJSON_ARRAY_CLOSED);
- /* move after the array */
- ret = lyjson_ctx_next(lydctx->jsonctx, &status);
- LY_CHECK_GOTO(ret, cleanup);
+ /* move after the item(s) */
+ LY_CHECK_GOTO(ret = lyjson_ctx_next(lydctx->jsonctx, &status), cleanup);
+ } while (status != LYJSON_ARRAY_CLOSED);
break;
case LYS_LEAF:
@@ -1435,9 +1530,8 @@
}
/* process the value/object */
- ret = lydjson_parse_instance(lydctx, (struct lyd_node_inner *)parent, first_p, snode, name, name_len,
- prefix, prefix_len, &status, &node);
- if (ret == LY_EINVAL) {
+ ret = lydjson_parse_instance(lydctx, parent, first_p, snode, name, name_len, prefix, prefix_len, &status, &node);
+ if (ret == LY_ENOT) {
goto representation_error;
} else if (ret) {
goto cleanup;
@@ -1447,20 +1541,23 @@
/* rememeber the RPC/action/notification */
lydctx->op_node = node;
}
-
break;
}
}
/* finally connect the parsed node */
- lydjson_maintain_children((struct lyd_node_inner *)parent, first_p, &node,
- lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+ lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
/* rememeber a successfully parsed node */
if (parsed) {
ly_set_add(parsed, node, 1, NULL);
}
+ if (!parse_subtree) {
+ /* move after the item(s) */
+ LY_CHECK_GOTO(ret = lyjson_ctx_next(lydctx->jsonctx, &status), cleanup);
+ }
+
/* success */
goto cleanup;
@@ -1495,6 +1592,7 @@
LY_ERR ret = LY_SUCCESS;
struct lyd_json_ctx *lydctx;
size_t i;
+ ly_bool subtree;
assert(lydctx_p);
assert(status);
@@ -1514,15 +1612,16 @@
}
}
- LY_CHECK_ERR_RET(ret = lyjson_ctx_new(ctx, in, &lydctx->jsonctx), free(lydctx), ret);
+ subtree = (parse_opts & LYD_PARSE_SUBTREE) ? 1 : 0;
+ LY_CHECK_ERR_RET(ret = lyjson_ctx_new(ctx, in, subtree, &lydctx->jsonctx), free(lydctx), ret);
*status = lyjson_ctx_status(lydctx->jsonctx, 0);
+
if ((*status == LYJSON_END) || (*status == LYJSON_OBJECT_EMPTY) || (*status == LYJSON_OBJECT)) {
*lydctx_p = lydctx;
return LY_SUCCESS;
} else {
/* expecting top-level object */
- LOGVAL(ctx, LYVE_SYNTAX_JSON, "Expected top-level JSON object, but %s found.",
- lyjson_token2str(*status));
+ LOGVAL(ctx, LYVE_SYNTAX_JSON, "Expected top-level JSON object, but %s found.", lyjson_token2str(*status));
*lydctx_p = NULL;
lyd_json_ctx_free((struct lyd_ctx *)lydctx);
return LY_EVALID;
@@ -1537,7 +1636,7 @@
LY_ERR rc = LY_SUCCESS;
struct lyd_json_ctx *lydctx = NULL;
enum LYJSON_PARSER_STATUS status;
- uint32_t int_opts;
+ uint32_t int_opts = 0;
rc = lyd_parse_json_init(ctx, in, parse_opts, val_opts, &lydctx, &status);
LY_CHECK_GOTO(rc || status == LYJSON_END || status == LYJSON_OBJECT_EMPTY, cleanup);
@@ -1546,7 +1645,9 @@
switch (data_type) {
case LYD_TYPE_DATA_YANG:
- int_opts = LYD_INTOPT_WITH_SIBLINGS;
+ if (!(parse_opts & LYD_PARSE_SUBTREE)) {
+ int_opts = LYD_INTOPT_WITH_SIBLINGS;
+ }
break;
case LYD_TYPE_RPC_YANG:
int_opts = LYD_INTOPT_RPC | LYD_INTOPT_ACTION | LYD_INTOPT_NO_SIBLINGS;
@@ -1596,6 +1697,19 @@
rc = lydjson_metadata_finish(lydctx, parent ? lyd_node_child_p(parent) : first_p);
LY_CHECK_GOTO(rc, cleanup);
+ if (parse_opts & LYD_PARSE_SUBTREE) {
+ /* check for a sibling object */
+ assert(subtree_sibling);
+ if (lydctx->jsonctx->in->current[0] == ',') {
+ *subtree_sibling = 1;
+
+ /* move to the next object */
+ ly_in_skip(lydctx->jsonctx->in, 1);
+ } else {
+ *subtree_sibling = 0;
+ }
+ }
+
cleanup:
/* there should be no unresolved types stored */
assert(!(parse_opts & LYD_PARSE_ONLY) || !lydctx || (!lydctx->node_types.count && !lydctx->meta_types.count &&
diff --git a/src/parser_xml.c b/src/parser_xml.c
index e874231..224b3c3 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -453,7 +453,7 @@
ext_val = malloc(sizeof *ext_val);
LY_CHECK_ERR_RET(!ext_val, LOGMEM(lydctx->xmlctx->ctx), LY_EMEM);
ext_val->ext = &nested_exts[u];
- ext_val->sibling = lyd_child(parent);
+ ext_val->sibling = lyd_child_no_keys(parent);
LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
}
@@ -585,7 +585,7 @@
if (lydctx->parse_opts & LYD_PARSE_STRICT) {
if (parent) {
LOGVAL(ctx, LYVE_REFERENCE, "Node \"%.*s\" not found as a child of \"%s\" node.",
- (int)name_len, name, parent->schema->name);
+ (int)name_len, name, LYD_NAME(parent));
} else if (lydctx->ext) {
if (lydctx->ext->argument) {
LOGVAL(ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" %s extension instance.",
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index 2dba714..f521d7d 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -219,6 +219,16 @@
struct lyplg_ext plugin; /**< data to utilize plugin implementation */
};
+/**
+ * @brief Get specific run-time extension instance data from a callback set by ::ly_ctx_set_ext_data_clb().
+ *
+ * @param[in] ctx Context with the callback.
+ * @param[in] ext Compiled extension instance.
+ * @param[out] ext_data Provided extension instance data.
+ * @param[out] ext_data_free Whether the extension instance should free @p ext_data or not.
+ * @return LY_SUCCESS on success.
+ * @return LY_ERR on error.
+ */
LIBYANG_API_DECL LY_ERR lyplg_ext_get_data(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, void **ext_data,
ly_bool *ext_data_free);
diff --git a/src/printer_internal.h b/src/printer_internal.h
index 8410535..48f3c42 100644
--- a/src/printer_internal.h
+++ b/src/printer_internal.h
@@ -48,8 +48,8 @@
/**
* @brief Helper macros for data printers
*/
-#define DO_FORMAT (!(ctx->options & LY_PRINT_SHRINK))
-#define LEVEL ctx->level /**< current level */
+#define DO_FORMAT (!(pctx->options & LY_PRINT_SHRINK))
+#define LEVEL pctx->level /**< current level */
#define INDENT (DO_FORMAT ? (LEVEL)*2 : 0),"" /**< indentation parameters for printer functions */
#define LEVEL_INC LEVEL++ /**< increase indentation level */
#define LEVEL_DEC LEVEL-- /**< decrease indentation level */
diff --git a/src/printer_json.c b/src/printer_json.c
index 7c251a1..cb3e094 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -49,14 +49,14 @@
* @brief Mark that something was already written in the current level,
* used to decide if a comma is expected between the items
*/
-#define LEVEL_PRINTED ctx->level_printed = ctx->level
+#define LEVEL_PRINTED pctx->level_printed = pctx->level
#define PRINT_COMMA \
- if (ctx->level_printed >= ctx->level) {\
- ly_print_(ctx->out, ",%s", (DO_FORMAT ? "\n" : ""));\
+ if (pctx->level_printed >= pctx->level) { \
+ ly_print_(pctx->out, ",%s", (DO_FORMAT ? "\n" : "")); \
}
-static LY_ERR json_print_node(struct jsonpr_ctx *ctx, const struct lyd_node *node);
+static LY_ERR json_print_node(struct jsonpr_ctx *pctx, const struct lyd_node *node);
/**
* Compare 2 nodes, despite it is regular data node or an opaq node, and
@@ -96,10 +96,10 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_array_open(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_array_open(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- ly_print_(ctx->out, "[%s", DO_FORMAT ? "\n" : "");
- LY_CHECK_RET(ly_set_add(&ctx->open, (void *)node, 0, NULL));
+ ly_print_(pctx->out, "[%s", DO_FORMAT ? "\n" : "");
+ LY_CHECK_RET(ly_set_add(&pctx->open, (void *)node, 0, NULL));
LEVEL_INC;
return LY_SUCCESS;
@@ -114,9 +114,9 @@
* @return 0 in case the provided @p node is not connected with the currently open array (or there is no open array).
*/
static int
-is_open_array(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+is_open_array(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- if (ctx->open.count && matching_node(node, (const struct lyd_node *)ctx->open.objs[ctx->open.count - 1])) {
+ if (pctx->open.count && matching_node(node, pctx->open.dnodes[pctx->open.count - 1])) {
return 1;
} else {
return 0;
@@ -129,11 +129,11 @@
* @param[in] ctx JSON printer context.
*/
static void
-json_print_array_close(struct jsonpr_ctx *ctx)
+json_print_array_close(struct jsonpr_ctx *pctx)
{
LEVEL_DEC;
- ly_set_rm_index(&ctx->open, ctx->open.count - 1, NULL);
- ly_print_(ctx->out, "%s%*s]", DO_FORMAT ? "\n" : "", INDENT);
+ ly_set_rm_index(&pctx->open, pctx->open.count - 1, NULL);
+ ly_print_(pctx->out, "%s%*s]", DO_FORMAT ? "\n" : "", INDENT);
}
/**
@@ -256,16 +256,15 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_member(struct jsonpr_ctx *ctx, const struct lyd_node *node, ly_bool is_attr)
+json_print_member(struct jsonpr_ctx *pctx, const struct lyd_node *node, ly_bool is_attr)
{
PRINT_COMMA;
- if ((LEVEL == 1) || json_nscmp(node, (const struct lyd_node *)node->parent)) {
+ if ((LEVEL == 1) || json_nscmp(node, lyd_parent(node))) {
/* print "namespace" */
- ly_print_(ctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "",
+ ly_print_(pctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "",
node_prefix(node), node->schema->name, DO_FORMAT ? " " : "");
} else {
- ly_print_(ctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "",
- node->schema->name, DO_FORMAT ? " " : "");
+ ly_print_(pctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "", node->schema->name, DO_FORMAT ? " " : "");
}
return LY_SUCCESS;
@@ -282,7 +281,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_member2(struct jsonpr_ctx *ctx, const struct lyd_node *parent, LY_VALUE_FORMAT format,
+json_print_member2(struct jsonpr_ctx *pctx, const struct lyd_node *parent, LY_VALUE_FORMAT format,
const struct ly_opaq_name *name, ly_bool is_attr)
{
const char *module_name = NULL, *name_str;
@@ -298,14 +297,14 @@
module_name = name->module_name;
break;
case LY_VALUE_XML:
- mod = ly_ctx_get_module_implemented_ns(ctx->ctx, name->module_ns);
+ mod = ly_ctx_get_module_implemented_ns(pctx->ctx, name->module_ns);
if (mod) {
module_name = mod->name;
}
break;
default:
/* cannot be created */
- LOGINT_RET(ctx->ctx);
+ LOGINT_RET(pctx->ctx);
}
name_str = name->name;
@@ -315,9 +314,9 @@
/* print the member */
if (module_name && (!parent || (node_prefix(parent) != module_name))) {
- ly_print_(ctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "", module_name, name_str, DO_FORMAT ? " " : "");
+ ly_print_(pctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "", module_name, name_str, DO_FORMAT ? " " : "");
} else {
- ly_print_(ctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "", name_str, DO_FORMAT ? " " : "");
+ ly_print_(pctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "", name_str, DO_FORMAT ? " " : "");
}
return LY_SUCCESS;
@@ -326,16 +325,17 @@
/**
* @brief Print data value.
*
- * @param[in] ctx JSON printer context.
+ * @param[in] pctx JSON printer context.
+ * @param[in] ctx Context used to print the value.
* @param[in] val Data value to be printed.
* @return LY_ERR value.
*/
static LY_ERR
-json_print_value(struct jsonpr_ctx *ctx, const struct lyd_value *val)
+json_print_value(struct jsonpr_ctx *pctx, const struct ly_ctx *ctx, const struct lyd_value *val)
{
ly_bool dynamic;
LY_DATA_TYPE basetype;
- const char *value = val->realtype->plugin->print(ctx->ctx, val, LY_VALUE_JSON, NULL, &dynamic, NULL);
+ const char *value = val->realtype->plugin->print(ctx, val, LY_VALUE_JSON, NULL, &dynamic, NULL);
basetype = val->realtype->basetype;
@@ -356,7 +356,7 @@
case LY_TYPE_UINT64:
case LY_TYPE_DEC64:
case LY_TYPE_IDENT:
- json_print_string(ctx->out, value);
+ json_print_string(pctx->out, value);
break;
case LY_TYPE_INT8:
@@ -366,16 +366,16 @@
case LY_TYPE_UINT16:
case LY_TYPE_UINT32:
case LY_TYPE_BOOL:
- ly_print_(ctx->out, "%s", value[0] ? value : "null");
+ ly_print_(pctx->out, "%s", value[0] ? value : "null");
break;
case LY_TYPE_EMPTY:
- ly_print_(ctx->out, "[null]");
+ ly_print_(pctx->out, "[null]");
break;
default:
/* error */
- LOGINT_RET(ctx->ctx);
+ LOGINT_RET(pctx->ctx);
}
if (dynamic) {
@@ -394,25 +394,25 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_attribute(struct jsonpr_ctx *ctx, const struct lyd_node_opaq *node, const struct lys_module *wdmod)
+json_print_attribute(struct jsonpr_ctx *pctx, const struct lyd_node_opaq *node, const struct lys_module *wdmod)
{
struct lyd_attr *attr;
if (wdmod) {
- ly_print_(ctx->out, "%*s\"%s:default\":\"true\"", INDENT, wdmod->name);
+ ly_print_(pctx->out, "%*s\"%s:default\":\"true\"", INDENT, wdmod->name);
LEVEL_PRINTED;
}
for (attr = node->attr; attr; attr = attr->next) {
PRINT_COMMA;
- json_print_member2(ctx, &node->node, attr->format, &attr->name, 0);
+ json_print_member2(pctx, &node->node, attr->format, &attr->name, 0);
if (attr->hints & (LYD_VALHINT_BOOLEAN | LYD_VALHINT_DECNUM)) {
- ly_print_(ctx->out, "%s", attr->value[0] ? attr->value : "null");
+ ly_print_(pctx->out, "%s", attr->value[0] ? attr->value : "null");
} else if (attr->hints & LYD_VALHINT_EMPTY) {
- ly_print_(ctx->out, "[null]");
+ ly_print_(pctx->out, "[null]");
} else {
- json_print_string(ctx->out, attr->value);
+ json_print_string(pctx->out, attr->value);
}
LEVEL_PRINTED;
}
@@ -429,19 +429,19 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_metadata(struct jsonpr_ctx *ctx, const struct lyd_node *node, const struct lys_module *wdmod)
+json_print_metadata(struct jsonpr_ctx *pctx, const struct lyd_node *node, const struct lys_module *wdmod)
{
struct lyd_meta *meta;
if (wdmod) {
- ly_print_(ctx->out, "%*s\"%s:default\":\"true\"", INDENT, wdmod->name);
+ ly_print_(pctx->out, "%*s\"%s:default\":\"true\"", INDENT, wdmod->name);
LEVEL_PRINTED;
}
for (meta = node->meta; meta; meta = meta->next) {
PRINT_COMMA;
- ly_print_(ctx->out, "%*s\"%s:%s\":%s", INDENT, meta->annotation->module->name, meta->name, DO_FORMAT ? " " : "");
- LY_CHECK_RET(json_print_value(ctx, &meta->value));
+ ly_print_(pctx->out, "%*s\"%s:%s\":%s", INDENT, meta->annotation->module->name, meta->name, DO_FORMAT ? " " : "");
+ LY_CHECK_RET(json_print_value(pctx, LYD_CTX(node), &meta->value));
LEVEL_PRINTED;
}
@@ -457,11 +457,11 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_attributes(struct jsonpr_ctx *ctx, const struct lyd_node *node, ly_bool inner)
+json_print_attributes(struct jsonpr_ctx *pctx, const struct lyd_node *node, ly_bool inner)
{
const struct lys_module *wdmod = NULL;
- if ((node->flags & LYD_DEFAULT) && (ctx->options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) {
+ if ((node->flags & LYD_DEFAULT) && (pctx->options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) {
/* we have implicit OR explicit default node */
/* get with-defaults module */
wdmod = ly_ctx_get_module_implemented(LYD_CTX(node), "ietf-netconf-with-defaults");
@@ -469,28 +469,28 @@
if (node->schema && node->meta) {
if (inner) {
- LY_CHECK_RET(json_print_member2(ctx, NULL, LY_VALUE_JSON, NULL, 1));
+ LY_CHECK_RET(json_print_member2(pctx, NULL, LY_VALUE_JSON, NULL, 1));
} else {
- LY_CHECK_RET(json_print_member(ctx, node, 1));
+ LY_CHECK_RET(json_print_member(pctx, node, 1));
}
- ly_print_(ctx->out, "{%s", (DO_FORMAT ? "\n" : ""));
+ ly_print_(pctx->out, "{%s", (DO_FORMAT ? "\n" : ""));
LEVEL_INC;
- LY_CHECK_RET(json_print_metadata(ctx, node, wdmod));
+ LY_CHECK_RET(json_print_metadata(pctx, node, wdmod));
LEVEL_DEC;
- ly_print_(ctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
LEVEL_PRINTED;
} else if (!node->schema && ((struct lyd_node_opaq *)node)->attr) {
if (inner) {
- LY_CHECK_RET(json_print_member2(ctx, NULL, LY_VALUE_JSON, NULL, 1));
+ LY_CHECK_RET(json_print_member2(pctx, NULL, LY_VALUE_JSON, NULL, 1));
} else {
- LY_CHECK_RET(json_print_member2(ctx, node, ((struct lyd_node_opaq *)node)->format,
+ LY_CHECK_RET(json_print_member2(pctx, node, ((struct lyd_node_opaq *)node)->format,
&((struct lyd_node_opaq *)node)->name, 1));
}
- ly_print_(ctx->out, "{%s", (DO_FORMAT ? "\n" : ""));
+ ly_print_(pctx->out, "{%s", (DO_FORMAT ? "\n" : ""));
LEVEL_INC;
- LY_CHECK_RET(json_print_attribute(ctx, (struct lyd_node_opaq *)node, wdmod));
+ LY_CHECK_RET(json_print_attribute(pctx, (struct lyd_node_opaq *)node, wdmod));
LEVEL_DEC;
- ly_print_(ctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
LEVEL_PRINTED;
}
@@ -505,14 +505,14 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_leaf(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_leaf(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- LY_CHECK_RET(json_print_member(ctx, node, 0));
- LY_CHECK_RET(json_print_value(ctx, &((const struct lyd_node_term *)node)->value));
+ LY_CHECK_RET(json_print_member(pctx, node, 0));
+ LY_CHECK_RET(json_print_value(pctx, LYD_CTX(node), &((const struct lyd_node_term *)node)->value));
LEVEL_PRINTED;
/* print attributes as sibling */
- json_print_attributes(ctx, node, 0);
+ json_print_attributes(pctx, node, 0);
return LY_SUCCESS;
}
@@ -525,7 +525,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_any_content(struct jsonpr_ctx *ctx, struct lyd_node_any *any)
+json_print_any_content(struct jsonpr_ctx *pctx, struct lyd_node_any *any)
{
LY_ERR ret = LY_SUCCESS;
struct lyd_node *iter;
@@ -537,7 +537,7 @@
if (!any->value.tree) {
/* no content */
if (any->schema->nodetype == LYS_ANYXML) {
- ly_print_(ctx->out, "null");
+ ly_print_(pctx->out, "null");
}
return LY_SUCCESS;
}
@@ -549,7 +549,7 @@
prev_lo = ly_log_options(0);
/* try to parse it into a data tree */
- if (lyd_parse_data_mem(ctx->ctx, any->value.mem, LYD_LYB, parser_options, 0, &iter) == LY_SUCCESS) {
+ if (lyd_parse_data_mem(pctx->ctx, any->value.mem, LYD_LYB, parser_options, 0, &iter) == LY_SUCCESS) {
/* successfully parsed */
free(any->value.mem);
any->value.tree = iter;
@@ -564,46 +564,46 @@
case LYD_ANYDATA_DATATREE:
if (any->schema->nodetype == LYS_ANYXML) {
/* print always as a string */
- ly_print_(ctx->out, "\"%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "\"%s", DO_FORMAT ? "\n" : "");
}
/* close opening tag and print data */
- prev_opts = ctx->options;
- ctx->options &= ~LYD_PRINT_WITHSIBLINGS;
+ prev_opts = pctx->options;
+ pctx->options &= ~LYD_PRINT_WITHSIBLINGS;
LY_LIST_FOR(any->value.tree, iter) {
- ret = json_print_node(ctx, iter);
+ ret = json_print_node(pctx, iter);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
}
- ctx->options = prev_opts;
+ pctx->options = prev_opts;
if (any->schema->nodetype == LYS_ANYXML) {
/* terminate the string */
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
}
break;
case LYD_ANYDATA_JSON:
/* print without escaping special characters */
if (any->schema->nodetype == LYS_ANYXML) {
/* print as a string */
- ly_print_(ctx->out, "\"%s\"", any->value.str);
+ ly_print_(pctx->out, "\"%s\"", any->value.str);
} else if (any->value.str[0]) {
/* print with indent */
- ly_print_(ctx->out, "%*s%s", INDENT, any->value.str);
+ ly_print_(pctx->out, "%*s%s", INDENT, any->value.str);
}
break;
case LYD_ANYDATA_STRING:
case LYD_ANYDATA_XML:
if (any->schema->nodetype == LYS_ANYXML) {
/* print as a string */
- ly_print_(ctx->out, "\"%s\"", any->value.str);
+ ly_print_(pctx->out, "\"%s\"", any->value.str);
break;
}
/* fallthrough */
case LYD_ANYDATA_LYB:
/* JSON and LYB format is not supported */
- LOGWRN(ctx->ctx, "Unable to print anydata content (type %d) as XML.", any->value_type);
+ LOGWRN(pctx->ctx, "Unable to print anydata content (type %d) as XML.", any->value_type);
break;
}
@@ -619,13 +619,13 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_inner(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_inner(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
struct lyd_node *child;
ly_bool has_content = 0;
LY_LIST_FOR(lyd_child(node), child) {
- if (ly_should_print(child, ctx->options)) {
+ if (ly_should_print(child, pctx->options)) {
break;
}
}
@@ -637,31 +637,31 @@
if ((node->schema && (node->schema->nodetype == LYS_LIST)) ||
(!node->schema && (((struct lyd_node_opaq *)node)->hints & LYD_NODEHINT_LIST))) {
- ly_print_(ctx->out, "%s%*s{%s", (is_open_array(ctx, node) && ctx->level_printed >= ctx->level) ?
+ ly_print_(pctx->out, "%s%*s{%s", (is_open_array(pctx, node) && (pctx->level_printed >= pctx->level)) ?
(DO_FORMAT ? ",\n" : ",") : "", INDENT, (DO_FORMAT && has_content) ? "\n" : "");
} else {
- ly_print_(ctx->out, "%s{%s", (is_open_array(ctx, node) && ctx->level_printed >= ctx->level) ? "," : "",
+ ly_print_(pctx->out, "%s{%s", (is_open_array(pctx, node) && (pctx->level_printed >= pctx->level)) ? "," : "",
(DO_FORMAT && has_content) ? "\n" : "");
}
LEVEL_INC;
- json_print_attributes(ctx, node, 1);
+ json_print_attributes(pctx, node, 1);
if (!node->schema || !(node->schema->nodetype & LYS_ANYDATA)) {
/* print children */
LY_LIST_FOR(lyd_child(node), child) {
- LY_CHECK_RET(json_print_node(ctx, child));
+ LY_CHECK_RET(json_print_node(pctx, child));
}
} else {
/* anydata */
- json_print_any_content(ctx, (struct lyd_node_any *)node);
+ json_print_any_content(pctx, (struct lyd_node_any *)node);
}
LEVEL_DEC;
if (DO_FORMAT && has_content) {
- ly_print_(ctx->out, "\n%*s}", INDENT);
+ ly_print_(pctx->out, "\n%*s}", INDENT);
} else {
- ly_print_(ctx->out, "}");
+ ly_print_(pctx->out, "}");
}
LEVEL_PRINTED;
@@ -676,10 +676,10 @@
* @return LY_ERR value.
*/
static int
-json_print_container(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_container(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- LY_CHECK_RET(json_print_member(ctx, node, 0));
- LY_CHECK_RET(json_print_inner(ctx, node));
+ LY_CHECK_RET(json_print_member(pctx, node, 0));
+ LY_CHECK_RET(json_print_inner(pctx, node));
return LY_SUCCESS;
}
@@ -692,14 +692,14 @@
* @return LY_ERR value.
*/
static int
-json_print_anyxml(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_anyxml(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- LY_CHECK_RET(json_print_member(ctx, node, 0));
- LY_CHECK_RET(json_print_any_content(ctx, (struct lyd_node_any *)node));
+ LY_CHECK_RET(json_print_member(pctx, node, 0));
+ LY_CHECK_RET(json_print_any_content(pctx, (struct lyd_node_any *)node));
LEVEL_PRINTED;
/* print attributes as sibling */
- json_print_attributes(ctx, node, 0);
+ json_print_attributes(pctx, node, 0);
return LY_SUCCESS;
}
@@ -712,14 +712,14 @@
* @return Whether it is the last printed instance or not.
*/
static ly_bool
-json_print_array_is_last_inst(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_array_is_last_inst(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- if (!is_open_array(ctx, node)) {
+ if (!is_open_array(pctx, node)) {
/* no array open */
return 0;
}
- if ((ctx->root == node) && !(ctx->options & LYD_PRINT_WITHSIBLINGS)) {
+ if ((pctx->root == node) && !(pctx->options & LYD_PRINT_WITHSIBLINGS)) {
/* the only printed instance */
return 1;
}
@@ -744,38 +744,38 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_leaf_list(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_leaf_list(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- if (!is_open_array(ctx, node)) {
- LY_CHECK_RET(json_print_member(ctx, node, 0));
- LY_CHECK_RET(json_print_array_open(ctx, node));
+ if (!is_open_array(pctx, node)) {
+ LY_CHECK_RET(json_print_member(pctx, node, 0));
+ LY_CHECK_RET(json_print_array_open(pctx, node));
if (node->schema->nodetype == LYS_LEAFLIST) {
- ly_print_(ctx->out, "%*s", INDENT);
+ ly_print_(pctx->out, "%*s", INDENT);
}
} else if (node->schema->nodetype == LYS_LEAFLIST) {
- ly_print_(ctx->out, ",%s%*s", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, ",%s%*s", DO_FORMAT ? "\n" : "", INDENT);
}
if (node->schema->nodetype == LYS_LIST) {
if (!lyd_child(node)) {
/* empty, e.g. in case of filter */
- ly_print_(ctx->out, "%s%snull", (ctx->level_printed >= ctx->level) ? "," : "", DO_FORMAT ? " " : "");
+ ly_print_(pctx->out, "%s%snull", (pctx->level_printed >= pctx->level) ? "," : "", DO_FORMAT ? " " : "");
LEVEL_PRINTED;
} else {
/* print list's content */
- LY_CHECK_RET(json_print_inner(ctx, node));
+ LY_CHECK_RET(json_print_inner(pctx, node));
}
} else {
assert(node->schema->nodetype == LYS_LEAFLIST);
- LY_CHECK_RET(json_print_value(ctx, &((const struct lyd_node_term *)node)->value));
+ LY_CHECK_RET(json_print_value(pctx, LYD_CTX(node), &((const struct lyd_node_term *)node)->value));
- if (node->meta && !ctx->print_sibling_metadata) {
- ctx->print_sibling_metadata = node;
+ if (node->meta && !pctx->print_sibling_metadata) {
+ pctx->print_sibling_metadata = node;
}
}
- if (json_print_array_is_last_inst(ctx, node)) {
- json_print_array_close(ctx);
+ if (json_print_array_is_last_inst(pctx, node)) {
+ json_print_array_close(pctx);
}
return LY_SUCCESS;
@@ -789,33 +789,33 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_metadata_leaflist(struct jsonpr_ctx *ctx)
+json_print_metadata_leaflist(struct jsonpr_ctx *pctx)
{
const struct lyd_node *prev, *node, *iter;
- if (!ctx->print_sibling_metadata) {
+ if (!pctx->print_sibling_metadata) {
return LY_SUCCESS;
}
- for (node = ctx->print_sibling_metadata, prev = ctx->print_sibling_metadata->prev;
+ for (node = pctx->print_sibling_metadata, prev = pctx->print_sibling_metadata->prev;
prev->next && matching_node(node, prev);
node = prev, prev = node->prev) {}
/* node is the first instance of the leaf-list */
- LY_CHECK_RET(json_print_member(ctx, node, 1));
- ly_print_(ctx->out, "[%s", (DO_FORMAT ? "\n" : ""));
+ LY_CHECK_RET(json_print_member(pctx, node, 1));
+ ly_print_(pctx->out, "[%s", (DO_FORMAT ? "\n" : ""));
LEVEL_INC;
LY_LIST_FOR(node, iter) {
PRINT_COMMA;
if (iter->meta) {
- ly_print_(ctx->out, "%*s%s", INDENT, DO_FORMAT ? "{\n" : "{");
+ ly_print_(pctx->out, "%*s%s", INDENT, DO_FORMAT ? "{\n" : "{");
LEVEL_INC;
- LY_CHECK_RET(json_print_metadata(ctx, iter, NULL));
+ LY_CHECK_RET(json_print_metadata(pctx, iter, NULL));
LEVEL_DEC;
- ly_print_(ctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, "%s%*s}", DO_FORMAT ? "\n" : "", INDENT);
} else {
- ly_print_(ctx->out, "null");
+ ly_print_(pctx->out, "null");
}
LEVEL_PRINTED;
if (!matching_node(iter, iter->next)) {
@@ -823,7 +823,7 @@
}
}
LEVEL_DEC;
- ly_print_(ctx->out, "%s%*s]", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, "%s%*s]", DO_FORMAT ? "\n" : "", INDENT);
LEVEL_PRINTED;
return LY_SUCCESS;
@@ -837,7 +837,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_opaq(struct jsonpr_ctx *ctx, const struct lyd_node_opaq *node)
+json_print_opaq(struct jsonpr_ctx *pctx, const struct lyd_node_opaq *node)
{
ly_bool first = 1, last = 1;
@@ -851,37 +851,37 @@
}
if (first) {
- LY_CHECK_RET(json_print_member2(ctx, lyd_parent(&node->node), node->format, &node->name, 0));
+ LY_CHECK_RET(json_print_member2(pctx, lyd_parent(&node->node), node->format, &node->name, 0));
if (node->hints & (LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST)) {
- LY_CHECK_RET(json_print_array_open(ctx, &node->node));
+ LY_CHECK_RET(json_print_array_open(pctx, &node->node));
}
if (node->hints & LYD_NODEHINT_LEAFLIST) {
- ly_print_(ctx->out, "%*s", INDENT);
+ ly_print_(pctx->out, "%*s", INDENT);
}
} else if (node->hints & LYD_NODEHINT_LEAFLIST) {
- ly_print_(ctx->out, ",%s%*s", DO_FORMAT ? "\n" : "", INDENT);
+ ly_print_(pctx->out, ",%s%*s", DO_FORMAT ? "\n" : "", INDENT);
}
if (node->child || (node->hints & LYD_NODEHINT_LIST)) {
- LY_CHECK_RET(json_print_inner(ctx, &node->node));
+ LY_CHECK_RET(json_print_inner(pctx, &node->node));
LEVEL_PRINTED;
} else {
if (node->hints & LYD_VALHINT_EMPTY) {
- ly_print_(ctx->out, "[null]");
+ ly_print_(pctx->out, "[null]");
} else if (node->hints & (LYD_VALHINT_BOOLEAN | LYD_VALHINT_DECNUM)) {
- ly_print_(ctx->out, "%s", node->value);
+ ly_print_(pctx->out, "%s", node->value);
} else {
/* string */
- ly_print_(ctx->out, "\"%s\"", node->value);
+ ly_print_(pctx->out, "\"%s\"", node->value);
}
LEVEL_PRINTED;
/* attributes */
- json_print_attributes(ctx, (const struct lyd_node *)node, 0);
+ json_print_attributes(pctx, (const struct lyd_node *)node, 0);
}
if (last && (node->hints & (LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST))) {
- json_print_array_close(ctx);
+ json_print_array_close(pctx);
LEVEL_PRINTED;
}
@@ -896,17 +896,17 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_node(struct jsonpr_ctx *ctx, const struct lyd_node *node)
+json_print_node(struct jsonpr_ctx *pctx, const struct lyd_node *node)
{
- if (!ly_should_print(node, ctx->options)) {
- if (json_print_array_is_last_inst(ctx, node)) {
- json_print_array_close(ctx);
+ if (!ly_should_print(node, pctx->options)) {
+ if (json_print_array_is_last_inst(pctx, node)) {
+ json_print_array_close(pctx);
}
return LY_SUCCESS;
}
if (!node->schema) {
- LY_CHECK_RET(json_print_opaq(ctx, (const struct lyd_node_opaq *)node));
+ LY_CHECK_RET(json_print_opaq(pctx, (const struct lyd_node_opaq *)node));
} else {
switch (node->schema->nodetype) {
case LYS_RPC:
@@ -914,29 +914,29 @@
case LYS_NOTIF:
case LYS_ANYDATA:
case LYS_CONTAINER:
- LY_CHECK_RET(json_print_container(ctx, node));
+ LY_CHECK_RET(json_print_container(pctx, node));
break;
case LYS_LEAF:
- LY_CHECK_RET(json_print_leaf(ctx, node));
+ LY_CHECK_RET(json_print_leaf(pctx, node));
break;
case LYS_LEAFLIST:
case LYS_LIST:
- LY_CHECK_RET(json_print_leaf_list(ctx, node));
+ LY_CHECK_RET(json_print_leaf_list(pctx, node));
break;
case LYS_ANYXML:
- LY_CHECK_RET(json_print_anyxml(ctx, node));
+ LY_CHECK_RET(json_print_anyxml(pctx, node));
break;
default:
- LOGINT(node->schema->module->ctx);
+ LOGINT(pctx->ctx);
return EXIT_FAILURE;
}
}
- ctx->level_printed = ctx->level;
+ pctx->level_printed = pctx->level;
- if (ctx->print_sibling_metadata && !matching_node(node->next, ctx->print_sibling_metadata)) {
- json_print_metadata_leaflist(ctx);
- ctx->print_sibling_metadata = NULL;
+ if (pctx->print_sibling_metadata && !matching_node(node->next, pctx->print_sibling_metadata)) {
+ json_print_metadata_leaflist(pctx);
+ pctx->print_sibling_metadata = NULL;
}
return LY_SUCCESS;
@@ -946,7 +946,7 @@
json_print_data(struct ly_out *out, const struct lyd_node *root, uint32_t options)
{
const struct lyd_node *node;
- struct jsonpr_ctx ctx = {0};
+ struct jsonpr_ctx pctx = {0};
const char *delimiter = (options & LYD_PRINT_SHRINK) ? "" : "\n";
if (!root) {
@@ -955,19 +955,19 @@
return LY_SUCCESS;
}
- ctx.out = out;
- ctx.level = 1;
- ctx.level_printed = 0;
- ctx.options = options;
- ctx.ctx = LYD_CTX(root);
+ pctx.out = out;
+ pctx.level = 1;
+ pctx.level_printed = 0;
+ pctx.options = options;
+ pctx.ctx = LYD_CTX(root);
/* start */
- ly_print_(ctx.out, "{%s", delimiter);
+ ly_print_(pctx.out, "{%s", delimiter);
/* content */
LY_LIST_FOR(root, node) {
- ctx.root = node;
- LY_CHECK_RET(json_print_node(&ctx, node));
+ pctx.root = node;
+ LY_CHECK_RET(json_print_node(&pctx, node));
if (!(options & LYD_PRINT_WITHSIBLINGS)) {
break;
}
@@ -976,8 +976,8 @@
/* end */
ly_print_(out, "%s}%s", delimiter, delimiter);
- assert(!ctx.open.count);
- ly_set_erase(&ctx.open, NULL);
+ assert(!pctx.open.count);
+ ly_set_erase(&pctx.open, NULL);
ly_print_flush(out);
return LY_SUCCESS;
diff --git a/src/printer_xml.c b/src/printer_xml.c
index fc1d9b2..5c17aa8 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -59,69 +59,69 @@
* @return Printed prefix of the namespace to use.
*/
static const char *
-xml_print_ns(struct xmlpr_ctx *ctx, const char *ns, const char *new_prefix, uint32_t prefix_opts)
+xml_print_ns(struct xmlpr_ctx *pctx, const char *ns, const char *new_prefix, uint32_t prefix_opts)
{
uint32_t i;
- for (i = ctx->ns.count; i > 0; --i) {
+ for (i = pctx->ns.count; i > 0; --i) {
if (!new_prefix) {
/* find default namespace */
- if (!ctx->prefix.objs[i - 1]) {
- if (!strcmp(ctx->ns.objs[i - 1], ns)) {
+ if (!pctx->prefix.objs[i - 1]) {
+ if (!strcmp(pctx->ns.objs[i - 1], ns)) {
/* matching default namespace */
- return ctx->prefix.objs[i - 1];
+ return pctx->prefix.objs[i - 1];
}
/* not matching default namespace */
break;
}
} else {
/* find prefixed namespace */
- if (!strcmp(ctx->ns.objs[i - 1], ns)) {
- if (!ctx->prefix.objs[i - 1]) {
+ if (!strcmp(pctx->ns.objs[i - 1], ns)) {
+ if (!pctx->prefix.objs[i - 1]) {
/* default namespace is not interesting */
continue;
}
- if (!strcmp(ctx->prefix.objs[i - 1], new_prefix) || !(prefix_opts & LYXML_PREFIX_REQUIRED)) {
+ if (!strcmp(pctx->prefix.objs[i - 1], new_prefix) || !(prefix_opts & LYXML_PREFIX_REQUIRED)) {
/* the same prefix or can be any */
- return ctx->prefix.objs[i - 1];
+ return pctx->prefix.objs[i - 1];
}
}
}
}
/* suitable namespace not found, must be printed */
- ly_print_(ctx->out, " xmlns%s%s=\"%s\"", new_prefix ? ":" : "", new_prefix ? new_prefix : "", ns);
+ ly_print_(pctx->out, " xmlns%s%s=\"%s\"", new_prefix ? ":" : "", new_prefix ? new_prefix : "", ns);
/* and added into namespaces */
if (new_prefix) {
- LY_CHECK_RET(lydict_insert(ctx->ctx, new_prefix, 0, &new_prefix), NULL);
+ LY_CHECK_RET(lydict_insert(pctx->ctx, new_prefix, 0, &new_prefix), NULL);
}
- LY_CHECK_RET(ly_set_add(&ctx->prefix, (void *)new_prefix, 1, NULL), NULL);
- LY_CHECK_RET(ly_set_add(&ctx->ns, (void *)ns, 1, &i), NULL);
+ LY_CHECK_RET(ly_set_add(&pctx->prefix, (void *)new_prefix, 1, NULL), NULL);
+ LY_CHECK_RET(ly_set_add(&pctx->ns, (void *)ns, 1, &i), NULL);
/* return it */
- return ctx->prefix.objs[i];
+ return pctx->prefix.objs[i];
}
static const char *
-xml_print_ns_opaq(struct xmlpr_ctx *ctx, LY_VALUE_FORMAT format, const struct ly_opaq_name *name, uint32_t prefix_opts)
+xml_print_ns_opaq(struct xmlpr_ctx *pctx, LY_VALUE_FORMAT format, const struct ly_opaq_name *name, uint32_t prefix_opts)
{
switch (format) {
case LY_VALUE_XML:
- return xml_print_ns(ctx, name->module_ns, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : name->prefix, prefix_opts);
+ return xml_print_ns(pctx, name->module_ns, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : name->prefix, prefix_opts);
break;
case LY_VALUE_JSON:
if (name->module_name) {
- const struct lys_module *mod = ly_ctx_get_module_latest(ctx->ctx, name->module_name);
+ const struct lys_module *mod = ly_ctx_get_module_latest(pctx->ctx, name->module_name);
if (mod) {
- return xml_print_ns(ctx, mod->ns, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : name->prefix, prefix_opts);
+ return xml_print_ns(pctx, mod->ns, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : name->prefix, prefix_opts);
}
}
break;
default:
/* cannot be created */
- LOGINT(ctx->ctx);
+ LOGINT(pctx->ctx);
}
return NULL;
@@ -137,7 +137,7 @@
* @return LY_ERR value.
*/
static void
-xml_print_ns_prefix_data(struct xmlpr_ctx *ctx, LY_VALUE_FORMAT format, void *prefix_data, uint32_t prefix_opts)
+xml_print_ns_prefix_data(struct xmlpr_ctx *pctx, LY_VALUE_FORMAT format, void *prefix_data, uint32_t prefix_opts)
{
const struct ly_set *set;
const struct lyxml_ns *ns;
@@ -148,12 +148,12 @@
set = prefix_data;
for (i = 0; i < set->count; ++i) {
ns = set->objs[i];
- xml_print_ns(ctx, ns->uri, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : ns->prefix, prefix_opts);
+ xml_print_ns(pctx, ns->uri, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : ns->prefix, prefix_opts);
}
break;
default:
/* cannot be created */
- LOGINT(ctx->ctx);
+ LOGINT(pctx->ctx);
}
}
@@ -161,7 +161,7 @@
* TODO
*/
static void
-xml_print_meta(struct xmlpr_ctx *ctx, const struct lyd_node *node)
+xml_print_meta(struct xmlpr_ctx *pctx, const struct lyd_node *node)
{
struct lyd_meta *meta;
const struct lys_module *mod;
@@ -171,12 +171,12 @@
/* with-defaults */
if (node->schema->nodetype & LYD_NODE_TERM) {
- if (((node->flags & LYD_DEFAULT) && (ctx->options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) ||
- ((ctx->options & LYD_PRINT_WD_ALL_TAG) && lyd_is_default(node))) {
+ if (((node->flags & LYD_DEFAULT) && (pctx->options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) ||
+ ((pctx->options & LYD_PRINT_WD_ALL_TAG) && lyd_is_default(node))) {
/* we have implicit OR explicit default node, print attribute only if context include with-defaults schema */
mod = ly_ctx_get_module_latest(LYD_CTX(node), "ietf-netconf-with-defaults");
if (mod) {
- ly_print_(ctx->out, " %s:default=\"true\"", xml_print_ns(ctx, mod->ns, mod->prefix, 0));
+ ly_print_(pctx->out, " %s:default=\"true\"", xml_print_ns(pctx, mod->ns, mod->prefix, 0));
}
}
}
@@ -197,7 +197,7 @@
/* print namespaces connected with the value's prefixes */
for (uint32_t i = 0; i < ns_list.count; ++i) {
mod = ns_list.objs[i];
- xml_print_ns(ctx, mod->ns, mod->prefix, 1);
+ xml_print_ns(pctx, mod->ns, mod->prefix, 1);
}
ly_set_erase(&ns_list, NULL);
@@ -205,17 +205,17 @@
if (filter_attrs && !strcmp(mod->name, "ietf-netconf") && (!strcmp(meta->name, "type") ||
!strcmp(meta->name, "select"))) {
/* print special NETCONF filter unqualified attributes */
- ly_print_(ctx->out, " %s=\"", meta->name);
+ ly_print_(pctx->out, " %s=\"", meta->name);
} else {
/* print the metadata with its namespace */
- ly_print_(ctx->out, " %s:%s=\"", xml_print_ns(ctx, mod->ns, mod->prefix, 1), meta->name);
+ ly_print_(pctx->out, " %s:%s=\"", xml_print_ns(pctx, mod->ns, mod->prefix, 1), meta->name);
}
/* print metadata value */
if (value && value[0]) {
- lyxml_dump_text(ctx->out, value, 1);
+ lyxml_dump_text(pctx->out, value, 1);
}
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
if (dynamic) {
free((void *)value);
}
@@ -231,20 +231,20 @@
* @param[in] node Data node to be printed.
*/
static void
-xml_print_node_open(struct xmlpr_ctx *ctx, const struct lyd_node *node)
+xml_print_node_open(struct xmlpr_ctx *pctx, const struct lyd_node *node)
{
/* print node name */
- ly_print_(ctx->out, "%*s<%s", INDENT, node->schema->name);
+ ly_print_(pctx->out, "%*s<%s", INDENT, node->schema->name);
/* print default namespace */
- xml_print_ns(ctx, node->schema->module->ns, NULL, 0);
+ xml_print_ns(pctx, node->schema->module->ns, NULL, 0);
/* print metadata */
- xml_print_meta(ctx, node);
+ xml_print_meta(pctx, node);
}
static LY_ERR
-xml_print_attr(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
+xml_print_attr(struct xmlpr_ctx *pctx, const struct lyd_node_opaq *node)
{
const struct lyd_attr *attr;
const char *pref;
@@ -253,18 +253,18 @@
pref = NULL;
if (attr->name.prefix) {
/* print attribute namespace */
- pref = xml_print_ns_opaq(ctx, attr->format, &attr->name, 0);
+ pref = xml_print_ns_opaq(pctx, attr->format, &attr->name, 0);
}
/* print namespaces connected with the value's prefixes */
if (attr->val_prefix_data) {
- xml_print_ns_prefix_data(ctx, attr->format, attr->val_prefix_data, LYXML_PREFIX_REQUIRED);
+ xml_print_ns_prefix_data(pctx, attr->format, attr->val_prefix_data, LYXML_PREFIX_REQUIRED);
}
/* print the attribute with its prefix and value */
- ly_print_(ctx->out, " %s%s%s=\"", pref ? pref : "", pref ? ":" : "", attr->name.name);
- lyxml_dump_text(ctx->out, attr->value, 1);
- ly_print_(ctx->out, "\""); /* print attribute value terminator */
+ ly_print_(pctx->out, " %s%s%s=\"", pref ? pref : "", pref ? ":" : "", attr->name.name);
+ lyxml_dump_text(pctx->out, attr->value, 1);
+ ly_print_(pctx->out, "\""); /* print attribute value terminator */
}
@@ -272,21 +272,21 @@
}
static LY_ERR
-xml_print_opaq_open(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
+xml_print_opaq_open(struct xmlpr_ctx *pctx, const struct lyd_node_opaq *node)
{
/* print node name */
- ly_print_(ctx->out, "%*s<%s", INDENT, node->name.name);
+ ly_print_(pctx->out, "%*s<%s", INDENT, node->name.name);
/* print default namespace */
- xml_print_ns_opaq(ctx, node->format, &node->name, LYXML_PREFIX_DEFAULT);
+ xml_print_ns_opaq(pctx, node->format, &node->name, LYXML_PREFIX_DEFAULT);
/* print attributes */
- LY_CHECK_RET(xml_print_attr(ctx, node));
+ LY_CHECK_RET(xml_print_attr(pctx, node));
return LY_SUCCESS;
}
-static LY_ERR xml_print_node(struct xmlpr_ctx *ctx, const struct lyd_node *node);
+static LY_ERR xml_print_node(struct xmlpr_ctx *pctx, const struct lyd_node *node);
/**
* @brief Print XML element representing lyd_node_term.
@@ -296,13 +296,13 @@
* @return LY_ERR value.
*/
static LY_ERR
-xml_print_term(struct xmlpr_ctx *ctx, const struct lyd_node_term *node)
+xml_print_term(struct xmlpr_ctx *pctx, const struct lyd_node_term *node)
{
struct ly_set ns_list = {0};
ly_bool dynamic;
const char *value;
- xml_print_node_open(ctx, &node->node);
+ xml_print_node_open(pctx, &node->node);
value = ((struct lysc_node_leaf *)node->schema)->type->plugin->print(LYD_CTX(node), &node->value, LY_VALUE_XML,
&ns_list, &dynamic, NULL);
LY_CHECK_RET(!value, LY_EINVAL);
@@ -310,16 +310,16 @@
/* print namespaces connected with the values's prefixes */
for (uint32_t u = 0; u < ns_list.count; ++u) {
const struct lys_module *mod = (const struct lys_module *)ns_list.objs[u];
- ly_print_(ctx->out, " xmlns:%s=\"%s\"", mod->prefix, mod->ns);
+ ly_print_(pctx->out, " xmlns:%s=\"%s\"", mod->prefix, mod->ns);
}
ly_set_erase(&ns_list, NULL);
if (!value[0]) {
- ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "/>%s", DO_FORMAT ? "\n" : "");
} else {
- ly_print_(ctx->out, ">");
- lyxml_dump_text(ctx->out, value, 0);
- ly_print_(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, ">");
+ lyxml_dump_text(pctx->out, value, 0);
+ ly_print_(pctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
if (dynamic) {
free((void *)value);
@@ -336,53 +336,53 @@
* @return LY_ERR value.
*/
static LY_ERR
-xml_print_inner(struct xmlpr_ctx *ctx, const struct lyd_node_inner *node)
+xml_print_inner(struct xmlpr_ctx *pctx, const struct lyd_node_inner *node)
{
LY_ERR ret;
struct lyd_node *child;
- xml_print_node_open(ctx, &node->node);
+ xml_print_node_open(pctx, &node->node);
LY_LIST_FOR(node->child, child) {
- if (ly_should_print(child, ctx->options)) {
+ if (ly_should_print(child, pctx->options)) {
break;
}
}
if (!child) {
/* there are no children that will be printed */
- ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
/* children */
- ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, ">%s", DO_FORMAT ? "\n" : "");
LEVEL_INC;
LY_LIST_FOR(node->child, child) {
- ret = xml_print_node(ctx, child);
+ ret = xml_print_node(pctx, child);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
}
LEVEL_DEC;
- ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
static LY_ERR
-xml_print_anydata(struct xmlpr_ctx *ctx, const struct lyd_node_any *node)
+xml_print_anydata(struct xmlpr_ctx *pctx, const struct lyd_node_any *node)
{
struct lyd_node_any *any = (struct lyd_node_any *)node;
struct lyd_node *iter;
uint32_t prev_opts, prev_lo;
LY_ERR ret;
- xml_print_node_open(ctx, &node->node);
+ xml_print_node_open(pctx, &node->node);
if (!any->value.tree) {
/* no content */
no_content:
- ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
} else {
if (any->value_type == LYD_ANYDATA_LYB) {
@@ -404,18 +404,18 @@
switch (any->value_type) {
case LYD_ANYDATA_DATATREE:
/* close opening tag and print data */
- prev_opts = ctx->options;
- ctx->options &= ~LYD_PRINT_WITHSIBLINGS;
+ prev_opts = pctx->options;
+ pctx->options &= ~LYD_PRINT_WITHSIBLINGS;
LEVEL_INC;
- ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, ">%s", DO_FORMAT ? "\n" : "");
LY_LIST_FOR(any->value.tree, iter) {
- ret = xml_print_node(ctx, iter);
+ ret = xml_print_node(pctx, iter);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
}
LEVEL_DEC;
- ctx->options = prev_opts;
+ pctx->options = prev_opts;
break;
case LYD_ANYDATA_STRING:
/* escape XML-sensitive characters */
@@ -423,28 +423,28 @@
goto no_content;
}
/* close opening tag and print data */
- ly_print_(ctx->out, ">");
- lyxml_dump_text(ctx->out, any->value.str, 0);
+ ly_print_(pctx->out, ">");
+ lyxml_dump_text(pctx->out, any->value.str, 0);
break;
case LYD_ANYDATA_XML:
/* print without escaping special characters */
if (!any->value.str[0]) {
goto no_content;
}
- ly_print_(ctx->out, ">%s", any->value.str);
+ ly_print_(pctx->out, ">%s", any->value.str);
break;
case LYD_ANYDATA_JSON:
case LYD_ANYDATA_LYB:
/* JSON and LYB format is not supported */
- LOGWRN(LYD_CTX(node), "Unable to print anydata content (type %d) as XML.", any->value_type);
+ LOGWRN(pctx->ctx, "Unable to print anydata content (type %d) as XML.", any->value_type);
goto no_content;
}
/* closing tag */
if (any->value_type == LYD_ANYDATA_DATATREE) {
- ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
} else {
- ly_print_(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
}
@@ -452,42 +452,42 @@
}
static LY_ERR
-xml_print_opaq(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
+xml_print_opaq(struct xmlpr_ctx *pctx, const struct lyd_node_opaq *node)
{
LY_ERR ret;
struct lyd_node *child;
- LY_CHECK_RET(xml_print_opaq_open(ctx, node));
+ LY_CHECK_RET(xml_print_opaq_open(pctx, node));
if (node->value[0]) {
/* print namespaces connected with the value's prefixes */
if (node->val_prefix_data) {
- xml_print_ns_prefix_data(ctx, node->format, node->val_prefix_data, LYXML_PREFIX_REQUIRED);
+ xml_print_ns_prefix_data(pctx, node->format, node->val_prefix_data, LYXML_PREFIX_REQUIRED);
}
- ly_print_(ctx->out, ">");
- lyxml_dump_text(ctx->out, node->value, 0);
+ ly_print_(pctx->out, ">");
+ lyxml_dump_text(pctx->out, node->value, 0);
}
if (node->child) {
/* children */
if (!node->value[0]) {
- ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, ">%s", DO_FORMAT ? "\n" : "");
}
LEVEL_INC;
LY_LIST_FOR(node->child, child) {
- ret = xml_print_node(ctx, child);
+ ret = xml_print_node(pctx, child);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
}
LEVEL_DEC;
- ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->name.name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "%*s</%s>%s", INDENT, node->name.name, DO_FORMAT ? "\n" : "");
} else if (node->value[0]) {
- ly_print_(ctx->out, "</%s>%s", node->name.name, DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "</%s>%s", node->name.name, DO_FORMAT ? "\n" : "");
} else {
/* no value or children */
- ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(pctx->out, "/>%s", DO_FORMAT ? "\n" : "");
}
return LY_SUCCESS;
@@ -501,21 +501,21 @@
* @return LY_ERR value.
*/
static LY_ERR
-xml_print_node(struct xmlpr_ctx *ctx, const struct lyd_node *node)
+xml_print_node(struct xmlpr_ctx *pctx, const struct lyd_node *node)
{
LY_ERR ret = LY_SUCCESS;
uint32_t ns_count;
- if (!ly_should_print(node, ctx->options)) {
+ if (!ly_should_print(node, pctx->options)) {
/* do not print at all */
return LY_SUCCESS;
}
/* remember namespace definition count on this level */
- ns_count = ctx->ns.count;
+ ns_count = pctx->ns.count;
if (!node->schema) {
- ret = xml_print_opaq(ctx, (const struct lyd_node_opaq *)node);
+ ret = xml_print_opaq(pctx, (const struct lyd_node_opaq *)node);
} else {
switch (node->schema->nodetype) {
case LYS_CONTAINER:
@@ -523,28 +523,28 @@
case LYS_NOTIF:
case LYS_RPC:
case LYS_ACTION:
- ret = xml_print_inner(ctx, (const struct lyd_node_inner *)node);
+ ret = xml_print_inner(pctx, (const struct lyd_node_inner *)node);
break;
case LYS_LEAF:
case LYS_LEAFLIST:
- ret = xml_print_term(ctx, (const struct lyd_node_term *)node);
+ ret = xml_print_term(pctx, (const struct lyd_node_term *)node);
break;
case LYS_ANYXML:
case LYS_ANYDATA:
- ret = xml_print_anydata(ctx, (const struct lyd_node_any *)node);
+ ret = xml_print_anydata(pctx, (const struct lyd_node_any *)node);
break;
default:
- LOGINT(node->schema->module->ctx);
+ LOGINT(pctx->ctx);
ret = LY_EINT;
break;
}
}
/* remove all added namespaces */
- while (ns_count < ctx->ns.count) {
- lydict_remove(ctx->ctx, ctx->prefix.objs[ctx->prefix.count - 1]);
- ly_set_rm_index(&ctx->prefix, ctx->prefix.count - 1, NULL);
- ly_set_rm_index(&ctx->ns, ctx->ns.count - 1, NULL);
+ while (ns_count < pctx->ns.count) {
+ lydict_remove(pctx->ctx, pctx->prefix.objs[pctx->prefix.count - 1]);
+ ly_set_rm_index(&pctx->prefix, pctx->prefix.count - 1, NULL);
+ ly_set_rm_index(&pctx->ns, pctx->ns.count - 1, NULL);
}
return ret;
@@ -554,7 +554,7 @@
xml_print_data(struct ly_out *out, const struct lyd_node *root, uint32_t options)
{
const struct lyd_node *node;
- struct xmlpr_ctx ctx = {0};
+ struct xmlpr_ctx pctx = {0};
if (!root) {
if ((out->type == LY_OUT_MEMORY) || (out->type == LY_OUT_CALLBACK)) {
@@ -563,23 +563,23 @@
goto finish;
}
- ctx.out = out;
- ctx.level = 0;
- ctx.options = options;
- ctx.ctx = LYD_CTX(root);
+ pctx.out = out;
+ pctx.level = 0;
+ pctx.options = options;
+ pctx.ctx = LYD_CTX(root);
/* content */
LY_LIST_FOR(root, node) {
- LY_CHECK_RET(xml_print_node(&ctx, node));
+ LY_CHECK_RET(xml_print_node(&pctx, node));
if (!(options & LYD_PRINT_WITHSIBLINGS)) {
break;
}
}
finish:
- assert(!ctx.prefix.count && !ctx.ns.count);
- ly_set_erase(&ctx.prefix, NULL);
- ly_set_erase(&ctx.ns, NULL);
+ assert(!pctx.prefix.count && !pctx.ns.count);
+ ly_set_erase(&pctx.prefix, NULL);
+ ly_set_erase(&pctx.ns, NULL);
ly_print_flush(out);
return LY_SUCCESS;
}
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 8510faa..e1e4f20 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -47,12 +47,12 @@
#define YPR_CTX_FLAG_EXTRA_LINE 0x01 /**< Flag for ::ypr_ctx::flags to print extra line in schema */
-#define YPR_EXTRA_LINE(COND, CTX) if (COND) { (CTX)->flags |= YPR_CTX_FLAG_EXTRA_LINE; }
-#define YPR_EXTRA_LINE_PRINT(CTX) \
- if ((CTX)->flags & YPR_CTX_FLAG_EXTRA_LINE) { \
- (CTX)->flags &= ~YPR_CTX_FLAG_EXTRA_LINE; \
+#define YPR_EXTRA_LINE(COND, PCTX) if (COND) { (PCTX)->flags |= YPR_CTX_FLAG_EXTRA_LINE; }
+#define YPR_EXTRA_LINE_PRINT(PCTX) \
+ if ((PCTX)->flags & YPR_CTX_FLAG_EXTRA_LINE) { \
+ (PCTX)->flags &= ~YPR_CTX_FLAG_EXTRA_LINE; \
if (DO_FORMAT) { \
- ly_print_((CTX)->out, "\n"); \
+ ly_print_((PCTX)->out, "\n"); \
} \
}
@@ -156,43 +156,43 @@
}
static void
-ypr_close(struct lys_ypr_ctx *ctx, ly_bool flag)
+ypr_close(struct lys_ypr_ctx *pctx, ly_bool flag)
{
if (flag) {
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
} else {
- ly_print_(ctx->out, ";\n");
+ ly_print_(pctx->out, ";\n");
}
}
static void
-ypr_text(struct lys_ypr_ctx *ctx, const char *name, const char *text, ly_bool singleline, ly_bool closed)
+ypr_text(struct lys_ypr_ctx *pctx, const char *name, const char *text, ly_bool singleline, ly_bool closed)
{
const char *s, *t;
if (singleline) {
- ly_print_(ctx->out, "%*s%s \"", INDENT, name);
+ ly_print_(pctx->out, "%*s%s \"", INDENT, name);
} else {
- ly_print_(ctx->out, "%*s%s\n", INDENT, name);
+ ly_print_(pctx->out, "%*s%s\n", INDENT, name);
LEVEL++;
- ly_print_(ctx->out, "%*s\"", INDENT);
+ ly_print_(pctx->out, "%*s\"", INDENT);
}
t = text;
while ((s = strchr(t, '\n'))) {
- ypr_encode(ctx->out, t, s - t);
- ly_print_(ctx->out, "\n");
+ ypr_encode(pctx->out, t, s - t);
+ ly_print_(pctx->out, "\n");
t = s + 1;
if (*t != '\n') {
- ly_print_(ctx->out, "%*s ", INDENT);
+ ly_print_(pctx->out, "%*s ", INDENT);
}
}
- ypr_encode(ctx->out, t, strlen(t));
+ ypr_encode(pctx->out, t, strlen(t));
if (closed) {
- ly_print_(ctx->out, "\";\n");
+ ly_print_(pctx->out, "\";\n");
} else {
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
}
if (!singleline) {
LEVEL--;
@@ -200,42 +200,42 @@
}
static void
-yprp_stmt(struct lys_ypr_ctx *ctx, struct lysp_stmt *stmt)
+yprp_stmt(struct lys_ypr_ctx *pctx, struct lysp_stmt *stmt)
{
struct lysp_stmt *childstmt;
const char *s, *t;
if (stmt->arg) {
if (stmt->flags) {
- ly_print_(ctx->out, "%*s%s\n", INDENT, stmt->stmt);
+ ly_print_(pctx->out, "%*s%s\n", INDENT, stmt->stmt);
LEVEL++;
- ly_print_(ctx->out, "%*s%c", INDENT, (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'');
+ ly_print_(pctx->out, "%*s%c", INDENT, (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'');
t = stmt->arg;
while ((s = strchr(t, '\n'))) {
- ypr_encode(ctx->out, t, s - t);
- ly_print_(ctx->out, "\n");
+ ypr_encode(pctx->out, t, s - t);
+ ly_print_(pctx->out, "\n");
t = s + 1;
if (*t != '\n') {
- ly_print_(ctx->out, "%*s ", INDENT);
+ ly_print_(pctx->out, "%*s ", INDENT);
}
}
LEVEL--;
- ypr_encode(ctx->out, t, strlen(t));
- ly_print_(ctx->out, "%c%s", (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'', stmt->child ? " {\n" : ";\n");
+ ypr_encode(pctx->out, t, strlen(t));
+ ly_print_(pctx->out, "%c%s", (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'', stmt->child ? " {\n" : ";\n");
} else {
- ly_print_(ctx->out, "%*s%s %s%s", INDENT, stmt->stmt, stmt->arg, stmt->child ? " {\n" : ";\n");
+ ly_print_(pctx->out, "%*s%s %s%s", INDENT, stmt->stmt, stmt->arg, stmt->child ? " {\n" : ";\n");
}
} else {
- ly_print_(ctx->out, "%*s%s%s", INDENT, stmt->stmt, stmt->child ? " {\n" : ";\n");
+ ly_print_(pctx->out, "%*s%s%s", INDENT, stmt->stmt, stmt->child ? " {\n" : ";\n");
}
if (stmt->child) {
LEVEL++;
LY_LIST_FOR(stmt->child, childstmt) {
- yprp_stmt(ctx, childstmt);
+ yprp_stmt(pctx, childstmt);
}
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
}
@@ -243,7 +243,7 @@
* @param[in] count Number of extensions to print, 0 to print them all.
*/
static void
-yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,
+yprp_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysp_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)
{
LY_ARRAY_COUNT_TYPE u;
@@ -265,20 +265,20 @@
continue;
}
- lysp_ext_find_definition(ctx->module->ctx, &ext[u], NULL, &ext_def);
+ lysp_ext_find_definition(pctx->module->ctx, &ext[u], NULL, &ext_def);
if (!ext_def) {
continue;
}
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
if (ext_def->argname) {
- ly_print_(ctx->out, "%*s%s \"", INDENT, ext[u].name);
- lysp_ext_instance_resolve_argument(ctx->module->ctx, &ext[u], ext_def);
- ypr_encode(ctx->out, ext[u].argument, -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*s%s \"", INDENT, ext[u].name);
+ lysp_ext_instance_resolve_argument(pctx->module->ctx, &ext[u], ext_def);
+ ypr_encode(pctx->out, ext[u].argument, -1);
+ ly_print_(pctx->out, "\"");
} else {
- ly_print_(ctx->out, "%*s%s", INDENT, ext[u].name);
+ ly_print_(pctx->out, "%*s%s", INDENT, ext[u].name);
}
child_presence = 0;
@@ -288,25 +288,25 @@
continue;
}
if (!child_presence) {
- ly_print_(ctx->out, " {\n");
+ ly_print_(pctx->out, " {\n");
child_presence = 1;
}
- yprp_stmt(ctx, stmt);
+ yprp_stmt(pctx, stmt);
}
LEVEL--;
if (child_presence) {
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
} else {
- ly_print_(ctx->out, ";\n");
+ ly_print_(pctx->out, ";\n");
}
}
}
-static void yprc_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,
+static void yprc_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count);
static void
-ypr_substmt(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)
+ypr_substmt(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool extflag = 0;
@@ -317,9 +317,9 @@
}
if (stmt_attr_info[substmt].flags & STMT_FLAG_ID) {
- ly_print_(ctx->out, "%*s%s %s", INDENT, stmt_attr_info[substmt].name, text);
+ ly_print_(pctx->out, "%*s%s %s", INDENT, stmt_attr_info[substmt].name, text);
} else {
- ypr_text(ctx, stmt_attr_info[substmt].name, text,
+ ypr_text(pctx, stmt_attr_info[substmt].name, text,
(stmt_attr_info[substmt].flags & STMT_FLAG_YIN) ? 0 : 1, 0);
}
@@ -328,252 +328,252 @@
if ((((struct lysp_ext_instance *)ext)[u].parent_stmt != substmt) || (((struct lysp_ext_instance *)ext)[u].parent_stmt_index != substmt_index)) {
continue;
}
- if (ctx->schema == LYS_YPR_PARSED) {
- yprp_extension_instances(ctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
+ if (pctx->schema == LYS_YPR_PARSED) {
+ yprp_extension_instances(pctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
} else {
- yprc_extension_instances(ctx, substmt, substmt_index, &((struct lysc_ext_instance *)ext)[u], &extflag, 1);
+ yprc_extension_instances(pctx, substmt, substmt_index, &((struct lysc_ext_instance *)ext)[u], &extflag, 1);
}
}
LEVEL--;
- ypr_close(ctx, extflag);
+ ypr_close(pctx, extflag);
}
static void
-ypr_unsigned(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)
+ypr_unsigned(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)
{
char *str;
if (asprintf(&str, "%lu", attr_value) == -1) {
- LOGMEM(ctx->module->ctx);
+ LOGMEM(pctx->module->ctx);
return;
}
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, substmt, substmt_index, str, exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, substmt, substmt_index, str, exts);
free(str);
}
static void
-ypr_signed(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)
+ypr_signed(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)
{
char *str;
if (asprintf(&str, "%ld", attr_value) == -1) {
- LOGMEM(ctx->module->ctx);
+ LOGMEM(pctx->module->ctx);
return;
}
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, substmt, substmt_index, str, exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, substmt, substmt_index, str, exts);
free(str);
}
static void
-yprp_revision(struct lys_ypr_ctx *ctx, const struct lysp_revision *rev)
+yprp_revision(struct lys_ypr_ctx *pctx, const struct lysp_revision *rev)
{
if (rev->dsc || rev->ref || rev->exts) {
- ly_print_(ctx->out, "%*srevision %s {\n", INDENT, rev->date);
+ ly_print_(pctx->out, "%*srevision %s {\n", INDENT, rev->date);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
+ yprp_extension_instances(pctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
} else {
- ly_print_(ctx->out, "%*srevision %s;\n", INDENT, rev->date);
+ ly_print_(pctx->out, "%*srevision %s;\n", INDENT, rev->date);
}
}
static void
-ypr_mandatory(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
+ypr_mandatory(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, ly_bool *flag)
{
if (flags & LYS_MAND_MASK) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);
}
}
static void
-ypr_config(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
+ypr_config(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, ly_bool *flag)
{
if (flags & LYS_CONFIG_MASK) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);
}
}
static void
-ypr_status(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
+ypr_status(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, ly_bool *flag)
{
const char *status = NULL;
if (flags & LYS_STATUS_CURR) {
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
status = "current";
} else if (flags & LYS_STATUS_DEPRC) {
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
status = "deprecated";
} else if (flags & LYS_STATUS_OBSLT) {
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
status = "obsolete";
}
- ypr_substmt(ctx, LY_STMT_STATUS, 0, status, exts);
+ ypr_substmt(pctx, LY_STMT_STATUS, 0, status, exts);
}
static void
-ypr_description(struct lys_ypr_ctx *ctx, const char *dsc, void *exts, ly_bool *flag)
+ypr_description(struct lys_ypr_ctx *pctx, const char *dsc, void *exts, ly_bool *flag)
{
if (dsc) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, dsc, exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, dsc, exts);
}
}
static void
-ypr_reference(struct lys_ypr_ctx *ctx, const char *ref, void *exts, ly_bool *flag)
+ypr_reference(struct lys_ypr_ctx *pctx, const char *ref, void *exts, ly_bool *flag)
{
if (ref) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, ref, exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, ref, exts);
}
}
static void
-yprp_iffeatures(struct lys_ypr_ctx *ctx, struct lysp_qname *iffs, struct lysp_ext_instance *exts, ly_bool *flag)
+yprp_iffeatures(struct lys_ypr_ctx *pctx, struct lysp_qname *iffs, struct lysp_ext_instance *exts, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u, v;
ly_bool extflag;
LY_ARRAY_FOR(iffs, u) {
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
extflag = 0;
- ly_print_(ctx->out, "%*sif-feature \"%s\"", INDENT, iffs[u].str);
+ ly_print_(pctx->out, "%*sif-feature \"%s\"", INDENT, iffs[u].str);
/* extensions */
LEVEL++;
LY_ARRAY_FOR(exts, v) {
- yprp_extension_instances(ctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);
+ yprp_extension_instances(pctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);
}
LEVEL--;
- ypr_close(ctx, extflag);
+ ypr_close(pctx, extflag);
}
}
static void
-yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)
+yprp_extension(struct lys_ypr_ctx *pctx, const struct lysp_ext *ext)
{
ly_bool flag = 0, flag2 = 0;
LY_ARRAY_COUNT_TYPE u;
- ly_print_(ctx->out, "%*sextension %s", INDENT, ext->name);
+ ly_print_(pctx->out, "%*sextension %s", INDENT, ext->name);
LEVEL++;
if (ext->exts) {
- yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
+ yprp_extension_instances(pctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
if (ext->argname) {
- ypr_open(ctx->out, &flag);
- ly_print_(ctx->out, "%*sargument %s", INDENT, ext->argname);
+ ypr_open(pctx->out, &flag);
+ ly_print_(pctx->out, "%*sargument %s", INDENT, ext->argname);
LEVEL++;
if (ext->exts) {
u = -1;
while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LY_STMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {
- yprp_extension_instances(ctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
+ yprp_extension_instances(pctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
}
}
if ((ext->flags & LYS_YINELEM_MASK) ||
(ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LY_STMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {
- ypr_open(ctx->out, &flag2);
- ypr_substmt(ctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
+ ypr_open(pctx->out, &flag2);
+ ypr_substmt(pctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
}
LEVEL--;
- ypr_close(ctx, flag2);
+ ypr_close(pctx, flag2);
}
- ypr_status(ctx, ext->flags, ext->exts, &flag);
- ypr_description(ctx, ext->dsc, ext->exts, &flag);
- ypr_reference(ctx, ext->ref, ext->exts, &flag);
+ ypr_status(pctx, ext->flags, ext->exts, &flag);
+ ypr_description(pctx, ext->dsc, ext->exts, &flag);
+ ypr_reference(pctx, ext->ref, ext->exts, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_feature(struct lys_ypr_ctx *ctx, const struct lysp_feature *feat)
+yprp_feature(struct lys_ypr_ctx *pctx, const struct lysp_feature *feat)
{
ly_bool flag = 0;
- ly_print_(ctx->out, "%*sfeature %s", INDENT, feat->name);
+ ly_print_(pctx->out, "%*sfeature %s", INDENT, feat->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
- yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);
- ypr_status(ctx, feat->flags, feat->exts, &flag);
- ypr_description(ctx, feat->dsc, feat->exts, &flag);
- ypr_reference(ctx, feat->ref, feat->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
+ yprp_iffeatures(pctx, feat->iffeatures, feat->exts, &flag);
+ ypr_status(pctx, feat->flags, feat->exts, &flag);
+ ypr_description(pctx, feat->dsc, feat->exts, &flag);
+ ypr_reference(pctx, feat->ref, feat->exts, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_identity(struct lys_ypr_ctx *ctx, const struct lysp_ident *ident)
+yprp_identity(struct lys_ypr_ctx *pctx, const struct lysp_ident *ident)
{
ly_bool flag = 0;
LY_ARRAY_COUNT_TYPE u;
- ly_print_(ctx->out, "%*sidentity %s", INDENT, ident->name);
+ ly_print_(pctx->out, "%*sidentity %s", INDENT, ident->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
- yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
+ yprp_iffeatures(pctx, ident->iffeatures, ident->exts, &flag);
LY_ARRAY_FOR(ident->bases, u) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);
}
- ypr_status(ctx, ident->flags, ident->exts, &flag);
- ypr_description(ctx, ident->dsc, ident->exts, &flag);
- ypr_reference(ctx, ident->ref, ident->exts, &flag);
+ ypr_status(pctx, ident->flags, ident->exts, &flag);
+ ypr_description(pctx, ident->dsc, ident->exts, &flag);
+ ypr_reference(pctx, ident->ref, ident->exts, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_identity(struct lys_ypr_ctx *ctx, const struct lysc_ident *ident)
+yprc_identity(struct lys_ypr_ctx *pctx, const struct lysc_ident *ident)
{
ly_bool flag = 0;
LY_ARRAY_COUNT_TYPE u;
- ly_print_(ctx->out, "%*sidentity %s", INDENT, ident->name);
+ ly_print_(pctx->out, "%*sidentity %s", INDENT, ident->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
- ypr_open(ctx->out, &flag);
+ ypr_open(pctx->out, &flag);
if (lys_identity_iffeature_value(ident) == LY_ENOT) {
- ly_print_(ctx->out, "%*s/* identity \"%s\" is disabled by if-feature(s) */\n", INDENT, ident->name);
+ ly_print_(pctx->out, "%*s/* identity \"%s\" is disabled by if-feature(s) */\n", INDENT, ident->name);
}
LY_ARRAY_FOR(ident->derived, u) {
- if (ctx->module != ident->derived[u]->module) {
- ly_print_(ctx->out, "%*sderived %s:%s;\n", INDENT, ident->derived[u]->module->prefix, ident->derived[u]->name);
+ if (pctx->module != ident->derived[u]->module) {
+ ly_print_(pctx->out, "%*sderived %s:%s;\n", INDENT, ident->derived[u]->module->prefix, ident->derived[u]->name);
} else {
- ly_print_(ctx->out, "%*sderived %s;\n", INDENT, ident->derived[u]->name);
+ ly_print_(pctx->out, "%*sderived %s;\n", INDENT, ident->derived[u]->name);
}
}
- ypr_status(ctx, ident->flags, ident->exts, &flag);
- ypr_description(ctx, ident->dsc, ident->exts, &flag);
- ypr_reference(ctx, ident->ref, ident->exts, &flag);
+ ypr_status(pctx, ident->flags, ident->exts, &flag);
+ ypr_description(pctx, ident->dsc, ident->exts, &flag);
+ ypr_reference(pctx, ident->ref, ident->exts, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, enum ly_stmt stmt, ly_bool *flag)
+yprp_restr(struct lys_ypr_ctx *pctx, const struct lysp_restr *restr, enum ly_stmt stmt, ly_bool *flag)
{
ly_bool inner_flag = 0;
@@ -581,64 +581,64 @@
return;
}
- ypr_open(ctx->out, flag);
- ly_print_(ctx->out, "%*s%s \"", INDENT, ly_stmt2str(stmt));
- ypr_encode(ctx->out,
+ ypr_open(pctx->out, flag);
+ ly_print_(pctx->out, "%*s%s \"", INDENT, ly_stmt2str(stmt));
+ ypr_encode(pctx->out,
(restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK && restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK) ?
restr->arg.str : &restr->arg.str[1], -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, stmt, 0, restr->exts, &inner_flag, 0);
+ yprp_extension_instances(pctx, stmt, 0, restr->exts, &inner_flag, 0);
if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);
}
if (restr->emsg) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);
}
if (restr->eapptag) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);
}
- ypr_description(ctx, restr->dsc, restr->exts, &inner_flag);
- ypr_reference(ctx, restr->ref, restr->exts, &inner_flag);
+ ypr_description(pctx, restr->dsc, restr->exts, &inner_flag);
+ ypr_reference(pctx, restr->ref, restr->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprc_must(struct lys_ypr_ctx *ctx, const struct lysc_must *must, ly_bool *flag)
+yprc_must(struct lys_ypr_ctx *pctx, const struct lysc_must *must, ly_bool *flag)
{
ly_bool inner_flag = 0;
- ypr_open(ctx->out, flag);
- ly_print_(ctx->out, "%*smust \"", INDENT);
- ypr_encode(ctx->out, must->cond->expr, -1);
- ly_print_(ctx->out, "\"");
+ ypr_open(pctx->out, flag);
+ ly_print_(pctx->out, "%*smust \"", INDENT);
+ ypr_encode(pctx->out, must->cond->expr, -1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_MUST, 0, must->exts, &inner_flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_MUST, 0, must->exts, &inner_flag, 0);
if (must->emsg) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, must->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, must->exts);
}
if (must->eapptag) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, must->eapptag, must->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, must->eapptag, must->exts);
}
- ypr_description(ctx, must->dsc, must->exts, &inner_flag);
- ypr_reference(ctx, must->ref, must->exts, &inner_flag);
+ ypr_description(pctx, must->dsc, must->exts, &inner_flag);
+ ypr_reference(pctx, must->ref, must->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprc_range(struct lys_ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE basetype, ly_bool *flag)
+yprc_range(struct lys_ypr_ctx *pctx, const struct lysc_range *range, LY_DATA_TYPE basetype, ly_bool *flag)
{
ly_bool inner_flag = 0;
LY_ARRAY_COUNT_TYPE u;
@@ -647,227 +647,227 @@
return;
}
- ypr_open(ctx->out, flag);
- ly_print_(ctx->out, "%*s%s \"", INDENT, (basetype == LY_TYPE_STRING || basetype == LY_TYPE_BINARY) ? "length" : "range");
+ ypr_open(pctx->out, flag);
+ ly_print_(pctx->out, "%*s%s \"", INDENT, (basetype == LY_TYPE_STRING || basetype == LY_TYPE_BINARY) ? "length" : "range");
LY_ARRAY_FOR(range->parts, u) {
if (u > 0) {
- ly_print_(ctx->out, " | ");
+ ly_print_(pctx->out, " | ");
}
if (range->parts[u].max_64 == range->parts[u].min_64) {
if (basetype <= LY_TYPE_STRING) { /* unsigned values */
- ly_print_(ctx->out, "%" PRIu64, range->parts[u].max_u64);
+ ly_print_(pctx->out, "%" PRIu64, range->parts[u].max_u64);
} else { /* signed values */
- ly_print_(ctx->out, "%" PRId64, range->parts[u].max_64);
+ ly_print_(pctx->out, "%" PRId64, range->parts[u].max_64);
}
} else {
if (basetype <= LY_TYPE_STRING) { /* unsigned values */
- ly_print_(ctx->out, "%" PRIu64 "..%" PRIu64, range->parts[u].min_u64, range->parts[u].max_u64);
+ ly_print_(pctx->out, "%" PRIu64 "..%" PRIu64, range->parts[u].min_u64, range->parts[u].max_u64);
} else { /* signed values */
- ly_print_(ctx->out, "%" PRId64 "..%" PRId64, range->parts[u].min_64, range->parts[u].max_64);
+ ly_print_(pctx->out, "%" PRId64 "..%" PRId64, range->parts[u].min_64, range->parts[u].max_64);
}
}
}
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_RANGE, 0, range->exts, &inner_flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_RANGE, 0, range->exts, &inner_flag, 0);
if (range->emsg) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, range->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, range->exts);
}
if (range->eapptag) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, range->eapptag, range->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, range->eapptag, range->exts);
}
- ypr_description(ctx, range->dsc, range->exts, &inner_flag);
- ypr_reference(ctx, range->ref, range->exts, &inner_flag);
+ ypr_description(pctx, range->dsc, range->exts, &inner_flag);
+ ypr_reference(pctx, range->ref, range->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprc_pattern(struct lys_ypr_ctx *ctx, const struct lysc_pattern *pattern, ly_bool *flag)
+yprc_pattern(struct lys_ypr_ctx *pctx, const struct lysc_pattern *pattern, ly_bool *flag)
{
ly_bool inner_flag = 0;
- ypr_open(ctx->out, flag);
- ly_print_(ctx->out, "%*spattern \"", INDENT);
- ypr_encode(ctx->out, pattern->expr, -1);
- ly_print_(ctx->out, "\"");
+ ypr_open(pctx->out, flag);
+ ly_print_(pctx->out, "%*spattern \"", INDENT);
+ ypr_encode(pctx->out, pattern->expr, -1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_PATTERN, 0, pattern->exts, &inner_flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_PATTERN, 0, pattern->exts, &inner_flag, 0);
if (pattern->inverted) {
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", pattern->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", pattern->exts);
}
if (pattern->emsg) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, pattern->emsg, pattern->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, pattern->emsg, pattern->exts);
}
if (pattern->eapptag) {
- ypr_open(ctx->out, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, pattern->eapptag, pattern->exts);
+ ypr_open(pctx->out, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, pattern->eapptag, pattern->exts);
}
- ypr_description(ctx, pattern->dsc, pattern->exts, &inner_flag);
- ypr_reference(ctx, pattern->ref, pattern->exts, &inner_flag);
+ ypr_description(pctx, pattern->dsc, pattern->exts, &inner_flag);
+ ypr_reference(pctx, pattern->ref, pattern->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprp_when(struct lys_ypr_ctx *ctx, struct lysp_when *when, ly_bool *flag)
+yprp_when(struct lys_ypr_ctx *pctx, struct lysp_when *when, ly_bool *flag)
{
ly_bool inner_flag = 0;
if (!when) {
return;
}
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
- ly_print_(ctx->out, "%*swhen \"", INDENT);
- ypr_encode(ctx->out, when->cond, -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*swhen \"", INDENT);
+ ypr_encode(pctx->out, when->cond, -1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
- ypr_description(ctx, when->dsc, when->exts, &inner_flag);
- ypr_reference(ctx, when->ref, when->exts, &inner_flag);
+ yprp_extension_instances(pctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
+ ypr_description(pctx, when->dsc, when->exts, &inner_flag);
+ ypr_reference(pctx, when->ref, when->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprc_when(struct lys_ypr_ctx *ctx, struct lysc_when *when, ly_bool *flag)
+yprc_when(struct lys_ypr_ctx *pctx, struct lysc_when *when, ly_bool *flag)
{
ly_bool inner_flag = 0;
if (!when) {
return;
}
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
- ly_print_(ctx->out, "%*swhen \"", INDENT);
- ypr_encode(ctx->out, when->cond->expr, -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*swhen \"", INDENT);
+ ypr_encode(pctx->out, when->cond->expr, -1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
- ypr_description(ctx, when->dsc, when->exts, &inner_flag);
- ypr_reference(ctx, when->ref, when->exts, &inner_flag);
+ yprc_extension_instances(pctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
+ ypr_description(pctx, when->dsc, when->exts, &inner_flag);
+ ypr_reference(pctx, when->ref, when->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
static void
-yprp_enum(struct lys_ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, ly_bool *flag)
+yprp_enum(struct lys_ypr_ctx *pctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool inner_flag;
LY_ARRAY_FOR(items, u) {
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
if (type == LY_TYPE_BITS) {
- ly_print_(ctx->out, "%*sbit %s", INDENT, items[u].name);
+ ly_print_(pctx->out, "%*sbit %s", INDENT, items[u].name);
} else { /* LY_TYPE_ENUM */
- ly_print_(ctx->out, "%*senum \"", INDENT);
- ypr_encode(ctx->out, items[u].name, -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*senum \"", INDENT);
+ ypr_encode(pctx->out, items[u].name, -1);
+ ly_print_(pctx->out, "\"");
}
inner_flag = 0;
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
- yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);
+ yprp_extension_instances(pctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
+ yprp_iffeatures(pctx, items[u].iffeatures, items[u].exts, &inner_flag);
if (items[u].flags & LYS_SET_VALUE) {
if (type == LY_TYPE_BITS) {
- ypr_unsigned(ctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag);
+ ypr_unsigned(pctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag);
} else { /* LY_TYPE_ENUM */
- ypr_signed(ctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag);
+ ypr_signed(pctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag);
}
}
- ypr_status(ctx, items[u].flags, items[u].exts, &inner_flag);
- ypr_description(ctx, items[u].dsc, items[u].exts, &inner_flag);
- ypr_reference(ctx, items[u].ref, items[u].exts, &inner_flag);
+ ypr_status(pctx, items[u].flags, items[u].exts, &inner_flag);
+ ypr_description(pctx, items[u].dsc, items[u].exts, &inner_flag);
+ ypr_reference(pctx, items[u].ref, items[u].exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
}
static void
-yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)
+yprp_type(struct lys_ypr_ctx *pctx, const struct lysp_type *type)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
- ly_print_(ctx->out, "%*stype %s", INDENT, type->name);
+ ly_print_(pctx->out, "%*stype %s", INDENT, type->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
+ yprp_extension_instances(pctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
- yprp_restr(ctx, type->range, LY_STMT_RANGE, &flag);
- yprp_restr(ctx, type->length, LY_STMT_LENGTH, &flag);
+ yprp_restr(pctx, type->range, LY_STMT_RANGE, &flag);
+ yprp_restr(pctx, type->length, LY_STMT_LENGTH, &flag);
LY_ARRAY_FOR(type->patterns, u) {
- yprp_restr(ctx, &type->patterns[u], LY_STMT_PATTERN, &flag);
+ yprp_restr(pctx, &type->patterns[u], LY_STMT_PATTERN, &flag);
}
- yprp_enum(ctx, type->bits, LY_TYPE_BITS, &flag);
- yprp_enum(ctx, type->enums, LY_TYPE_ENUM, &flag);
+ yprp_enum(pctx, type->bits, LY_TYPE_BITS, &flag);
+ yprp_enum(pctx, type->enums, LY_TYPE_ENUM, &flag);
if (type->path) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_PATH, 0, type->path->expr, type->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_PATH, 0, type->path->expr, type->exts);
}
if (type->flags & LYS_SET_REQINST) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);
}
if (type->flags & LYS_SET_FRDIGITS) {
- ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits, &flag);
+ ypr_unsigned(pctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits, &flag);
}
LY_ARRAY_FOR(type->bases, u) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_BASE, u, type->bases[u], type->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_BASE, u, type->bases[u], type->exts);
}
LY_ARRAY_FOR(type->types, u) {
- ypr_open(ctx->out, &flag);
- yprp_type(ctx, &type->types[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_type(pctx, &type->types[u]);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_dflt_value(struct lys_ypr_ctx *ctx, const struct ly_ctx *ly_ctx, const struct lyd_value *value,
+yprc_dflt_value(struct lys_ypr_ctx *pctx, const struct ly_ctx *ly_pctx, const struct lyd_value *value,
struct lysc_ext_instance *exts)
{
ly_bool dynamic;
const char *str;
- str = value->realtype->plugin->print(ly_ctx, value, LY_VALUE_JSON, NULL, &dynamic, NULL);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, str, exts);
+ str = value->realtype->plugin->print(ly_pctx, value, LY_VALUE_JSON, NULL, &dynamic, NULL);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, str, exts);
if (dynamic) {
free((void *)str);
}
}
static void
-yprc_type(struct lys_ypr_ctx *ctx, const struct lysc_type *type)
+yprc_type(struct lys_ypr_ctx *pctx, const struct lysc_type *type)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
- ly_print_(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));
+ ly_print_(pctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
switch (type->basetype) {
case LY_TYPE_BINARY: {
struct lysc_type_bin *bin = (struct lysc_type_bin *)type;
- yprc_range(ctx, bin->length, type->basetype, &flag);
+ yprc_range(pctx, bin->length, type->basetype, &flag);
break;
}
case LY_TYPE_UINT8:
@@ -879,14 +879,14 @@
case LY_TYPE_INT32:
case LY_TYPE_INT64: {
struct lysc_type_num *num = (struct lysc_type_num *)type;
- yprc_range(ctx, num->range, type->basetype, &flag);
+ yprc_range(pctx, num->range, type->basetype, &flag);
break;
}
case LY_TYPE_STRING: {
struct lysc_type_str *str = (struct lysc_type_str *)type;
- yprc_range(ctx, str->length, type->basetype, &flag);
+ yprc_range(pctx, str->length, type->basetype, &flag);
LY_ARRAY_FOR(str->patterns, u) {
- yprc_pattern(ctx, str->patterns[u], &flag);
+ yprc_pattern(pctx, str->patterns[u], &flag);
}
break;
}
@@ -898,23 +898,23 @@
struct lysc_type_bitenum_item *item = &bits->bits[u];
ly_bool inner_flag = 0;
- ypr_open(ctx->out, &flag);
- ly_print_(ctx->out, "%*s%s \"", INDENT, type->basetype == LY_TYPE_BITS ? "bit" : "enum");
- ypr_encode(ctx->out, item->name, -1);
- ly_print_(ctx->out, "\"");
+ ypr_open(pctx->out, &flag);
+ ly_print_(pctx->out, "%*s%s \"", INDENT, type->basetype == LY_TYPE_BITS ? "bit" : "enum");
+ ypr_encode(pctx->out, item->name, -1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
if (type->basetype == LY_TYPE_BITS) {
- yprc_extension_instances(ctx, LY_STMT_BIT, 0, item->exts, &inner_flag, 0);
- ypr_unsigned(ctx, LY_STMT_POSITION, 0, item->exts, item->position, &inner_flag);
+ yprc_extension_instances(pctx, LY_STMT_BIT, 0, item->exts, &inner_flag, 0);
+ ypr_unsigned(pctx, LY_STMT_POSITION, 0, item->exts, item->position, &inner_flag);
} else { /* LY_TYPE_ENUM */
- yprc_extension_instances(ctx, LY_STMT_ENUM, 0, item->exts, &inner_flag, 0);
- ypr_signed(ctx, LY_STMT_VALUE, 0, item->exts, item->value, &inner_flag);
+ yprc_extension_instances(pctx, LY_STMT_ENUM, 0, item->exts, &inner_flag, 0);
+ ypr_signed(pctx, LY_STMT_VALUE, 0, item->exts, item->value, &inner_flag);
}
- ypr_status(ctx, item->flags, item->exts, &inner_flag);
- ypr_description(ctx, item->dsc, item->exts, &inner_flag);
- ypr_reference(ctx, item->ref, item->exts, &inner_flag);
+ ypr_status(pctx, item->flags, item->exts, &inner_flag);
+ ypr_description(pctx, item->dsc, item->exts, &inner_flag);
+ ypr_reference(pctx, item->ref, item->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
break;
}
@@ -924,81 +924,81 @@
break;
case LY_TYPE_DEC64: {
struct lysc_type_dec *dec = (struct lysc_type_dec *)type;
- ypr_open(ctx->out, &flag);
- ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, dec->fraction_digits, &flag);
- yprc_range(ctx, dec->range, dec->basetype, &flag);
+ ypr_open(pctx->out, &flag);
+ ypr_unsigned(pctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, dec->fraction_digits, &flag);
+ yprc_range(pctx, dec->range, dec->basetype, &flag);
break;
}
case LY_TYPE_IDENT: {
struct lysc_type_identityref *ident = (struct lysc_type_identityref *)type;
LY_ARRAY_FOR(ident->bases, u) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u]->name, type->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u]->name, type->exts);
}
break;
}
case LY_TYPE_INST: {
struct lysc_type_instanceid *inst = (struct lysc_type_instanceid *)type;
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts);
break;
}
case LY_TYPE_LEAFREF: {
struct lysc_type_leafref *lr = (struct lysc_type_leafref *)type;
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_PATH, 0, lr->path->expr, lr->exts);
- ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts);
- yprc_type(ctx, lr->realtype);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_PATH, 0, lr->path->expr, lr->exts);
+ ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts);
+ yprc_type(pctx, lr->realtype);
break;
}
case LY_TYPE_UNION: {
struct lysc_type_union *un = (struct lysc_type_union *)type;
LY_ARRAY_FOR(un->types, u) {
- ypr_open(ctx->out, &flag);
- yprc_type(ctx, un->types[u]);
+ ypr_open(pctx->out, &flag);
+ yprc_type(pctx, un->types[u]);
}
break;
}
default:
- LOGINT(ctx->module->ctx);
+ LOGINT(pctx->module->ctx);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_typedef(struct lys_ypr_ctx *ctx, const struct lysp_tpdf *tpdf)
+yprp_typedef(struct lys_ypr_ctx *pctx, const struct lysp_tpdf *tpdf)
{
- ly_print_(ctx->out, "%*stypedef %s {\n", INDENT, tpdf->name);
+ ly_print_(pctx->out, "%*stypedef %s {\n", INDENT, tpdf->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
- yprp_type(ctx, &tpdf->type);
+ yprp_type(pctx, &tpdf->type);
if (tpdf->units) {
- ypr_substmt(ctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);
}
if (tpdf->dflt.str) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);
}
- ypr_status(ctx, tpdf->flags, tpdf->exts, NULL);
- ypr_description(ctx, tpdf->dsc, tpdf->exts, NULL);
- ypr_reference(ctx, tpdf->ref, tpdf->exts, NULL);
+ ypr_status(pctx, tpdf->flags, tpdf->exts, NULL);
+ ypr_description(pctx, tpdf->dsc, tpdf->exts, NULL);
+ ypr_reference(pctx, tpdf->ref, tpdf->exts, NULL);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
-static void yprp_node(struct lys_ypr_ctx *ctx, const struct lysp_node *node);
-static void yprc_node(struct lys_ypr_ctx *ctx, const struct lysc_node *node);
-static void yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action);
-static void yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif);
+static void yprp_node(struct lys_ypr_ctx *pctx, const struct lysp_node *node);
+static void yprc_node(struct lys_ypr_ctx *pctx, const struct lysc_node *node);
+static void yprp_action(struct lys_ypr_ctx *pctx, const struct lysp_node_action *action);
+static void yprp_notification(struct lys_ypr_ctx *pctx, const struct lysp_node_notif *notif);
static void
-yprp_grouping(struct lys_ypr_ctx *ctx, const struct lysp_node_grp *grp)
+yprp_grouping(struct lys_ypr_ctx *pctx, const struct lysp_node_grp *grp)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
@@ -1007,45 +1007,45 @@
struct lysp_node_notif *notif;
struct lysp_node_grp *subgrp;
- ly_print_(ctx->out, "%*sgrouping %s", INDENT, grp->name);
+ ly_print_(pctx->out, "%*sgrouping %s", INDENT, grp->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
- ypr_status(ctx, grp->flags, grp->exts, &flag);
- ypr_description(ctx, grp->dsc, grp->exts, &flag);
- ypr_reference(ctx, grp->ref, grp->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
+ ypr_status(pctx, grp->flags, grp->exts, &flag);
+ ypr_description(pctx, grp->dsc, grp->exts, &flag);
+ ypr_reference(pctx, grp->ref, grp->exts, &flag);
LY_ARRAY_FOR(grp->typedefs, u) {
- ypr_open(ctx->out, &flag);
- yprp_typedef(ctx, &grp->typedefs[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_typedef(pctx, &grp->typedefs[u]);
}
LY_LIST_FOR(grp->groupings, subgrp) {
- ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, subgrp);
+ ypr_open(pctx->out, &flag);
+ yprp_grouping(pctx, subgrp);
}
LY_LIST_FOR(grp->child, data) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, data);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, data);
}
LY_LIST_FOR(grp->actions, action) {
- ypr_open(ctx->out, &flag);
- yprp_action(ctx, action);
+ ypr_open(pctx->out, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(grp->notifs, notif) {
- ypr_open(ctx->out, &flag);
- yprp_notification(ctx, notif);
+ ypr_open(pctx->out, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_inout(struct lys_ypr_ctx *ctx, const struct lysp_node_action_inout *inout, ly_bool *flag)
+yprp_inout(struct lys_ypr_ctx *pctx, const struct lysp_node_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
@@ -1055,33 +1055,33 @@
/* no children */
return;
}
- ypr_open(ctx->out, flag);
- YPR_EXTRA_LINE_PRINT(ctx);
+ ypr_open(pctx->out, flag);
+ YPR_EXTRA_LINE_PRINT(pctx);
- ly_print_(ctx->out, "%*s%s {\n", INDENT, inout->name);
+ ly_print_(pctx->out, "%*s%s {\n", INDENT, inout->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_MUST, 0, inout->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_MUST, 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
- yprp_restr(ctx, &inout->musts[u], LY_STMT_MUST, NULL);
+ yprp_restr(pctx, &inout->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(inout->typedefs, u) {
- yprp_typedef(ctx, &inout->typedefs[u]);
+ yprp_typedef(pctx, &inout->typedefs[u]);
}
LY_LIST_FOR(inout->groupings, grp) {
- yprp_grouping(ctx, grp);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(inout->child, data) {
- yprp_node(ctx, data);
+ yprp_node(pctx, data);
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
static void
-yprc_inout(struct lys_ypr_ctx *ctx, const struct lysc_node_action_inout *inout, ly_bool *flag)
+yprc_inout(struct lys_ypr_ctx *pctx, const struct lysc_node_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_node *data;
@@ -1090,203 +1090,203 @@
/* input/output is empty */
return;
}
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
- ly_print_(ctx->out, "\n%*s%s {\n", INDENT, inout->name);
+ ly_print_(pctx->out, "\n%*s%s {\n", INDENT, inout->name);
LEVEL++;
- yprc_extension_instances(ctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
+ yprc_extension_instances(pctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
- yprc_must(ctx, &inout->musts[u], NULL);
+ yprc_must(pctx, &inout->musts[u], NULL);
}
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
LY_LIST_FOR(inout->child, data) {
- yprc_node(ctx, data);
+ yprc_node(pctx, data);
}
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
static void
-yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif)
+yprp_notification(struct lys_ypr_ctx *pctx, const struct lysp_node_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node *data;
struct lysp_node_grp *grp;
- ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
+ ly_print_(pctx->out, "%*snotification %s", INDENT, notif->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
- yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
+ yprp_iffeatures(pctx, notif->iffeatures, notif->exts, &flag);
LY_ARRAY_FOR(notif->musts, u) {
- yprp_restr(ctx, ¬if->musts[u], LY_STMT_MUST, &flag);
+ yprp_restr(pctx, ¬if->musts[u], LY_STMT_MUST, &flag);
}
- ypr_status(ctx, notif->flags, notif->exts, &flag);
- ypr_description(ctx, notif->dsc, notif->exts, &flag);
- ypr_reference(ctx, notif->ref, notif->exts, &flag);
+ ypr_status(pctx, notif->flags, notif->exts, &flag);
+ ypr_description(pctx, notif->dsc, notif->exts, &flag);
+ ypr_reference(pctx, notif->ref, notif->exts, &flag);
LY_ARRAY_FOR(notif->typedefs, u) {
- ypr_open(ctx->out, &flag);
- yprp_typedef(ctx, ¬if->typedefs[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_typedef(pctx, ¬if->typedefs[u]);
}
LY_LIST_FOR(notif->groupings, grp) {
- ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, grp);
+ ypr_open(pctx->out, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(notif->child, data) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, data);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, data);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_notification(struct lys_ypr_ctx *ctx, const struct lysc_node_notif *notif)
+yprc_notification(struct lys_ypr_ctx *pctx, const struct lysc_node_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysc_node *data;
- ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
+ ly_print_(pctx->out, "%*snotification %s", INDENT, notif->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
LY_ARRAY_FOR(notif->musts, u) {
- yprc_must(ctx, ¬if->musts[u], &flag);
+ yprc_must(pctx, ¬if->musts[u], &flag);
}
- ypr_status(ctx, notif->flags, notif->exts, &flag);
- ypr_description(ctx, notif->dsc, notif->exts, &flag);
- ypr_reference(ctx, notif->ref, notif->exts, &flag);
+ ypr_status(pctx, notif->flags, notif->exts, &flag);
+ ypr_description(pctx, notif->dsc, notif->exts, &flag);
+ ypr_reference(pctx, notif->ref, notif->exts, &flag);
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
LY_LIST_FOR(notif->child, data) {
- ypr_open(ctx->out, &flag);
- yprc_node(ctx, data);
+ ypr_open(pctx->out, &flag);
+ yprc_node(pctx, data);
}
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action)
+yprp_action(struct lys_ypr_ctx *pctx, const struct lysp_node_action *action)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node_grp *grp;
- ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
+ ly_print_(pctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
LEVEL++;
- yprp_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
- yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);
- ypr_status(ctx, action->flags, action->exts, &flag);
- ypr_description(ctx, action->dsc, action->exts, &flag);
- ypr_reference(ctx, action->ref, action->exts, &flag);
+ yprp_extension_instances(pctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
+ yprp_iffeatures(pctx, action->iffeatures, action->exts, &flag);
+ ypr_status(pctx, action->flags, action->exts, &flag);
+ ypr_description(pctx, action->dsc, action->exts, &flag);
+ ypr_reference(pctx, action->ref, action->exts, &flag);
- YPR_EXTRA_LINE(flag, ctx);
+ YPR_EXTRA_LINE(flag, pctx);
LY_ARRAY_FOR(action->typedefs, u) {
- ypr_open(ctx->out, &flag);
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_typedef(ctx, &action->typedefs[u]);
+ ypr_open(pctx->out, &flag);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_typedef(pctx, &action->typedefs[u]);
}
- YPR_EXTRA_LINE(action->typedefs, ctx);
+ YPR_EXTRA_LINE(action->typedefs, pctx);
LY_LIST_FOR(action->groupings, grp) {
- ypr_open(ctx->out, &flag);
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_grouping(ctx, grp);
+ ypr_open(pctx->out, &flag);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_grouping(pctx, grp);
}
- YPR_EXTRA_LINE(action->groupings, ctx);
+ YPR_EXTRA_LINE(action->groupings, pctx);
- yprp_inout(ctx, &action->input, &flag);
- yprp_inout(ctx, &action->output, &flag);
+ yprp_inout(pctx, &action->input, &flag);
+ yprp_inout(pctx, &action->output, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_action(struct lys_ypr_ctx *ctx, const struct lysc_node_action *action)
+yprc_action(struct lys_ypr_ctx *pctx, const struct lysc_node_action *action)
{
ly_bool flag = 0;
- ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
+ ly_print_(pctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
LEVEL++;
- yprc_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
- ypr_status(ctx, action->flags, action->exts, &flag);
- ypr_description(ctx, action->dsc, action->exts, &flag);
- ypr_reference(ctx, action->ref, action->exts, &flag);
+ yprc_extension_instances(pctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
+ ypr_status(pctx, action->flags, action->exts, &flag);
+ ypr_description(pctx, action->dsc, action->exts, &flag);
+ ypr_reference(pctx, action->ref, action->exts, &flag);
- yprc_inout(ctx, &action->input, &flag);
- yprc_inout(ctx, &action->output, &flag);
+ yprc_inout(pctx, &action->input, &flag);
+ yprc_inout(pctx, &action->output, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_node_common1(struct lys_ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag)
+yprp_node_common1(struct lys_ypr_ctx *pctx, const struct lysp_node *node, ly_bool *flag)
{
- ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
+ ly_print_(pctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
LEVEL++;
- yprp_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
- yprp_when(ctx, lysp_node_when(node), flag);
- yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);
+ yprp_extension_instances(pctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
+ yprp_when(pctx, lysp_node_when(node), flag);
+ yprp_iffeatures(pctx, node->iffeatures, node->exts, flag);
}
static void
-yprc_node_common1(struct lys_ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag)
+yprc_node_common1(struct lys_ypr_ctx *pctx, const struct lysc_node *node, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_when **when;
- ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
+ ly_print_(pctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
LEVEL++;
- yprc_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
+ yprc_extension_instances(pctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
when = lysc_node_when(node);
LY_ARRAY_FOR(when, u) {
- yprc_when(ctx, when[u], flag);
+ yprc_when(pctx, when[u], flag);
}
}
/* macr oto unify the code */
#define YPR_NODE_COMMON2 \
- ypr_config(ctx, node->flags, node->exts, flag); \
+ ypr_config(pctx, node->flags, node->exts, flag); \
if (node->nodetype & (LYS_CHOICE | LYS_LEAF | LYS_ANYDATA)) { \
- ypr_mandatory(ctx, node->flags, node->exts, flag); \
+ ypr_mandatory(pctx, node->flags, node->exts, flag); \
} \
- ypr_status(ctx, node->flags, node->exts, flag); \
- ypr_description(ctx, node->dsc, node->exts, flag); \
- ypr_reference(ctx, node->ref, node->exts, flag)
+ ypr_status(pctx, node->flags, node->exts, flag); \
+ ypr_description(pctx, node->dsc, node->exts, flag); \
+ ypr_reference(pctx, node->ref, node->exts, flag)
static void
-yprp_node_common2(struct lys_ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag)
+yprp_node_common2(struct lys_ypr_ctx *pctx, const struct lysp_node *node, ly_bool *flag)
{
YPR_NODE_COMMON2;
}
static void
-yprc_node_common2(struct lys_ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag)
+yprc_node_common2(struct lys_ypr_ctx *pctx, const struct lysc_node *node, ly_bool *flag)
{
YPR_NODE_COMMON2;
}
@@ -1294,7 +1294,7 @@
#undef YPR_NODE_COMMON2
static void
-yprp_container(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_container(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
@@ -1304,49 +1304,49 @@
struct lysp_node_grp *grp;
struct lysp_node_container *cont = (struct lysp_node_container *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(cont->musts, u) {
- yprp_restr(ctx, &cont->musts[u], LY_STMT_MUST, &flag);
+ yprp_restr(pctx, &cont->musts[u], LY_STMT_MUST, &flag);
}
if (cont->presence) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_ARRAY_FOR(cont->typedefs, u) {
- ypr_open(ctx->out, &flag);
- yprp_typedef(ctx, &cont->typedefs[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_typedef(pctx, &cont->typedefs[u]);
}
LY_LIST_FOR(cont->groupings, grp) {
- ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, grp);
+ ypr_open(pctx->out, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(cont->child, child) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(cont->actions, action) {
- ypr_open(ctx->out, &flag);
- yprp_action(ctx, action);
+ ypr_open(pctx->out, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(cont->notifs, notif) {
- ypr_open(ctx->out, &flag);
- yprp_notification(ctx, notif);
+ ypr_open(pctx->out, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_container(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_container(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
@@ -1355,253 +1355,253 @@
struct lysc_node_notif *notif;
struct lysc_node_container *cont = (struct lysc_node_container *)node;
- yprc_node_common1(ctx, node, &flag);
+ yprc_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(cont->musts, u) {
- yprc_must(ctx, &cont->musts[u], &flag);
+ yprc_must(pctx, &cont->musts[u], &flag);
}
if (cont->flags & LYS_PRESENCE) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_PRESENCE, 0, "true", cont->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_PRESENCE, 0, "true", cont->exts);
}
- yprc_node_common2(ctx, node, &flag);
+ yprc_node_common2(pctx, node, &flag);
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
LY_LIST_FOR(cont->child, child) {
- ypr_open(ctx->out, &flag);
- yprc_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprc_node(pctx, child);
}
LY_LIST_FOR(cont->actions, action) {
- ypr_open(ctx->out, &flag);
- yprc_action(ctx, action);
+ ypr_open(pctx->out, &flag);
+ yprc_action(pctx, action);
}
LY_LIST_FOR(cont->notifs, notif) {
- ypr_open(ctx->out, &flag);
- yprc_notification(ctx, notif);
+ ypr_open(pctx->out, &flag);
+ yprc_notification(pctx, notif);
}
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_case(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_case(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_case *cas = (struct lysp_node_case *)node;
- yprp_node_common1(ctx, node, &flag);
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_LIST_FOR(cas->child, child) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, child);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_case(struct lys_ypr_ctx *ctx, const struct lysc_node_case *cs)
+yprc_case(struct lys_ypr_ctx *pctx, const struct lysc_node_case *cs)
{
ly_bool flag = 0;
struct lysc_node *child;
- yprc_node_common1(ctx, &cs->node, &flag);
- yprc_node_common2(ctx, &cs->node, &flag);
+ yprc_node_common1(pctx, &cs->node, &flag);
+ yprc_node_common2(pctx, &cs->node, &flag);
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
for (child = cs->child; child && child->parent == (struct lysc_node *)cs; child = child->next) {
- ypr_open(ctx->out, &flag);
- yprc_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprc_node(pctx, child);
}
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_choice(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_choice(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_choice *choice = (struct lysp_node_choice *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
if (choice->dflt.str) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_LIST_FOR(choice->child, child) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, child);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_choice(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_choice(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
ly_bool flag = 0;
struct lysc_node_case *cs;
struct lysc_node_choice *choice = (struct lysc_node_choice *)node;
- yprc_node_common1(ctx, node, &flag);
+ yprc_node_common1(pctx, node, &flag);
if (choice->dflt) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt->name, choice->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt->name, choice->exts);
}
- yprc_node_common2(ctx, node, &flag);
+ yprc_node_common2(pctx, node, &flag);
for (cs = choice->cases; cs; cs = (struct lysc_node_case *)cs->next) {
- ypr_open(ctx->out, &flag);
- yprc_case(ctx, cs);
+ ypr_open(pctx->out, &flag);
+ yprc_case(pctx, cs);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_leaf(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_leaf(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node;
- yprp_node_common1(ctx, node, NULL);
+ yprp_node_common1(pctx, node, NULL);
- yprp_type(ctx, &leaf->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
+ yprp_type(pctx, &leaf->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
LY_ARRAY_FOR(leaf->musts, u) {
- yprp_restr(ctx, &leaf->musts[u], LY_STMT_MUST, NULL);
+ yprp_restr(pctx, &leaf->musts[u], LY_STMT_MUST, NULL);
}
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
- yprp_node_common2(ctx, node, NULL);
+ yprp_node_common2(pctx, node, NULL);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
static void
-yprc_leaf(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_leaf(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_node_leaf *leaf = (struct lysc_node_leaf *)node;
- yprc_node_common1(ctx, node, NULL);
+ yprc_node_common1(pctx, node, NULL);
- yprc_type(ctx, leaf->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
+ yprc_type(pctx, leaf->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
LY_ARRAY_FOR(leaf->musts, u) {
- yprc_must(ctx, &leaf->musts[u], NULL);
+ yprc_must(pctx, &leaf->musts[u], NULL);
}
if (leaf->dflt) {
- yprc_dflt_value(ctx, node->module->ctx, leaf->dflt, leaf->exts);
+ yprc_dflt_value(pctx, node->module->ctx, leaf->dflt, leaf->exts);
}
- yprc_node_common2(ctx, node, NULL);
+ yprc_node_common2(pctx, node, NULL);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
static void
-yprp_leaflist(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_leaflist(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node;
- yprp_node_common1(ctx, node, NULL);
+ yprp_node_common1(pctx, node, NULL);
- yprp_type(ctx, &llist->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
+ yprp_type(pctx, &llist->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
LY_ARRAY_FOR(llist->musts, u) {
- yprp_restr(ctx, &llist->musts[u], LY_STMT_MUST, NULL);
+ yprp_restr(pctx, &llist->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
}
- ypr_config(ctx, node->flags, node->exts, NULL);
+ ypr_config(pctx, node->flags, node->exts, NULL);
if (llist->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);
}
if (llist->flags & LYS_SET_MAX) {
if (llist->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
}
}
if (llist->flags & LYS_ORDBY_MASK) {
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
}
- ypr_status(ctx, node->flags, node->exts, NULL);
- ypr_description(ctx, node->dsc, node->exts, NULL);
- ypr_reference(ctx, node->ref, node->exts, NULL);
+ ypr_status(pctx, node->flags, node->exts, NULL);
+ ypr_description(pctx, node->dsc, node->exts, NULL);
+ ypr_reference(pctx, node->ref, node->exts, NULL);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
static void
-yprc_leaflist(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_leaflist(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_node_leaflist *llist = (struct lysc_node_leaflist *)node;
- yprc_node_common1(ctx, node, NULL);
+ yprc_node_common1(pctx, node, NULL);
- yprc_type(ctx, llist->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
+ yprc_type(pctx, llist->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
LY_ARRAY_FOR(llist->musts, u) {
- yprc_must(ctx, &llist->musts[u], NULL);
+ yprc_must(pctx, &llist->musts[u], NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
- yprc_dflt_value(ctx, node->module->ctx, llist->dflts[u], llist->exts);
+ yprc_dflt_value(pctx, node->module->ctx, llist->dflts[u], llist->exts);
}
- ypr_config(ctx, node->flags, node->exts, NULL);
+ ypr_config(pctx, node->flags, node->exts, NULL);
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);
if (llist->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
}
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
- ypr_status(ctx, node->flags, node->exts, NULL);
- ypr_description(ctx, node->dsc, node->exts, NULL);
- ypr_reference(ctx, node->ref, node->exts, NULL);
+ ypr_status(pctx, node->flags, node->exts, NULL);
+ ypr_description(pctx, node->dsc, node->exts, NULL);
+ ypr_reference(pctx, node->ref, node->exts, NULL);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
static void
-yprp_list(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_list(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
@@ -1611,311 +1611,311 @@
struct lysp_node_grp *grp;
struct lysp_node_list *list = (struct lysp_node_list *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(list->musts, u) {
- yprp_restr(ctx, &list->musts[u], LY_STMT_MUST, &flag);
+ yprp_restr(pctx, &list->musts[u], LY_STMT_MUST, &flag);
}
if (list->key) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_KEY, 0, list->key, list->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_KEY, 0, list->key, list->exts);
}
LY_ARRAY_FOR(list->uniques, u) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);
}
- ypr_config(ctx, node->flags, node->exts, &flag);
+ ypr_config(pctx, node->flags, node->exts, &flag);
if (list->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, &flag);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, &flag);
}
if (list->flags & LYS_SET_MAX) {
if (list->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, &flag);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, &flag);
} else {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
}
}
if (list->flags & LYS_ORDBY_MASK) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
}
- ypr_status(ctx, node->flags, node->exts, &flag);
- ypr_description(ctx, node->dsc, node->exts, &flag);
- ypr_reference(ctx, node->ref, node->exts, &flag);
+ ypr_status(pctx, node->flags, node->exts, &flag);
+ ypr_description(pctx, node->dsc, node->exts, &flag);
+ ypr_reference(pctx, node->ref, node->exts, &flag);
LY_ARRAY_FOR(list->typedefs, u) {
- ypr_open(ctx->out, &flag);
- yprp_typedef(ctx, &list->typedefs[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_typedef(pctx, &list->typedefs[u]);
}
LY_LIST_FOR(list->groupings, grp) {
- ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, grp);
+ ypr_open(pctx->out, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(list->child, child) {
- ypr_open(ctx->out, &flag);
- yprp_node(ctx, child);
+ ypr_open(pctx->out, &flag);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(list->actions, action) {
- ypr_open(ctx->out, &flag);
- yprp_action(ctx, action);
+ ypr_open(pctx->out, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(list->notifs, notif) {
- ypr_open(ctx->out, &flag);
- yprp_notification(ctx, notif);
+ ypr_open(pctx->out, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_list(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_list(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u, v;
struct lysc_node_list *list = (struct lysc_node_list *)node;
- yprc_node_common1(ctx, node, NULL);
+ yprc_node_common1(pctx, node, NULL);
LY_ARRAY_FOR(list->musts, u) {
- yprc_must(ctx, &list->musts[u], NULL);
+ yprc_must(pctx, &list->musts[u], NULL);
}
if (!(list->flags & LYS_KEYLESS)) {
- ly_print_(ctx->out, "%*skey \"", INDENT);
+ ly_print_(pctx->out, "%*skey \"", INDENT);
for (struct lysc_node *key = list->child; key && key->nodetype == LYS_LEAF && (key->flags & LYS_KEY); key = key->next) {
- ly_print_(ctx->out, "%s%s", u > 0 ? ", " : "", key->name);
+ ly_print_(pctx->out, "%s%s", u > 0 ? ", " : "", key->name);
}
- ly_print_(ctx->out, "\";\n");
+ ly_print_(pctx->out, "\";\n");
}
LY_ARRAY_FOR(list->uniques, u) {
- ly_print_(ctx->out, "%*sunique \"", INDENT);
+ ly_print_(pctx->out, "%*sunique \"", INDENT);
LY_ARRAY_FOR(list->uniques[u], v) {
- ly_print_(ctx->out, "%s%s", v > 0 ? ", " : "", list->uniques[u][v]->name);
+ ly_print_(pctx->out, "%s%s", v > 0 ? ", " : "", list->uniques[u][v]->name);
}
- ypr_close(ctx, 0);
+ ypr_close(pctx, 0);
}
- ypr_config(ctx, node->flags, node->exts, NULL);
+ ypr_config(pctx, node->flags, node->exts, NULL);
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, NULL);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, NULL);
if (list->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
}
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
- ypr_status(ctx, node->flags, node->exts, NULL);
- ypr_description(ctx, node->dsc, node->exts, NULL);
- ypr_reference(ctx, node->ref, node->exts, NULL);
+ ypr_status(pctx, node->flags, node->exts, NULL);
+ ypr_description(pctx, node->dsc, node->exts, NULL);
+ ypr_reference(pctx, node->ref, node->exts, NULL);
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
struct lysc_node *child;
struct lysc_node_action *action;
struct lysc_node_notif *notif;
LY_LIST_FOR(list->child, child) {
- yprc_node(ctx, child);
+ yprc_node(pctx, child);
}
LY_LIST_FOR(list->actions, action) {
- yprc_action(ctx, action);
+ yprc_action(pctx, action);
}
LY_LIST_FOR(list->notifs, notif) {
- yprc_notification(ctx, notif);
+ yprc_notification(pctx, notif);
}
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
static void
-yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)
+yprp_refine(struct lys_ypr_ctx *pctx, struct lysp_refine *refine)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
- ly_print_(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid);
+ ly_print_(pctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
- yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
+ yprp_iffeatures(pctx, refine->iffeatures, refine->exts, &flag);
LY_ARRAY_FOR(refine->musts, u) {
- ypr_open(ctx->out, &flag);
- yprp_restr(ctx, &refine->musts[u], LY_STMT_MUST, NULL);
+ ypr_open(pctx->out, &flag);
+ yprp_restr(pctx, &refine->musts[u], LY_STMT_MUST, NULL);
}
if (refine->presence) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);
}
LY_ARRAY_FOR(refine->dflts, u) {
- ypr_open(ctx->out, &flag);
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);
+ ypr_open(pctx->out, &flag);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);
}
- ypr_config(ctx, refine->flags, refine->exts, &flag);
- ypr_mandatory(ctx, refine->flags, refine->exts, &flag);
+ ypr_config(pctx, refine->flags, refine->exts, &flag);
+ ypr_mandatory(pctx, refine->flags, refine->exts, &flag);
if (refine->flags & LYS_SET_MIN) {
- ypr_open(ctx->out, &flag);
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min, NULL);
+ ypr_open(pctx->out, &flag);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min, NULL);
}
if (refine->flags & LYS_SET_MAX) {
- ypr_open(ctx->out, &flag);
+ ypr_open(pctx->out, &flag);
if (refine->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);
}
}
- ypr_description(ctx, refine->dsc, refine->exts, &flag);
- ypr_reference(ctx, refine->ref, refine->exts, &flag);
+ ypr_description(pctx, refine->dsc, refine->exts, &flag);
+ ypr_reference(pctx, refine->ref, refine->exts, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_augment(struct lys_ypr_ctx *ctx, const struct lysp_node_augment *aug)
+yprp_augment(struct lys_ypr_ctx *pctx, const struct lysp_node_augment *aug)
{
struct lysp_node *child;
struct lysp_node_action *action;
struct lysp_node_notif *notif;
- ly_print_(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid);
+ ly_print_(pctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
- yprp_when(ctx, aug->when, NULL);
- yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);
- ypr_status(ctx, aug->flags, aug->exts, NULL);
- ypr_description(ctx, aug->dsc, aug->exts, NULL);
- ypr_reference(ctx, aug->ref, aug->exts, NULL);
+ yprp_extension_instances(pctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
+ yprp_when(pctx, aug->when, NULL);
+ yprp_iffeatures(pctx, aug->iffeatures, aug->exts, NULL);
+ ypr_status(pctx, aug->flags, aug->exts, NULL);
+ ypr_description(pctx, aug->dsc, aug->exts, NULL);
+ ypr_reference(pctx, aug->ref, aug->exts, NULL);
LY_LIST_FOR(aug->child, child) {
- yprp_node(ctx, child);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(aug->actions, action) {
- yprp_action(ctx, action);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(aug->notifs, notif) {
- yprp_notification(ctx, notif);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
static void
-yprp_uses(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_uses(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
struct lysp_node_augment *aug;
- yprp_node_common1(ctx, node, &flag);
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_ARRAY_FOR(uses->refines, u) {
- ypr_open(ctx->out, &flag);
- yprp_refine(ctx, &uses->refines[u]);
+ ypr_open(pctx->out, &flag);
+ yprp_refine(pctx, &uses->refines[u]);
}
LY_LIST_FOR(uses->augments, aug) {
- ypr_open(ctx->out, &flag);
- yprp_augment(ctx, aug);
+ ypr_open(pctx->out, &flag);
+ yprp_augment(pctx, aug);
}
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_anydata(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_anydata(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node_anydata *any = (struct lysp_node_anydata *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(any->musts, u) {
- ypr_open(ctx->out, &flag);
- yprp_restr(ctx, &any->musts[u], LY_STMT_MUST, NULL);
+ ypr_open(pctx->out, &flag);
+ yprp_restr(pctx, &any->musts[u], LY_STMT_MUST, NULL);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprc_anydata(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_anydata(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysc_node_anydata *any = (struct lysc_node_anydata *)node;
- yprc_node_common1(ctx, node, &flag);
+ yprc_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(any->musts, u) {
- ypr_open(ctx->out, &flag);
- yprc_must(ctx, &any->musts[u], NULL);
+ ypr_open(pctx->out, &flag);
+ yprc_must(pctx, &any->musts[u], NULL);
}
- yprc_node_common2(ctx, node, &flag);
+ yprc_node_common2(pctx, node, &flag);
LEVEL--;
- ypr_close(ctx, flag);
+ ypr_close(pctx, flag);
}
static void
-yprp_node(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_node(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
switch (node->nodetype) {
case LYS_CONTAINER:
- yprp_container(ctx, node);
+ yprp_container(pctx, node);
break;
case LYS_CHOICE:
- yprp_choice(ctx, node);
+ yprp_choice(pctx, node);
break;
case LYS_LEAF:
- yprp_leaf(ctx, node);
+ yprp_leaf(pctx, node);
break;
case LYS_LEAFLIST:
- yprp_leaflist(ctx, node);
+ yprp_leaflist(pctx, node);
break;
case LYS_LIST:
- yprp_list(ctx, node);
+ yprp_list(pctx, node);
break;
case LYS_USES:
- yprp_uses(ctx, node);
+ yprp_uses(pctx, node);
break;
case LYS_ANYXML:
case LYS_ANYDATA:
- yprp_anydata(ctx, node);
+ yprp_anydata(pctx, node);
break;
case LYS_CASE:
- yprp_case(ctx, node);
+ yprp_case(pctx, node);
break;
default:
break;
@@ -1923,27 +1923,27 @@
}
static void
-yprc_node(struct lys_ypr_ctx *ctx, const struct lysc_node *node)
+yprc_node(struct lys_ypr_ctx *pctx, const struct lysc_node *node)
{
switch (node->nodetype) {
case LYS_CONTAINER:
- yprc_container(ctx, node);
+ yprc_container(pctx, node);
break;
case LYS_CHOICE:
- yprc_choice(ctx, node);
+ yprc_choice(pctx, node);
break;
case LYS_LEAF:
- yprc_leaf(ctx, node);
+ yprc_leaf(pctx, node);
break;
case LYS_LEAFLIST:
- yprc_leaflist(ctx, node);
+ yprc_leaflist(pctx, node);
break;
case LYS_LIST:
- yprc_list(ctx, node);
+ yprc_list(pctx, node);
break;
case LYS_ANYXML:
case LYS_ANYDATA:
- yprc_anydata(ctx, node);
+ yprc_anydata(pctx, node);
break;
default:
break;
@@ -1951,7 +1951,7 @@
}
static void
-yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)
+yprp_deviation(struct lys_ypr_ctx *pctx, const struct lysp_deviation *deviation)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_deviate_add *add;
@@ -1959,104 +1959,104 @@
struct lysp_deviate_del *del;
struct lysp_deviate *elem;
- ly_print_(ctx->out, "%*sdeviation \"%s\" {\n", INDENT, deviation->nodeid);
+ ly_print_(pctx->out, "%*sdeviation \"%s\" {\n", INDENT, deviation->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
- ypr_description(ctx, deviation->dsc, deviation->exts, NULL);
- ypr_reference(ctx, deviation->ref, deviation->exts, NULL);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
+ ypr_description(pctx, deviation->dsc, deviation->exts, NULL);
+ ypr_reference(pctx, deviation->ref, deviation->exts, NULL);
LY_LIST_FOR(deviation->deviates, elem) {
- ly_print_(ctx->out, "%*sdeviate ", INDENT);
+ ly_print_(pctx->out, "%*sdeviate ", INDENT);
if (elem->mod == LYS_DEV_NOT_SUPPORTED) {
if (elem->exts) {
- ly_print_(ctx->out, "not-supported {\n");
+ ly_print_(pctx->out, "not-supported {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
} else {
- ly_print_(ctx->out, "not-supported;\n");
+ ly_print_(pctx->out, "not-supported;\n");
continue;
}
} else if (elem->mod == LYS_DEV_ADD) {
add = (struct lysp_deviate_add *)elem;
- ly_print_(ctx->out, "add {\n");
+ ly_print_(pctx->out, "add {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, add->units, add->exts);
LY_ARRAY_FOR(add->musts, u) {
- yprp_restr(ctx, &add->musts[u], LY_STMT_MUST, NULL);
+ yprp_restr(pctx, &add->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(add->uniques, u) {
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
}
LY_ARRAY_FOR(add->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);
}
- ypr_config(ctx, add->flags, add->exts, NULL);
- ypr_mandatory(ctx, add->flags, add->exts, NULL);
+ ypr_config(pctx, add->flags, add->exts, NULL);
+ ypr_mandatory(pctx, add->flags, add->exts, NULL);
if (add->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min, NULL);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min, NULL);
}
if (add->flags & LYS_SET_MAX) {
if (add->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);
}
}
} else if (elem->mod == LYS_DEV_REPLACE) {
rpl = (struct lysp_deviate_rpl *)elem;
- ly_print_(ctx->out, "replace {\n");
+ ly_print_(pctx->out, "replace {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
if (rpl->type) {
- yprp_type(ctx, rpl->type);
+ yprp_type(pctx, rpl->type);
}
- ypr_substmt(ctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);
- ypr_config(ctx, rpl->flags, rpl->exts, NULL);
- ypr_mandatory(ctx, rpl->flags, rpl->exts, NULL);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);
+ ypr_config(pctx, rpl->flags, rpl->exts, NULL);
+ ypr_mandatory(pctx, rpl->flags, rpl->exts, NULL);
if (rpl->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min, NULL);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min, NULL);
}
if (rpl->flags & LYS_SET_MAX) {
if (rpl->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max, NULL);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max, NULL);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);
}
}
} else if (elem->mod == LYS_DEV_DELETE) {
del = (struct lysp_deviate_del *)elem;
- ly_print_(ctx->out, "delete {\n");
+ ly_print_(pctx->out, "delete {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, del->units, del->exts);
LY_ARRAY_FOR(del->musts, u) {
- yprp_restr(ctx, &del->musts[u], LY_STMT_MUST, NULL);
+ yprp_restr(pctx, &del->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(del->uniques, u) {
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
}
LY_ARRAY_FOR(del->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);
}
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
LEVEL--;
- ypr_close(ctx, 1);
+ ypr_close(pctx, 1);
}
static void
-yang_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)
+yang_print_parsed_linkage(struct lys_ypr_ctx *pctx, const struct lysp_module *modp)
{
LY_ARRAY_COUNT_TYPE u;
@@ -2065,47 +2065,47 @@
continue;
}
- YPR_EXTRA_LINE_PRINT(ctx);
- ly_print_(ctx->out, "%*simport %s {\n", INDENT, modp->imports[u].name);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ ly_print_(pctx->out, "%*simport %s {\n", INDENT, modp->imports[u].name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
+ yprp_extension_instances(pctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
if (modp->imports[u].rev[0]) {
- ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
}
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
- YPR_EXTRA_LINE(modp->imports, ctx);
+ YPR_EXTRA_LINE(modp->imports, pctx);
LY_ARRAY_FOR(modp->includes, u) {
if (modp->includes[u].injected) {
/* do not print the includes injected from submodules */
continue;
}
- YPR_EXTRA_LINE_PRINT(ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {
- ly_print_(ctx->out, "%*sinclude %s {\n", INDENT, modp->includes[u].name);
+ ly_print_(pctx->out, "%*sinclude %s {\n", INDENT, modp->includes[u].name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
if (modp->includes[u].rev[0]) {
- ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
}
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
} else {
- ly_print_(ctx->out, "\n%*sinclude \"%s\";\n", INDENT, modp->includes[u].name);
+ ly_print_(pctx->out, "\n%*sinclude \"%s\";\n", INDENT, modp->includes[u].name);
}
}
- YPR_EXTRA_LINE(modp->includes, ctx);
+ YPR_EXTRA_LINE(modp->includes, pctx);
}
static void
-yang_print_parsed_body(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)
+yang_print_parsed_body(struct lys_ypr_ctx *pctx, const struct lysp_module *modp)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
@@ -2115,85 +2115,85 @@
struct lysp_node_augment *aug;
LY_ARRAY_FOR(modp->extensions, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_extension(ctx, &modp->extensions[u]);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_extension(pctx, &modp->extensions[u]);
}
- YPR_EXTRA_LINE(modp->extensions, ctx);
+ YPR_EXTRA_LINE(modp->extensions, pctx);
if (modp->exts) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_extension_instances(ctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_extension_instances(pctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
}
- YPR_EXTRA_LINE(modp->exts, ctx);
+ YPR_EXTRA_LINE(modp->exts, pctx);
LY_ARRAY_FOR(modp->features, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_feature(ctx, &modp->features[u]);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_feature(pctx, &modp->features[u]);
+ YPR_EXTRA_LINE(1, pctx);
}
- YPR_EXTRA_LINE(modp->features, ctx);
+ YPR_EXTRA_LINE(modp->features, pctx);
LY_ARRAY_FOR(modp->identities, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_identity(ctx, &modp->identities[u]);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_identity(pctx, &modp->identities[u]);
+ YPR_EXTRA_LINE(1, pctx);
}
- YPR_EXTRA_LINE(modp->identities, ctx);
+ YPR_EXTRA_LINE(modp->identities, pctx);
LY_ARRAY_FOR(modp->typedefs, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_typedef(ctx, &modp->typedefs[u]);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_typedef(pctx, &modp->typedefs[u]);
+ YPR_EXTRA_LINE(1, pctx);
}
- YPR_EXTRA_LINE(modp->typedefs, ctx);
+ YPR_EXTRA_LINE(modp->typedefs, pctx);
LY_LIST_FOR(modp->groupings, grp) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_grouping(ctx, grp);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_grouping(pctx, grp);
+ YPR_EXTRA_LINE(1, pctx);
}
- YPR_EXTRA_LINE(modp->groupings, ctx);
+ YPR_EXTRA_LINE(modp->groupings, pctx);
LY_LIST_FOR(modp->data, data) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_node(ctx, data);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_node(pctx, data);
}
- YPR_EXTRA_LINE(modp->data, ctx);
+ YPR_EXTRA_LINE(modp->data, pctx);
LY_LIST_FOR(modp->augments, aug) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_augment(ctx, aug);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_augment(pctx, aug);
}
- YPR_EXTRA_LINE(modp->augments, ctx);
+ YPR_EXTRA_LINE(modp->augments, pctx);
LY_LIST_FOR(modp->rpcs, action) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_action(ctx, action);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_action(pctx, action);
}
- YPR_EXTRA_LINE(modp->rpcs, ctx);
+ YPR_EXTRA_LINE(modp->rpcs, pctx);
LY_LIST_FOR(modp->notifs, notif) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_notification(ctx, notif);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_notification(pctx, notif);
}
- YPR_EXTRA_LINE(modp->notifs, ctx);
+ YPR_EXTRA_LINE(modp->notifs, pctx);
LY_ARRAY_FOR(modp->deviations, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_deviation(ctx, &modp->deviations[u]);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_deviation(pctx, &modp->deviations[u]);
}
- YPR_EXTRA_LINE(modp->deviations, ctx);
+ YPR_EXTRA_LINE(modp->deviations, pctx);
}
LY_ERR
@@ -2201,44 +2201,50 @@
{
LY_ARRAY_COUNT_TYPE u;
const struct lys_module *module = modp->mod;
- struct lys_ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .schema = LYS_YPR_PARSED, .options = options}, *ctx = &ctx_;
+ struct lys_ypr_ctx pctx_ = {
+ .out = out,
+ .level = 0,
+ .module = module,
+ .schema = LYS_YPR_PARSED,
+ .options = options
+ }, *pctx = &pctx_;
- ly_print_(ctx->out, "%*smodule %s {\n", INDENT, module->name);
+ ly_print_(pctx->out, "%*smodule %s {\n", INDENT, module->name);
LEVEL++;
/* module-header-stmts */
if (modp->version) {
- ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);
+ ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);
}
- ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);
+ ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE(1, pctx);
/* linkage-stmts (import/include) */
- yang_print_parsed_linkage(ctx, modp);
+ yang_print_parsed_linkage(pctx, modp);
/* meta-stmts */
if (module->org || module->contact || module->dsc || module->ref) {
- YPR_EXTRA_LINE_PRINT(ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
}
- ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);
- ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);
+ ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);
+ ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);
- YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, ctx);
+ YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, pctx);
/* revision-stmts */
LY_ARRAY_FOR(modp->revs, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_revision(ctx, &modp->revs[u]);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_revision(pctx, &modp->revs[u]);
}
- YPR_EXTRA_LINE(modp->revs, ctx);
+ YPR_EXTRA_LINE(modp->revs, pctx);
/* body-stmts */
- yang_print_parsed_body(ctx, modp);
+ yang_print_parsed_body(pctx, modp);
LEVEL--;
ly_print_(out, "%*s}\n", INDENT);
@@ -2248,61 +2254,61 @@
}
static void
-yprp_belongsto(struct lys_ypr_ctx *ctx, const struct lysp_submodule *submodp)
+yprp_belongsto(struct lys_ypr_ctx *pctx, const struct lysp_submodule *submodp)
{
- ly_print_(ctx->out, "%*sbelongs-to %s {\n", INDENT, submodp->mod->name);
+ ly_print_(pctx->out, "%*sbelongs-to %s {\n", INDENT, submodp->mod->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);
+ yprp_extension_instances(pctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
}
LY_ERR
yang_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *submodp, uint32_t options)
{
LY_ARRAY_COUNT_TYPE u;
- struct lys_ypr_ctx ctx_ = {
+ struct lys_ypr_ctx pctx_ = {
.out = out, .level = 0, .module = submodp->mod, .schema = LYS_YPR_PARSED,
.options = options
- }, *ctx = &ctx_;
+ }, *pctx = &pctx_;
- ly_print_(ctx->out, "%*ssubmodule %s {\n", INDENT, submodp->name);
+ ly_print_(pctx->out, "%*ssubmodule %s {\n", INDENT, submodp->name);
LEVEL++;
/* submodule-header-stmts */
if (submodp->version) {
- ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);
+ ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);
}
- yprp_belongsto(ctx, submodp);
+ yprp_belongsto(pctx, submodp);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE(1, pctx);
/* linkage-stmts (import/include) */
- yang_print_parsed_linkage(ctx, (struct lysp_module *)submodp);
+ yang_print_parsed_linkage(pctx, (struct lysp_module *)submodp);
/* meta-stmts */
if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) {
- YPR_EXTRA_LINE_PRINT(ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
}
- ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);
- ypr_substmt(ctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);
- YPR_EXTRA_LINE(submodp->org || submodp->contact || submodp->dsc || submodp->ref, ctx);
+ YPR_EXTRA_LINE(submodp->org || submodp->contact || submodp->dsc || submodp->ref, pctx);
/* revision-stmts */
LY_ARRAY_FOR(submodp->revs, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprp_revision(ctx, &submodp->revs[u]);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprp_revision(pctx, &submodp->revs[u]);
}
- YPR_EXTRA_LINE(submodp->revs, ctx);
+ YPR_EXTRA_LINE(submodp->revs, pctx);
/* body-stmts */
- yang_print_parsed_body(ctx, (struct lysp_module *)submodp);
+ yang_print_parsed_body(pctx, (struct lysp_module *)submodp);
LEVEL--;
ly_print_(out, "%*s}\n", INDENT);
@@ -2314,9 +2320,9 @@
LY_ERR
yang_print_compiled_node(struct ly_out *out, const struct lysc_node *node, uint32_t options)
{
- struct lys_ypr_ctx ctx_ = {.out = out, .level = 0, .module = node->module, .options = options}, *ctx = &ctx_;
+ struct lys_ypr_ctx pctx_ = {.out = out, .level = 0, .module = node->module, .options = options}, *pctx = &pctx_;
- yprc_node(ctx, node);
+ yprc_node(pctx, node);
ly_print_flush(out);
return LY_SUCCESS;
@@ -2327,75 +2333,75 @@
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_module *modc = module->compiled;
- struct lys_ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_;
+ struct lys_ypr_ctx pctx_ = {.out = out, .level = 0, .module = module, .options = options}, *pctx = &pctx_;
- ly_print_(ctx->out, "%*smodule %s {\n", INDENT, module->name);
+ ly_print_(pctx->out, "%*smodule %s {\n", INDENT, module->name);
LEVEL++;
/* module-header-stmts */
- ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modc->exts);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modc->exts);
+ ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, modc->exts);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, modc->exts);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE(1, pctx);
/* no linkage-stmts */
/* meta-stmts */
if (module->org || module->contact || module->dsc || module->ref) {
- YPR_EXTRA_LINE_PRINT(ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
}
- ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modc->exts);
- ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modc->exts);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modc->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modc->exts);
+ ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, modc->exts);
+ ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, modc->exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, modc->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, modc->exts);
- YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, ctx);
+ YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, pctx);
/* revision-stmts */
if (module->revision) {
- YPR_EXTRA_LINE_PRINT(ctx);
- ly_print_(ctx->out, "%*srevision %s;\n", INDENT, module->revision);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ ly_print_(pctx->out, "%*srevision %s;\n", INDENT, module->revision);
+ YPR_EXTRA_LINE(1, pctx);
}
/* body-stmts */
if (modc->exts) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprc_extension_instances(ctx, LY_STMT_MODULE, 0, module->compiled->exts, NULL, 0);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprc_extension_instances(pctx, LY_STMT_MODULE, 0, module->compiled->exts, NULL, 0);
+ YPR_EXTRA_LINE(1, pctx);
}
LY_ARRAY_FOR(module->identities, u) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprc_identity(ctx, &module->identities[u]);
- YPR_EXTRA_LINE(1, ctx);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprc_identity(pctx, &module->identities[u]);
+ YPR_EXTRA_LINE(1, pctx);
}
- if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ if (!(pctx->options & LYS_PRINT_NO_SUBSTMT)) {
struct lysc_node *data;
struct lysc_node_action *rpc;
struct lysc_node_notif *notif;
LY_LIST_FOR(modc->data, data) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprc_node(ctx, data);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprc_node(pctx, data);
}
- YPR_EXTRA_LINE(modc->data, ctx);
+ YPR_EXTRA_LINE(modc->data, pctx);
LY_LIST_FOR(modc->rpcs, rpc) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprc_action(ctx, rpc);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprc_action(pctx, rpc);
}
- YPR_EXTRA_LINE(modc->rpcs, ctx);
+ YPR_EXTRA_LINE(modc->rpcs, pctx);
LY_LIST_FOR(modc->notifs, notif) {
- YPR_EXTRA_LINE_PRINT(ctx);
- yprc_notification(ctx, notif);
+ YPR_EXTRA_LINE_PRINT(pctx);
+ yprc_notification(pctx, notif);
}
- YPR_EXTRA_LINE(modc->notifs, ctx);
+ YPR_EXTRA_LINE(modc->notifs, pctx);
}
LEVEL--;
@@ -2409,7 +2415,7 @@
* @param[in] count Number of extensions to print, 0 to print them all.
*/
static void
-yprc_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,
+yprc_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)
{
LY_ARRAY_COUNT_TYPE u;
@@ -2429,31 +2435,31 @@
continue;
}
- ypr_open(ctx->out, flag);
+ ypr_open(pctx->out, flag);
if (ext[u].argument) {
- ly_print_(ctx->out, "%*s%s:%s \"", INDENT, ext[u].def->module->name, ext[u].def->name);
- ypr_encode(ctx->out, ext[u].argument, -1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*s%s:%s \"", INDENT, ext[u].def->module->name, ext[u].def->name);
+ ypr_encode(pctx->out, ext[u].argument, -1);
+ ly_print_(pctx->out, "\"");
} else {
- ly_print_(ctx->out, "%*s%s:%s", INDENT, ext[u].def->module->name, ext[u].def->name);
+ ly_print_(pctx->out, "%*s%s:%s", INDENT, ext[u].def->module->name, ext[u].def->name);
}
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_EXTENSION_INSTANCE, 0, ext[u].exts, &inner_flag, 0);
+ yprc_extension_instances(pctx, LY_STMT_EXTENSION_INSTANCE, 0, ext[u].exts, &inner_flag, 0);
if (ext[u].def->plugin && ext[u].def->plugin->sprinter) {
- ext[u].def->plugin->sprinter(&ctx->printer_ctx, &ext[u], &inner_flag);
+ ext[u].def->plugin->sprinter(&pctx->printer_ctx, &ext[u], &inner_flag);
}
LEVEL--;
- ypr_close(ctx, inner_flag);
+ ypr_close(pctx, inner_flag);
}
}
void
lysc_print_extension_instance(struct lyspr_ctx *ctx_generic, const struct lysc_ext_instance *ext, ly_bool *flag)
{
- struct lys_ypr_ctx *ctx = (struct lys_ypr_ctx *)ctx_generic;
+ struct lys_ypr_ctx *pctx = (struct lys_ypr_ctx *)ctx_generic;
LY_ARRAY_COUNT_TYPE u, v;
LY_ARRAY_FOR(ext->substmts, u) {
@@ -2463,8 +2469,8 @@
const struct lysc_node *node;
LY_LIST_FOR(*(const struct lysc_node **)ext->substmts[u].storage, node) {
- ypr_open(ctx->out, flag);
- yprc_node(ctx, node);
+ ypr_open(pctx->out, flag);
+ yprc_node(pctx, node);
}
break;
}
@@ -2473,14 +2479,14 @@
case LY_STMT_UNITS:
if (ext->substmts[u].cardinality < LY_STMT_CARD_SOME) {
if (*(const char **)ext->substmts[u].storage) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, ext->exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, ext->exts);
}
} else {
const char **strings = *(const char ***)ext->substmts[u].storage;
LY_ARRAY_FOR(strings, v) {
- ypr_open(ctx->out, flag);
- ypr_substmt(ctx, ext->substmts[u].stmt, v, strings[v], ext->exts);
+ ypr_open(pctx->out, flag);
+ ypr_substmt(pctx, ext->substmts[u].stmt, v, strings[v], ext->exts);
}
}
break;
@@ -2488,25 +2494,25 @@
/* nothing to do */
break;
case LY_STMT_STATUS:
- ypr_status(ctx, *(uint16_t *)ext->substmts[u].storage, ext->exts, flag);
+ ypr_status(pctx, *(uint16_t *)ext->substmts[u].storage, ext->exts, flag);
break;
case LY_STMT_TYPE:
if (ext->substmts[u].cardinality < LY_STMT_CARD_SOME) {
if (*(const struct lysc_type **)ext->substmts[u].storage) {
- ypr_open(ctx->out, flag);
- yprc_type(ctx, *(const struct lysc_type **)ext->substmts[u].storage);
+ ypr_open(pctx->out, flag);
+ yprc_type(pctx, *(const struct lysc_type **)ext->substmts[u].storage);
}
} else {
const struct lysc_type **types = *(const struct lysc_type ***)ext->substmts[u].storage;
LY_ARRAY_FOR(types, v) {
- ypr_open(ctx->out, flag);
- yprc_type(ctx, types[v]);
+ ypr_open(pctx->out, flag);
+ yprc_type(pctx, types[v]);
}
}
break;
/* TODO support other substatements */
default:
- LOGWRN(ctx->module->ctx, "Statement \"%s\" is not supported for an extension printer.",
+ LOGWRN(pctx->module->ctx, "Statement \"%s\" is not supported for an extension printer.",
ly_stmt2str(ext->substmts[u].stmt));
break;
}
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 8883b68..9739ede 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -47,30 +47,30 @@
/* YIN printer specific members */
};
-static void yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,
+static void yprp_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysp_ext_instance *ext, int8_t *flag, LY_ARRAY_COUNT_TYPE count);
static void
-ypr_open(struct lys_ypr_ctx *ctx, const char *elem_name, const char *attr_name, const char *attr_value, int8_t flag)
+ypr_open(struct lys_ypr_ctx *pctx, const char *elem_name, const char *attr_name, const char *attr_value, int8_t flag)
{
- ly_print_(ctx->out, "%*s<%s", INDENT, elem_name);
+ ly_print_(pctx->out, "%*s<%s", INDENT, elem_name);
if (attr_name) {
- ly_print_(ctx->out, " %s=\"", attr_name);
- lyxml_dump_text(ctx->out, attr_value, 1);
- ly_print_(ctx->out, "\"%s", flag == -1 ? "/>\n" : flag == 1 ? ">\n" : "");
+ ly_print_(pctx->out, " %s=\"", attr_name);
+ lyxml_dump_text(pctx->out, attr_value, 1);
+ ly_print_(pctx->out, "\"%s", flag == -1 ? "/>\n" : flag == 1 ? ">\n" : "");
} else if (flag) {
- ly_print_(ctx->out, flag == -1 ? "/>\n" : ">\n");
+ ly_print_(pctx->out, flag == -1 ? "/>\n" : ">\n");
}
}
static void
-ypr_close(struct lys_ypr_ctx *ctx, const char *elem_name, int8_t flag)
+ypr_close(struct lys_ypr_ctx *pctx, const char *elem_name, int8_t flag)
{
if (flag) {
- ly_print_(ctx->out, "%*s</%s>\n", INDENT, elem_name);
+ ly_print_(pctx->out, "%*s</%s>\n", INDENT, elem_name);
} else {
- ly_print_(ctx->out, "/>\n");
+ ly_print_(pctx->out, "/>\n");
}
}
@@ -80,24 +80,24 @@
* 1 or NULL - parent already closed, do nothing
*/
static void
-ypr_close_parent(struct lys_ypr_ctx *ctx, int8_t *par_close_flag)
+ypr_close_parent(struct lys_ypr_ctx *pctx, int8_t *par_close_flag)
{
if (par_close_flag && !(*par_close_flag)) {
(*par_close_flag) = 1;
- ly_print_(ctx->out, ">\n");
+ ly_print_(pctx->out, ">\n");
}
}
static void
-ypr_yin_arg(struct lys_ypr_ctx *ctx, const char *arg, const char *text)
+ypr_yin_arg(struct lys_ypr_ctx *pctx, const char *arg, const char *text)
{
- ly_print_(ctx->out, "%*s<%s>", INDENT, arg);
- lyxml_dump_text(ctx->out, text, 0);
- ly_print_(ctx->out, "</%s>\n", arg);
+ ly_print_(pctx->out, "%*s<%s>", INDENT, arg);
+ lyxml_dump_text(pctx->out, text, 0);
+ ly_print_(pctx->out, "</%s>\n", arg);
}
static void
-ypr_substmt(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)
+ypr_substmt(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)
{
LY_ARRAY_COUNT_TYPE u;
int8_t extflag = 0;
@@ -109,9 +109,9 @@
if (stmt_attr_info[substmt].flags & STMT_FLAG_YIN) {
extflag = 1;
- ypr_open(ctx, stmt_attr_info[substmt].name, NULL, NULL, extflag);
+ ypr_open(pctx, stmt_attr_info[substmt].name, NULL, NULL, extflag);
} else {
- ypr_open(ctx, stmt_attr_info[substmt].name, stmt_attr_info[substmt].arg, text, extflag);
+ ypr_open(pctx, stmt_attr_info[substmt].name, stmt_attr_info[substmt].arg, text, extflag);
}
LEVEL++;
@@ -119,223 +119,223 @@
if ((((struct lysp_ext_instance *)ext)[u].parent_stmt != substmt) || (((struct lysp_ext_instance *)ext)[u].parent_stmt_index != substmt_index)) {
continue;
}
- yprp_extension_instances(ctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
+ yprp_extension_instances(pctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
}
/* argument as yin-element */
if (stmt_attr_info[substmt].flags & STMT_FLAG_YIN) {
- ypr_yin_arg(ctx, stmt_attr_info[substmt].arg, text);
+ ypr_yin_arg(pctx, stmt_attr_info[substmt].arg, text);
}
LEVEL--;
- ypr_close(ctx, stmt_attr_info[substmt].name, extflag);
+ ypr_close(pctx, stmt_attr_info[substmt].name, extflag);
}
static void
-ypr_unsigned(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value)
+ypr_unsigned(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value)
{
char *str;
if (asprintf(&str, "%lu", attr_value) == -1) {
- LOGMEM(ctx->module->ctx);
+ LOGMEM(pctx->module->ctx);
return;
}
- ypr_substmt(ctx, substmt, substmt_index, str, exts);
+ ypr_substmt(pctx, substmt, substmt_index, str, exts);
free(str);
}
static void
-ypr_signed(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value)
+ypr_signed(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value)
{
char *str;
if (asprintf(&str, "%ld", attr_value) == -1) {
- LOGMEM(ctx->module->ctx);
+ LOGMEM(pctx->module->ctx);
return;
}
- ypr_substmt(ctx, substmt, substmt_index, str, exts);
+ ypr_substmt(pctx, substmt, substmt_index, str, exts);
free(str);
}
static void
-yprp_revision(struct lys_ypr_ctx *ctx, const struct lysp_revision *rev)
+yprp_revision(struct lys_ypr_ctx *pctx, const struct lysp_revision *rev)
{
if (rev->dsc || rev->ref || rev->exts) {
- ypr_open(ctx, "revision", "date", rev->date, 1);
+ ypr_open(pctx, "revision", "date", rev->date, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
+ yprp_extension_instances(pctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
LEVEL--;
- ypr_close(ctx, "revision", 1);
+ ypr_close(pctx, "revision", 1);
} else {
- ypr_open(ctx, "revision", "date", rev->date, -1);
+ ypr_open(pctx, "revision", "date", rev->date, -1);
}
}
static void
-ypr_mandatory(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)
+ypr_mandatory(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, int8_t *flag)
{
if (flags & LYS_MAND_MASK) {
- ypr_close_parent(ctx, flag);
- ypr_substmt(ctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);
+ ypr_close_parent(pctx, flag);
+ ypr_substmt(pctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);
}
}
static void
-ypr_config(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)
+ypr_config(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, int8_t *flag)
{
if (flags & LYS_CONFIG_MASK) {
- ypr_close_parent(ctx, flag);
- ypr_substmt(ctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);
+ ypr_close_parent(pctx, flag);
+ ypr_substmt(pctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);
}
}
static void
-ypr_status(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)
+ypr_status(struct lys_ypr_ctx *pctx, uint16_t flags, void *exts, int8_t *flag)
{
const char *status = NULL;
if (flags & LYS_STATUS_CURR) {
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
status = "current";
} else if (flags & LYS_STATUS_DEPRC) {
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
status = "deprecated";
} else if (flags & LYS_STATUS_OBSLT) {
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
status = "obsolete";
}
- ypr_substmt(ctx, LY_STMT_STATUS, 0, status, exts);
+ ypr_substmt(pctx, LY_STMT_STATUS, 0, status, exts);
}
static void
-ypr_description(struct lys_ypr_ctx *ctx, const char *dsc, void *exts, int8_t *flag)
+ypr_description(struct lys_ypr_ctx *pctx, const char *dsc, void *exts, int8_t *flag)
{
if (dsc) {
- ypr_close_parent(ctx, flag);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, dsc, exts);
+ ypr_close_parent(pctx, flag);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, dsc, exts);
}
}
static void
-ypr_reference(struct lys_ypr_ctx *ctx, const char *ref, void *exts, int8_t *flag)
+ypr_reference(struct lys_ypr_ctx *pctx, const char *ref, void *exts, int8_t *flag)
{
if (ref) {
- ypr_close_parent(ctx, flag);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, ref, exts);
+ ypr_close_parent(pctx, flag);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, ref, exts);
}
}
static void
-yprp_iffeatures(struct lys_ypr_ctx *ctx, struct lysp_qname *iffs, struct lysp_ext_instance *exts, int8_t *flag)
+yprp_iffeatures(struct lys_ypr_ctx *pctx, struct lysp_qname *iffs, struct lysp_ext_instance *exts, int8_t *flag)
{
LY_ARRAY_COUNT_TYPE u, v;
int8_t extflag;
LY_ARRAY_FOR(iffs, u) {
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
extflag = 0;
- ly_print_(ctx->out, "%*s<if-feature name=\"%s", INDENT, iffs[u].str);
+ ly_print_(pctx->out, "%*s<if-feature name=\"%s", INDENT, iffs[u].str);
/* extensions */
LEVEL++;
LY_ARRAY_FOR(exts, v) {
- yprp_extension_instances(ctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);
+ yprp_extension_instances(pctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);
}
LEVEL--;
- ly_print_(ctx->out, "\"/>\n");
+ ly_print_(pctx->out, "\"/>\n");
}
}
static void
-yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)
+yprp_extension(struct lys_ypr_ctx *pctx, const struct lysp_ext *ext)
{
int8_t flag = 0, flag2 = 0;
LY_ARRAY_COUNT_TYPE u;
- ypr_open(ctx, "extension", "name", ext->name, flag);
+ ypr_open(pctx, "extension", "name", ext->name, flag);
LEVEL++;
if (ext->exts) {
- ypr_close_parent(ctx, &flag);
- yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
+ ypr_close_parent(pctx, &flag);
+ yprp_extension_instances(pctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
if (ext->argname) {
- ypr_close_parent(ctx, &flag);
- ypr_open(ctx, "argument", "name", ext->argname, flag2);
+ ypr_close_parent(pctx, &flag);
+ ypr_open(pctx, "argument", "name", ext->argname, flag2);
LEVEL++;
if (ext->exts) {
u = -1;
while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LY_STMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {
- ypr_close_parent(ctx, &flag2);
- yprp_extension_instances(ctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
+ ypr_close_parent(pctx, &flag2);
+ yprp_extension_instances(pctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
}
}
if ((ext->flags & LYS_YINELEM_MASK) ||
(ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LY_STMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {
- ypr_close_parent(ctx, &flag2);
- ypr_substmt(ctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
+ ypr_close_parent(pctx, &flag2);
+ ypr_substmt(pctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
}
LEVEL--;
- ypr_close(ctx, "argument", flag2);
+ ypr_close(pctx, "argument", flag2);
}
- ypr_status(ctx, ext->flags, ext->exts, &flag);
- ypr_description(ctx, ext->dsc, ext->exts, &flag);
- ypr_reference(ctx, ext->ref, ext->exts, &flag);
+ ypr_status(pctx, ext->flags, ext->exts, &flag);
+ ypr_description(pctx, ext->dsc, ext->exts, &flag);
+ ypr_reference(pctx, ext->ref, ext->exts, &flag);
LEVEL--;
- ypr_close(ctx, "extension", flag);
+ ypr_close(pctx, "extension", flag);
}
static void
-yprp_feature(struct lys_ypr_ctx *ctx, const struct lysp_feature *feat)
+yprp_feature(struct lys_ypr_ctx *pctx, const struct lysp_feature *feat)
{
int8_t flag = 0;
- ypr_open(ctx, "feature", "name", feat->name, flag);
+ ypr_open(pctx, "feature", "name", feat->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
- yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);
- ypr_status(ctx, feat->flags, feat->exts, &flag);
- ypr_description(ctx, feat->dsc, feat->exts, &flag);
- ypr_reference(ctx, feat->ref, feat->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
+ yprp_iffeatures(pctx, feat->iffeatures, feat->exts, &flag);
+ ypr_status(pctx, feat->flags, feat->exts, &flag);
+ ypr_description(pctx, feat->dsc, feat->exts, &flag);
+ ypr_reference(pctx, feat->ref, feat->exts, &flag);
LEVEL--;
- ypr_close(ctx, "feature", flag);
+ ypr_close(pctx, "feature", flag);
}
static void
-yprp_identity(struct lys_ypr_ctx *ctx, const struct lysp_ident *ident)
+yprp_identity(struct lys_ypr_ctx *pctx, const struct lysp_ident *ident)
{
int8_t flag = 0;
LY_ARRAY_COUNT_TYPE u;
- ypr_open(ctx, "identity", "name", ident->name, flag);
+ ypr_open(pctx, "identity", "name", ident->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
- yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
+ yprp_iffeatures(pctx, ident->iffeatures, ident->exts, &flag);
LY_ARRAY_FOR(ident->bases, u) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);
}
- ypr_status(ctx, ident->flags, ident->exts, &flag);
- ypr_description(ctx, ident->dsc, ident->exts, &flag);
- ypr_reference(ctx, ident->ref, ident->exts, &flag);
+ ypr_status(pctx, ident->flags, ident->exts, &flag);
+ ypr_description(pctx, ident->dsc, ident->exts, &flag);
+ ypr_reference(pctx, ident->ref, ident->exts, &flag);
LEVEL--;
- ypr_close(ctx, "identity", flag);
+ ypr_close(pctx, "identity", flag);
}
static void
-yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, enum ly_stmt stmt, const char *attr, int8_t *flag)
+yprp_restr(struct lys_ypr_ctx *pctx, const struct lysp_restr *restr, enum ly_stmt stmt, const char *attr, int8_t *flag)
{
(void)flag;
int8_t inner_flag = 0;
@@ -344,36 +344,36 @@
return;
}
- ly_print_(ctx->out, "%*s<%s %s=\"", INDENT, ly_stmt2str(stmt), attr);
- lyxml_dump_text(ctx->out,
+ ly_print_(pctx->out, "%*s<%s %s=\"", INDENT, ly_stmt2str(stmt), attr);
+ lyxml_dump_text(pctx->out,
(restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK && restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK) ?
restr->arg.str : &restr->arg.str[1], 1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, stmt, 0, restr->exts, &inner_flag, 0);
+ yprp_extension_instances(pctx, stmt, 0, restr->exts, &inner_flag, 0);
if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {
- ypr_close_parent(ctx, &inner_flag);
+ ypr_close_parent(pctx, &inner_flag);
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
- ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);
+ ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);
}
if (restr->emsg) {
- ypr_close_parent(ctx, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);
+ ypr_close_parent(pctx, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);
}
if (restr->eapptag) {
- ypr_close_parent(ctx, &inner_flag);
- ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);
+ ypr_close_parent(pctx, &inner_flag);
+ ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);
}
- ypr_description(ctx, restr->dsc, restr->exts, &inner_flag);
- ypr_reference(ctx, restr->ref, restr->exts, &inner_flag);
+ ypr_description(pctx, restr->dsc, restr->exts, &inner_flag);
+ ypr_reference(pctx, restr->ref, restr->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, ly_stmt2str(stmt), inner_flag);
+ ypr_close(pctx, ly_stmt2str(stmt), inner_flag);
}
static void
-yprp_when(struct lys_ypr_ctx *ctx, struct lysp_when *when, int8_t *flag)
+yprp_when(struct lys_ypr_ctx *pctx, struct lysp_when *when, int8_t *flag)
{
int8_t inner_flag = 0;
@@ -381,21 +381,21 @@
return;
}
- ypr_close_parent(ctx, flag);
- ly_print_(ctx->out, "%*s<when condition=\"", INDENT);
- lyxml_dump_text(ctx->out, when->cond, 1);
- ly_print_(ctx->out, "\"");
+ ypr_close_parent(pctx, flag);
+ ly_print_(pctx->out, "%*s<when condition=\"", INDENT);
+ lyxml_dump_text(pctx->out, when->cond, 1);
+ ly_print_(pctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
- ypr_description(ctx, when->dsc, when->exts, &inner_flag);
- ypr_reference(ctx, when->ref, when->exts, &inner_flag);
+ yprp_extension_instances(pctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
+ ypr_description(pctx, when->dsc, when->exts, &inner_flag);
+ ypr_reference(pctx, when->ref, when->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, "when", inner_flag);
+ ypr_close(pctx, "when", inner_flag);
}
static void
-yprp_enum(struct lys_ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, int8_t *flag)
+yprp_enum(struct lys_ypr_ctx *pctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, int8_t *flag)
{
LY_ARRAY_COUNT_TYPE u;
int8_t inner_flag;
@@ -404,117 +404,117 @@
LY_ARRAY_FOR(items, u) {
if (type == LY_TYPE_BITS) {
- ly_print_(ctx->out, "%*s<bit name=\"", INDENT);
- lyxml_dump_text(ctx->out, items[u].name, 1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*s<bit name=\"", INDENT);
+ lyxml_dump_text(pctx->out, items[u].name, 1);
+ ly_print_(pctx->out, "\"");
} else { /* LY_TYPE_ENUM */
- ly_print_(ctx->out, "%*s<enum name=\"", INDENT);
- lyxml_dump_text(ctx->out, items[u].name, 1);
- ly_print_(ctx->out, "\"");
+ ly_print_(pctx->out, "%*s<enum name=\"", INDENT);
+ lyxml_dump_text(pctx->out, items[u].name, 1);
+ ly_print_(pctx->out, "\"");
}
inner_flag = 0;
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
- yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);
+ yprp_extension_instances(pctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
+ yprp_iffeatures(pctx, items[u].iffeatures, items[u].exts, &inner_flag);
if (items[u].flags & LYS_SET_VALUE) {
if (type == LY_TYPE_BITS) {
- ypr_close_parent(ctx, &inner_flag);
- ypr_unsigned(ctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value);
+ ypr_close_parent(pctx, &inner_flag);
+ ypr_unsigned(pctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value);
} else { /* LY_TYPE_ENUM */
- ypr_close_parent(ctx, &inner_flag);
- ypr_signed(ctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value);
+ ypr_close_parent(pctx, &inner_flag);
+ ypr_signed(pctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value);
}
}
- ypr_status(ctx, items[u].flags, items[u].exts, &inner_flag);
- ypr_description(ctx, items[u].dsc, items[u].exts, &inner_flag);
- ypr_reference(ctx, items[u].ref, items[u].exts, &inner_flag);
+ ypr_status(pctx, items[u].flags, items[u].exts, &inner_flag);
+ ypr_description(pctx, items[u].dsc, items[u].exts, &inner_flag);
+ ypr_reference(pctx, items[u].ref, items[u].exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, type == LY_TYPE_BITS ? "bit" : "enum", inner_flag);
+ ypr_close(pctx, type == LY_TYPE_BITS ? "bit" : "enum", inner_flag);
}
}
static void
-yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)
+yprp_type(struct lys_ypr_ctx *pctx, const struct lysp_type *type)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
- if (!ctx || !type) {
+ if (!pctx || !type) {
return;
}
- ypr_open(ctx, "type", "name", type->name, flag);
+ ypr_open(pctx, "type", "name", type->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
+ yprp_extension_instances(pctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
if (type->range || type->length || type->patterns || type->bits || type->enums) {
- ypr_close_parent(ctx, &flag);
+ ypr_close_parent(pctx, &flag);
}
- yprp_restr(ctx, type->range, LY_STMT_RANGE, "value", &flag);
- yprp_restr(ctx, type->length, LY_STMT_LENGTH, "value", &flag);
+ yprp_restr(pctx, type->range, LY_STMT_RANGE, "value", &flag);
+ yprp_restr(pctx, type->length, LY_STMT_LENGTH, "value", &flag);
LY_ARRAY_FOR(type->patterns, u) {
- yprp_restr(ctx, &type->patterns[u], LY_STMT_PATTERN, "value", &flag);
+ yprp_restr(pctx, &type->patterns[u], LY_STMT_PATTERN, "value", &flag);
}
- yprp_enum(ctx, type->bits, LY_TYPE_BITS, &flag);
- yprp_enum(ctx, type->enums, LY_TYPE_ENUM, &flag);
+ yprp_enum(pctx, type->bits, LY_TYPE_BITS, &flag);
+ yprp_enum(pctx, type->enums, LY_TYPE_ENUM, &flag);
if (type->path) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_PATH, 0, type->path->expr, type->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_PATH, 0, type->path->expr, type->exts);
}
if (type->flags & LYS_SET_REQINST) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);
}
if (type->flags & LYS_SET_FRDIGITS) {
- ypr_close_parent(ctx, &flag);
- ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits);
+ ypr_close_parent(pctx, &flag);
+ ypr_unsigned(pctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits);
}
LY_ARRAY_FOR(type->bases, u) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_BASE, u, type->bases[u], type->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_BASE, u, type->bases[u], type->exts);
}
LY_ARRAY_FOR(type->types, u) {
- ypr_close_parent(ctx, &flag);
- yprp_type(ctx, &type->types[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_type(pctx, &type->types[u]);
}
LEVEL--;
- ypr_close(ctx, "type", flag);
+ ypr_close(pctx, "type", flag);
}
static void
-yprp_typedef(struct lys_ypr_ctx *ctx, const struct lysp_tpdf *tpdf)
+yprp_typedef(struct lys_ypr_ctx *pctx, const struct lysp_tpdf *tpdf)
{
- ypr_open(ctx, "typedef", "name", tpdf->name, 1);
+ ypr_open(pctx, "typedef", "name", tpdf->name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
- yprp_type(ctx, &tpdf->type);
+ yprp_type(pctx, &tpdf->type);
if (tpdf->units) {
- ypr_substmt(ctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);
}
if (tpdf->dflt.str) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);
}
- ypr_status(ctx, tpdf->flags, tpdf->exts, NULL);
- ypr_description(ctx, tpdf->dsc, tpdf->exts, NULL);
- ypr_reference(ctx, tpdf->ref, tpdf->exts, NULL);
+ ypr_status(pctx, tpdf->flags, tpdf->exts, NULL);
+ ypr_description(pctx, tpdf->dsc, tpdf->exts, NULL);
+ ypr_reference(pctx, tpdf->ref, tpdf->exts, NULL);
LEVEL--;
- ypr_close(ctx, "typedef", 1);
+ ypr_close(pctx, "typedef", 1);
}
-static void yprp_node(struct lys_ypr_ctx *ctx, const struct lysp_node *node);
-static void yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action);
-static void yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif);
+static void yprp_node(struct lys_ypr_ctx *pctx, const struct lysp_node *node);
+static void yprp_action(struct lys_ypr_ctx *pctx, const struct lysp_node_action *action);
+static void yprp_notification(struct lys_ypr_ctx *pctx, const struct lysp_node_notif *notif);
static void
-yprp_grouping(struct lys_ypr_ctx *ctx, const struct lysp_node_grp *grp)
+yprp_grouping(struct lys_ypr_ctx *pctx, const struct lysp_node_grp *grp)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
@@ -523,45 +523,45 @@
struct lysp_node_notif *notif;
struct lysp_node_grp *subgrp;
- ypr_open(ctx, "grouping", "name", grp->name, flag);
+ ypr_open(pctx, "grouping", "name", grp->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
- ypr_status(ctx, grp->flags, grp->exts, &flag);
- ypr_description(ctx, grp->dsc, grp->exts, &flag);
- ypr_reference(ctx, grp->ref, grp->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
+ ypr_status(pctx, grp->flags, grp->exts, &flag);
+ ypr_description(pctx, grp->dsc, grp->exts, &flag);
+ ypr_reference(pctx, grp->ref, grp->exts, &flag);
LY_ARRAY_FOR(grp->typedefs, u) {
- ypr_close_parent(ctx, &flag);
- yprp_typedef(ctx, &grp->typedefs[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_typedef(pctx, &grp->typedefs[u]);
}
LY_LIST_FOR(grp->groupings, subgrp) {
- ypr_close_parent(ctx, &flag);
- yprp_grouping(ctx, subgrp);
+ ypr_close_parent(pctx, &flag);
+ yprp_grouping(pctx, subgrp);
}
LY_LIST_FOR(grp->child, data) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, data);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, data);
}
LY_LIST_FOR(grp->actions, action) {
- ypr_close_parent(ctx, &flag);
- yprp_action(ctx, action);
+ ypr_close_parent(pctx, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(grp->notifs, notif) {
- ypr_close_parent(ctx, &flag);
- yprp_notification(ctx, notif);
+ ypr_close_parent(pctx, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, "grouping", flag);
+ ypr_close(pctx, "grouping", flag);
}
static void
-yprp_inout(struct lys_ypr_ctx *ctx, const struct lysp_node_action_inout *inout, int8_t *flag)
+yprp_inout(struct lys_ypr_ctx *pctx, const struct lysp_node_action_inout *inout, int8_t *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
@@ -571,129 +571,129 @@
/* input/output is empty */
return;
}
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
- ypr_open(ctx, inout->name, NULL, NULL, *flag);
+ ypr_open(pctx, inout->name, NULL, NULL, *flag);
LEVEL++;
- yprp_extension_instances(ctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
+ yprp_extension_instances(pctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
- yprp_restr(ctx, &inout->musts[u], LY_STMT_MUST, "condition", NULL);
+ yprp_restr(pctx, &inout->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(inout->typedefs, u) {
- yprp_typedef(ctx, &inout->typedefs[u]);
+ yprp_typedef(pctx, &inout->typedefs[u]);
}
LY_LIST_FOR(inout->groupings, grp) {
- yprp_grouping(ctx, grp);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(inout->child, data) {
- yprp_node(ctx, data);
+ yprp_node(pctx, data);
}
LEVEL--;
- ypr_close(ctx, inout->name, 1);
+ ypr_close(pctx, inout->name, 1);
}
static void
-yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif)
+yprp_notification(struct lys_ypr_ctx *pctx, const struct lysp_node_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
struct lysp_node *data;
struct lysp_node_grp *grp;
- ypr_open(ctx, "notification", "name", notif->name, flag);
+ ypr_open(pctx, "notification", "name", notif->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
- yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
+ yprp_iffeatures(pctx, notif->iffeatures, notif->exts, &flag);
LY_ARRAY_FOR(notif->musts, u) {
- ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, ¬if->musts[u], LY_STMT_MUST, "condition", &flag);
+ ypr_close_parent(pctx, &flag);
+ yprp_restr(pctx, ¬if->musts[u], LY_STMT_MUST, "condition", &flag);
}
- ypr_status(ctx, notif->flags, notif->exts, &flag);
- ypr_description(ctx, notif->dsc, notif->exts, &flag);
- ypr_reference(ctx, notif->ref, notif->exts, &flag);
+ ypr_status(pctx, notif->flags, notif->exts, &flag);
+ ypr_description(pctx, notif->dsc, notif->exts, &flag);
+ ypr_reference(pctx, notif->ref, notif->exts, &flag);
LY_ARRAY_FOR(notif->typedefs, u) {
- ypr_close_parent(ctx, &flag);
- yprp_typedef(ctx, ¬if->typedefs[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_typedef(pctx, ¬if->typedefs[u]);
}
LY_LIST_FOR(notif->groupings, grp) {
- ypr_close_parent(ctx, &flag);
- yprp_grouping(ctx, grp);
+ ypr_close_parent(pctx, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(notif->child, data) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, data);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, data);
}
LEVEL--;
- ypr_close(ctx, "notification", flag);
+ ypr_close(pctx, "notification", flag);
}
static void
-yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action)
+yprp_action(struct lys_ypr_ctx *pctx, const struct lysp_node_action *action)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
struct lysp_node_grp *grp;
- ypr_open(ctx, action->parent ? "action" : "rpc", "name", action->name, flag);
+ ypr_open(pctx, action->parent ? "action" : "rpc", "name", action->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
- yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);
- ypr_status(ctx, action->flags, action->exts, &flag);
- ypr_description(ctx, action->dsc, action->exts, &flag);
- ypr_reference(ctx, action->ref, action->exts, &flag);
+ yprp_extension_instances(pctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
+ yprp_iffeatures(pctx, action->iffeatures, action->exts, &flag);
+ ypr_status(pctx, action->flags, action->exts, &flag);
+ ypr_description(pctx, action->dsc, action->exts, &flag);
+ ypr_reference(pctx, action->ref, action->exts, &flag);
LY_ARRAY_FOR(action->typedefs, u) {
- ypr_close_parent(ctx, &flag);
- yprp_typedef(ctx, &action->typedefs[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_typedef(pctx, &action->typedefs[u]);
}
LY_LIST_FOR(action->groupings, grp) {
- ypr_close_parent(ctx, &flag);
- yprp_grouping(ctx, grp);
+ ypr_close_parent(pctx, &flag);
+ yprp_grouping(pctx, grp);
}
- yprp_inout(ctx, &action->input, &flag);
- yprp_inout(ctx, &action->output, &flag);
+ yprp_inout(pctx, &action->input, &flag);
+ yprp_inout(pctx, &action->output, &flag);
LEVEL--;
- ypr_close(ctx, action->parent ? "action" : "rpc", flag);
+ ypr_close(pctx, action->parent ? "action" : "rpc", flag);
}
static void
-yprp_node_common1(struct lys_ypr_ctx *ctx, const struct lysp_node *node, int8_t *flag)
+yprp_node_common1(struct lys_ypr_ctx *pctx, const struct lysp_node *node, int8_t *flag)
{
- ypr_open(ctx, lys_nodetype2str(node->nodetype), "name", node->name, *flag);
+ ypr_open(pctx, lys_nodetype2str(node->nodetype), "name", node->name, *flag);
LEVEL++;
- yprp_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
- yprp_when(ctx, lysp_node_when(node), flag);
- yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);
+ yprp_extension_instances(pctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
+ yprp_when(pctx, lysp_node_when(node), flag);
+ yprp_iffeatures(pctx, node->iffeatures, node->exts, flag);
}
static void
-yprp_node_common2(struct lys_ypr_ctx *ctx, const struct lysp_node *node, int8_t *flag)
+yprp_node_common2(struct lys_ypr_ctx *pctx, const struct lysp_node *node, int8_t *flag)
{
- ypr_config(ctx, node->flags, node->exts, flag);
+ ypr_config(pctx, node->flags, node->exts, flag);
if (node->nodetype & (LYS_CHOICE | LYS_LEAF | LYS_ANYDATA)) {
- ypr_mandatory(ctx, node->flags, node->exts, flag);
+ ypr_mandatory(pctx, node->flags, node->exts, flag);
}
- ypr_status(ctx, node->flags, node->exts, flag);
- ypr_description(ctx, node->dsc, node->exts, flag);
- ypr_reference(ctx, node->ref, node->exts, flag);
+ ypr_status(pctx, node->flags, node->exts, flag);
+ ypr_description(pctx, node->dsc, node->exts, flag);
+ ypr_reference(pctx, node->ref, node->exts, flag);
}
static void
-yprp_container(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_container(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
@@ -703,160 +703,160 @@
struct lysp_node_grp *grp;
struct lysp_node_container *cont = (struct lysp_node_container *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(cont->musts, u) {
- ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &cont->musts[u], LY_STMT_MUST, "condition", &flag);
+ ypr_close_parent(pctx, &flag);
+ yprp_restr(pctx, &cont->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (cont->presence) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_ARRAY_FOR(cont->typedefs, u) {
- ypr_close_parent(ctx, &flag);
- yprp_typedef(ctx, &cont->typedefs[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_typedef(pctx, &cont->typedefs[u]);
}
LY_LIST_FOR(cont->groupings, grp) {
- ypr_close_parent(ctx, &flag);
- yprp_grouping(ctx, grp);
+ ypr_close_parent(pctx, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(cont->child, child) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, child);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(cont->actions, action) {
- ypr_close_parent(ctx, &flag);
- yprp_action(ctx, action);
+ ypr_close_parent(pctx, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(cont->notifs, notif) {
- ypr_close_parent(ctx, &flag);
- yprp_notification(ctx, notif);
+ ypr_close_parent(pctx, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, "container", flag);
+ ypr_close(pctx, "container", flag);
}
static void
-yprp_case(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_case(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
int8_t flag = 0;
struct lysp_node *child;
struct lysp_node_case *cas = (struct lysp_node_case *)node;
- yprp_node_common1(ctx, node, &flag);
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_LIST_FOR(cas->child, child) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, child);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, child);
}
LEVEL--;
- ypr_close(ctx, "case", flag);
+ ypr_close(pctx, "case", flag);
}
static void
-yprp_choice(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_choice(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
int8_t flag = 0;
struct lysp_node *child;
struct lysp_node_choice *choice = (struct lysp_node_choice *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
if (choice->dflt.str) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_LIST_FOR(choice->child, child) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, child);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, child);
}
LEVEL--;
- ypr_close(ctx, "choice", flag);
+ ypr_close(pctx, "choice", flag);
}
static void
-yprp_leaf(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_leaf(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node;
int8_t flag = 1;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
- yprp_type(ctx, &leaf->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
+ yprp_type(pctx, &leaf->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
LY_ARRAY_FOR(leaf->musts, u) {
- yprp_restr(ctx, &leaf->musts[u], LY_STMT_MUST, "condition", &flag);
+ yprp_restr(pctx, &leaf->musts[u], LY_STMT_MUST, "condition", &flag);
}
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LEVEL--;
- ypr_close(ctx, "leaf", flag);
+ ypr_close(pctx, "leaf", flag);
}
static void
-yprp_leaflist(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_leaflist(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node;
int8_t flag = 1;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
- yprp_type(ctx, &llist->type);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
+ yprp_type(pctx, &llist->type);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
LY_ARRAY_FOR(llist->musts, u) {
- yprp_restr(ctx, &llist->musts[u], LY_STMT_MUST, "condition", NULL);
+ yprp_restr(pctx, &llist->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
}
- ypr_config(ctx, node->flags, node->exts, NULL);
+ ypr_config(pctx, node->flags, node->exts, NULL);
if (llist->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min);
}
if (llist->flags & LYS_SET_MAX) {
if (llist->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
}
}
if (llist->flags & LYS_ORDBY_MASK) {
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
}
- ypr_status(ctx, node->flags, node->exts, &flag);
- ypr_description(ctx, node->dsc, node->exts, &flag);
- ypr_reference(ctx, node->ref, node->exts, &flag);
+ ypr_status(pctx, node->flags, node->exts, &flag);
+ ypr_description(pctx, node->dsc, node->exts, &flag);
+ ypr_reference(pctx, node->ref, node->exts, &flag);
LEVEL--;
- ypr_close(ctx, "leaf-list", flag);
+ ypr_close(pctx, "leaf-list", flag);
}
static void
-yprp_list(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_list(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
@@ -866,228 +866,228 @@
struct lysp_node_grp *grp;
struct lysp_node_list *list = (struct lysp_node_list *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(list->musts, u) {
- ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &list->musts[u], LY_STMT_MUST, "condition", &flag);
+ ypr_close_parent(pctx, &flag);
+ yprp_restr(pctx, &list->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (list->key) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_KEY, 0, list->key, list->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_KEY, 0, list->key, list->exts);
}
LY_ARRAY_FOR(list->uniques, u) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);
}
- ypr_config(ctx, node->flags, node->exts, NULL);
+ ypr_config(pctx, node->flags, node->exts, NULL);
if (list->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min);
}
if (list->flags & LYS_SET_MAX) {
if (list->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
}
}
if (list->flags & LYS_ORDBY_MASK) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
}
- ypr_status(ctx, node->flags, node->exts, &flag);
- ypr_description(ctx, node->dsc, node->exts, &flag);
- ypr_reference(ctx, node->ref, node->exts, &flag);
+ ypr_status(pctx, node->flags, node->exts, &flag);
+ ypr_description(pctx, node->dsc, node->exts, &flag);
+ ypr_reference(pctx, node->ref, node->exts, &flag);
LY_ARRAY_FOR(list->typedefs, u) {
- ypr_close_parent(ctx, &flag);
- yprp_typedef(ctx, &list->typedefs[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_typedef(pctx, &list->typedefs[u]);
}
LY_LIST_FOR(list->groupings, grp) {
- ypr_close_parent(ctx, &flag);
- yprp_grouping(ctx, grp);
+ ypr_close_parent(pctx, &flag);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(list->child, child) {
- ypr_close_parent(ctx, &flag);
- yprp_node(ctx, child);
+ ypr_close_parent(pctx, &flag);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(list->actions, action) {
- ypr_close_parent(ctx, &flag);
- yprp_action(ctx, action);
+ ypr_close_parent(pctx, &flag);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(list->notifs, notif) {
- ypr_close_parent(ctx, &flag);
- yprp_notification(ctx, notif);
+ ypr_close_parent(pctx, &flag);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, "list", flag);
+ ypr_close(pctx, "list", flag);
}
static void
-yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)
+yprp_refine(struct lys_ypr_ctx *pctx, struct lysp_refine *refine)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
- ypr_open(ctx, "refine", "target-node", refine->nodeid, flag);
+ ypr_open(pctx, "refine", "target-node", refine->nodeid, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
- yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);
+ yprp_extension_instances(pctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
+ yprp_iffeatures(pctx, refine->iffeatures, refine->exts, &flag);
LY_ARRAY_FOR(refine->musts, u) {
- ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &refine->musts[u], LY_STMT_MUST, "condition", &flag);
+ ypr_close_parent(pctx, &flag);
+ yprp_restr(pctx, &refine->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (refine->presence) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);
}
LY_ARRAY_FOR(refine->dflts, u) {
- ypr_close_parent(ctx, &flag);
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);
+ ypr_close_parent(pctx, &flag);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);
}
- ypr_config(ctx, refine->flags, refine->exts, &flag);
- ypr_mandatory(ctx, refine->flags, refine->exts, &flag);
+ ypr_config(pctx, refine->flags, refine->exts, &flag);
+ ypr_mandatory(pctx, refine->flags, refine->exts, &flag);
if (refine->flags & LYS_SET_MIN) {
- ypr_close_parent(ctx, &flag);
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min);
+ ypr_close_parent(pctx, &flag);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min);
}
if (refine->flags & LYS_SET_MAX) {
- ypr_close_parent(ctx, &flag);
+ ypr_close_parent(pctx, &flag);
if (refine->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);
}
}
- ypr_description(ctx, refine->dsc, refine->exts, &flag);
- ypr_reference(ctx, refine->ref, refine->exts, &flag);
+ ypr_description(pctx, refine->dsc, refine->exts, &flag);
+ ypr_reference(pctx, refine->ref, refine->exts, &flag);
LEVEL--;
- ypr_close(ctx, "refine", flag);
+ ypr_close(pctx, "refine", flag);
}
static void
-yprp_augment(struct lys_ypr_ctx *ctx, const struct lysp_node_augment *aug)
+yprp_augment(struct lys_ypr_ctx *pctx, const struct lysp_node_augment *aug)
{
struct lysp_node *child;
struct lysp_node_action *action;
struct lysp_node_notif *notif;
- ypr_open(ctx, "augment", "target-node", aug->nodeid, 1);
+ ypr_open(pctx, "augment", "target-node", aug->nodeid, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
- yprp_when(ctx, aug->when, NULL);
- yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);
- ypr_status(ctx, aug->flags, aug->exts, NULL);
- ypr_description(ctx, aug->dsc, aug->exts, NULL);
- ypr_reference(ctx, aug->ref, aug->exts, NULL);
+ yprp_extension_instances(pctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
+ yprp_when(pctx, aug->when, NULL);
+ yprp_iffeatures(pctx, aug->iffeatures, aug->exts, NULL);
+ ypr_status(pctx, aug->flags, aug->exts, NULL);
+ ypr_description(pctx, aug->dsc, aug->exts, NULL);
+ ypr_reference(pctx, aug->ref, aug->exts, NULL);
LY_LIST_FOR(aug->child, child) {
- yprp_node(ctx, child);
+ yprp_node(pctx, child);
}
LY_LIST_FOR(aug->actions, action) {
- yprp_action(ctx, action);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(aug->notifs, notif) {
- yprp_notification(ctx, notif);
+ yprp_notification(pctx, notif);
}
LEVEL--;
- ypr_close(ctx, "augment", 1);
+ ypr_close(pctx, "augment", 1);
}
static void
-yprp_uses(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_uses(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
struct lysp_node_augment *aug;
- yprp_node_common1(ctx, node, &flag);
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LY_ARRAY_FOR(uses->refines, u) {
- ypr_close_parent(ctx, &flag);
- yprp_refine(ctx, &uses->refines[u]);
+ ypr_close_parent(pctx, &flag);
+ yprp_refine(pctx, &uses->refines[u]);
}
LY_LIST_FOR(uses->augments, aug) {
- ypr_close_parent(ctx, &flag);
- yprp_augment(ctx, aug);
+ ypr_close_parent(pctx, &flag);
+ yprp_augment(pctx, aug);
}
LEVEL--;
- ypr_close(ctx, "uses", flag);
+ ypr_close(pctx, "uses", flag);
}
static void
-yprp_anydata(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_anydata(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
int8_t flag = 0;
struct lysp_node_anydata *any = (struct lysp_node_anydata *)node;
- yprp_node_common1(ctx, node, &flag);
+ yprp_node_common1(pctx, node, &flag);
LY_ARRAY_FOR(any->musts, u) {
- ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &any->musts[u], LY_STMT_MUST, "condition", &flag);
+ ypr_close_parent(pctx, &flag);
+ yprp_restr(pctx, &any->musts[u], LY_STMT_MUST, "condition", &flag);
}
- yprp_node_common2(ctx, node, &flag);
+ yprp_node_common2(pctx, node, &flag);
LEVEL--;
- ypr_close(ctx, lys_nodetype2str(node->nodetype), flag);
+ ypr_close(pctx, lys_nodetype2str(node->nodetype), flag);
}
static void
-yprp_node(struct lys_ypr_ctx *ctx, const struct lysp_node *node)
+yprp_node(struct lys_ypr_ctx *pctx, const struct lysp_node *node)
{
switch (node->nodetype) {
case LYS_CONTAINER:
- yprp_container(ctx, node);
+ yprp_container(pctx, node);
break;
case LYS_CHOICE:
- yprp_choice(ctx, node);
+ yprp_choice(pctx, node);
break;
case LYS_LEAF:
- yprp_leaf(ctx, node);
+ yprp_leaf(pctx, node);
break;
case LYS_LEAFLIST:
- yprp_leaflist(ctx, node);
+ yprp_leaflist(pctx, node);
break;
case LYS_LIST:
- yprp_list(ctx, node);
+ yprp_list(pctx, node);
break;
case LYS_USES:
- yprp_uses(ctx, node);
+ yprp_uses(pctx, node);
break;
case LYS_ANYXML:
case LYS_ANYDATA:
- yprp_anydata(ctx, node);
+ yprp_anydata(pctx, node);
break;
case LYS_CASE:
- yprp_case(ctx, node);
+ yprp_case(pctx, node);
break;
default:
break;
@@ -1095,7 +1095,7 @@
}
static void
-yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)
+yprp_deviation(struct lys_ypr_ctx *pctx, const struct lysp_deviation *deviation)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_deviate_add *add;
@@ -1103,121 +1103,121 @@
struct lysp_deviate_del *del;
struct lysp_deviate *elem;
- ypr_open(ctx, "deviation", "target-node", deviation->nodeid, 1);
+ ypr_open(pctx, "deviation", "target-node", deviation->nodeid, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
- ypr_description(ctx, deviation->dsc, deviation->exts, NULL);
- ypr_reference(ctx, deviation->ref, deviation->exts, NULL);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
+ ypr_description(pctx, deviation->dsc, deviation->exts, NULL);
+ ypr_reference(pctx, deviation->ref, deviation->exts, NULL);
LY_LIST_FOR(deviation->deviates, elem) {
- ly_print_(ctx->out, "%*s<deviate value=\"", INDENT);
+ ly_print_(pctx->out, "%*s<deviate value=\"", INDENT);
if (elem->mod == LYS_DEV_NOT_SUPPORTED) {
if (elem->exts) {
- ly_print_(ctx->out, "not-supported\"/>\n");
+ ly_print_(pctx->out, "not-supported\"/>\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
} else {
- ly_print_(ctx->out, "not-supported\"/>\n");
+ ly_print_(pctx->out, "not-supported\"/>\n");
continue;
}
} else if (elem->mod == LYS_DEV_ADD) {
add = (struct lysp_deviate_add *)elem;
- ly_print_(ctx->out, "add\">\n");
+ ly_print_(pctx->out, "add\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, add->units, add->exts);
LY_ARRAY_FOR(add->musts, u) {
- yprp_restr(ctx, &add->musts[u], LY_STMT_MUST, "condition", NULL);
+ yprp_restr(pctx, &add->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(add->uniques, u) {
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
}
LY_ARRAY_FOR(add->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);
}
- ypr_config(ctx, add->flags, add->exts, NULL);
- ypr_mandatory(ctx, add->flags, add->exts, NULL);
+ ypr_config(pctx, add->flags, add->exts, NULL);
+ ypr_mandatory(pctx, add->flags, add->exts, NULL);
if (add->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min);
}
if (add->flags & LYS_SET_MAX) {
if (add->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);
}
}
} else if (elem->mod == LYS_DEV_REPLACE) {
rpl = (struct lysp_deviate_rpl *)elem;
- ly_print_(ctx->out, "replace\">\n");
+ ly_print_(pctx->out, "replace\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
if (rpl->type) {
- yprp_type(ctx, rpl->type);
+ yprp_type(pctx, rpl->type);
}
- ypr_substmt(ctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);
- ypr_substmt(ctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);
- ypr_config(ctx, rpl->flags, rpl->exts, NULL);
- ypr_mandatory(ctx, rpl->flags, rpl->exts, NULL);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);
+ ypr_config(pctx, rpl->flags, rpl->exts, NULL);
+ ypr_mandatory(pctx, rpl->flags, rpl->exts, NULL);
if (rpl->flags & LYS_SET_MIN) {
- ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min);
+ ypr_unsigned(pctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min);
}
if (rpl->flags & LYS_SET_MAX) {
if (rpl->max) {
- ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max);
+ ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max);
} else {
- ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);
+ ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);
}
}
} else if (elem->mod == LYS_DEV_DELETE) {
del = (struct lysp_deviate_del *)elem;
- ly_print_(ctx->out, "delete\">\n");
+ ly_print_(pctx->out, "delete\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);
+ yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_UNITS, 0, del->units, del->exts);
LY_ARRAY_FOR(del->musts, u) {
- yprp_restr(ctx, &del->musts[u], LY_STMT_MUST, "condition", NULL);
+ yprp_restr(pctx, &del->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(del->uniques, u) {
- ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
+ ypr_substmt(pctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
}
LY_ARRAY_FOR(del->dflts, u) {
- ypr_substmt(ctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);
+ ypr_substmt(pctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);
}
}
LEVEL--;
- ypr_close(ctx, "deviate", 1);
+ ypr_close(pctx, "deviate", 1);
}
LEVEL--;
- ypr_close(ctx, "deviation", 1);
+ ypr_close(pctx, "deviation", 1);
}
static void
-ypr_xmlns(struct lys_ypr_ctx *ctx, const struct lys_module *module, uint16_t indent)
+ypr_xmlns(struct lys_ypr_ctx *pctx, const struct lys_module *module, uint16_t indent)
{
- ly_print_(ctx->out, "%*sxmlns=\"%s\"", indent + INDENT, YIN_NS_URI);
- ly_print_(ctx->out, "\n%*sxmlns:%s=\"%s\"", indent + INDENT, module->prefix, module->ns);
+ ly_print_(pctx->out, "%*sxmlns=\"%s\"", indent + INDENT, YIN_NS_URI);
+ ly_print_(pctx->out, "\n%*sxmlns:%s=\"%s\"", indent + INDENT, module->prefix, module->ns);
}
static void
-ypr_import_xmlns(struct lys_ypr_ctx *ctx, const struct lysp_module *modp, uint16_t indent)
+ypr_import_xmlns(struct lys_ypr_ctx *pctx, const struct lysp_module *modp, uint16_t indent)
{
LY_ARRAY_COUNT_TYPE u;
LY_ARRAY_FOR(modp->imports, u){
- ly_print_(ctx->out, "\n%*sxmlns:%s=\"%s\"", indent + INDENT, modp->imports[u].prefix, modp->imports[u].module->ns);
+ ly_print_(pctx->out, "\n%*sxmlns:%s=\"%s\"", indent + INDENT, modp->imports[u].prefix, modp->imports[u].module->ns);
}
}
static void
-yprp_stmt(struct lys_ypr_ctx *ctx, struct lysp_stmt *stmt)
+yprp_stmt(struct lys_ypr_ctx *pctx, struct lysp_stmt *stmt)
{
struct lysp_stmt *childstmt;
int8_t flag = stmt->child ? 1 : -1;
@@ -1228,20 +1228,20 @@
currently it is ignored */
if (stmt_attr_info[stmt->kw].name) {
if (stmt_attr_info[stmt->kw].flags & STMT_FLAG_YIN) {
- ypr_open(ctx, stmt->stmt, NULL, NULL, flag);
- ypr_yin_arg(ctx, stmt_attr_info[stmt->kw].arg, stmt->arg);
+ ypr_open(pctx, stmt->stmt, NULL, NULL, flag);
+ ypr_yin_arg(pctx, stmt_attr_info[stmt->kw].arg, stmt->arg);
} else {
- ypr_open(ctx, stmt->stmt, stmt_attr_info[stmt->kw].arg, stmt->arg, flag);
+ ypr_open(pctx, stmt->stmt, stmt_attr_info[stmt->kw].arg, stmt->arg, flag);
}
}
if (stmt->child) {
LEVEL++;
LY_LIST_FOR(stmt->child, childstmt) {
- yprp_stmt(ctx, childstmt);
+ yprp_stmt(pctx, childstmt);
}
LEVEL--;
- ypr_close(ctx, stmt->stmt, flag);
+ ypr_close(pctx, stmt->stmt, flag);
}
}
@@ -1249,7 +1249,7 @@
* @param[in] count Number of extensions to print, 0 to print them all.
*/
static void
-yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,
+yprp_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysp_ext_instance *ext, int8_t *flag, LY_ARRAY_COUNT_TYPE count)
{
LY_ARRAY_COUNT_TYPE u;
@@ -1271,48 +1271,48 @@
continue;
}
- lysp_ext_find_definition(ctx->module->ctx, &ext[u], NULL, &ext_def);
+ lysp_ext_find_definition(pctx->module->ctx, &ext[u], NULL, &ext_def);
if (!ext_def) {
continue;
}
- ypr_close_parent(ctx, flag);
+ ypr_close_parent(pctx, flag);
inner_flag = 0;
if (ext_def->argname) {
- lysp_ext_instance_resolve_argument(ctx->module->ctx, &ext[u], ext_def);
+ lysp_ext_instance_resolve_argument(pctx->module->ctx, &ext[u], ext_def);
}
- ypr_open(ctx, ext[u].name, (ext_def->flags & LYS_YINELEM_TRUE) ? NULL : ext_def->argname, ext[u].argument, inner_flag);
+ ypr_open(pctx, ext[u].name, (ext_def->flags & LYS_YINELEM_TRUE) ? NULL : ext_def->argname, ext[u].argument, inner_flag);
LEVEL++;
if (ext_def->flags & LYS_YINELEM_TRUE) {
const char *prefix, *name, *id;
size_t prefix_len, name_len;
- ypr_close_parent(ctx, &inner_flag);
+ ypr_close_parent(pctx, &inner_flag);
/* we need to use the same namespace as for the extension instance element */
id = ext[u].name;
ly_parse_nodeid(&id, &prefix, &prefix_len, &name, &name_len);
- ly_print_(ctx->out, "%*s<%.*s:%s>", INDENT, (int)prefix_len, prefix, ext_def->argname);
- lyxml_dump_text(ctx->out, ext[u].argument, 0);
- ly_print_(ctx->out, "</%.*s:%s>\n", (int)prefix_len, prefix, ext_def->argname);
+ ly_print_(pctx->out, "%*s<%.*s:%s>", INDENT, (int)prefix_len, prefix, ext_def->argname);
+ lyxml_dump_text(pctx->out, ext[u].argument, 0);
+ ly_print_(pctx->out, "</%.*s:%s>\n", (int)prefix_len, prefix, ext_def->argname);
}
LY_LIST_FOR(ext[u].child, stmt) {
if (stmt->flags & (LYS_YIN_ATTR | LYS_YIN_ARGUMENT)) {
continue;
}
- ypr_close_parent(ctx, &inner_flag);
- yprp_stmt(ctx, stmt);
+ ypr_close_parent(pctx, &inner_flag);
+ yprp_stmt(pctx, stmt);
}
LEVEL--;
- ypr_close(ctx, ext[u].name, inner_flag);
+ ypr_close(pctx, ext[u].name, inner_flag);
}
}
static void
-yin_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)
+yin_print_parsed_linkage(struct lys_ypr_ctx *pctx, const struct lysp_module *modp)
{
LY_ARRAY_COUNT_TYPE u;
@@ -1321,17 +1321,17 @@
continue;
}
- ypr_open(ctx, "import", "module", modp->imports[u].name, 1);
+ ypr_open(pctx, "import", "module", modp->imports[u].name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
+ yprp_extension_instances(pctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
if (modp->imports[u].rev[0]) {
- ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
}
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);
LEVEL--;
- ypr_close(ctx, "import", 1);
+ ypr_close(pctx, "import", 1);
}
LY_ARRAY_FOR(modp->includes, u) {
if (modp->includes[u].injected) {
@@ -1339,24 +1339,24 @@
continue;
}
if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {
- ypr_open(ctx, "include", "module", modp->includes[u].name, 1);
+ ypr_open(pctx, "include", "module", modp->includes[u].name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
+ yprp_extension_instances(pctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
if (modp->includes[u].rev[0]) {
- ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
}
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);
LEVEL--;
- ly_print_(ctx->out, "%*s}\n", INDENT);
+ ly_print_(pctx->out, "%*s}\n", INDENT);
} else {
- ypr_open(ctx, "include", "module", modp->includes[u].name, -1);
+ ypr_open(pctx, "include", "module", modp->includes[u].name, -1);
}
}
}
static void
-yin_print_parsed_body(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)
+yin_print_parsed_body(struct lys_ypr_ctx *pctx, const struct lysp_module *modp)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
@@ -1366,48 +1366,48 @@
struct lysp_node_augment *aug;
LY_ARRAY_FOR(modp->extensions, u) {
- ly_print_(ctx->out, "\n");
- yprp_extension(ctx, &modp->extensions[u]);
+ ly_print_(pctx->out, "\n");
+ yprp_extension(pctx, &modp->extensions[u]);
}
if (modp->exts) {
- ly_print_(ctx->out, "\n");
- yprp_extension_instances(ctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
+ ly_print_(pctx->out, "\n");
+ yprp_extension_instances(pctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
}
LY_ARRAY_FOR(modp->features, u) {
- yprp_feature(ctx, &modp->features[u]);
+ yprp_feature(pctx, &modp->features[u]);
}
LY_ARRAY_FOR(modp->identities, u) {
- yprp_identity(ctx, &modp->identities[u]);
+ yprp_identity(pctx, &modp->identities[u]);
}
LY_ARRAY_FOR(modp->typedefs, u) {
- yprp_typedef(ctx, &modp->typedefs[u]);
+ yprp_typedef(pctx, &modp->typedefs[u]);
}
LY_LIST_FOR(modp->groupings, grp) {
- yprp_grouping(ctx, grp);
+ yprp_grouping(pctx, grp);
}
LY_LIST_FOR(modp->data, data) {
- yprp_node(ctx, data);
+ yprp_node(pctx, data);
}
LY_LIST_FOR(modp->augments, aug) {
- yprp_augment(ctx, aug);
+ yprp_augment(pctx, aug);
}
LY_LIST_FOR(modp->rpcs, action) {
- yprp_action(ctx, action);
+ yprp_action(pctx, action);
}
LY_LIST_FOR(modp->notifs, notif) {
- yprp_notification(ctx, notif);
+ yprp_notification(pctx, notif);
}
LY_ARRAY_FOR(modp->deviations, u) {
- yprp_deviation(ctx, &modp->deviations[u]);
+ yprp_deviation(pctx, &modp->deviations[u]);
}
}
@@ -1416,45 +1416,45 @@
{
LY_ARRAY_COUNT_TYPE u;
const struct lys_module *module = modp->mod;
- struct lys_ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_;
+ struct lys_ypr_ctx pctx_ = {.out = out, .level = 0, .module = module, .options = options}, *pctx = &pctx_;
- ly_print_(ctx->out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- ly_print_(ctx->out, "%*s<module name=\"%s\"\n", INDENT, module->name);
- ypr_xmlns(ctx, module, XML_NS_INDENT);
- ypr_import_xmlns(ctx, modp, XML_NS_INDENT);
- ly_print_(ctx->out, ">\n");
+ ly_print_(pctx->out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ ly_print_(pctx->out, "%*s<module name=\"%s\"\n", INDENT, module->name);
+ ypr_xmlns(pctx, module, XML_NS_INDENT);
+ ypr_import_xmlns(pctx, modp, XML_NS_INDENT);
+ ly_print_(pctx->out, ">\n");
LEVEL++;
/* module-header-stmts */
if (modp->version) {
- ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);
+ ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);
}
- ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);
+ ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);
/* linkage-stmts (import/include) */
- yin_print_parsed_linkage(ctx, modp);
+ yin_print_parsed_linkage(pctx, modp);
/* meta-stmts */
if (module->org || module->contact || module->dsc || module->ref) {
ly_print_(out, "\n");
}
- ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);
- ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);
+ ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);
+ ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);
/* revision-stmts */
if (modp->revs) {
ly_print_(out, "\n");
}
LY_ARRAY_FOR(modp->revs, u) {
- yprp_revision(ctx, &modp->revs[u]);
+ yprp_revision(pctx, &modp->revs[u]);
}
/* body-stmts */
- yin_print_parsed_body(ctx, modp);
+ yin_print_parsed_body(pctx, modp);
LEVEL--;
ly_print_(out, "%*s</module>\n", INDENT);
@@ -1464,58 +1464,58 @@
}
static void
-yprp_belongsto(struct lys_ypr_ctx *ctx, const struct lysp_submodule *submodp)
+yprp_belongsto(struct lys_ypr_ctx *pctx, const struct lysp_submodule *submodp)
{
- ypr_open(ctx, "belongs-to", "module", submodp->mod->name, 1);
+ ypr_open(pctx, "belongs-to", "module", submodp->mod->name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);
- ypr_substmt(ctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);
+ yprp_extension_instances(pctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);
+ ypr_substmt(pctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);
LEVEL--;
- ypr_close(ctx, "belongs-to", 1);
+ ypr_close(pctx, "belongs-to", 1);
}
LY_ERR
yin_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *submodp, uint32_t options)
{
LY_ARRAY_COUNT_TYPE u;
- struct lys_ypr_ctx ctx_ = {.out = out, .level = 0, .module = submodp->mod, .options = options}, *ctx = &ctx_;
+ struct lys_ypr_ctx pctx_ = {.out = out, .level = 0, .module = submodp->mod, .options = options}, *pctx = &pctx_;
- ly_print_(ctx->out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- ly_print_(ctx->out, "%*s<submodule name=\"%s\"\n", INDENT, submodp->name);
- ypr_xmlns(ctx, submodp->mod, XML_NS_INDENT);
- ypr_import_xmlns(ctx, (struct lysp_module *)submodp, XML_NS_INDENT);
- ly_print_(ctx->out, ">\n");
+ ly_print_(pctx->out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ ly_print_(pctx->out, "%*s<submodule name=\"%s\"\n", INDENT, submodp->name);
+ ypr_xmlns(pctx, submodp->mod, XML_NS_INDENT);
+ ypr_import_xmlns(pctx, (struct lysp_module *)submodp, XML_NS_INDENT);
+ ly_print_(pctx->out, ">\n");
LEVEL++;
/* submodule-header-stmts */
if (submodp->version) {
- ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);
+ ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);
}
- yprp_belongsto(ctx, submodp);
+ yprp_belongsto(pctx, submodp);
/* linkage-stmts (import/include) */
- yin_print_parsed_linkage(ctx, (struct lysp_module *)submodp);
+ yin_print_parsed_linkage(pctx, (struct lysp_module *)submodp);
/* meta-stmts */
if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) {
ly_print_(out, "\n");
}
- ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);
- ypr_substmt(ctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);
- ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);
- ypr_substmt(ctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);
+ ypr_substmt(pctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);
/* revision-stmts */
if (submodp->revs) {
ly_print_(out, "\n");
}
LY_ARRAY_FOR(submodp->revs, u) {
- yprp_revision(ctx, &submodp->revs[u]);
+ yprp_revision(pctx, &submodp->revs[u]);
}
/* body-stmts */
- yin_print_parsed_body(ctx, (struct lysp_module *)submodp);
+ yin_print_parsed_body(pctx, (struct lysp_module *)submodp);
LEVEL--;
ly_print_(out, "%*s</submodule>\n", INDENT);
diff --git a/src/tree_data.c b/src/tree_data.c
index 893bdd0..d5099b3 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2358,6 +2358,8 @@
return NULL;
}
+ assert(!first_sibling || (LYD_CTX(first_sibling) == LYD_CTX(new_node)));
+
getnext_opts = 0;
if (new_node->schema->flags & LYS_IS_OUTPUT) {
getnext_opts = LYS_GETNEXT_OUTPUT;
@@ -2707,7 +2709,7 @@
while (first) {
iter = first->next;
lyd_unlink_tree(first);
- lyd_insert_node(parent, NULL, first, 0);
+ lyd_insert_node(parent, NULL, first, 1);
first = iter;
}
return LY_SUCCESS;
diff --git a/src/tree_data.h b/src/tree_data.h
index 65a9bda..e6250ce 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -495,7 +495,7 @@
* @param ELEM Iterator.
*/
#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
- for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
+ for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
(ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
(ELEM) = (NEXT))
diff --git a/src/validation.c b/src/validation.c
index 5699c8d..8004b44 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1330,6 +1330,11 @@
/* validate all restrictions of nodes themselves */
LY_LIST_FOR_SAFE(first, next, node) {
+ if (node->flags & LYD_EXT) {
+ /* ext instance data should have already been validated */
+ continue;
+ }
+
if (!node->parent && mod && (lyd_owner_module(node) != mod)) {
/* all top-level data from this module checked */
break;