Loading...
Searching...
No Matches
context.h
Go to the documentation of this file.
#ifndef LY_CONTEXT_H_
#define LY_CONTEXT_H_
#include <stdint.h>
#include "log.h"
#include "parser_schema.h"
#include "tree_data.h"
#ifdef __cplusplus
extern "C" {
#endif
struct lys_module;
struct ly_ctx;
#define LY_CTX_ALL_IMPLEMENTED 0x01
#define LY_CTX_REF_IMPLEMENTED 0x02
#define LY_CTX_NO_YANGLIBRARY 0x04
#define LY_CTX_DISABLE_SEARCHDIRS 0x08
#define LY_CTX_DISABLE_SEARCHDIR_CWD 0x10
#define LY_CTX_PREFER_SEARCHDIRS 0x20
#define LY_CTX_SET_PRIV_PARSED 0x40
#define LY_CTX_EXPLICIT_COMPILE 0x80
#define LY_CTX_ENABLE_IMP_FEATURES 0x0100
#define LY_CTX_LEAFREF_EXTENDED 0x0200
#define LY_CTX_LEAFREF_LINKING 0x0400
#define LY_CTX_BUILTIN_PLUGINS_ONLY 0x0800
LIBYANG_API_DECL LY_ERR ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_new_ylpath(const char *search_dir, const char *path, LYD_FORMAT format, int options,
struct ly_ctx **ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options,
struct ly_ctx **ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_new_yldata(const char *search_dir, const struct lyd_node *tree, int options,
struct ly_ctx **ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_compile(struct ly_ctx *ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir);
LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir(struct ly_ctx *ctx, const char *value);
LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir_last(struct ly_ctx *ctx, uint32_t count);
LIBYANG_API_DECL const char * const *ly_ctx_get_searchdirs(const struct ly_ctx *ctx);
LIBYANG_API_DECL uint16_t ly_ctx_get_options(const struct ly_ctx *ctx);
LIBYANG_API_DECL LY_ERR ly_ctx_set_options(struct ly_ctx *ctx, uint16_t option);
LIBYANG_API_DECL LY_ERR ly_ctx_unset_options(struct ly_ctx *ctx, uint16_t option);
LIBYANG_API_DECL uint16_t ly_ctx_get_change_count(const struct ly_ctx *ctx);
LIBYANG_API_DECL uint32_t ly_ctx_get_modules_hash(const struct ly_ctx *ctx);
typedef void (*ly_module_imp_data_free_clb)(void *module_data, void *user_data);
typedef LY_ERR (*ly_module_imp_clb)(const char *mod_name, const char *mod_rev, const char *submod_name, const char *submod_rev,
void *user_data, LYS_INFORMAT *format, const char **module_data, ly_module_imp_data_free_clb *free_module_data);
LIBYANG_API_DECL ly_module_imp_clb ly_ctx_get_module_imp_clb(const struct ly_ctx *ctx, void **user_data);
LIBYANG_API_DECL void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data);
typedef LY_ERR (*ly_ext_data_clb)(const struct lysc_ext_instance *ext, void *user_data, void **ext_data,
ly_bool *ext_data_free);
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);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_latest(const struct ly_ctx *ctx, const char *name);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_implemented(const struct ly_ctx *ctx, const char *name);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *index);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_ns(const struct ly_ctx *ctx, const char *ns, const char *revision);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_latest_ns(const struct ly_ctx *ctx, const char *ns);
LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_implemented_ns(const struct ly_ctx *ctx, const char *ns);
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_latest(const struct ly_ctx *ctx, const char *submodule);
LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2(const struct lys_module *module, const char *submodule,
const char *revision);
LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2_latest(const struct lys_module *module,
const char *submodule);
LIBYANG_API_DECL uint32_t ly_ctx_internal_modules_count(const struct ly_ctx *ctx);
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 LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root,
const char *content_id_format, ...);
LIBYANG_API_DECL void ly_ctx_destroy(struct ly_ctx *ctx);
#ifdef __cplusplus
}
#endif
#endif /* LY_CONTEXT_H_ */
ly_ctx_get_module_imp_clb
LIBYANG_API_DECL ly_module_imp_clb ly_ctx_get_module_imp_clb(const struct ly_ctx *ctx, void **user_data)
Get the custom callback for missing import/include module retrieval.
ly_ctx_unset_searchdir
LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir(struct ly_ctx *ctx, const char *value)
Clean the search path(s) from the libyang context.
ly_ctx_set_ext_data_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)
Set callback providing run-time extension instance data. The expected data depend on the extension....
ly_ctx_new
LIBYANG_API_DECL LY_ERR ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx)
Create libyang context.
ly_ctx_set_options
LIBYANG_API_DECL LY_ERR ly_ctx_set_options(struct ly_ctx *ctx, uint16_t option)
Set some of the context's options, see Context options.
ly_module_imp_clb
LY_ERR(* ly_module_imp_clb)(const char *mod_name, const char *mod_rev, const char *submod_name, const char *submod_rev, void *user_data, LYS_INFORMAT *format, const char **module_data, ly_module_imp_data_free_clb *free_module_data)
Callback for retrieving missing included or imported modules in a custom way.
Definition context.h:425
ly_ctx_get_module_implemented
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_implemented(const struct ly_ctx *ctx, const char *name)
Get the (only) implemented YANG module specified by its name.
ly_ctx_get_yanglib_data
LIBYANG_API_DECL LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root, const char *content_id_format,...)
Get data of the internal ietf-yang-library module with information about all the loaded modules....
ly_ctx_get_modules_hash
LIBYANG_API_DECL uint32_t ly_ctx_get_modules_hash(const struct ly_ctx *ctx)
Get the hash of all the modules in the context. Since order of the modules is significant,...
ly_ctx_get_options
LIBYANG_API_DECL uint16_t ly_ctx_get_options(const struct ly_ctx *ctx)
Get the currently set context's options.
ly_ctx_get_module
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision)
Get YANG module of the given name and revision.
ly_ctx_internal_modules_count
LIBYANG_API_DECL uint32_t ly_ctx_internal_modules_count(const struct ly_ctx *ctx)
Learn the number of internal modules of a context. Internal modules is considered one that was loaded...
ly_ctx_unset_options
LIBYANG_API_DECL LY_ERR ly_ctx_unset_options(struct ly_ctx *ctx, uint16_t option)
Unset some of the context's options, see Context options.
ly_ext_data_clb
LY_ERR(* ly_ext_data_clb)(const struct lysc_ext_instance *ext, void *user_data, void **ext_data, ly_bool *ext_data_free)
Callback for getting arbitrary run-time data required by an extension instance.
Definition context.h:457
ly_ctx_get_submodule
LIBYANG_API_DECL const struct lysp_submodule * ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *submodule, const char *revision)
Get a specific submodule from context. If its belongs-to module is known, use ly_ctx_get_submodule2()...
ly_ctx_set_module_imp_clb
LIBYANG_API_DECL void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data)
Set missing include or import module callback. It is meant to be used when the modules are not locall...
ly_ctx_destroy
LIBYANG_API_DECL void ly_ctx_destroy(struct ly_ctx *ctx)
Free all internal structures of the specified context.
ly_ctx_set_searchdir
LIBYANG_API_DECL LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir)
Add the search path into libyang context.
ly_ctx_get_submodule_latest
LIBYANG_API_DECL const struct lysp_submodule * ly_ctx_get_submodule_latest(const struct ly_ctx *ctx, const char *submodule)
Get the latests revision of a submodule from context. If its belongs-to module is known,...
ly_ctx_get_searchdirs
LIBYANG_API_DECL const char *const * ly_ctx_get_searchdirs(const struct ly_ctx *ctx)
Get the NULL-terminated list of the search paths in libyang context. Do not modify the result!
ly_ctx_new_ylmem
LIBYANG_API_DECL LY_ERR ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options, struct ly_ctx **ctx)
Create libyang context according to the provided yang-library data in a string.
ly_ctx_unset_searchdir_last
LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir_last(struct ly_ctx *ctx, uint32_t count)
Remove the least recently added search path(s) from the libyang context.
ly_ctx_get_submodule2_latest
LIBYANG_API_DECL const struct lysp_submodule * ly_ctx_get_submodule2_latest(const struct lys_module *module, const char *submodule)
Get the latest revision of a submodule from a module. If the belongs-to module is not known,...
ly_ctx_new_yldata
LIBYANG_API_DECL LY_ERR ly_ctx_new_yldata(const char *search_dir, const struct lyd_node *tree, int options, struct ly_ctx **ctx)
Create libyang context according to the provided yang-library data in a data tree.
ly_ctx_get_module_ns
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_ns(const struct ly_ctx *ctx, const char *ns, const char *revision)
Get YANG module of the given namespace and revision.
ly_ctx_get_module_latest_ns
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_latest_ns(const struct ly_ctx *ctx, const char *ns)
Get the latest revision of the YANG module specified by its namespace.
ly_ctx_load_module
LIBYANG_API_DECL struct lys_module * ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision, const char **features)
Try to find the module in the searchpaths of ctx and load it into it. If custom missing module callba...
ly_module_imp_data_free_clb
void(* ly_module_imp_data_free_clb)(void *module_data, void *user_data)
Callback for freeing returned module data in ly_module_imp_clb.
Definition context.h:401
ly_ctx_compile
LIBYANG_API_DECL LY_ERR ly_ctx_compile(struct ly_ctx *ctx)
Compile (recompile) the context applying all the performed changes after the last context compilation...
ly_ctx_get_module_iter
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *index)
Iterate over all modules in the given context.
ly_ctx_get_module_implemented_ns
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_implemented_ns(const struct ly_ctx *ctx, const char *ns)
Get the (only) implemented YANG module specified by its namespace.
ly_ctx_get_submodule2
LIBYANG_API_DECL const struct lysp_submodule * ly_ctx_get_submodule2(const struct lys_module *module, const char *submodule, const char *revision)
Get a specific submodule from a module. If the belongs-to module is not known, use ly_ctx_get_submodu...
ly_ctx_get_change_count
LIBYANG_API_DECL uint16_t ly_ctx_get_change_count(const struct ly_ctx *ctx)
Get the change count of the context (module set) during its life-time.
ly_ctx_get_module_latest
LIBYANG_API_DECL struct lys_module * ly_ctx_get_module_latest(const struct ly_ctx *ctx, const char *name)
Get the latest revision of the YANG module specified by its name.
ly_ctx_new_ylpath
LIBYANG_API_DECL LY_ERR ly_ctx_new_ylpath(const char *search_dir, const char *path, LYD_FORMAT format, int options, struct ly_ctx **ctx)
Create libyang context according to the provided yang-library data in a file.
ly_ctx
libyang context handler.
LYD_FORMAT
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:539
LY_ERR
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:237
lysc_ext_instance
YANG extension compiled instance.
Definition plugins_exts.h:437
lys_module::name
const char * name
Definition tree_schema.h:2139
lys_module::revision
const char * revision
Definition tree_schema.h:2140
lys_module::ns
const char * ns
Definition tree_schema.h:2141
lys_module::ctx
struct ly_ctx * ctx
Definition tree_schema.h:2138
LYS_INFORMAT
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
Definition parser_schema.h:91
lys_module
Available YANG schema tree structures representing YANG module.
Definition tree_schema.h:2137
lysp_submodule
Definition tree_schema.h:1126
log.h
Logger manipulation routines and error definitions.
ly_bool
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:35
parser_schema.h
Schema parsers for libyang.
tree_data.h
libyang representation of YANG data trees.
lyd_node
Generic structure for a data node.
Definition tree_data.h:795