libyang 2.0.231
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
Plugins: Extensions compilation support
Collaboration diagram for Plugins: Extensions compilation support:

Modules

 Schema compile flags
 

Functions

LIBYANG_API_DECL LY_ERR lys_compile_extension_instance (struct lysc_ctx *ctx, const struct lysp_ext_instance *ext_p, struct lysc_ext_instance *ext)
 Compile substatements of an extension instance. More...
 
LIBYANG_API_DECL struct ly_ctxlysc_ctx_get_ctx (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for libyang context. More...
 
LIBYANG_API_DECL const struct lys_modulelysc_ctx_get_cur_mod (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for current module. More...
 
LIBYANG_API_DECL uint32_t * lysc_ctx_get_options (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for compilation options. More...
 
LIBYANG_API_DECL const char * lysc_ctx_get_path (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for path being currently processed. More...
 
LIBYANG_API_DECL struct lysp_modulelysc_ctx_get_pmod (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for currently processed module. More...
 
LIBYANG_API_DECL struct lysc_extlysc_ext_dup (struct lysc_ext *orig)
 Duplicate the compiled extension (definition) structure. More...
 
LIBYANG_API_DECL void lysc_update_path (struct lysc_ctx *ctx, struct lys_module *parent_module, const char *name)
 Update path in the compile context, which is used for logging where the compilation failed. More...
 

Detailed Description

Helper functions to implement extension plugin's compile callback.

Function Documentation

◆ lys_compile_extension_instance()

LIBYANG_API_DECL LY_ERR lys_compile_extension_instance ( struct lysc_ctx *  ctx,
const struct lysp_ext_instance ext_p,
struct lysc_ext_instance ext 
)

Compile substatements of an extension instance.

Uses standard libyang schema compiler to transform YANG statements into the compiled schema structures. The plugins are supposed to use this function when the extension instance's substatements are supposed to be compiled in a standard way (or if just the Schema compile flags are enough to modify the compilation process).

Parameters
[in]ctxYANG schema compile context to track the compilation state.
[in]ext_pParsed representation of the extension instance being processed.
[in,out]extCompiled extension instance with the prepared lysc_ext_instance.substmts array, which will be updated by storing the compiled data.
Returns
LY_SUCCESS on success.
LY_EVALID if compilation of the substatements fails.
LY_ENOT if the extension is disabled (by if-feature) and should be ignored.

◆ lysc_ctx_get_ctx()

LIBYANG_API_DECL struct ly_ctx * lysc_ctx_get_ctx ( const struct lysc_ctx *  ctx)

YANG schema compilation context getter for libyang context.

Parameters
[in]ctxYANG schema compilation context.
Returns
libyang context connected with the compilation context.

◆ lysc_ctx_get_cur_mod()

LIBYANG_API_DECL const struct lys_module * lysc_ctx_get_cur_mod ( const struct lysc_ctx *  ctx)

YANG schema compilation context getter for current module.

Parameters
[in]ctxYANG schema compilation context.
Returns
current module.

◆ lysc_ctx_get_options()

LIBYANG_API_DECL uint32_t * lysc_ctx_get_options ( const struct lysc_ctx *  ctx)

YANG schema compilation context getter for compilation options.

Parameters
[in]ctxYANG schema compilation context.
Returns
pointer to the compilation options to allow modifying them with Schema compile flags values.

◆ lysc_ctx_get_path()

LIBYANG_API_DECL const char * lysc_ctx_get_path ( const struct lysc_ctx *  ctx)

YANG schema compilation context getter for path being currently processed.

Parameters
[in]ctxYANG schema compilation context.
Returns
path identifying the place in schema being currently processed by the schema compiler.

◆ lysc_ctx_get_pmod()

LIBYANG_API_DECL struct lysp_module * lysc_ctx_get_pmod ( const struct lysc_ctx *  ctx)

YANG schema compilation context getter for currently processed module.

Parameters
[in]ctxYANG schema compilation context.
Returns
Currently processed module.

◆ lysc_ext_dup()

LIBYANG_API_DECL struct lysc_ext * lysc_ext_dup ( struct lysc_ext orig)

Duplicate the compiled extension (definition) structure.

Parameters
[in]origThe extension structure to duplicate.
Returns
The duplicated structure to use.

◆ lysc_update_path()

LIBYANG_API_DECL void lysc_update_path ( struct lysc_ctx *  ctx,
struct lys_module parent_module,
const char *  name 
)

Update path in the compile context, which is used for logging where the compilation failed.

Parameters
[in]ctxCompile context with the path.
[in]parent_moduleModule of the current node's parent to check difference with the currently processed module (taken from ctx).
[in]nameName of the node to update path with. If NULL, the last segment is removed. If the format is {keyword}, the following call updates the segment to the form ‘{keyword='name’}` (to remove this compound segment, 2 calls with NULL name must be used).