blob: 9f1b8e6deb1d9e9c84a9b1b7b011f7ce688e07ab [file] [log] [blame]
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001/**
2 * @file context.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vasko0ace61d2023-05-09 15:18:58 +02004 * @author Michal Vasko <mvasko@cesnet.cz>
Radek Krejci5aeea3a2018-09-05 13:29:36 +02005 * @brief internal context structures and functions
6 *
Michal Vasko0ace61d2023-05-09 15:18:58 +02007 * Copyright (c) 2015 - 2023 CESNET, z.s.p.o.
Radek Krejci5aeea3a2018-09-05 13:29:36 +02008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef LY_CONTEXT_H_
17#define LY_CONTEXT_H_
18
Radek Krejcie7b95092019-05-15 11:03:07 +020019#include <stdint.h>
20
Radek Krejci6caa6ab2018-10-24 10:04:48 +020021#include "log.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020022#include "parser_schema.h"
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +020023#include "tree_data.h"
Radek Krejci5aeea3a2018-09-05 13:29:36 +020024
Radek Krejci6caa6ab2018-10-24 10:04:48 +020025#ifdef __cplusplus
26extern "C" {
27#endif
28
Radek Krejci77114102021-03-10 15:21:57 +010029struct lys_module;
Radek Krejcica376bd2020-06-11 16:04:06 +020030
Radek Krejci5aeea3a2018-09-05 13:29:36 +020031/**
Radek Krejci8678fa42020-08-18 16:07:28 +020032 * @page howtoContext Context
Radek Krejci52785a22019-09-11 12:57:26 +020033 *
Radek Krejci8678fa42020-08-18 16:07:28 +020034 * The context concept allows callers to work in environments with different sets of YANG modules.
Radek Krejci52785a22019-09-11 12:57:26 +020035 *
Radek Krejci8678fa42020-08-18 16:07:28 +020036 * The first step with libyang is to create a new context using ::ly_ctx_new(). It returns a handler used in the following work.
37 * Note that the context is supposed to provide a stable environment for work with the data. Therefore the caller should prepare
Michal Vasko5a5e7f82021-04-15 11:11:03 +020038 * a complete context and after starting working with the data, the context and its content should not change. If it does,
39 * in most cases it leads to the context being recompiled and any parsed data invalid. Despite the API not enforcing this
40 * approach, it may change in future versions in the form of a locking mechanism which would allow further
Radek Krejci8678fa42020-08-18 16:07:28 +020041 * optimization of data manipulation. Also note that modules cannot be removed from their context. If you need to change the set
42 * of the schema modules in the context, the recommended way is to create a new context. To remove the context, there is ::ly_ctx_destroy() function.
Radek Krejci52785a22019-09-11 12:57:26 +020043 *
Radek Krejci8678fa42020-08-18 16:07:28 +020044 * The context has [several options](@ref contextoptions) changing behavior when processing YANG modules being inserted. The
45 * specific behavior is mentioned below. All the options can be set as a parameter when the context is being created or later
46 * with ::ly_ctx_set_options().
47 *
48 * When creating a new context, another optional parameter is search_dir It provide directory where libyang
49 * will automatically search for YANG modules being imported or included. There is actually a set of search paths which can be later
50 * modified using ::ly_ctx_set_searchdir(), ::ly_ctx_unset_searchdir() and ::ly_ctx_unset_searchdir_last() functions. Before the values
51 * in the set are used, also the current working directory is (non-recursively) searched. For the case of the explicitly set
52 * search directories, they are searched recursively - all their subdirectories (and symlinks) are taken into account. Searching
53 * in the current working directory can be avoided with the context's ::LY_CTX_DISABLE_SEARCHDIR_CWD option.
Radek Krejci52785a22019-09-11 12:57:26 +020054 * Searching in all the context's search dirs (without removing them) can be avoided with the context's
Radek Krejci8678fa42020-08-18 16:07:28 +020055 * ::LY_CTX_DISABLE_SEARCHDIRS option (or via ::ly_ctx_set_options()). This automatic searching can be preceded
56 * by a custom module searching callback (::ly_module_imp_clb) set via ::ly_ctx_set_module_imp_clb(). The algorithm of
57 * searching in search dirs is also available via API as ::lys_search_localfile() function.
Radek Krejci52785a22019-09-11 12:57:26 +020058 *
Radek Krejci8678fa42020-08-18 16:07:28 +020059 * YANG modules are added into the context using [parser functions](@ref howtoSchemaParsers) - \b lys_parse*().
60 * Alternatively, also ::ly_ctx_load_module() can be used - in that case the ::ly_module_imp_clb or automatic
61 * search in search directories and in the current working directory is used, as described above. YANG submodules cannot be loaded
62 * or even validated directly, they are loaded always only as includes of YANG modules. Explicitly parsed/loaded modules are
63 * handled as implemented - libyang is able to instantiate data representing such a module. The modules loaded implicitly, are
64 * not implemented and serve only as a source of grouping or typedef definitions. Context can hold multiple revisions of the same
65 * YANG module, but only one of them can be implemented. Details about the difference between implemented and imported modules
Michal Vasko25d6ad02020-10-22 12:20:22 +020066 * can be found on @ref howtoSchema page. This behavior can be changed with the context's ::LY_CTX_ALL_IMPLEMENTED option, which
67 * causes that all the parsed modules, whether loaded explicitly or implicitly, are set to be implemented. Note, that as
68 * a consequence of this option, only a single revision of any module can be present in the context in this case. Also, a less
69 * crude option ::LY_CTX_REF_IMPLEMENTED can be used to implement only referenced modules that should also be implemented.
Radek Krejci52785a22019-09-11 12:57:26 +020070 *
71 * When loading/importing a module without revision, the latest revision of the required module is supposed to load.
72 * For a context, the first time the latest revision of a module is requested, it is properly searched for and loaded.
73 * However, when this module is requested (without revision) the second time, the one found previously is returned.
Radek Krejci8678fa42020-08-18 16:07:28 +020074 * This has the advantage of not searching for the module repeatedly but there is a drawback in case the content of search
aPiecekd4911ee2021-07-30 07:40:24 +020075 * directories is updated and a later revision become available.
Radek Krejci52785a22019-09-11 12:57:26 +020076 *
Radek Krejci8678fa42020-08-18 16:07:28 +020077 * Context holds all the schema modules internally. To get a specific module, use ::ly_ctx_get_module() (or some of its
78 * variants). If you need to do something with all the modules in the context, it is advised to iterate over them using
79 * ::ly_ctx_get_module_iter(). Alternatively, the ::ly_ctx_get_yanglib_data() function can be used to get complex information about the schemas in the context
80 * in the form of data tree defined by <a href="https://tools.ietf.org/html/rfc7895">ietf-yang-library</a> module.
Radek Krejci52785a22019-09-11 12:57:26 +020081 *
Radek Krejci8678fa42020-08-18 16:07:28 +020082 * YANG data can be parsed by \b lyd_parse_*() functions. Note, that functions for schema have \b lys_
83 * prefix (or \b lysp_ for the parsed and \b lysc_ for the compiled schema - for details see @ref howtoSchema page) while
84 * functions for instance data have \b lyd_ prefix. Details about data formats or handling data without the appropriate
85 * YANG module in context can be found on @ref howtoData page.
Radek Krejci52785a22019-09-11 12:57:26 +020086 *
Radek Krejci8678fa42020-08-18 16:07:28 +020087 * Besides the YANG modules, context holds also [error information](@ref howtoErrors) and
88 * [database of strings](@ref howtoContextDict), both connected with the processed YANG modules and data.
89 *
90 * - @subpage howtoErrors
91 * - @subpage howtoContextDict
Radek Krejci52785a22019-09-11 12:57:26 +020092 *
93 * \note API for this group of functions is available in the [context module](@ref context).
94 *
95 * Functions List
96 * --------------
Radek Krejci8678fa42020-08-18 16:07:28 +020097 *
Radek Krejci52785a22019-09-11 12:57:26 +020098 * - ::ly_ctx_new()
Radek Krejci8678fa42020-08-18 16:07:28 +020099 * - ::ly_ctx_destroy()
100 *
Radek Krejci52785a22019-09-11 12:57:26 +0200101 * - ::ly_ctx_set_searchdir()
Radek Krejci52785a22019-09-11 12:57:26 +0200102 * - ::ly_ctx_get_searchdirs()
Radek Krejci8678fa42020-08-18 16:07:28 +0200103 * - ::ly_ctx_unset_searchdir()
104 * - ::ly_ctx_unset_searchdir_last()
105 *
106 * - ::ly_ctx_set_options()
107 * - ::ly_ctx_get_options()
108 * - ::ly_ctx_unset_options()
109 *
Radek Krejci52785a22019-09-11 12:57:26 +0200110 * - ::ly_ctx_set_module_imp_clb()
111 * - ::ly_ctx_get_module_imp_clb()
Radek Krejci8678fa42020-08-18 16:07:28 +0200112 *
Radek Krejci52785a22019-09-11 12:57:26 +0200113 * - ::ly_ctx_load_module()
Radek Krejci52785a22019-09-11 12:57:26 +0200114 * - ::ly_ctx_get_module_iter()
115 * - ::ly_ctx_get_module()
116 * - ::ly_ctx_get_module_ns()
117 * - ::ly_ctx_get_module_implemented()
118 * - ::ly_ctx_get_module_implemented_ns()
119 * - ::ly_ctx_get_module_latest()
120 * - ::ly_ctx_get_module_latest_ns()
Michal Vasko8dc31992021-02-22 10:30:47 +0100121 * - ::ly_ctx_get_submodule()
122 * - ::ly_ctx_get_submodule_latest()
123 * - ::ly_ctx_get_submodule2()
124 * - ::ly_ctx_get_submodule2_latest()
Radek Krejci8678fa42020-08-18 16:07:28 +0200125 *
126 * - ::ly_ctx_get_yanglib_data()
Radek Krejci8678fa42020-08-18 16:07:28 +0200127 *
Michal Vasko794ab4b2021-03-31 09:42:19 +0200128 * - ::ly_ctx_get_change_count()
Radek Krejci0a60f1d2020-10-26 22:24:43 +0100129 * - ::ly_ctx_internal_modules_count()
Radek Krejci8678fa42020-08-18 16:07:28 +0200130 *
Radek Krejci52785a22019-09-11 12:57:26 +0200131 * - ::lys_search_localfile()
Radek Krejci8678fa42020-08-18 16:07:28 +0200132 * - ::lys_set_implemented()
133 *
134 */
135
136/**
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200137 * @defgroup context Context
138 * @{
139 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200140 * Structures and functions to manipulate with the libyang context containers.
141 *
142 * The \em context concept allows callers to work in environments with different sets of YANG schemas.
143 * More detailed information can be found at @ref howtoContext page.
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200144 */
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200145
146/**
147 * @struct ly_ctx
148 * @brief libyang context handler.
149 */
150struct ly_ctx;
151
152/**
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200153 * @ingroup context
Radek Krejci8678fa42020-08-18 16:07:28 +0200154 * @defgroup contextoptions Context options
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200155 *
156 * Options to change context behavior.
Radek Krejci474f9b82019-07-24 11:36:37 +0200157 *
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200158 * @{
159 */
160
Michal Vasko25d6ad02020-10-22 12:20:22 +0200161#define LY_CTX_ALL_IMPLEMENTED 0x01 /**< All the imported modules of the schema being parsed are implemented. */
162#define LY_CTX_REF_IMPLEMENTED 0x02 /**< Implement all imported modules "referenced" from an implemented module.
163 Normally, leafrefs, augment and deviation targets are implemented as
164 specified by YANG 1.1. In addition to this, implement any modules of
165 nodes referenced by when and must conditions and by any default values.
166 Generally, only if all these modules are implemented, the explicitly
167 implemented modules can be properly used and instantiated in data. */
168#define LY_CTX_NO_YANGLIBRARY 0x04 /**< Do not internally implement ietf-yang-library module. The option
Radek Krejci8678fa42020-08-18 16:07:28 +0200169 causes that function ::ly_ctx_get_yanglib_data() does not work (returns ::LY_EINVAL) until
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200170 the ietf-yang-library module is loaded manually. While any revision
171 of this schema can be loaded with this option, note that the only
Radek Krejci8678fa42020-08-18 16:07:28 +0200172 revisions implemented by ::ly_ctx_get_yanglib_data() are 2016-06-21 and 2019-01-04.
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200173 This option cannot be changed on existing context. */
174#define LY_CTX_DISABLE_SEARCHDIRS 0x08 /**< Do not search for schemas in context's searchdirs neither in current
175 working directory. It is entirely skipped and the only way to get
Radek Krejci8678fa42020-08-18 16:07:28 +0200176 schema data for imports or for ::ly_ctx_load_module() is to use the
177 callbacks provided by caller via ::ly_ctx_set_module_imp_clb() */
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200178#define LY_CTX_DISABLE_SEARCHDIR_CWD 0x10 /**< Do not automatically search for schemas in current working
179 directory, which is by default searched automatically (despite not
180 recursively). */
181#define LY_CTX_PREFER_SEARCHDIRS 0x20 /**< When searching for schema, prefer searchdirs instead of user callback. */
aPiecek9922ea92021-04-12 07:59:20 +0200182#define LY_CTX_SET_PRIV_PARSED 0x40 /**< For all compiled nodes, their private objects (::lysc_node.priv) are used
183 by libyang as a reference to the corresponding parsed node (::lysp_node).
aPiecekb0445f22021-06-24 11:34:07 +0200184 The exception are \"case\" statements, which are omitted (shorthand),
aPiecek082c7dc2021-05-20 08:55:07 +0200185 in that case the private objects are set to NULL.
aPiecek9922ea92021-04-12 07:59:20 +0200186 So if this option is set, the user must not change private objects.
187 Setting this option by ::ly_ctx_set_options() may result in context recompilation.
188 Resetting this option by ::ly_ctx_unset_options() cause that private
189 objects will be set to NULL. */
Michal Vasko01db7de2021-04-16 12:23:30 +0200190#define LY_CTX_EXPLICIT_COMPILE 0x80 /**< If this flag is set, the compiled modules and their schema nodes are
191 not automatically updated (compiled) on any context changes. In other words, they do
192 not immediately take effect. To do that, call ::ly_ctx_compile(). Changes
193 requiring compilation include adding new modules, changing their features,
194 and implementing parsed-only modules. This option allows efficient compiled
195 context creation without redundant recompilations. */
Michal Vaskoc56d6372021-10-19 12:29:00 +0200196#define LY_CTX_ENABLE_IMP_FEATURES 0x0100 /**< By default, all features of newly implemented imported modules of
197 a module that is being loaded are disabled. With this flag they all become
198 enabled. */
stewegd8e2fc92023-05-31 09:52:56 +0200199#define LY_CTX_LEAFREF_EXTENDED 0x0200 /**< By default, path attribute of leafref accepts only path as defined in RFC 7950.
200 By using this option, the path attribute will also allow using XPath functions as deref() */
stewegf9041a22024-01-18 13:29:12 +0100201#define LY_CTX_LEAFREF_LINKING 0x0400 /**< Link valid leafref nodes with its target during validation if leafref node is not using
202 'require-instance false;'. It also enables usage of
203 [lyd_leafref_get_links](@ref lyd_leafref_get_links) and
204 [lyd_leafref_link_node_tree](@ref lyd_leafref_link_node_tree) APIs. */
stewegd4cde642024-02-21 08:34:16 +0100205#define LY_CTX_BUILTIN_PLUGINS_ONLY 0x0800 /**< By default, context loads all available built-in plugins and extensions. This
206 options prohibits loading of built-in non-YANG plugin types and extensions (ipv4-address,
207 ipv6-address, etc.). Instead the value is processed by built-in YANG plugins (usually string)
208 with all its behavioral implications as hex-string comparison becoming case-sensitive.
209 Change of this flag during the lifetime of context is not fully supported. Once the non-YANG
210 plugins or extensions are loaded during context creation, they will be used regardless of this
211 flag. Therefore it is recommended to set this flag during the first context creation. */
Radek Krejci0af46292019-01-11 16:02:31 +0100212
Michal Vaskob36053d2020-03-26 15:49:30 +0100213/** @} contextoptions */
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200214
215/**
216 * @brief Create libyang context.
217 *
218 * Context is used to hold all information about schemas. Usually, the application is supposed
219 * to work with a single context in which libyang is holding all schemas (and other internal
220 * information) according to which the data trees will be processed and validated. So, the schema
221 * trees are tightly connected with the specific context and they are held by the context internally
Radek Krejci8678fa42020-08-18 16:07:28 +0200222 * - caller does not need to keep pointers to the schemas returned by ::lys_parse(), context knows
223 * about them. The data trees created with \b lyd_parse_*() are still connected with the specific context,
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200224 * but they are not internally held by the context. The data tree just points and lean on some data
225 * held by the context (schema tree, string dictionary, etc.). Therefore, in case of data trees, caller
Radek Krejci8678fa42020-08-18 16:07:28 +0200226 * is supposed to keep pointers returned by the \b lyd_parse_*() functions and manage the data tree on its own. This
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200227 * also affects the number of instances of both tree types. While you can have only one instance of
228 * specific schema connected with a single context, number of data tree instances is not connected.
229 *
Jan Kundrát34bb9282021-12-13 18:45:50 +0100230 * @param[in] search_dir Directory (or directories) where libyang will search for the imported or included modules
231 * and submodules. If no such directory is available, NULL is accepted. Several directories can be specified,
232 * delimited by colon ":" (on Windows, use semicolon ";" instead).
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200233 * @param[in] options Context options, see @ref contextoptions.
234 * @param[out] new_ctx Pointer to the created libyang context if LY_SUCCESS returned.
235 * @return LY_ERR return value.
236 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100237LIBYANG_API_DECL LY_ERR ly_ctx_new(const char *search_dir, uint16_t options, struct ly_ctx **new_ctx);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200238
239/**
Michal Vaskoddd76592022-01-17 13:34:48 +0100240 * @brief Create libyang context according to the provided yang-library data in a file.
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200241 *
242 * This function loads the yang-library data from the given path. If you need to pass the data as
243 * string, use ::::ly_ctx_new_ylmem(). Both functions extend functionality of ::ly_ctx_new() by loading
244 * modules specified in the ietf-yang-library form into the context being created.
245 * The preferred tree model revision is 2019-01-04. However, only the first module-set is processed and loaded
246 * into the context. If there are no matching nodes from this tree, the legacy tree (originally from model revision 2016-04-09)
247 * 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
248 * yang-library data are ignored and the modules are loaded from the context's search locations. On the other hand, YANG features
249 * of the modules are set as specified in the yang-library data.
250 * To get yang library data from a libyang context, use ::ly_ctx_get_yanglib_data().
251 *
252 * @param[in] search_dir Directory where libyang will search for the imported or included modules and submodules.
253 * If no such directory is available, NULL is accepted.
254 * @param[in] path Path to the file containing yang-library-data in the specified format
255 * @param[in] format Format of the data in the provided file.
256 * @param[in] options Context options, see @ref contextoptions.
ekinzie0ab8b302022-10-10 03:03:57 -0400257 * @param[in,out] ctx If *ctx is not NULL, the existing libyang context is modified. Otherwise, a pointer to a
258 * newly created context is returned here if LY_SUCCESS.
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200259 * @return LY_ERR return value
260 */
Michal Vaskoddd76592022-01-17 13:34:48 +0100261LIBYANG_API_DECL LY_ERR ly_ctx_new_ylpath(const char *search_dir, const char *path, LYD_FORMAT format, int options,
262 struct ly_ctx **ctx);
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200263
264/**
Michal Vaskoddd76592022-01-17 13:34:48 +0100265 * @brief Create libyang context according to the provided yang-library data in a string.
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200266 *
Michal Vaskoddd76592022-01-17 13:34:48 +0100267 * Details in ::ly_ctx_new_ylpath().
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200268 *
269 * @param[in] search_dir Directory where libyang will search for the imported or included modules and submodules.
270 * If no such directory is available, NULL is accepted.
271 * @param[in] data String containing yang-library data in the specified format.
272 * @param[in] format Format of the data in the provided file.
273 * @param[in] options Context options, see @ref contextoptions.
ekinzie0ab8b302022-10-10 03:03:57 -0400274 * @param[in,out] ctx If *ctx is not NULL, the existing libyang context is modified. Otherwise, a pointer to a
275 * newly created context is returned here if LY_SUCCESS.
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200276 * @return LY_ERR return value
277 */
Michal Vaskoddd76592022-01-17 13:34:48 +0100278LIBYANG_API_DECL LY_ERR ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options,
279 struct ly_ctx **ctx);
280
281/**
282 * @brief Create libyang context according to the provided yang-library data in a data tree.
283 *
284 * Details in ::ly_ctx_new_ylpath().
285 *
286 * @param[in] search_dir Directory where libyang will search for the imported or included modules and submodules.
287 * If no such directory is available, NULL is accepted.
288 * @param[in] tree Data tree containing yang-library data.
289 * @param[in] options Context options, see @ref contextoptions.
ekinzie0ab8b302022-10-10 03:03:57 -0400290 * @param[in,out] ctx If *ctx is not NULL, the existing libyang context is modified. Otherwise, a pointer to a
291 * newly created context is returned here if LY_SUCCESS.
Michal Vaskoddd76592022-01-17 13:34:48 +0100292 * @return LY_ERR return value
293 */
294LIBYANG_API_DECL LY_ERR ly_ctx_new_yldata(const char *search_dir, const struct lyd_node *tree, int options,
295 struct ly_ctx **ctx);
Tadeáš Vintrlík390b2722021-04-07 13:52:45 +0200296
297/**
Michal Vasko01db7de2021-04-16 12:23:30 +0200298 * @brief Compile (recompile) the context applying all the performed changes after the last context compilation.
299 * Should be used only if ::LY_CTX_EXPLICIT_COMPILE option is set, has no effect otherwise.
300 *
301 * @param[in] ctx Context to compile.
302 * @return LY_ERR return value.
303 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100304LIBYANG_API_DECL LY_ERR ly_ctx_compile(struct ly_ctx *ctx);
Michal Vasko01db7de2021-04-16 12:23:30 +0200305
306/**
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200307 * @brief Add the search path into libyang context
308 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200309 * To reset search paths set in the context, use ::ly_ctx_unset_searchdir() and then
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200310 * set search paths again.
311 *
312 * @param[in] ctx Context to be modified.
313 * @param[in] search_dir New search path to add to the current paths previously set in ctx.
314 * @return LY_ERR return value.
315 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100316LIBYANG_API_DECL LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200317
318/**
319 * @brief Clean the search path(s) from the libyang context
320 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200321 * To remove the recently added search path(s), use ::ly_ctx_unset_searchdir_last().
Radek Krejcied5acc52019-04-25 15:57:04 +0200322 *
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200323 * @param[in] ctx Context to be modified.
324 * @param[in] value Searchdir to be removed, use NULL to remove them all.
325 * @return LY_ERR return value
326 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100327LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir(struct ly_ctx *ctx, const char *value);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200328
329/**
Radek Krejcie58f97f2020-08-18 11:45:08 +0200330 * @brief Remove the least recently added search path(s) from the libyang context.
Radek Krejcied5acc52019-04-25 15:57:04 +0200331 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200332 * To remove a specific search path by its value, use ::ly_ctx_unset_searchdir().
Radek Krejcied5acc52019-04-25 15:57:04 +0200333 *
334 * @param[in] ctx Context to be modified.
Radek Krejcie58f97f2020-08-18 11:45:08 +0200335 * @param[in] count Number of the searchdirs to be removed (starting by the least recently added).
336 * If the value is higher then the actual number of search paths, all paths are removed and no error is returned.
337 * Value 0 does not change the search path set.
Radek Krejcied5acc52019-04-25 15:57:04 +0200338 * @return LY_ERR return value
339 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100340LIBYANG_API_DECL LY_ERR ly_ctx_unset_searchdir_last(struct ly_ctx *ctx, uint32_t count);
Radek Krejcied5acc52019-04-25 15:57:04 +0200341
342/**
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200343 * @brief Get the NULL-terminated list of the search paths in libyang context. Do not modify the result!
344 *
345 * @param[in] ctx Context to query.
346 * @return NULL-terminated list (array) of the search paths, NULL if no searchpath was set.
347 * Do not modify the provided data in any way!
348 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100349LIBYANG_API_DECL const char * const *ly_ctx_get_searchdirs(const struct ly_ctx *ctx);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200350
351/**
352 * @brief Get the currently set context's options.
353 *
354 * @param[in] ctx Context to query.
355 * @return Combination of all the currently set context's options, see @ref contextoptions.
356 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100357LIBYANG_API_DECL uint16_t ly_ctx_get_options(const struct ly_ctx *ctx);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200358
359/**
360 * @brief Set some of the context's options, see @ref contextoptions.
361 * @param[in] ctx Context to be modified.
362 * @param[in] option Combination of the context's options to be set, see @ref contextoptions.
aPiecek9922ea92021-04-12 07:59:20 +0200363 * If there is to be a change to ::LY_CTX_SET_PRIV_PARSED, the context will be recompiled
364 * and all ::lysc_node.priv in the modules will be overwritten, see ::LY_CTX_SET_PRIV_PARSED.
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200365 * @return LY_ERR value.
366 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100367LIBYANG_API_DECL LY_ERR ly_ctx_set_options(struct ly_ctx *ctx, uint16_t option);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200368
369/**
370 * @brief Unset some of the context's options, see @ref contextoptions.
371 * @param[in] ctx Context to be modified.
372 * @param[in] option Combination of the context's options to be unset, see @ref contextoptions.
373 * @return LY_ERR value.
374 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100375LIBYANG_API_DECL LY_ERR ly_ctx_unset_options(struct ly_ctx *ctx, uint16_t option);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200376
377/**
Michal Vasko794ab4b2021-03-31 09:42:19 +0200378 * @brief Get the change count of the context (module set) during its life-time.
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200379 *
380 * @param[in] ctx Context to be examined.
Michal Vasko794ab4b2021-03-31 09:42:19 +0200381 * @return Context change count.
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200382 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100383LIBYANG_API_DECL uint16_t ly_ctx_get_change_count(const struct ly_ctx *ctx);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200384
385/**
Michal Vaskof332f032023-04-11 13:44:52 +0200386 * @brief Get the hash of all the modules in the context. Since order of the modules is significant,
Michal Vaskof9943e42023-03-22 07:29:37 +0100387 * even when 2 contexts have the same modules but loaded in a different order, the hash will differ.
388 *
Michal Vaskof332f032023-04-11 13:44:52 +0200389 * Hash consists of all module names (1), their revisions (2), all enabled features (3), and their
390 * imported/implemented state (4).
391 *
Michal Vaskof9943e42023-03-22 07:29:37 +0100392 * @param[in] ctx Context to be examined.
393 * @return Context modules hash.
394 */
395LIBYANG_API_DECL uint32_t ly_ctx_get_modules_hash(const struct ly_ctx *ctx);
396
397/**
Michal Vaskob2786d72020-08-24 13:19:52 +0200398 * @brief Callback for freeing returned module data in #ly_module_imp_clb.
399 *
400 * @param[in] module_data Data to free.
401 * @param[in] user_data User-supplied callback data, same as for #ly_module_imp_clb.
402 */
403typedef void (*ly_module_imp_data_free_clb)(void *module_data, void *user_data);
404
405/**
Radek Krejcid33273d2018-10-25 14:55:52 +0200406 * @brief Callback for retrieving missing included or imported models in a custom way.
407 *
Radek Krejcibb9d2242021-01-04 10:51:31 +0100408 * When @p submod_name is provided, the submodule is requested instead of the module (in this case only
Radek Krejcid33273d2018-10-25 14:55:52 +0200409 * the module name without its revision is provided).
410 *
411 * If an @arg free_module_data callback is provided, it will be used later to free the allegedly const data
412 * which were returned by this callback.
413 *
414 * @param[in] mod_name Missing module name.
Radek Krejci086c7132018-10-26 15:29:04 +0200415 * @param[in] mod_rev Optional missing module revision. If NULL and submod_name is not provided, the latest revision is
416 * requested, the parsed module is then marked by the latest_revision flag.
Radek Krejcid33273d2018-10-25 14:55:52 +0200417 * @param[in] submod_name Optional missing submodule name.
Radek Krejci086c7132018-10-26 15:29:04 +0200418 * @param[in] submod_rev Optional missing submodule revision. If NULL and submod_name is provided, the latest revision is
419 * requested, the parsed submodule is then marked by the latest_revision flag.
Radek Krejcid33273d2018-10-25 14:55:52 +0200420 * @param[in] user_data User-supplied callback data.
421 * @param[out] format Format of the returned module data.
422 * @param[out] module_data Requested module data.
423 * @param[out] free_module_data Callback for freeing the returned module data. If not set, the data will be left untouched.
424 * @return LY_ERR value. If the returned value differs from LY_SUCCESS, libyang continue in trying to get the module data
425 * according to the settings of its mechanism to search for the imported/included schemas.
426 */
Radek Krejcibb9d2242021-01-04 10:51:31 +0100427typedef LY_ERR (*ly_module_imp_clb)(const char *mod_name, const char *mod_rev, const char *submod_name, const char *submod_rev,
Michal Vaskob2786d72020-08-24 13:19:52 +0200428 void *user_data, LYS_INFORMAT *format, const char **module_data, ly_module_imp_data_free_clb *free_module_data);
Radek Krejcid33273d2018-10-25 14:55:52 +0200429
430/**
431 * @brief Get the custom callback for missing import/include module retrieval.
432 *
433 * @param[in] ctx Context to read from.
434 * @param[in] user_data Optional pointer for getting the user-supplied callback data.
435 * @return Callback or NULL if not set.
436 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100437LIBYANG_API_DECL ly_module_imp_clb ly_ctx_get_module_imp_clb(const struct ly_ctx *ctx, void **user_data);
Radek Krejcid33273d2018-10-25 14:55:52 +0200438
439/**
440 * @brief Set missing include or import module callback. It is meant to be used when the models
441 * are not locally available (such as when downloading modules from a NETCONF server), it should
442 * not be required in other cases.
443 *
444 * @param[in] ctx Context that will use this callback.
445 * @param[in] clb Callback responsible for returning the missing model.
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100446 * @param[in] user_data Arbitrary data that will always be passed to the callback @p clb.
Radek Krejcid33273d2018-10-25 14:55:52 +0200447 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100448LIBYANG_API_DECL void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data);
Radek Krejcid33273d2018-10-25 14:55:52 +0200449
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100450/**
451 * @brief Callback for getting arbitrary run-time data required by an extension instance.
452 *
453 * @param[in] ext Compiled extension instance.
454 * @param[in] user_data User-supplied callback data.
455 * @param[out] ext_data Provided extension instance data.
456 * @param[out] ext_data_free Whether the extension instance should free @p ext_data or not.
457 * @return LY_ERR value.
458 */
Michal Vaskoddd76592022-01-17 13:34:48 +0100459typedef LY_ERR (*ly_ext_data_clb)(const struct lysc_ext_instance *ext, void *user_data, void **ext_data,
460 ly_bool *ext_data_free);
461
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100462/**
463 * @brief Set callback providing run-time extension instance data. The expected data depend on the extension.
464 * Data expected by internal extensions:
465 *
466 * - *ietf-yang-schema-mount:mount-point* (struct lyd_node \*\*ext_data)\n
467 * Operational data tree with at least `ietf-yang-library` data describing the mounted schema and
468 * `ietf-yang-schema-mount` **validated** data describing the specific mount point
469 * ([ref](https://datatracker.ietf.org/doc/html/rfc8528#section-3.3)).
470 *
471 * @param[in] ctx Context that will use this callback.
472 * @param[in] clb Callback responsible for returning the extension instance data.
473 * @param[in] user_data Arbitrary data that will always be passed to the callback @p clb.
474 */
Michal Vaskoddd76592022-01-17 13:34:48 +0100475LIBYANG_API_DECL ly_ext_data_clb ly_ctx_set_ext_data_clb(struct ly_ctx *ctx, ly_ext_data_clb clb, void *user_data);
476
Radek Krejcid33273d2018-10-25 14:55:52 +0200477/**
Radek Krejcib7db73a2018-10-24 14:18:40 +0200478 * @brief Get YANG module of the given name and revision.
479 *
480 * @param[in] ctx Context to work in.
481 * @param[in] name Name of the YANG module to get.
482 * @param[in] revision Requested revision date of the YANG module to get. If not specified,
483 * the schema with no revision is returned, if it is present in the context.
484 * @return Pointer to the YANG module, NULL if no schema in the context follows the name and revision requirements.
485 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100486LIBYANG_API_DECL struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200487
488/**
489 * @brief Get the latest revision of the YANG module specified by its name.
490 *
491 * YANG modules with no revision are supposed to be the oldest one.
492 *
493 * @param[in] ctx Context where to search.
494 * @param[in] name Name of the YANG module to get.
495 * @return The latest revision of the specified YANG module in the given context, NULL if no YANG module of the
496 * given name is present in the context.
497 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100498LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_latest(const struct ly_ctx *ctx, const char *name);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200499
500/**
501 * @brief Get the (only) implemented YANG module specified by its name.
502 *
503 * @param[in] ctx Context where to search.
504 * @param[in] name Name of the YANG module to get.
505 * @return The only implemented YANG module revision of the given name in the given context. NULL if there is no
506 * implemented module of the given name.
507 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100508LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_implemented(const struct ly_ctx *ctx, const char *name);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200509
510/**
Radek Krejcied5acc52019-04-25 15:57:04 +0200511 * @brief Iterate over all modules in the given context.
512 *
513 * @param[in] ctx Context with the modules.
514 * @param[in,out] index Index of the next module to get. Value of 0 starts from the beginning.
515 * The value is updated with each call, so to iterate over all modules the same variable is supposed
516 * to be used in all calls starting with value 0.
517 * @return Next context module, NULL if the last was already returned.
518 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100519LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *index);
Radek Krejcied5acc52019-04-25 15:57:04 +0200520
521/**
Radek Krejcib7db73a2018-10-24 14:18:40 +0200522 * @brief Get YANG module of the given namespace and revision.
523 *
524 * @param[in] ctx Context to work in.
525 * @param[in] ns Namespace of the YANG module to get.
526 * @param[in] revision Requested revision date of the YANG module to get. If not specified,
527 * the schema with no revision is returned, if it is present in the context.
528 * @return Pointer to the YANG module, NULL if no schema in the context follows the namespace and revision requirements.
529 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100530LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_ns(const struct ly_ctx *ctx, const char *ns, const char *revision);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200531
532/**
533 * @brief Get the latest revision of the YANG module specified by its namespace.
534 *
535 * YANG modules with no revision are supposed to be the oldest one.
536 *
537 * @param[in] ctx Context where to search.
538 * @param[in] ns Namespace of the YANG module to get.
539 * @return The latest revision of the specified YANG module in the given context, NULL if no YANG module of the
540 * given namespace is present in the context.
541 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100542LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_latest_ns(const struct ly_ctx *ctx, const char *ns);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200543
544/**
545 * @brief Get the (only) implemented YANG module specified by its namespace.
546 *
547 * @param[in] ctx Context where to search.
548 * @param[in] ns Namespace of the YANG module to get.
549 * @return The only implemented YANG module revision of the given namespace in the given context. NULL if there is no
550 * implemented module of the given namespace.
551 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100552LIBYANG_API_DECL struct lys_module *ly_ctx_get_module_implemented_ns(const struct ly_ctx *ctx, const char *ns);
Radek Krejcib7db73a2018-10-24 14:18:40 +0200553
554/**
Michal Vasko8dc31992021-02-22 10:30:47 +0100555 * @brief Get a specific submodule from context. If its belongs-to module is known, use ::ly_ctx_get_submodule2().
556 *
557 * @param[in] ctx libyang context to search in.
558 * @param[in] submodule Submodule name to find.
559 * @param[in] revision Revision of the submodule to find, NULL for a submodule without a revision.
560 * @return Found submodule, NULL if there is none.
561 */
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100562LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *submodule,
563 const char *revision);
Michal Vasko8dc31992021-02-22 10:30:47 +0100564
565/**
566 * @brief Get the latests revision of a submodule from context. If its belongs-to module is known,
567 * use ::ly_ctx_get_submodule2_latest().
568 *
569 * @param[in] ctx libyang context to search in.
570 * @param[in] submodule Submodule name to find.
571 * @return Found submodule, NULL if there is none.
572 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100573LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule_latest(const struct ly_ctx *ctx, const char *submodule);
Michal Vasko8dc31992021-02-22 10:30:47 +0100574
575/**
576 * @brief Get a specific submodule from a module. If the belongs-to module is not known, use ::ly_ctx_get_submodule().
577 *
578 * @param[in] module Belongs-to module to search in.
579 * @param[in] submodule Submodule name to find.
580 * @param[in] revision Revision of the submodule to find, NULL for a submodule without a revision.
581 * @return Found submodule, NULL if there is none.
582 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100583LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2(const struct lys_module *module, const char *submodule,
Michal Vasko8dc31992021-02-22 10:30:47 +0100584 const char *revision);
585
586/**
587 * @brief Get the latest revision of a submodule from a module. If the belongs-to module is not known,
588 * use ::ly_ctx_get_submodule_latest().
589 *
590 * @param[in] module Belongs-to module to search in.
591 * @param[in] submodule Submodule name to find.
592 * @return Found submodule, NULL if there is none.
593 */
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100594LIBYANG_API_DECL const struct lysp_submodule *ly_ctx_get_submodule2_latest(const struct lys_module *module,
595 const char *submodule);
Michal Vasko8dc31992021-02-22 10:30:47 +0100596
597/**
Michal Vaskode79e222020-08-10 11:55:46 +0200598 * @brief Learn the number of internal modules of a context. Internal modules
599 * is considered one that was loaded during the context creation.
600 *
601 * @param[in] ctx libyang context to examine.
602 * @return Number of internal modules.
603 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100604LIBYANG_API_DECL uint32_t ly_ctx_internal_modules_count(const struct ly_ctx *ctx);
Michal Vaskode79e222020-08-10 11:55:46 +0200605
606/**
Radek Krejcied5acc52019-04-25 15:57:04 +0200607 * @brief Try to find the model in the searchpaths of \p ctx and load it into it. If custom missing
608 * module callback is set, it is used instead.
609 *
610 * The context itself is searched for the requested module first. If \p revision is not specified
611 * (the module of the latest revision is requested) and there is implemented revision of the requested
612 * module in the context, this implemented revision is returned despite there might be a newer revision.
613 * This behavior is cause by the fact that it is not possible to have multiple implemented revisions of
614 * the same module in the context.
615 *
616 * @param[in] ctx Context to add to.
617 * @param[in] name Name of the module to load.
618 * @param[in] revision Optional revision date of the module. If not specified, the latest revision is loaded.
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100619 * @param[in] features Optional array of features ended with NULL to be enabled if the module is being implemented.
Radek Krejci2415f882021-01-20 16:27:09 +0100620 * The feature string '*' enables all and array of length 1 with only the terminating NULL explicitly disables all
621 * the features. In case the parameter is NULL, the features are untouched - left disabled in newly loaded module or
622 * with the current features settings in case the module is already present in the context.
Radek Krejcied5acc52019-04-25 15:57:04 +0200623 * @return Pointer to the data model structure, NULL if not found or some error occurred.
624 */
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100625LIBYANG_API_DECL struct lys_module *ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision,
626 const char **features);
Radek Krejcied5acc52019-04-25 15:57:04 +0200627
628/**
Michal Vasko57c10cd2020-05-27 15:57:11 +0200629 * @brief Get data of the internal ietf-yang-library module with information about all the loaded modules.
630 * ietf-yang-library module must be loaded.
631 *
Michal Vasko794ab4b2021-03-31 09:42:19 +0200632 * Note that "/ietf-yang-library:yang-library/datastore" list instances are not created and should be
633 * appended by the caller. There is a single "/ietf-yang-library:yang-library/schema" instance created
634 * with the key value "complete".
635 *
636 * If the data identifier can be limited to the existence and changes of this context, the following
637 * last 2 parameters can be used:
638 *
Michal Vaskof9943e42023-03-22 07:29:37 +0100639 * "%u" as @p content_id_format and ::ly_ctx_get_change_count() as its parameter;
640 * "%u" as @p content_id_format and ::ly_ctx_get_modules_hash() as its parameter.
Michal Vasko794ab4b2021-03-31 09:42:19 +0200641 *
Michal Vasko57c10cd2020-05-27 15:57:11 +0200642 * @param[in] ctx Context with the modules.
Michal Vasko3a41dff2020-07-15 14:30:28 +0200643 * @param[out] root Generated yang-library data.
Michal Vasko794ab4b2021-03-31 09:42:19 +0200644 * @param[in] content_id_format Format string (printf-like) for the yang-library data identifier, which is
645 * the "content_id" node in the 2019-01-04 revision of ietf-yang-library.
646 * @param[in] ... Parameters for @p content_id_format.
Michal Vasko3a41dff2020-07-15 14:30:28 +0200647 * @return LY_ERR value
Michal Vasko57c10cd2020-05-27 15:57:11 +0200648 */
Michal Vasko61ad1ff2022-02-10 15:48:39 +0100649LIBYANG_API_DECL LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root,
650 const char *content_id_format, ...);
Michal Vasko57c10cd2020-05-27 15:57:11 +0200651
652/**
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200653 * @brief Free all internal structures of the specified context.
654 *
655 * The function should be used before terminating the application to destroy
656 * and free all structures internally used by libyang. If the caller uses
657 * multiple contexts, the function should be called for each used context.
658 *
Michal Vasko1817df82021-11-12 10:21:54 +0100659 * All instance data are supposed to be freed before destroying the context using ::lyd_free_all(), for example.
660 * Data models (schemas) are destroyed automatically as part of ::ly_ctx_destroy() call.
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200661 *
Radek Krejci90ed21e2021-04-12 14:47:46 +0200662 * Note that the data stored by user into the ::lysc_node.priv pointer are kept
663 * untouched and the caller is responsible for freeing this private data.
664 *
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200665 * @param[in] ctx libyang context to destroy
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200666 */
Jan Kundrátc53a7ec2021-12-09 16:01:19 +0100667LIBYANG_API_DECL void ly_ctx_destroy(struct ly_ctx *ctx);
Radek Krejci6caa6ab2018-10-24 10:04:48 +0200668
669/** @} context */
670
671#ifdef __cplusplus
672}
673#endif
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200674
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200675#endif /* LY_CONTEXT_H_ */