Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 0 additions & 127 deletions src/plugins_exts.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,133 +434,6 @@ lyplg_ext_print_get_level(const struct lyspr_ctx *ctx)
return &((struct lyspr_ctx *)ctx)->level;
}

LIBYANG_API_DEF LY_ERR
lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_ext_instance *ext,
lyplg_ext_sprinter_ctree_override_clb clb)
{
LY_ERR rc = LY_SUCCESS;
uint32_t i;
struct lysc_node *schema;

LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL);

LY_ARRAY_FOR(ext->substmts, i) {
switch (ext->substmts[i].stmt) {
case LY_STMT_NOTIFICATION:
case LY_STMT_INPUT:
case LY_STMT_OUTPUT:
case LY_STMT_ACTION:
case LY_STMT_RPC:
case LY_STMT_ANYDATA:
case LY_STMT_ANYXML:
case LY_STMT_CASE:
case LY_STMT_CHOICE:
case LY_STMT_CONTAINER:
case LY_STMT_LEAF:
case LY_STMT_LEAF_LIST:
case LY_STMT_LIST:
schema = *ext->substmts[i].storage_p;
if (schema) {
rc = lyplg_ext_sprinter_ctree_add_nodes(ctx, schema, clb);
return rc;
}
default:
break;
}
}

return rc;
}

LIBYANG_API_DEF LY_ERR
lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_ext_instance *ext,
lyplg_ext_sprinter_ptree_override_clb clb)
{
LY_ERR rc = LY_SUCCESS;
uint32_t i;
struct lysp_node *schema;

LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL);

LY_ARRAY_FOR(ext->substmts, i) {
switch (ext->substmts[i].stmt) {
case LY_STMT_NOTIFICATION:
case LY_STMT_INPUT:
case LY_STMT_OUTPUT:
case LY_STMT_ACTION:
case LY_STMT_RPC:
case LY_STMT_ANYDATA:
case LY_STMT_ANYXML:
case LY_STMT_CASE:
case LY_STMT_CHOICE:
case LY_STMT_CONTAINER:
case LY_STMT_LEAF:
case LY_STMT_LEAF_LIST:
case LY_STMT_LIST:
schema = *ext->substmts[i].storage_p;
if (schema) {
rc = lyplg_ext_sprinter_ptree_add_nodes(ctx, schema, clb);
return rc;
}
default:
break;
}
}

return rc;
}

LIBYANG_API_DEF LY_ERR
lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_node *nodes,
lyplg_ext_sprinter_ctree_override_clb clb)
{
struct lyspr_tree_schema *new;

LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);

if (!nodes) {
return LY_SUCCESS;
}

LY_ARRAY_NEW_RET(NULL, ((struct lyspr_tree_ctx *)ctx)->schemas, new, LY_EMEM);
new->compiled = 1;
new->ctree = nodes;
new->cn_overr = clb;

return LY_SUCCESS;
}

LIBYANG_API_DEF LY_ERR
lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_node *nodes,
lyplg_ext_sprinter_ptree_override_clb clb)
{
struct lyspr_tree_schema *new;

LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);

if (!nodes) {
return LY_SUCCESS;
}

LY_ARRAY_NEW_RET(NULL, ((struct lyspr_tree_ctx *)ctx)->schemas, new, LY_EMEM);
new->compiled = 0;
new->ptree = nodes;
new->pn_overr = clb;

return LY_SUCCESS;
}

LIBYANG_API_DEF LY_ERR
lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv, void (*free_clb)(void *plugin_priv))
{
LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);

((struct lyspr_tree_ctx *)ctx)->plugin_priv = plugin_priv;
((struct lyspr_tree_ctx *)ctx)->free_plugin_priv = free_clb;

return LY_SUCCESS;
}

