libyang  2.0.7
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
context.h
Go to the documentation of this file.
1 
15 #ifndef LY_CONTEXT_H_
16 #define LY_CONTEXT_H_
17 
18 #include <stdint.h>
19 
20 #include "log.h"
21 #include "parser_schema.h"
22 #include "tree_data.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 struct lyd_node;
29 struct lys_module;
30 struct lysc_node;
31 
153 struct ly_ctx;
154 
164 #define LY_CTX_ALL_IMPLEMENTED 0x01
165 #define LY_CTX_REF_IMPLEMENTED 0x02
171 #define LY_CTX_NO_YANGLIBRARY 0x04
177 #define LY_CTX_DISABLE_SEARCHDIRS 0x08
181 #define LY_CTX_DISABLE_SEARCHDIR_CWD 0x10
184 #define LY_CTX_PREFER_SEARCHDIRS 0x20
185 #define LY_CTX_SET_PRIV_PARSED 0x40
193 #define LY_CTX_EXPLICIT_COMPILE 0x80
223 LY_ERR ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx);
224 
246 LY_ERR ly_ctx_new_ylpath(const char *search_dir, const char *path, LYD_FORMAT format, int options, struct ly_ctx **ctx);
247 
269 LY_ERR ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options, struct ly_ctx **ctx);
270 
279 
290 LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir);
291 
301 LY_ERR ly_ctx_unset_searchdir(struct ly_ctx *ctx, const char *value);
302 
314 LY_ERR ly_ctx_unset_searchdir_last(struct ly_ctx *ctx, uint32_t count);
315 
323 const char * const *ly_ctx_get_searchdirs(const struct ly_ctx *ctx);
324 
331 uint16_t ly_ctx_get_options(const struct ly_ctx *ctx);
332 
341 LY_ERR ly_ctx_set_options(struct ly_ctx *ctx, uint16_t option);
342 
349 LY_ERR ly_ctx_unset_options(struct ly_ctx *ctx, uint16_t option);
350 
357 uint16_t ly_ctx_get_change_count(const struct ly_ctx *ctx);
358 
365 typedef void (*ly_module_imp_data_free_clb)(void *module_data, void *user_data);
366 
389 typedef LY_ERR (*ly_module_imp_clb)(const char *mod_name, const char *mod_rev, const char *submod_name, const char *submod_rev,
390  void *user_data, LYS_INFORMAT *format, const char **module_data, ly_module_imp_data_free_clb *free_module_data);
391 
399 ly_module_imp_clb ly_ctx_get_module_imp_clb(const struct ly_ctx *ctx, void **user_data);
400 
410 void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data);
411 
421 struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision);
422 
433 struct lys_module *ly_ctx_get_module_latest(const struct ly_ctx *ctx, const char *name);
434 
443 struct lys_module *ly_ctx_get_module_implemented(const struct ly_ctx *ctx, const char *name);
444 
454 const struct lys_module *ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *index);
455 
465 struct lys_module *ly_ctx_get_module_ns(const struct ly_ctx *ctx, const char *ns, const char *revision);
466 
477 struct lys_module *ly_ctx_get_module_latest_ns(const struct ly_ctx *ctx, const char *ns);
478 
487 struct lys_module *ly_ctx_get_module_implemented_ns(const struct ly_ctx *ctx, const char *ns);
488 
497 const struct lysp_submodule *ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *submodule, const char *revision);
498 
507 const struct lysp_submodule *ly_ctx_get_submodule_latest(const struct ly_ctx *ctx, const char *submodule);
508 
517 const struct lysp_submodule *ly_ctx_get_submodule2(const struct lys_module *module, const char *submodule,
518  const char *revision);
519 
528 const struct lysp_submodule *ly_ctx_get_submodule2_latest(const struct lys_module *module, const char *submodule);
529 
545 void ly_ctx_reset_latests(struct ly_ctx *ctx);
546 
554 uint32_t ly_ctx_internal_modules_count(const struct ly_ctx *ctx);
555 
575 const struct lys_module *ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision,
576  const char **features);
577 
598 LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root, const char *content_id_format, ...);
599 
615 void ly_ctx_destroy(struct ly_ctx *ctx);
616 
619 #ifdef __cplusplus
620 }
621 #endif
622 
623 #endif /* LY_CONTEXT_H_ */
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.
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_ERR ly_ctx_compile(struct ly_ctx *ctx)
Compile (recompile) the context applying all the performed changes after the last context compilation...
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_ERR ly_ctx_unset_searchdir(struct ly_ctx *ctx, const char *value)
Clean the search path(s) from the libyang context.
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.
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.
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_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 content of the given yang-library data.
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.
Definition: context.h:389
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.
const struct lys_module * ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *index)
Iterate over all modules in the given context.
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...
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...
uint16_t ly_ctx_get_options(const struct ly_ctx *ctx)
Get the currently set context's options.
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 content of the given yang-library data.
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_ERR ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx)
Create libyang context.
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_ERR ly_ctx_set_options(struct ly_ctx *ctx, uint16_t option)
Set some of the context's options, see Context options.
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!
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_ERR ly_ctx_unset_options(struct ly_ctx *ctx, uint16_t option)
Unset some of the context's options, see Context options.
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,...
void ly_ctx_reset_latests(struct ly_ctx *ctx)
Reset cached latest revision information of the schemas in the context.
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:365
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.
void ly_ctx_destroy(struct ly_ctx *ctx)
Free all internal structures of the specified context.
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.
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()...
const 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 callbac...
LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir)
Add the search path into libyang context.
libyang context handler.
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:504
LY_ERR
libyang's error codes returned by the libyang functions.
Definition: log.h:242
const char * name
Definition: tree_schema.h:2297
const char * revision
Definition: tree_schema.h:2298
const char * ns
Definition: tree_schema.h:2299
struct ly_ctx * ctx
Definition: tree_schema.h:2296
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
Definition: parser_schema.h:89
Available YANG schema tree structures representing YANG module.
Definition: tree_schema.h:2295
Compiled YANG data node.
Definition: tree_schema.h:1644
Logger manipulation routines and error definitions.
Schema parsers for libyang.
libyang representation of YANG data trees.
Generic structure for a data node.
Definition: tree_data.h:754