libyang  2.2.8
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
context.h File Reference

internal context structures and functions More...

#include <stdint.h>
#include "log.h"
#include "parser_schema.h"
#include "tree_data.h"
Include dependency graph for context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LY_CTX_ALL_IMPLEMENTED   0x01
 
#define LY_CTX_BUILTIN_PLUGINS_ONLY   0x0800
 
#define LY_CTX_DISABLE_SEARCHDIR_CWD   0x10
 
#define LY_CTX_DISABLE_SEARCHDIRS   0x08
 
#define LY_CTX_ENABLE_IMP_FEATURES   0x0100
 
#define LY_CTX_EXPLICIT_COMPILE   0x80
 
#define LY_CTX_LEAFREF_EXTENDED   0x0200
 
#define LY_CTX_LEAFREF_LINKING   0x0400
 
#define LY_CTX_NO_YANGLIBRARY   0x04
 
#define LY_CTX_PREFER_SEARCHDIRS   0x20
 
#define LY_CTX_REF_IMPLEMENTED   0x02
 
#define LY_CTX_SET_PRIV_PARSED   0x40
 

Typedefs

typedef 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. More...
 
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)
 Callback for retrieving missing included or imported models in a custom way. More...
 
typedef void(* ly_module_imp_data_free_clb )(void *module_data, void *user_data)
 Callback for freeing returned module data in ly_module_imp_clb. More...
 

Functions

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. Should be used only if LY_CTX_EXPLICIT_COMPILE option is set, has no effect otherwise. More...
 
LIBYANG_API_DECL void ly_ctx_destroy (struct ly_ctx *ctx)
 Free all internal structures of the specified context. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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, even when 2 contexts have the same modules but loaded in a different order, the hash will differ. More...
 
LIBYANG_API_DECL uint16_t ly_ctx_get_options (const struct ly_ctx *ctx)
 Get the currently set context's options. More...
 
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! More...
 
LIBYANG_API_DECL 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(). More...
 
LIBYANG_API_DECL 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_submodule(). More...
 
LIBYANG_API_DECL 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, use ly_ctx_get_submodule_latest(). More...
 
LIBYANG_API_DECL 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, use ly_ctx_get_submodule2_latest(). More...
 
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. ietf-yang-library module must be loaded. More...
 
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 during the context creation. More...
 
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 model in the searchpaths of ctx and load it into it. If custom missing module callback is set, it is used instead. More...
 
LIBYANG_API_DECL LY_ERR ly_ctx_new (const char *search_dir, uint16_t options, struct ly_ctx **new_ctx)
 Create libyang context. More...
 
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. More...
 
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. More...
 
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. More...
 
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. Data expected by internal extensions: More...
 
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 models are not locally available (such as when downloading modules from a NETCONF server), it should not be required in other cases. More...
 
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. More...
 
LIBYANG_API_DECL LY_ERR ly_ctx_set_searchdir (struct ly_ctx *ctx, const char *search_dir)
 Add the search path into libyang context. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

internal context structures and functions

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz
Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz Copyright (c) 2015 - 2023 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. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file context.h.