Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 1 | /** |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 2 | * @file libyang.h |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 4 | * @brief The main libyang public header. |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the |
| 16 | * distribution. |
| 17 | * 3. Neither the name of the Company nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this |
| 19 | * software without specific prior written permission. |
| 20 | */ |
| 21 | |
| 22 | #ifndef LY_LIBYANG_H_ |
| 23 | #define LY_LIBYANG_H_ |
| 24 | |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 25 | #include <stdio.h> |
| 26 | |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame] | 27 | #include "tree_schema.h" |
| 28 | #include "tree_data.h" |
Radek Krejci | c6704c8 | 2015-10-06 11:12:45 +0200 | [diff] [blame] | 29 | #include "xml.h" |
Radek Krejci | 41912fe | 2015-10-22 10:22:12 +0200 | [diff] [blame] | 30 | #include "dict.h" |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 31 | |
Radek Krejci | 39d8d0d | 2015-08-17 13:42:45 +0200 | [diff] [blame] | 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 36 | /** |
| 37 | * @page howto How To ... |
| 38 | * |
| 39 | * - @subpage howtocontext |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 40 | * - @subpage howtoschemas |
| 41 | * - @subpage howtodata |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 42 | * - @subpage howtologger |
| 43 | */ |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 44 | |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 45 | /** @page howtocontext Context |
| 46 | * |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 47 | * The context concept allows callers to work in environments with different sets of YANG schemas. |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 48 | * |
| 49 | * The first step in libyang is to create a new context using ly_ctx_new(). It returns a handler |
| 50 | * used in the following work. |
| 51 | * |
| 52 | * When creating a new context, search dir can be specified (NULL is accepted) to provide directory |
| 53 | * where libyang will automatically search for schemas being imported or included. The search path |
| 54 | * can be later changed via ly_ctx_set_searchdir() function. Before exploring the specified search |
| 55 | * dir, libyang tries to get imported and included schemas from the current working directory first. |
| 56 | * |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 57 | * Schemas are added into the context using [parser functions](@ref parsers) - lys_parse() or lys_read(). |
| 58 | * Note, that parser functions for schemas have \b lys_ prefix while instance data parser functions have |
| 59 | * \b lyd_ prefix. |
| 60 | * |
Radek Krejci | f647e61 | 2015-07-30 11:36:07 +0200 | [diff] [blame] | 61 | * Context can hold multiple revisons of the same schema. |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 62 | * |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 63 | * Context holds all modules and their submodules internally. The list of available module names is |
| 64 | * provided via ly_ctx_get_module_names() functions. Similarly, caller can get also a list of submodules |
| 65 | * names of a specific module using ly_ctx_get_submodule_names() function. The returned names can be |
| 66 | * subsequently used to get the (sub)module structures using ly_ctx_get_module() and ly_ctx_get_submodule(). |
| 67 | * |
| 68 | * Modules held by a context cannot be removed one after one. The only way how to \em change modules in the |
| 69 | * context is to create a new context and remove the old one. To remove a context, there is ly_ctx_destroy() |
| 70 | * function. |
| 71 | * |
| 72 | * \note API for this group of functions is available in the [context module](@ref context). |
| 73 | * |
| 74 | */ |
| 75 | |
| 76 | /** |
| 77 | * @page howtoschemas Schemas |
| 78 | * |
| 79 | * Schema is an internal libyang's representation of a YANG data model. Each schema is connected with |
| 80 | * its [context](@ref howtocontext) and loaded using [parser functions](@ref parsers). It means, that |
| 81 | * the schema cannot be created (nor changed) programatically. In libyang, schemas are used only to |
| 82 | * access data model definitions. |
| 83 | * |
| 84 | * \note There are many functions to access information from the schema trees. Details are available in |
| 85 | * the [Schema Tree module](@ref schematree). |
| 86 | * |
| 87 | * YANG Features Manipulation |
| 88 | * -------------------------- |
| 89 | * |
| 90 | * The group of functions prefixed by \b lys_features_ are used to access and manipulate with the schema's |
| 91 | * features. |
| 92 | * |
| 93 | * The first two functions are used to access information about the features in the schema. |
| 94 | * lys_features_list() provides list of all features defined in the specific schema and its |
| 95 | * submodules. Optionally, it can also provides information about the state of all features. |
| 96 | * Alternatively, caller can use lys_features_state() function to get state of one specific |
| 97 | * feature. |
| 98 | * |
| 99 | * The remaining two functions, lys_features_enable() and lys_features_disable(), are used |
| 100 | * to enable and disable the specific feature. By default, when the module is loaded by libyang |
| 101 | * parser, all features are disabled. |
| 102 | * |
| 103 | * Note, that feature's state can affect some of the output formats (e.g. Tree format). |
| 104 | * |
| 105 | */ |
| 106 | |
| 107 | /** |
| 108 | * @page howtodata Data Instances |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 109 | * |
| 110 | */ |
Radek Krejci | 94ca54b | 2015-07-08 15:48:47 +0200 | [diff] [blame] | 111 | |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 112 | /** |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 113 | * |
| 114 | * @page howtologger Logger |
| 115 | * |
| 116 | * There are 4 verbosity levels defined as ::LY_LOG_LEVEL. The level can be |
| 117 | * changed by the ly_verb() function. By default, the verbosity level is |
| 118 | * set to #LY_LLERR value. |
| 119 | * |
| 120 | * In case the logger has an error message (LY_LLERR) to print, also an error |
| 121 | * code is recorded in extern ly_errno variable. Possible values are of type |
| 122 | * ::LY_ERR. |
| 123 | * |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 124 | * \note API for this group of functions is available in the [logger module](@ref logger). |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 125 | */ |
| 126 | |
| 127 | /** |
| 128 | * @defgroup context Context |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 129 | * @{ |
| 130 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 131 | * Structures and functions to manipulate with the libyang "containers". The \em context concept allows callers |
| 132 | * to work in environments with different sets of YANG schemas. More detailed information can be found at |
| 133 | * @ref howtocontext page. |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 134 | */ |
| 135 | |
| 136 | /** |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 137 | * @brief libyang context handler. |
| 138 | */ |
| 139 | struct ly_ctx; |
| 140 | |
| 141 | /** |
| 142 | * @brief Create libyang context |
| 143 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 144 | * Context is used to hold all information about schemas. Usually, the application is supposed |
Radek Krejci | 91b833c | 2015-09-04 11:49:43 +0200 | [diff] [blame] | 145 | * to work with a single context in which libyang is holding all schemas (and other internal |
| 146 | * information) according to which the data trees will be processed and validated. So, the schema |
| 147 | * trees are tightly connected with the specific context and they are held by the context internally |
| 148 | * - caller does not need to keep pointers to the schemas returned by lys_parse(), context knows |
| 149 | * about them. The data trees created with lyd_parse() are still connected with the specific context, |
| 150 | * but they are not internally held by the context. The data tree just points and lean on some data |
| 151 | * held by the context (schema tree, string dictionary, etc.). Therefore, in case of data trees, caller |
| 152 | * is supposed to keep pointers returned by the lyd_parse() and manage the data tree on its own. This |
| 153 | * also affects the number of instances of both tree types. While you can have only one instance of |
| 154 | * specific schema connected with a single context, number of data tree instances is not connected. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 155 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 156 | * @param[in] search_dir Directory where libyang will search for the imported or included modules |
| 157 | * and submodules. If no such directory is available, NULL is accepted. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 158 | * |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 159 | * @return Pointer to the created libyang context, NULL in case of error. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 160 | */ |
| 161 | struct ly_ctx *ly_ctx_new(const char *search_dir); |
| 162 | |
| 163 | /** |
Michal Vasko | 60ba9a6 | 2015-07-03 14:42:31 +0200 | [diff] [blame] | 164 | * @brief Change the search path in libyang context |
| 165 | * |
| 166 | * @param[in] ctx Context to be modified. |
| 167 | * @param[in] search_dir New search path to replace the current one in ctx. |
| 168 | */ |
| 169 | void ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir); |
| 170 | |
| 171 | /** |
Radek Krejci | 5a79757 | 2015-10-21 15:45:45 +0200 | [diff] [blame] | 172 | * @brief Get current value of the search path in libyang context |
| 173 | * |
| 174 | * @param[in] ctx Context to query. |
| 175 | * @return Current value of the search path. |
| 176 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 177 | const char *ly_ctx_get_searchdir(const struct ly_ctx *ctx); |
Radek Krejci | 5a79757 | 2015-10-21 15:45:45 +0200 | [diff] [blame] | 178 | |
| 179 | /** |
Radek Krejci | 7ab2515 | 2015-08-07 14:48:45 +0200 | [diff] [blame] | 180 | * @brief Get data of an internal ietf-yang-library module. |
| 181 | * |
| 182 | * @param[in] ctx Context with the modules. |
| 183 | * @return Root data node corresponding to the model, NULL on error. |
| 184 | * Caller is responsible for freeing the returned data tree using lyd_free(). |
| 185 | */ |
| 186 | struct lyd_node *ly_ctx_info(struct ly_ctx *ctx); |
| 187 | |
| 188 | /** |
Radek Krejci | 96a10da | 2015-07-30 11:00:14 +0200 | [diff] [blame] | 189 | * @brief Get the names of the loaded modules. |
| 190 | * |
| 191 | * @param[in] ctx Context with the modules. |
| 192 | * @return NULL-terminated array of the module names, |
| 193 | * NULL on error. The returned array must be freed by the caller, do not free |
| 194 | * names in the array. Also remember that the names will be freed with freeing |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 195 | * the context. |
Radek Krejci | 96a10da | 2015-07-30 11:00:14 +0200 | [diff] [blame] | 196 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 197 | const char **ly_ctx_get_module_names(const struct ly_ctx *ctx); |
Radek Krejci | 96a10da | 2015-07-30 11:00:14 +0200 | [diff] [blame] | 198 | |
| 199 | /** |
| 200 | * @brief Get the names of the loaded submodules of the specified module. |
| 201 | * |
| 202 | * @param[in] ctx Context with the modules. |
| 203 | * @param[in] module_name Name of the parent module. |
| 204 | * @return NULL-terminated array of submodule names of the parent module, |
| 205 | * NULL on error. The returned array must be freed by the caller, do not free |
| 206 | * names in the array. Also remember that the names will be freed with freeing |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 207 | * the context. |
Radek Krejci | 96a10da | 2015-07-30 11:00:14 +0200 | [diff] [blame] | 208 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 209 | const char **ly_ctx_get_submodule_names(const struct ly_ctx *ctx, const char *module_name); |
Radek Krejci | 96a10da | 2015-07-30 11:00:14 +0200 | [diff] [blame] | 210 | |
| 211 | /** |
Radek Krejci | fd4e6e3 | 2015-08-10 15:00:51 +0200 | [diff] [blame] | 212 | * @brief Get pointer to the schema tree of the module of the specified name. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 213 | * |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 214 | * @param[in] ctx Context to work in. |
| 215 | * @param[in] name Name of the YANG module to get. |
Radek Krejci | f647e61 | 2015-07-30 11:36:07 +0200 | [diff] [blame] | 216 | * @param[in] revision Optional revision date of the YANG module to get. If not specified, |
| 217 | * the schema in the newest revision is returned if any. |
| 218 | * @return Pointer to the data model structure, NULL if no schema following the name and |
Radek Krejci | fd4e6e3 | 2015-08-10 15:00:51 +0200 | [diff] [blame] | 219 | * revision requirements is present in the context. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 220 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 221 | const struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 222 | |
| 223 | /** |
Michal Vasko | 8246596 | 2015-11-10 11:03:11 +0100 | [diff] [blame] | 224 | * @brief Try to find the model in a specific directory and then the searchpath |
| 225 | * and load it into context. |
| 226 | * |
| 227 | * @param[in] ctx Context to add to. |
| 228 | * @param[in] dir Optional directory to search in first. |
| 229 | * @param[in] name Name of the module to load. |
| 230 | * @param[in] revision Optional revision date of the module. If not specified, it is |
| 231 | * assumed that there is only one model revision in the searchpath (the first matching file |
| 232 | * is parsed). |
| 233 | * @return Pointer to the data model structure, NULL if not found or some error occured. |
| 234 | */ |
| 235 | struct lys_module *ly_ctx_load_module(struct ly_ctx *ctx, const char *dir, const char *name, const char *revision); |
| 236 | |
| 237 | /** |
Radek Krejci | fd4e6e3 | 2015-08-10 15:00:51 +0200 | [diff] [blame] | 238 | * @brief Get pointer to the schema tree of the module of the specified namespace |
| 239 | * |
| 240 | * @param[in] ctx Context to work in. |
| 241 | * @param[in] ns Namespace of the YANG module to get. |
| 242 | * @param[in] revision Optional revision date of the YANG module to get. If not specified, |
| 243 | * the schema in the newest revision is returned if any. |
| 244 | * @return Pointer to the data model structure, NULL if no schema following the namespace and |
| 245 | * revision requirements is present in the context. |
| 246 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 247 | const struct lys_module *ly_ctx_get_module_by_ns(const struct ly_ctx *ctx, const char *ns, const char *revision); |
Radek Krejci | fd4e6e3 | 2015-08-10 15:00:51 +0200 | [diff] [blame] | 248 | |
| 249 | /** |
Michal Vasko | 7bf0688 | 2015-07-03 15:33:56 +0200 | [diff] [blame] | 250 | * @brief Get submodule from the context's search dir. |
| 251 | * |
| 252 | * @param[in] module Parent (belongs-to) module. |
| 253 | * @param[in] name Name of the YANG submodule to get. |
| 254 | * @param[in] revision Optional revision date of the YANG submodule to get. If |
| 255 | * not specified, the newest revision is returned (TODO). |
Michal Vasko | 7bf0688 | 2015-07-03 15:33:56 +0200 | [diff] [blame] | 256 | * @return Pointer to the data model structure. |
| 257 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 258 | const struct lys_submodule *ly_ctx_get_submodule(const struct lys_module *module, const char *name, |
| 259 | const char *revision); |
Michal Vasko | 7bf0688 | 2015-07-03 15:33:56 +0200 | [diff] [blame] | 260 | |
| 261 | /** |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 262 | * @brief Get schema node according to the given absolute schema node identifier. |
| 263 | * |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 264 | * @param[in] ctx Context to work in. |
| 265 | * @param[in] nodeid Absolute schema node identifier with module names used as |
| 266 | * prefixes. Prefix (module name) must be used whenever the child node is from |
| 267 | * other module (augments the parent node). The first node in the path must be |
| 268 | * always specified with the prefix. Here are some examples: |
| 269 | * |
| 270 | * - /ietf-netconf-monitoring:get-schema/input/identifier |
| 271 | * - /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address/ip |
| 272 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 273 | const struct lys_node *ly_ctx_get_node(const struct ly_ctx *ctx, const char *nodeid); |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 274 | |
| 275 | /** |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 276 | * @brief Free all internal structures of the specified context. |
| 277 | * |
| 278 | * The function should be used before terminating the application to destroy |
| 279 | * and free all structures internally used by libyang. If the caller uses |
| 280 | * multiple contexts, the function should be called for each used context. |
| 281 | * |
| 282 | * All instance data are supposed to be freed before destroying the context. |
| 283 | * Data models are destroyed automatically as part of ly_ctx_destroy() call. |
| 284 | * |
| 285 | * @param[in] ctx libyang context to destroy |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 286 | */ |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 287 | void ly_ctx_destroy(struct ly_ctx *ctx); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 288 | |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 289 | /**@} context */ |
| 290 | |
| 291 | /** |
| 292 | * @defgroup parsers Parsers |
| 293 | * @{ |
| 294 | * |
| 295 | * Parsers allows to read schema and data trees from a specific format. |
| 296 | * |
| 297 | * For schemas, the following formats are supported: |
| 298 | * - YANG |
| 299 | * |
| 300 | * Basic YANG schemas format described in [RFC 6020](http://tools.ietf.org/html/rfc6020). |
| 301 | * Currently, only YANG 1.0 is supported. |
| 302 | * |
| 303 | * \todo YANG input is not yet implemented |
| 304 | * |
| 305 | * - YIN |
| 306 | * |
| 307 | * Alternative XML-based format to YANG. The details can be found in |
| 308 | * [RFC 6020](http://tools.ietf.org/html/rfc6020#section-11). |
| 309 | * |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 310 | * For data instances, the following formats are supported: |
| 311 | * - \todo TBD |
| 312 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 313 | */ |
| 314 | |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 315 | /** |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 316 | * @brief Load a schema into the specified context. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 317 | * |
Radek Krejci | b20c62d | 2015-07-07 17:07:14 +0200 | [diff] [blame] | 318 | * LY_IN_YANG (YANG) format is not yet supported. |
| 319 | * |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 320 | * @param[in] ctx libyang context where to process the data model. |
| 321 | * @param[in] data The string containing the dumped data model in the specified |
Michal Vasko | d8aa32d | 2015-07-24 11:50:01 +0200 | [diff] [blame] | 322 | * format. |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 323 | * @param[in] format Format of the input data (YANG or YIN). |
| 324 | * @return Pointer to the data model structure or NULL on error. |
| 325 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 326 | const struct lys_module *lys_parse(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 327 | |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 328 | /** |
| 329 | * @brief Read a schema from file into the specified context. |
| 330 | * |
| 331 | * LY_IN_YANG (YANG) format is not yet supported. |
| 332 | * |
| 333 | * \note Current implementation supports only reading data from standard (disk) file, not from sockets, pipes, etc. |
| 334 | * |
| 335 | * @param[in] ctx libyang context where to process the data model. |
Radek Krejci | 4910e24 | 2015-11-30 10:40:45 +0100 | [diff] [blame] | 336 | * @param[in] fd File descriptor of a regular file (e.g. sockets are not supported) containing the schema |
| 337 | * in the specified format. |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 338 | * @param[in] format Format of the input data (YANG or YIN). |
| 339 | * @return Pointer to the data model structure or NULL on error. |
| 340 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 341 | const struct lys_module *lys_read(struct ly_ctx *ctx, int fd, LYS_INFORMAT format); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 342 | |
| 343 | /** |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 344 | * @defgroup parseroptions Data parser options |
| 345 | * @ingroup parsers |
| 346 | * |
| 347 | * Various options to change the data tree parsers behavior. |
| 348 | * |
| 349 | * By default, parser silently ignores the data without a matching node in schema trees. If the caller want to stop |
| 350 | * parsing in case of presence of unknown data, the #LYD_OPT_STRICT can be used. The strict mode is useful for |
| 351 | * NETCONF servers, since NETCONF clients should always send data according to the capabilities announced by the server. |
| 352 | * On the other hand, the default non-strict mode is useful for clients receiving data from NETCONF server since |
| 353 | * clients are not required to understand everything the server does. Of course, the optimal strategy is to use |
| 354 | * filtering to get only the required data. |
| 355 | * |
Radek Krejci | 20cdf63 | 2015-11-09 14:44:58 +0100 | [diff] [blame] | 356 | * The #LYD_OPT_DESTRUCT option is used to optimize memory consumption profile of the parser in case the input |
| 357 | * data are no more needed after the parser function call. It continuously free the input data whenever it is |
| 358 | * processed for the output. This option is applicable only in case the input data are in the XML tree format. |
| 359 | * |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 360 | * Parser also expects that the provided data are complete and performs data validation according to all |
Radek Krejci | 20cdf63 | 2015-11-09 14:44:58 +0100 | [diff] [blame] | 361 | * implemented YANG rules. This can be problem in case of representing NETCONF's subtree filter data, |
| 362 | * edit-config's data or the received data (after get or get-config request) where a filter was applied - such data |
| 363 | * do not represent a complete data set and different validation rules can fail. Therefore there are other options |
| 364 | * to make parser to accept such a data. |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 365 | * |
| 366 | * @{ |
| 367 | */ |
Radek Krejci | 20cdf63 | 2015-11-09 14:44:58 +0100 | [diff] [blame] | 368 | #define LYD_OPT_STRICT 0x01 /**< instead of silent ignoring data without schema definition, raise an error. |
| 369 | Having an unknown element of the known namespace is always an error. */ |
| 370 | #define LYD_OPT_DESTRUCT 0x02 /**< safe consumed memory and free the processed XML data continuously. |
| 371 | On success, only the top level XML element is kept in the end. This |
| 372 | option is applicable only with lyd_parse_xml(). */ |
| 373 | #define LYD_OPT_EDIT 0x04 /**< make validation to accept NETCONF edit-config's content: |
| 374 | - mandatory nodes can be omitted |
| 375 | - leafrefs and instance-identifier are not resolved |
| 376 | - status data are not allowed */ |
| 377 | #define LYD_OPT_FILTER 0x08 /**< make validation to accept NETCONF subtree filter data: |
| 378 | - leafs/leaf-lists with no data are allowed (even not allowed e.g. by length restriction) |
| 379 | - multiple instances of container/leaf/.. are allowed |
| 380 | - list's keys/unique nodes are not required |
| 381 | - mandatory nodes can be omitted |
| 382 | - leafrefs and instance-identifier are not resolved |
| 383 | - data from different choice's branches are allowed */ |
| 384 | #define LYD_OPT_GETCONFIG 0x10 /**< make validation to accept get-config's result data even with applied filter: |
| 385 | - mandatory nodes can be omitted |
| 386 | - leafrefs and instance-identifier are not resolved |
| 387 | - list's keys/unique nodes are not required (so duplication is not checked) |
| 388 | - status data are not allowed */ |
| 389 | #define LYD_OPT_GET 0x20 /**< make validation to accept get's result data even with applied filter: |
| 390 | - same as for #LYD_OPT_GETCONFIG but the status data are allowed */ |
Radek Krejci | 04b97de | 2015-10-31 23:09:15 +0100 | [diff] [blame] | 391 | |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 392 | /** |
| 393 | * @} |
| 394 | */ |
| 395 | |
| 396 | /** |
Radek Krejci | b20c62d | 2015-07-07 17:07:14 +0200 | [diff] [blame] | 397 | * @brief Parse (and validate according to appropriate schema from the given context) data. |
| 398 | * |
Radek Krejci | 4f0a874 | 2015-08-12 10:09:28 +0200 | [diff] [blame] | 399 | * In case of LY_XML format, the data string is expected to contain XML data under a single |
| 400 | * XML element. The element is not parsed, but it is expected to keep XML data well formed in all |
| 401 | * cases. There are no restrictions for the element name or its namespace. |
Radek Krejci | b20c62d | 2015-07-07 17:07:14 +0200 | [diff] [blame] | 402 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 403 | * @param[in] ctx Context to connect with the data tree being built here. |
| 404 | * @param[in] data Serialized data in the specified format. |
| 405 | * @param[in] format Format of the input data to be parsed. |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 406 | * @param[in] options Parser options, see @ref parseroptions. |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 407 | * @return Pointer to the built data tree. To free the returned structure, use lyd_free(). |
Radek Krejci | b20c62d | 2015-07-07 17:07:14 +0200 | [diff] [blame] | 408 | */ |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 409 | struct lyd_node *lyd_parse(struct ly_ctx *ctx, const char *data, LYD_FORMAT format, int options); |
Radek Krejci | b20c62d | 2015-07-07 17:07:14 +0200 | [diff] [blame] | 410 | |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 411 | /** |
Radek Krejci | c6704c8 | 2015-10-06 11:12:45 +0200 | [diff] [blame] | 412 | * @brief Parse (and validate according to appropriate schema from the given context) XML tree. |
| 413 | * |
| 414 | * The output data tree is parsed from the given XML tree previously parsed by one of the |
| 415 | * lyxml_read* functions. Note, that the parser removes successfully parsed data from the |
| 416 | * XML tree except the root element (see the note about XML format in lyd_parse()). When |
| 417 | * the given XML tree is successfully parsed, the given \p root is kept but it has no children |
| 418 | * which are returned as a top level nodes in the output data tree. |
| 419 | * |
| 420 | * The context must be the same as the context used to parse XML tree by lyxml_read* function. |
| 421 | * |
| 422 | * @param[in] ctx Context to connect with the data tree being built here. |
| 423 | * @param[in] root XML tree to parse (convert) to data tree. |
| 424 | * @param[in] options Parser options, see @ref parseroptions. |
| 425 | * @return Pointer to the built data tree. To free the returned structure, use lyd_free(). |
| 426 | */ |
| 427 | struct lyd_node *lyd_parse_xml(struct ly_ctx *ctx, struct lyxml_elem *root, int options); |
| 428 | |
| 429 | /** |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 430 | * @brief Read data from the given file |
| 431 | * |
| 432 | * TODO not implemented |
| 433 | * |
| 434 | * @param[in] ctx Context to connect with the data tree being built here. |
| 435 | * @param[in] fd The standard file descriptor of the file containing the data tree in the specified format. |
| 436 | * @param[in] format Format of the input data to be parsed. |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 437 | * @param[in] options Parser options, see @ref parseroptions. |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 438 | * @return Pointer to the built data tree. To free the returned structure, use lyd_free(). |
| 439 | */ |
Radek Krejci | 25b9fd3 | 2015-08-10 15:06:07 +0200 | [diff] [blame] | 440 | struct lyd_node *lyd_read(struct ly_ctx *ctx, int fd, LYD_FORMAT format, int options); |
Radek Krejci | 704a7a9 | 2015-08-07 12:50:15 +0200 | [diff] [blame] | 441 | |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 442 | /**@} parsers */ |
| 443 | |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 444 | /** |
| 445 | * @defgroup schematree Schema Tree |
| 446 | * @{ |
| 447 | * |
| 448 | * Data structures and functions to manipulate and access schema tree. |
| 449 | * |
| 450 | * @} |
| 451 | */ |
| 452 | |
| 453 | /** |
| 454 | * @defgroup datatree Data Tree |
| 455 | * @{ |
| 456 | * |
| 457 | * Data structures and functions to manipulate and access instance data tree. |
| 458 | * |
| 459 | * @} |
| 460 | */ |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 461 | |
| 462 | /** |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 463 | * @defgroup printers Printers |
| 464 | * @{ |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 465 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 466 | * Printers allows to serialize schema and data trees in a specific format. |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 467 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 468 | * For schemas, the following formats are supported: |
| 469 | * - YANG |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 470 | * |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 471 | * Basic YANG schemas format described in [RFC 6020](http://tools.ietf.org/html/rfc6020). |
| 472 | * Currently, only YANG 1.0 is supported. |
| 473 | * |
| 474 | * - YIN |
| 475 | * |
| 476 | * Alternative XML-based format to YANG. The details can be found in |
| 477 | * [RFC 6020](http://tools.ietf.org/html/rfc6020#section-11). |
| 478 | * |
| 479 | * \todo YIN output is not yet implemented |
| 480 | * |
| 481 | * - Tree |
| 482 | * |
| 483 | * Simple tree structure of the module. |
| 484 | * |
| 485 | * - Info |
| 486 | * |
| 487 | * Detailed information about the specific node in the schema tree. |
Michal Vasko | 6d6076e | 2015-08-13 15:53:09 +0200 | [diff] [blame] | 488 | * The target can be more specific than the module itself: |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 489 | * |
Michal Vasko | 6d6076e | 2015-08-13 15:53:09 +0200 | [diff] [blame] | 490 | * - absolute-schema-nodeid \a /modules/module-set-id in \a ietf-yang-library |
| 491 | * - <b>typedef/</b>typedef-name \a typedef/revision-identifier in \a ietf-yang-library |
| 492 | * - <b>feature/</b>feature-name \a feature/ssh in \a ietf-netconf-server |
| 493 | * - <b>grouping/</b>grouping-name/descendant-schema-nodeid \a grouping/module or \a grouping/module/module/submodules |
| 494 | * in \a ietf-yang-library |
| 495 | * - <b>type/</b>leaf-or-leaflist \a type/modules/module-set-id in \a ietf-yang-library |
Radek Krejci | d9ba3e3 | 2015-07-30 15:08:18 +0200 | [diff] [blame] | 496 | * |
| 497 | * For data instances, the following formats are supported: |
| 498 | * - \todo TBD |
| 499 | * |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 500 | */ |
| 501 | |
| 502 | /** |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 503 | * @brief Print schema tree in the specified format. |
| 504 | * |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 505 | * To write data into a file descriptor, use lys_print_fd(). |
| 506 | * |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 507 | * @param[in] module Schema tree to print. |
| 508 | * @param[in] f File stream where to print the schema. |
| 509 | * @param[in] format Schema output format. |
Radek Krejci | a9167ef | 2015-08-03 11:01:11 +0200 | [diff] [blame] | 510 | * @param[in] target_node Optional parameter for ::LYS_OUT_INFO format. It specifies which particular |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 511 | * node in the module will be printed. |
| 512 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 513 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 514 | int lys_print(FILE *f, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node); |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 515 | |
| 516 | /** |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 517 | * @brief Print schema tree in the specified format. |
| 518 | * |
| 519 | * Same as lys_print(), but output is written into the specified file descriptor. |
| 520 | * |
| 521 | * @param[in] module Schema tree to print. |
| 522 | * @param[in] fd File descriptor where to print the data. |
| 523 | * @param[in] format Schema output format. |
| 524 | * @param[in] target_node Optional parameter for ::LYS_OUT_INFO format. It specifies which particular |
| 525 | * node in the module will be printed. |
| 526 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 527 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 528 | int lys_print_fd(int fd, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node); |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 529 | |
| 530 | /** |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 531 | * @brief Print schema tree in the specified format. |
| 532 | * |
Radek Krejci | 2fa0fc1 | 2015-10-14 18:14:29 +0200 | [diff] [blame] | 533 | * Same as lys_print(), but it allocates memory and store the data into it. |
| 534 | * It is up to caller to free the returned string by free(). |
| 535 | * |
| 536 | * @param[out] strp Pointer to store the resulting dump. |
| 537 | * @param[in] module Schema tree to print. |
| 538 | * @param[in] format Schema output format. |
| 539 | * @param[in] target_node Optional parameter for ::LYS_OUT_INFO format. It specifies which particular |
| 540 | * node in the module will be printed. |
| 541 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 542 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 543 | int lys_print_mem(char **strp, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node); |
Radek Krejci | 2fa0fc1 | 2015-10-14 18:14:29 +0200 | [diff] [blame] | 544 | |
| 545 | /** |
| 546 | * @brief Print schema tree in the specified format. |
| 547 | * |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 548 | * Same as lys_print(), but output is written via provided callback. |
| 549 | * |
| 550 | * @param[in] module Schema tree to print. |
| 551 | * @param[in] writeclb Callback function to write the data (see write(1)). |
Radek Krejci | 50929eb | 2015-10-09 18:14:15 +0200 | [diff] [blame] | 552 | * @param[in] arg Optional caller-specific argument to be passed to the \p writeclb callback. |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 553 | * @param[in] format Schema output format. |
| 554 | * @param[in] target_node Optional parameter for ::LYS_OUT_INFO format. It specifies which particular |
| 555 | * node in the module will be printed. |
| 556 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 557 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 558 | int lys_print_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg, |
| 559 | const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node); |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 560 | |
| 561 | /** |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 562 | * @brief Print data tree in the specified format. |
| 563 | * |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 564 | * To write data into a file descriptor, use lyd_print_fd(). |
| 565 | * |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 566 | * @param[in] root Root node of the data tree to print. It can be actually any (not only real root) |
| 567 | * node of the data tree to print the specific subtree. |
| 568 | * @param[in] f File stream where to print the data. |
| 569 | * @param[in] format Data output format. |
| 570 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 571 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 572 | int lyd_print(FILE *f, const struct lyd_node *root, LYD_FORMAT format); |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 573 | |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 574 | /** |
| 575 | * @brief Print data tree in the specified format. |
| 576 | * |
| 577 | * Same as lyd_print(), but output is written into the specified file descriptor. |
| 578 | * |
| 579 | * @param[in] root Root node of the data tree to print. It can be actually any (not only real root) |
| 580 | * node of the data tree to print the specific subtree. |
| 581 | * @param[in] fd File descriptor where to print the data. |
| 582 | * @param[in] format Data output format. |
| 583 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 584 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 585 | int lyd_print_fd(int fd, const struct lyd_node *root, LYD_FORMAT format); |
Radek Krejci | 87f5237 | 2015-10-09 09:34:46 +0200 | [diff] [blame] | 586 | |
Radek Krejci | 2fa0fc1 | 2015-10-14 18:14:29 +0200 | [diff] [blame] | 587 | |
| 588 | /** |
| 589 | * @brief Print data tree in the specified format. |
| 590 | * |
| 591 | * Same as lyd_print(), but it allocates memory and store the data into it. |
| 592 | * It is up to caller to free the returned string by free(). |
| 593 | * |
| 594 | * @param[out] strp Pointer to store the resulting dump. |
| 595 | * @param[in] root Root node of the data tree to print. It can be actually any (not only real root) |
| 596 | * node of the data tree to print the specific subtree. |
| 597 | * @param[in] format Data output format. |
| 598 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 599 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 600 | int lyd_print_mem(char **strp, const struct lyd_node *root, LYD_FORMAT format); |
Radek Krejci | 2fa0fc1 | 2015-10-14 18:14:29 +0200 | [diff] [blame] | 601 | |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 602 | /** |
| 603 | * @brief Print data tree in the specified format. |
| 604 | * |
| 605 | * Same as lyd_print(), but output is written via provided callback. |
| 606 | * |
| 607 | * @param[in] root Root node of the data tree to print. It can be actually any (not only real root) |
| 608 | * node of the data tree to print the specific subtree. |
| 609 | * @param[in] writeclb Callback function to write the data (see write(1)). |
Radek Krejci | 50929eb | 2015-10-09 18:14:15 +0200 | [diff] [blame] | 610 | * @param[in] arg Optional caller-specific argument to be passed to the \p writeclb callback. |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 611 | * @param[in] format Data output format. |
| 612 | * @return 0 on success, 1 on failure (#ly_errno is set). |
| 613 | */ |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame^] | 614 | int lyd_print_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg, |
| 615 | const struct lyd_node *root, LYD_FORMAT format); |
Radek Krejci | 6140e4e | 2015-10-09 15:50:55 +0200 | [diff] [blame] | 616 | |
Radek Krejci | 912da45 | 2015-07-29 14:10:06 +0200 | [diff] [blame] | 617 | /**@} printers */ |
| 618 | |
| 619 | /** |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 620 | * @defgroup logger Logger |
| 621 | * @{ |
| 622 | * |
| 623 | * Publicly visible functions and values of the libyang logger. For more |
| 624 | * information, see \ref howtologger. |
| 625 | */ |
| 626 | |
| 627 | /** |
| 628 | * @typedef LY_LOG_LEVEL |
| 629 | * @brief Verbosity levels of the libyang logger. |
| 630 | */ |
| 631 | typedef enum { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 632 | LY_LLERR, /**< Print only error messages. */ |
| 633 | LY_LLWRN, /**< Print error and warning messages. */ |
| 634 | LY_LLVRB, /**< Besides errors and warnings, print some other verbose messages. */ |
| 635 | LY_LLDBG /**< Print all messages including some development debug messages. */ |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 636 | } LY_LOG_LEVEL; |
| 637 | |
| 638 | /** |
| 639 | * @brief Set logger verbosity level. |
| 640 | * @param[in] level Verbosity level. |
| 641 | */ |
| 642 | void ly_verb(LY_LOG_LEVEL level); |
| 643 | |
| 644 | /** |
| 645 | * @typedef LY_ERR |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 646 | * @brief libyang's error codes available via ly_errno extern variable. |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 647 | * @ingroup logger |
| 648 | */ |
| 649 | typedef enum { |
Radek Krejci | ae6817a | 2015-08-10 14:02:06 +0200 | [diff] [blame] | 650 | LY_SUCCESS, /**< no error, not set by functions, included just to complete #LY_ERR enumeration */ |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 651 | LY_EMEM, /**< Memory allocation failure */ |
| 652 | LY_ESYS, /**< System call failure */ |
| 653 | LY_EINVAL, /**< Invalid value */ |
| 654 | LY_EINT, /**< Internal error */ |
| 655 | LY_EVALID /**< Validation failure */ |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 656 | } LY_ERR; |
Radek Krejci | 26715a4 | 2015-07-29 14:10:45 +0200 | [diff] [blame] | 657 | /** |
| 658 | * @brief libyang specific errno. |
| 659 | */ |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 660 | extern LY_ERR ly_errno; |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 661 | |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 662 | /**@} logger */ |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 663 | |
Radek Krejci | 39d8d0d | 2015-08-17 13:42:45 +0200 | [diff] [blame] | 664 | #ifdef __cplusplus |
| 665 | } |
| 666 | #endif |
| 667 | |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 668 | #endif /* LY_LIBYANG_H_ */ |