LIBYANG_API_DEF int
lyplg_ext_compiled_stmts_storage_size(const struct lysc_ext_substmt *substmts, struct ly_ht *addr_ht)
{
Expand Down
114 changes: 1 addition & 113 deletions src/plugins_exts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ extern "C" {
* [helper functions](@ref pluginsExtensionsSprinterInfo) to access printer's context and to print standard YANG statements
* placed in the extension instance by libyang itself.
*
* The ::lyplg_ext.printer_ctree and ::lyplg_ext.printer_ptree callbacks implement printing of YANG tree diagrams
* (RFC 8340) for extension instance data. These callbacks are called for extension instances that have
* parents of type ::LY_STMT_MODULE, ::LY_STMT_SUBMODULE. Or these callbacks are called if the printer_tree finds
* a compiled/parsed data-node containing an extension instance. The callbacks should then decide which nodes
* should be printed within the extension instance. In addition, it is possible to register additional callbacks
* to the printer_tree context to override the form of the each node in the extension instance.
*
* The last callback, ::lyplg_ext.cfree, is supposed to free all the data allocated by the ::lyplg_ext.compile callback.
* To free the data created by helper function ::lyplg_ext_compile_extension_instance(), the plugin can used
* ::lyplg_ext_cfree_instance_substatements().
Expand All @@ -109,7 +102,7 @@ extern "C" {
/**
* @brief Extensions API version
*/
#define LYPLG_EXT_API_VERSION 11
#define LYPLG_EXT_API_VERSION 12

/**
* @brief Mask for an operation statement.
Expand Down Expand Up @@ -729,109 +722,6 @@ LIBYANG_API_DECL void lyplg_ext_print_info_extension_instance(struct lyspr_ctx *

/** @} pluginsExtensionsSprinterInfo */

/**
* @defgroup pluginsExtensionsSprinterTree Plugins: Extensions schema parsed and compiled tree printer support
* @ingroup pluginsExtensions
*
* Implementing extension plugin schema parsed and compiled tree printer callback.
*
* @{
*/

/**
* @brief Callback to print parent node of @p ext or to print the contents of the extension.
*
* Function is called in two different cases. If the printer_tree needs the tree-diagram form of a parent node,
* then @p ctx is set to NULL. In the second case, if printer_tree needs to print the contents of the extension,
* then @p ctx is set and function must prepare the nodes that should be printed using the
* lyplg_ext_sprinter_tree* functions.
*
* @param[in] ext Extension instance.
* @param[in,out] ctx Context for the tree printer. Extension contents can be inserted into it by functions
* lyplg_ext_sprinter_ctree_add_ext_nodes(), lyplg_ext_sprinter_ctree_add_nodes() or by their ptree alternatives.
* It parameter is set to NULL, then @p flags and @p add_opts are used by printer_tree.
* @param[out] flags Optional override tree-diagram \<flags\> in a parent node. If @p ctx is set, ignore this parameter.
* @param[out] add_opts Additional tree-diagram \<opts\> string in a parent node which is printed before \<opts\>. If @p ctx
* is set, ignore this parameter.
* @return LY_ERR value.
*/
typedef LY_ERR (*lyplg_ext_sprinter_ctree_clb)(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **flags, const char **add_opts);

/**
* @brief Callback for rewriting the tree-diagram form of a specific node.
*
* If this callback is set, then it is called for each node that belongs to the extension instance.
*
* @param[in] node Node whose tree-diagram form can be modified by the function.
* @param[in,out] plugin_priv Private context set by plugin.
* @param[out] skip Flag set to 1 removes the node from printed diagram.
* @param[out] flags Override tree-diagram \<flags\> string in the @p node.
* @param[out] add_opts Additional tree-diagram \<opts\> string in the @p node which is printed before \<opts\>.
* @return LY_ERR value.
*/
typedef LY_ERR (*lyplg_ext_sprinter_ctree_override_clb)(const struct lysc_node *node, const void *plugin_priv,
ly_bool *skip, const char **flags, const char **add_opts);

/**
* @brief Registration of printing a group of nodes, which is already in the extension.
*
* @param[in] ctx Context of printer_tree in which the group of nodes is saved and later printed.
* @param[in] ext Extension in which the group of nodes will be searched.
* @param[in] clb Override function that will be applied to each delivered node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx,
struct lysc_ext_instance *ext, lyplg_ext_sprinter_ctree_override_clb clb);

/**
* @brief Registration of printing the group of nodes which were defined in the plugin.
*
* @param[in] ctx Context of printer_tree in which the group of nodes is saved and later printed.
* @param[in] nodes Points to the first node in group.
* @param[in] clb Override function that will be applied to each delivered node.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_node *nodes,
lyplg_ext_sprinter_ctree_override_clb clb);

/**
* @brief Registration of plugin-private data defined by the plugin that is shared between override_clb calls.
*
* @param[in] ctx Context of printer_tree in which plugin-private data will be saved.
* @param[in] plugin_priv Plugin-private data shared between oberride_clb calls.
* @param[in] free_clb Release function for @p plugin_priv.
* @return LY_ERR value.
*/
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv,
void (*free_clb)(void *plugin_priv));

/**
* @copydoc lyplg_ext_sprinter_ctree_clb
*/
typedef LY_ERR (*lyplg_ext_sprinter_ptree_clb)(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **flags, const char **add_opts);

/**
* @copydoc lyplg_ext_sprinter_ctree_override_clb
*/
typedef LY_ERR (*lyplg_ext_sprinter_ptree_override_clb)(const struct lysp_node *node, const void *plugin_priv,
ly_bool *skip, const char **flags, const char **add_opts);

/**
* @copydoc lyplg_ext_sprinter_ctree_add_ext_nodes
*/
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx,
struct lysp_ext_instance *ext, lyplg_ext_sprinter_ptree_override_clb clb);

/**
* @copydoc lyplg_ext_sprinter_ctree_add_nodes
*/
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_node *nodes,
lyplg_ext_sprinter_ptree_override_clb clb);

