![]() |
libyang 1.0.184
YANG data modeling language library
|
Modules | |
Context options | |
Data Structures | |
struct | ly_ctx |
libyang context handler. More... | |
Macros | |
#define | LY_MODCLB_NOT_IMPLEMENTED 0x01 |
Typedefs | |
typedef const char *(* | ly_module_imp_clb) (const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, LYS_INFORMAT *format, void(**free_module_data) (void *model_data, void *user_data)) |
Callback for retrieving missing included or imported models in a custom way. More... | |
typedef const struct lys_module *(* | ly_module_data_clb) (struct ly_ctx *ctx, const char *name, const char *ns, int options, void *user_data) |
Callback for retrieving missing modules in the context, for which some data was found. More... | |
Functions | |
struct ly_ctx * | ly_ctx_new (const char *search_dir, int options) |
Create libyang context. More... | |
struct ly_ctx * | ly_ctx_new_ylpath (const char *search_dir, const char *path, LYD_FORMAT format, int options) |
Create libyang context according to the content of the given yang-library data. More... | |
struct ly_ctx * | ly_ctx_new_ylmem (const char *search_dir, const char *data, LYD_FORMAT format, int options) |
Create libyang context according to the content of the given yang-library data. More... | |
unsigned int | ly_ctx_internal_modules_count (struct ly_ctx *ctx) |
Number of internal modules, which are in the context and cannot be removed nor disabled. More... | |
int | ly_ctx_set_searchdir (struct ly_ctx *ctx, const char *search_dir) |
Add the search path into libyang context. More... | |
void | ly_ctx_unset_searchdirs (struct ly_ctx *ctx, int index) |
Clean the search path(s) from the libyang context. More... | |
const char *const * | ly_ctx_get_searchdirs (const struct ly_ctx *ctx) |
Get the NULL-terminated list of the search paths in libyang context. More... | |
int | ly_ctx_get_options (struct ly_ctx *ctx) |
Get the currently set context's options. More... | |
void | ly_ctx_set_disable_searchdirs (struct ly_ctx *ctx) |
Make context to stop searching for schemas (imported, included or requested via ly_ctx_load_module()) in searchdirs set via ly_ctx_set_searchdir() functions. Searchdirs are still stored in the context, so by unsetting the option by ly_ctx_unset_disable_searchdirs() searching in all previously searchdirs is restored. More... | |
void | ly_ctx_unset_disable_searchdirs (struct ly_ctx *ctx) |
Reverse function to ly_ctx_set_disable_searchdirs(). More... | |
void | ly_ctx_set_disable_searchdir_cwd (struct ly_ctx *ctx) |
Make context to stop implicitly searching for schemas (imported, included or requested via ly_ctx_load_module()) in current working directory. This flag can be unset by ly_ctx_unset_disable_searchdir_cwd(). More... | |
void | ly_ctx_unset_disable_searchdir_cwd (struct ly_ctx *ctx) |
Reverse function to ly_ctx_set_disable_searchdir_cwd(). More... | |
void | ly_ctx_set_prefer_searchdirs (struct ly_ctx *ctx) |
Prefer context's searchdirs before the user callback (ly_module_imp_clb) provided via ly_ctx_set_module_imp_clb()). More... | |
void | ly_ctx_unset_prefer_searchdirs (struct ly_ctx *ctx) |
Reverse function to ly_ctx_set_prefer_searchdirs(). More... | |
void | ly_ctx_set_allimplemented (struct ly_ctx *ctx) |
Make context to set all the imported modules to be implemented. By default, if the imported module is not used in leafref's path, augment or deviation, it is imported and its data tree is not taken into account. More... | |
void | ly_ctx_unset_allimplemented (struct ly_ctx *ctx) |
Reverse function to ly_ctx_set_allimplemented(). More... | |
void | ly_ctx_set_trusted (struct ly_ctx *ctx) |
Change the schema parser behavior when parsing new schemas forcing it to skip some of the schema validation checks to improve performance. Note that parsing invalid schemas this way may lead to an undefined behavior later, e.g. when working with data trees. More... | |
void | ly_ctx_unset_trusted (struct ly_ctx *ctx) |
Reverse function to ly_ctx_set_trusted(). More... | |
uint16_t | ly_ctx_get_module_set_id (const struct ly_ctx *ctx) |
Get current ID of the modules set. The value is available also as module-set-id in ly_ctx_info() result. More... | |
struct lyd_node * | ly_ctx_info (struct ly_ctx *ctx) |
Get data of an internal ietf-yang-library module. More... | |
const struct lys_module * | ly_ctx_get_module_iter (const struct ly_ctx *ctx, uint32_t *idx) |
Iterate over all (enabled) modules in a context. More... | |
const struct lys_module * | ly_ctx_get_disabled_module_iter (const struct ly_ctx *ctx, uint32_t *idx) |
Iterate over the disabled modules in a context. More... | |
const struct lys_module * | ly_ctx_get_module (const struct ly_ctx *ctx, const char *name, const char *revision, int implemented) |
Get pointer to the schema tree of the module of the specified name. More... | |
const struct lys_module * | ly_ctx_get_module_older (const struct ly_ctx *ctx, const struct lys_module *module) |
Get pointer to the older schema tree to the specified one in the provided context. More... | |
const struct lys_module * | ly_ctx_load_module (struct ly_ctx *ctx, const char *name, const char *revision) |
Try to find the model in the searchpath of ctx and load it into it. If custom missing module callback is set, it is used instead. More... | |
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... | |
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... | |
void | ly_ctx_set_module_data_clb (struct ly_ctx *ctx, ly_module_data_clb clb, void *user_data) |
Set the missing data module callback. It will be called when some data is parsed or searched for and their module is not found in the context or is not implemented. More... | |
ly_module_data_clb | ly_ctx_get_module_data_clb (const struct ly_ctx *ctx, void **user_data) |
Get the missing data module calback. More... | |
void | ly_ctx_set_priv_dup_clb (struct ly_ctx *ctx, void *(*priv_dup_clb)(const void *priv)) |
const struct lys_module * | ly_ctx_get_module_by_ns (const struct ly_ctx *ctx, const char *ns, const char *revision, int implemented) |
Get pointer to the schema tree of the module of the specified namespace. More... | |
const struct lys_submodule * | ly_ctx_get_submodule (const struct ly_ctx *ctx, const char *module, const char *revision, const char *submodule, const char *sub_revision) |
Get submodule of a main module. More... | |
const struct lys_submodule * | ly_ctx_get_submodule2 (const struct lys_module *main_module, const char *submodule) |
Get submodule of a main module. More... | |
const struct lys_node * | ly_ctx_get_node (const struct ly_ctx *ctx, const struct lys_node *start, const char *data_path, int output) |
Get schema node according to the given data path (JSON format, see XPath Addressing). More... | |
struct ly_set * | ly_ctx_find_path (struct ly_ctx *ctx, const char *path) |
Get schema node according to the given schema path (see XPath Addressing). More... | |
int | ly_ctx_remove_module (const struct lys_module *module, void(*private_destructor)(const struct lys_node *node, void *priv)) |
Remove the specified module from its context. More... | |
void | ly_ctx_clean (struct ly_ctx *ctx, void(*private_destructor)(const struct lys_node *node, void *priv)) |
Remove all the modules from the context except the internal modules. Also the addition data in dictionary are kept. More... | |
void | ly_ctx_destroy (struct ly_ctx *ctx, void(*private_destructor)(const struct lys_node *node, void *priv)) |
Free all internal structures of the specified context. More... | |
char * | ly_path_xml2json (struct ly_ctx *ctx, const char *xml_path, struct lyxml_elem *xml) |
Transform a data path in XML format (node prefixes are XML namespace prefixes of module namespaces) to JSON format (node prefixes are module names directly). More... | |
char * | ly_path_data2schema (struct ly_ctx *ctx, const char *data_path) |
Transform a data path into schema path (see XPath Addressing). More... | |
Structures and functions to manipulate with the libyang "containers". The context concept allows callers to work in environments with different sets of YANG schemas. More detailed information can be found at Context page.
struct ly_ctx |
libyang context handler.
typedef const char *(* ly_module_imp_clb) (const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, LYS_INFORMAT *format, void(**free_module_data)(void *model_data, void *user_data)) |
Callback for retrieving missing included or imported models in a custom way.
[in] | mod_name | Missing module name. |
[in] | mod_rev | Optional missing module revision. |
[in] | submod_name | Optional missing submodule name. |
[in] | submod_rev | Optional missing submodule revision. |
[in] | user_data | User-supplied callback data. |
[out] | format | Format of the returned module data. |
[out] | free_module_data | Callback for freeing the returned module data. If not set, the data will be left untouched. |
typedef const struct lys_module *(* ly_module_data_clb) (struct ly_ctx *ctx, const char *name, const char *ns, int options, void *user_data) |
Callback for retrieving missing modules in the context, for which some data was found.
Either name
or ns
is ALWAYS set, but both can also be set.
[in,out] | ctx | Context with the missing module. |
[in] | name | Missing module name. |
[in] | ns | Missing module namespace. |
[in] | options | Bitmask of LY_MODCLB_* values or 0. |
[in] | user_data | User-supplied callback data. |
struct ly_ctx * ly_ctx_new | ( | const char * | search_dir, |
int | options | ||
) |
Create libyang context.
Context is used to hold all information about schemas. Usually, the application is supposed to work with a single context in which libyang is holding all schemas (and other internal information) according to which the data trees will be processed and validated. So, the schema trees are tightly connected with the specific context and they are held by the context internally
[in] | search_dir | Directory where libyang will search for the imported or included modules and submodules. If no such directory is available, NULL is accepted. |
[in] | options | Context options, see Context options. |
struct ly_ctx * ly_ctx_new_ylpath | ( | const char * | search_dir, |
const char * | path, | ||
LYD_FORMAT | format, | ||
int | options | ||
) |
Create libyang context according to the content of the given yang-library data.
This function loads the yang-library data from the file at the given path. If you need to pass the data as string, use ly_ctx_new_ylmem(). Both functions extend functionality of ly_ctx_new() by loading modules specified in the ietf-yang-library form into the context being created.
The preferred tree model revision is 2018-01-17. However, only the first module-set is processed and loaded into the context. If there are no matching nodes from this tree, the legacy tree (originally from model revision 2016-04-09) is processed.
Note, that the modules are loaded the same way as in case of ly_ctx_load_module(), so the schema paths in the yang-library data are ignored and the modules are loaded from the context's search locations. On the other hand, YANG features of the modules are set as specified in the yang-library data.
To get yang library data from a libyang context, use ly_ctx_info().
[in] | search_dir | Directory where libyang will search for the imported or included modules and submodules. If no such directory is available, NULL is accepted. |
[in] | path | Path to the file containing yang-library data in the specified format . |
[in] | format | Format of the data in the provided file. |
[in] | options | Context options, see Context options. |
struct ly_ctx * ly_ctx_new_ylmem | ( | const char * | search_dir, |
const char * | data, | ||
LYD_FORMAT | format, | ||
int | options | ||
) |
Create libyang context according to the content of the given yang-library data.
This function loads the yang-library data from the given string. If you need to pass the data as path to a file holding the data, use ly_ctx_new_ylpath(). Both functions extend functionality of ly_ctx_new() by loading modules specified in the ietf-yang-library form into the context being created.
The preferred tree model revision is 2018-01-17. However, only the first module-set is processed and loaded into the context. If there are no matching nodes from this tree, the legacy tree (originally from model revision 2016-04-09) is processed.
Note, that the modules are loaded the same way as in case of ly_ctx_load_module(), so the schema paths in the yang-library data are ignored and the modules are loaded from the context's search locations. On the other hand, YANG features of the modules are set as specified in the yang-library data.
To get yang library data from a libyang context, use ly_ctx_info().
[in] | search_dir | Directory where libyang will search for the imported or included modules and submodules. If no such directory is available, NULL is accepted. |
[in] | data | String containing yang-library data in the specified format . |
[in] | format | Format of the data in the provided file. |
[in] | options | Context options, see Context options. |
unsigned int ly_ctx_internal_modules_count | ( | struct ly_ctx * | ctx | ) |
Number of internal modules, which are in the context and cannot be removed nor disabled.
[in] | ctx | Context to investigate. |
int ly_ctx_set_searchdir | ( | struct ly_ctx * | ctx, |
const char * | search_dir | ||
) |
Add the search path into libyang context.
To reset search paths set in the context, use ly_ctx_unset_searchdirs() and then set search paths again.
[in] | ctx | Context to be modified. |
[in] | search_dir | New search path to add to the current paths previously set in ctx. |
void ly_ctx_unset_searchdirs | ( | struct ly_ctx * | ctx, |
int | index | ||
) |
Clean the search path(s) from the libyang context.
[in] | ctx | Context to be modified. |
[in] | index | Index of the search path to be removed, use negative value to remove them all. Correct index value can be checked via ly_ctx_get_searchdirs(). |
const char *const * ly_ctx_get_searchdirs | ( | const struct ly_ctx * | ctx | ) |
Get the NULL-terminated list of the search paths in libyang context.
[in] | ctx | Context to query. |
int ly_ctx_get_options | ( | struct ly_ctx * | ctx | ) |
Get the currently set context's options.
[in] | ctx | Context to query. |
void ly_ctx_set_disable_searchdirs | ( | struct ly_ctx * | ctx | ) |
Make context to stop searching for schemas (imported, included or requested via ly_ctx_load_module()) in searchdirs set via ly_ctx_set_searchdir() functions. Searchdirs are still stored in the context, so by unsetting the option by ly_ctx_unset_disable_searchdirs() searching in all previously searchdirs is restored.
The same effect is achieved by using LY_CTX_DISABLE_SEARCHDIRS option when creating new context or parsing a specific schema.
[in] | ctx | Context to be modified. |
void ly_ctx_unset_disable_searchdirs | ( | struct ly_ctx * | ctx | ) |
Reverse function to ly_ctx_set_disable_searchdirs().
[in] | ctx | Context to be modified. |
void ly_ctx_set_disable_searchdir_cwd | ( | struct ly_ctx * | ctx | ) |
Make context to stop implicitly searching for schemas (imported, included or requested via ly_ctx_load_module()) in current working directory. This flag can be unset by ly_ctx_unset_disable_searchdir_cwd().
The same effect is achieved by using LY_CTX_DISABLE_SEARCHDIR_CWD option when creating new context or parsing a specific schema.
[in] | ctx | Context to be modified. |
void ly_ctx_unset_disable_searchdir_cwd | ( | struct ly_ctx * | ctx | ) |
Reverse function to ly_ctx_set_disable_searchdir_cwd().
[in] | ctx | Context to be modified. |
void ly_ctx_set_prefer_searchdirs | ( | struct ly_ctx * | ctx | ) |
Prefer context's searchdirs before the user callback (ly_module_imp_clb) provided via ly_ctx_set_module_imp_clb()).
The same effect is achieved by using LY_CTX_PREFER_SEARCHDIRS option when creating new context or parsing a specific schema.
[in] | ctx | Context to be modified. |
void ly_ctx_unset_prefer_searchdirs | ( | struct ly_ctx * | ctx | ) |
Reverse function to ly_ctx_set_prefer_searchdirs().
[in] | ctx | Context to be modified. |
void ly_ctx_set_allimplemented | ( | struct ly_ctx * | ctx | ) |
Make context to set all the imported modules to be implemented. By default, if the imported module is not used in leafref's path, augment or deviation, it is imported and its data tree is not taken into account.
The same effect is achieved by using LY_CTX_ALLIMPLEMENTED option when creating new context or parsing a specific schema.
Note, that function does not make the currently loaded modules, it just change the schema parser behavior for the future parsing. This flag can be unset by ly_ctx_unset_allimplemented().
[in] | ctx | Context to be modified. |
void ly_ctx_unset_allimplemented | ( | struct ly_ctx * | ctx | ) |
Reverse function to ly_ctx_set_allimplemented().
[in] | ctx | Context to be modified. |
void ly_ctx_set_trusted | ( | struct ly_ctx * | ctx | ) |
Change the schema parser behavior when parsing new schemas forcing it to skip some of the schema validation checks to improve performance. Note that parsing invalid schemas this way may lead to an undefined behavior later, e.g. when working with data trees.
The same effect is achieved by using LY_CTX_TRUSTED option when creating new context or parsing a specific schema.
This flag can be unset by ly_ctx_unset_trusted().
[in] | ctx | Context to be modified. |
void ly_ctx_unset_trusted | ( | struct ly_ctx * | ctx | ) |
Reverse function to ly_ctx_set_trusted().
[in] | ctx | Context to be modified. |
uint16_t ly_ctx_get_module_set_id | ( | const struct ly_ctx * | ctx | ) |
Get current ID of the modules set. The value is available also as module-set-id in ly_ctx_info() result.
[in] | ctx | Context to be examined. |
Get data of an internal ietf-yang-library module.
[in] | ctx | Context with the modules. |
const struct lys_module * ly_ctx_get_module_iter | ( | const struct ly_ctx * | ctx, |
uint32_t * | idx | ||
) |
Iterate over all (enabled) modules in a context.
[in] | ctx | Context with the modules. |
[in,out] | idx | Index of the next module to be returned. Value of 0 starts from the beginning. |
const struct lys_module * ly_ctx_get_disabled_module_iter | ( | const struct ly_ctx * | ctx, |
uint32_t * | idx | ||
) |
Iterate over the disabled modules in a context.
[in] | ctx | Context with the modules. |
[in,out] | idx | Index of the next module to be returned. Value of 0 starts from the beginning. |
const struct lys_module * ly_ctx_get_module | ( | const struct ly_ctx * | ctx, |
const char * | name, | ||
const char * | revision, | ||
int | implemented | ||
) |
Get pointer to the schema tree of the module of the specified name.
[in] | ctx | Context to work in. |
[in] | name | Name of the YANG module to get. |
[in] | revision | Optional revision date of the YANG module to get. If not specified, the schema in the newest/implemented revision (see implemented parameter) is returned if any. |
[in] | implemented | In case the revision is not specified, require the implemented module instead of the newest revision of the module. |
const struct lys_module * ly_ctx_get_module_older | ( | const struct ly_ctx * | ctx, |
const struct lys_module * | module | ||
) |
Get pointer to the older schema tree to the specified one in the provided context.
The module is not necessarily from the provided ctx
. If there are multiple schemas older than the provided one, the newest of them is returned.
The function can be used in combination with ly_ctx_get_module() to get all revisions of a module in a context:
[in] | ctx | Context to work in. |
[in] | module | YANG module to compare with |
const struct lys_module * ly_ctx_load_module | ( | struct ly_ctx * | ctx, |
const char * | name, | ||
const char * | revision | ||
) |
Try to find the model in the searchpath of ctx
and load it into it. If custom missing module callback is set, it is used instead.
If there is a possibility that the requested module is already in the context, you should call the ly_ctx_get_module() first to avoid a lot of work performed by ly_ctx_load_module().
[in] | ctx | Context to add to. |
[in] | name | Name of the module to load. |
[in] | revision | Optional revision date of the module. If not specified, it is assumed that there is only one model revision in the searchpath (the first matching file is parsed). |
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.
[in] | ctx | Context that will use this callback. |
[in] | clb | Callback responsible for returning the missing model. |
[in] | user_data | Arbitrary data that will always be passed to the callback clb . |
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.
[in] | ctx | Context to read from. |
[in] | user_data | Optional pointer for getting the user-supplied callback data. |
void ly_ctx_set_module_data_clb | ( | struct ly_ctx * | ctx, |
ly_module_data_clb | clb, | ||
void * | user_data | ||
) |
Set the missing data module callback. It will be called when some data is parsed or searched for and their module is not found in the context or is not implemented.
[in] | ctx | Context that will use this callback. |
[in] | clb | Callback responsible for returning the missing model. |
[in] | user_data | Arbitrary data that will always be passed to the callback clb . |
ly_module_data_clb ly_ctx_get_module_data_clb | ( | const struct ly_ctx * | ctx, |
void ** | user_data | ||
) |
Get the missing data module calback.
[in] | ctx | Context to read from. |
[in] | user_data | Optional pointer for getting the user-supplied callback data. |
void ly_ctx_set_priv_dup_clb | ( | struct ly_ctx * | ctx, |
void *(*)(const void *priv) | priv_dup_clb | ||
) |
const struct lys_module * ly_ctx_get_module_by_ns | ( | const struct ly_ctx * | ctx, |
const char * | ns, | ||
const char * | revision, | ||
int | implemented | ||
) |
Get pointer to the schema tree of the module of the specified namespace.
[in] | ctx | Context to work in. |
[in] | ns | Namespace of the YANG module to get. |
[in] | revision | Optional revision date of the YANG module to get. If not specified, the schema in the newest/implemented revision (see implemented parameter) is returned if any. |
[in] | implemented | In case the revision is not specified, require the implemented module instead of the newest revision of the module. |
const struct lys_submodule * ly_ctx_get_submodule | ( | const struct ly_ctx * | ctx, |
const char * | module, | ||
const char * | revision, | ||
const char * | submodule, | ||
const char * | sub_revision | ||
) |
Get submodule of a main module.
If you already have the pointer to the submodule's main module, use ly_ctx_get_submodule2() instead.
[in] | ctx | Context to work in. |
[in] | module | Name of the main (belongs-to) module. If NULL, all module submodules are searched. |
[in] | revision | Optional revision date of module . If NULL, all revisions of module are searched. If set, module must also be set. |
[in] | submodule | Name of the submodule to get. |
[in] | sub_revision | Optional revision date of submodule . If NULL, the newest revision of submodule is returned. |
const struct lys_submodule * ly_ctx_get_submodule2 | ( | const struct lys_module * | main_module, |
const char * | submodule | ||
) |
Get submodule of a main module.
If you have only the name (and optionally revision) of the submodule's main module, use ly_ctx_get_submodule() instead.
[in] | main_module | Main module (belongs to) of the searched submodule. |
[in] | submodule | Name of the submodule to get. |
const struct lys_node * ly_ctx_get_node | ( | const struct ly_ctx * | ctx, |
const struct lys_node * | start, | ||
const char * | data_path, | ||
int | output | ||
) |
Get schema node according to the given data path (JSON format, see XPath Addressing).
This function is meant as a utility function to ease getting a specific schema node directly from context having data_path
a const immutable string. Generally, it is better to use lyd_find_path(), lys_find_path(), or ly_ctx_find_path(). Also, it is possible to transform data paths into schema paths using ly_path_data2schema().
[in] | ctx | Context to work in. Must be set if start is NULL. |
[in] | start | Starting node for a relative data node identifier, in which case it is mandatory and ctx can be NULL. |
[in] | data_path | JSON data path of the node to get. |
[in] | output | Search operation output instead input. |
Get schema node according to the given schema path (see XPath Addressing).
Note that the given path must be absolute and fully prefixed (which is the default output of lys_path() function). To get node specified by a relative path, use lys_find_path() instead.
[in] | ctx | Context to work in. |
[in] | path | Schema path of the node to find. |
path
the returned set is empty. In case of an error, NULL is returned. int ly_ctx_remove_module | ( | const struct lys_module * | module, |
void(*)(const struct lys_node *node, void *priv) | private_destructor | ||
) |
Remove the specified module from its context.
Beside the selected module, also all other modules depending on all the modules being removed will be removed as well.
libyang internal modules (those present when the context is created) cannot be removed.
[in] | module | Module to be removed. |
[in] | private_destructor | Optional destructor function for private objects assigned to the nodes via lys_set_private(). If NULL, the private objects are not freed by libyang. |
void ly_ctx_clean | ( | struct ly_ctx * | ctx, |
void(*)(const struct lys_node *node, void *priv) | private_destructor | ||
) |
Remove all the modules from the context except the internal modules. Also the addition data in dictionary are kept.
[in] | ctx | Context to work in. |
[in] | private_destructor | Optional destructor function for private objects assigned to the nodes via lys_set_private(). If NULL, the private objects are not freed by libyang. |
void ly_ctx_destroy | ( | struct ly_ctx * | ctx, |
void(*)(const struct lys_node *node, void *priv) | private_destructor | ||
) |
Free all internal structures of the specified context.
The function should be used before terminating the application to destroy and free all structures internally used by libyang. If the caller uses multiple contexts, the function should be called for each used context.
All instance data are supposed to be freed before destroying the context. Data models are destroyed automatically as part of ly_ctx_destroy() call.
[in] | ctx | libyang context to destroy |
[in] | private_destructor | Optional destructor function for private objects assigned to the nodes via lys_set_private(). If NULL, the private objects are not freed by libyang. Remember the differences between the structures derived from lys_node and always check lys_node::nodetype. |
char * ly_path_xml2json | ( | struct ly_ctx * | ctx, |
const char * | xml_path, | ||
struct lyxml_elem * | xml | ||
) |
Transform a data path in XML format (node prefixes are XML namespace prefixes of module namespaces) to JSON format (node prefixes are module names directly).
[in] | ctx | Context to work in. |
[in] | xml_path | Path in XML format to transform. |
[in] | xml | XML tree to be used for XML namespace prefix resolution. |
char * ly_path_data2schema | ( | struct ly_ctx * | ctx, |
const char * | data_path | ||
) |
Transform a data path into schema path (see XPath Addressing).
Some XPath tokens such as "*" or "//" should not be used because they cannot be properly transformed into schema path. If used, any following nodes will not be transformed and simply copied, so use at your own risk! It causes no problems if the path ends with the aforementioned tokens.
[in] | ctx | Context to work in. |
[in] | data_path | Data path to be transformed. |