/** @} pluginsExtensionsSprinterTree */

/*
* node xpath
*/
Expand Down Expand Up @@ -1077,8 +967,6 @@ struct lyplg_ext {
lyplg_ext_parse_clb parse; /**< callback to parse the extension instance substatements */
lyplg_ext_compile_clb compile; /**< callback to compile extension instance from the parsed data */
lyplg_ext_sprinter_info_clb printer_info; /**< callback to print the compiled content (info format) */
lyplg_ext_sprinter_ctree_clb printer_ctree; /**< callback to print tree format of a compiled node */
lyplg_ext_sprinter_ptree_clb printer_ptree; /**< callback to print tree format of a parsed node */
lyplg_ext_node_xpath_clb node_xpath; /**< callback to get first XPath document root data child node */
lyplg_ext_snode_xpath_clb snode_xpath; /**< callback to get first XPath document root schema child node */
lyplg_ext_data_snode_clb snode; /**< callback to get schema node in various use-cases */
Expand Down
2 changes: 0 additions & 2 deletions src/plugins_exts/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ const struct lyplg_ext_record plugins_metadata[] = {
.plugin.parse = annotation_parse,
.plugin.compile = annotation_compile,
.plugin.printer_info = annotation_printer_info,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand Down
8 changes: 0 additions & 8 deletions src/plugins_exts/nacm.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ const struct lyplg_ext_record plugins_nacm[] = {
.plugin.parse = nacm_parse,
.plugin.compile = nacm_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand All @@ -202,8 +200,6 @@ const struct lyplg_ext_record plugins_nacm[] = {
.plugin.parse = nacm_parse,
.plugin.compile = nacm_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand All @@ -221,8 +217,6 @@ const struct lyplg_ext_record plugins_nacm[] = {
.plugin.parse = nacm_parse,
.plugin.compile = nacm_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand All @@ -240,8 +234,6 @@ const struct lyplg_ext_record plugins_nacm[] = {
.plugin.parse = nacm_parse,
.plugin.compile = nacm_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand Down
4 changes: 0 additions & 4 deletions src/plugins_exts/openconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ const struct lyplg_ext_record plugins_openconfig[] = {
.plugin.parse = regexp_posix_parse,
.plugin.compile = NULL,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand All @@ -188,8 +186,6 @@ const struct lyplg_ext_record plugins_openconfig[] = {
.plugin.parse = posix_pattern_parse,
.plugin.compile = posix_pattern_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = NULL,
.plugin.printer_ptree = NULL,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = NULL,
.plugin.snode = NULL,
Expand Down
39 changes: 0 additions & 39 deletions src/plugins_exts/schema_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ struct lyplg_ext_sm {
} inln; /**< inline mount points */
};

struct sprinter_tree_priv {
struct ly_ctx *ext_ctx;
struct ly_set *refs;
};

#define EXT_LOGERR_MEM_RET(cctx, ext) \
lyplg_ext_compile_log(cctx, ext, LY_LLERR, LY_EMEM, "Memory allocation failed (%s:%d).", __FILE__, __LINE__); \
return LY_EMEM
Expand Down Expand Up @@ -1451,38 +1446,6 @@ lyplg_ext_schema_mount_create_context(const struct lysc_ext_instance *ext, const
return rc;
}

/**
* @brief Schema mount schema parsed tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
*/
static LY_ERR
schema_mount_sprinter_ptree(struct lysp_ext_instance *UNUSED(ext), const struct lyspr_tree_ctx *ctx,
const char **flags, const char **UNUSED(add_opts))
{
if (!ctx) {
*flags = "mp";
}

return LY_SUCCESS;
}

/**
* @brief Schema mount schema compiled tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
*/
static LY_ERR
schema_mount_sprinter_ctree(struct lysc_ext_instance *UNUSED(ext), const struct lyspr_tree_ctx *ctx,
const char **flags, const char **UNUSED(add_opts))
{
if (!ctx) {
*flags = "mp";
}

return LY_SUCCESS;
}

static int
schema_mount_compiled_size(const struct lysc_ext_instance *ext, struct ly_ht *addr_ht)
{
Expand Down Expand Up @@ -1596,8 +1559,6 @@ const struct lyplg_ext_record plugins_schema_mount[] = {
.plugin.parse = schema_mount_parse,
.plugin.compile = schema_mount_compile,
.plugin.printer_info = NULL,
.plugin.printer_ctree = schema_mount_sprinter_ctree,
.plugin.printer_ptree = schema_mount_sprinter_ptree,
.plugin.node_xpath = NULL,
.plugin.snode_xpath = schema_mount_snode_xpath,
.plugin.snode = schema_mount_snode,
Expand Down
Loading