Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file schema_compile.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief Header for schema compilation. |
| 5 | * |
| 6 | * Copyright (c) 2015 - 2020 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
| 14 | |
| 15 | #ifndef LY_SCHEMA_COMPILE_H_ |
| 16 | #define LY_SCHEMA_COMPILE_H_ |
| 17 | |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 18 | #include <stddef.h> |
| 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "common.h" |
| 22 | #include "dict.h" |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 23 | #include "log.h" |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 24 | #include "set.h" |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 25 | #include "tree.h" |
| 26 | #include "tree_data.h" |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 27 | #include "tree_schema.h" |
| 28 | |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 29 | struct lyxp_expr; |
| 30 | |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 31 | /** |
| 32 | * @defgroup scflags Schema compile flags |
| 33 | * |
| 34 | * Flags are currently used only internally - the compilation process does not have a public interface and it is |
| 35 | * integrated in the schema parsers. The current options set does not make sense for public used, but it can be a way |
| 36 | * to modify behavior of the compilation process in future. |
| 37 | * |
| 38 | * @{ |
| 39 | */ |
Radek Krejci | 91531e1 | 2021-02-08 19:57:54 +0100 | [diff] [blame] | 40 | #define LYS_COMPILE_GROUPING 0x01 /**< Compiling (validation) of a non-instantiated grouping. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 41 | In this case not all the restrictions are checked since they can |
| 42 | be valid only in the real placement of the grouping. |
| 43 | TODO - what specifically is not done */ |
Radek Krejci | 91531e1 | 2021-02-08 19:57:54 +0100 | [diff] [blame] | 44 | #define LYS_COMPILE_DISABLED 0x02 /**< Compiling a disabled subtree (by its if-features). Meaning |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 45 | it will be removed at the end of compilation and should not be |
| 46 | added to any unres sets. */ |
Radek Krejci | 91531e1 | 2021-02-08 19:57:54 +0100 | [diff] [blame] | 47 | #define LYS_COMPILE_NO_CONFIG 0x04 /**< ignore config statements, neither inherit config value */ |
Radek Krejci | af0548b | 2021-02-15 15:11:22 +0100 | [diff] [blame] | 48 | #define LYS_COMPILE_NO_DISABLED 0x08 /**< ignore if-feature statements */ |
Radek Krejci | 91531e1 | 2021-02-08 19:57:54 +0100 | [diff] [blame] | 49 | |
| 50 | #define LYS_COMPILE_RPC_INPUT (LYS_IS_INPUT | LYS_COMPILE_NO_CONFIG) /**< Internal option when compiling schema tree of RPC/action input */ |
| 51 | #define LYS_COMPILE_RPC_OUTPUT (LYS_IS_OUTPUT | LYS_COMPILE_NO_CONFIG) /**< Internal option when compiling schema tree of RPC/action output */ |
| 52 | #define LYS_COMPILE_NOTIFICATION (LYS_IS_NOTIF | LYS_COMPILE_NO_CONFIG) /**< Internal option when compiling schema tree of Notification */ |
| 53 | |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 54 | /** @} scflags */ |
| 55 | |
| 56 | /** |
| 57 | * @brief internal context for compilation |
| 58 | */ |
| 59 | struct lysc_ctx { |
| 60 | struct ly_ctx *ctx; |
Michal Vasko | b8df576 | 2021-01-12 15:15:53 +0100 | [diff] [blame] | 61 | struct lys_module *cur_mod; /**< module currently being compiled, |
| 62 | - identifier/path - used as the current module for unprefixed nodes |
| 63 | - augment - module where the augment is defined |
| 64 | - deviation - module where the deviation is defined |
| 65 | - uses - module where the uses is defined */ |
| 66 | struct lysp_module *pmod; /**< parsed module being processed, |
| 67 | - identifier/path - used for searching imports to resolve prefixed nodes |
| 68 | - augment - module where the augment is defined |
| 69 | - deviation - module where the deviation is defined |
| 70 | - uses - module where the grouping is defined */ |
Radek Krejci | 6b88a46 | 2021-02-17 12:39:34 +0100 | [diff] [blame] | 71 | struct lysc_ext_instance *ext; /**< extension instance being processed and serving as a source for its substatements |
| 72 | instead of the module itself */ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 73 | struct ly_set groupings; /**< stack for groupings circular check */ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 74 | struct ly_set tpdf_chain; |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 75 | struct ly_set disabled; /**< set of compiled nodes whose if-feature(s) was not satisifed */ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 76 | struct ly_set augs; /**< set of compiled non-applied top-level augments */ |
| 77 | struct ly_set devs; /**< set of compiled non-applied deviations */ |
| 78 | struct ly_set uses_augs; /**< set of compiled non-applied uses augments */ |
| 79 | struct ly_set uses_rfns; /**< set of compiled non-applied uses refines */ |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 80 | struct lys_glob_unres *unres; /**< global unres sets */ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 81 | uint32_t path_len; |
| 82 | uint32_t options; /**< various @ref scflags. */ |
| 83 | #define LYSC_CTX_BUFSIZE 4078 |
| 84 | char path[LYSC_CTX_BUFSIZE]; |
| 85 | }; |
| 86 | |
| 87 | /** |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 88 | * @brief Structure for unresolved items that may depend on any implemented module data so their resolution |
| 89 | * can only be performed after all module basic compilation is done. |
| 90 | */ |
| 91 | struct lys_glob_unres { |
| 92 | struct ly_set implementing; /**< set of YANG schemas being atomically implemented (compiled); the first added |
| 93 | module is always the explcitly implemented module, the other ones are dependencies */ |
| 94 | struct ly_set creating; /**< set of YANG schemas being atomically created (parsed); it is a subset of implemented |
| 95 | and all these modules are freed if any error occurs */ |
| 96 | struct ly_set xpath; /**< when/must to check */ |
| 97 | struct ly_set leafrefs; /**< to validate leafref's targets */ |
| 98 | struct ly_set dflts; /**< set of incomplete default values */ |
| 99 | ly_bool recompile; /**< flag whether all the modules need to be recompiled (because of new deviations) */ |
| 100 | }; |
| 101 | |
| 102 | /** |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 103 | * @brief Structure for remembering default values of leaves and leaf-lists. They are resolved at schema compilation |
| 104 | * end when the whole schema tree is available. |
| 105 | */ |
| 106 | struct lysc_unres_dflt { |
| 107 | union { |
| 108 | struct lysc_node_leaf *leaf; |
| 109 | struct lysc_node_leaflist *llist; |
| 110 | }; |
| 111 | struct lysp_qname *dflt; |
| 112 | struct lysp_qname *dflts; /**< this is a sized array */ |
| 113 | }; |
| 114 | |
| 115 | /** |
| 116 | * @brief Duplicate string into dictionary |
| 117 | * @param[in] CTX libyang context of the dictionary. |
| 118 | * @param[in] ORIG String to duplicate. |
| 119 | * @param[out] DUP Where to store the result. |
| 120 | */ |
| 121 | #define DUP_STRING(CTX, ORIG, DUP, RET) if (ORIG) {RET = lydict_insert(CTX, ORIG, 0, &DUP);} |
Radek Krejci | 771928a | 2021-01-19 13:42:36 +0100 | [diff] [blame] | 122 | #define DUP_STRING_RET(CTX, ORIG, DUP) if (ORIG) {LY_ERR __ret = lydict_insert(CTX, ORIG, 0, &DUP); LY_CHECK_RET(__ret);} |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 123 | #define DUP_STRING_GOTO(CTX, ORIG, DUP, RET, GOTO) if (ORIG) {LY_CHECK_GOTO(RET = lydict_insert(CTX, ORIG, 0, &DUP), GOTO);} |
| 124 | |
| 125 | #define DUP_ARRAY(CTX, ORIG_ARRAY, NEW_ARRAY, DUP_FUNC) \ |
| 126 | if (ORIG_ARRAY) { \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 127 | LY_ARRAY_COUNT_TYPE __u; \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 128 | LY_ARRAY_CREATE_RET(CTX, NEW_ARRAY, LY_ARRAY_COUNT(ORIG_ARRAY), LY_EMEM); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 129 | LY_ARRAY_FOR(ORIG_ARRAY, __u) { \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 130 | LY_ARRAY_INCREMENT(NEW_ARRAY); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 131 | LY_CHECK_RET(DUP_FUNC(CTX, &(NEW_ARRAY)[__u], &(ORIG_ARRAY)[__u])); \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 132 | } \ |
| 133 | } |
| 134 | |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 135 | #define COMPILE_OP_ARRAY_GOTO(CTX, ARRAY_P, ARRAY_C, PARENT, FUNC, USES_STATUS, RET, GOTO) \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 136 | if (ARRAY_P) { \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 137 | LY_ARRAY_COUNT_TYPE __u = (ARRAY_C) ? LY_ARRAY_COUNT(ARRAY_C) : 0; \ |
| 138 | LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, __u + LY_ARRAY_COUNT(ARRAY_P), RET, GOTO); \ |
| 139 | LY_ARRAY_FOR(ARRAY_P, __u) { \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 140 | LY_ARRAY_INCREMENT(ARRAY_C); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 141 | RET = FUNC(CTX, &(ARRAY_P)[__u], PARENT, &(ARRAY_C)[LY_ARRAY_COUNT(ARRAY_C) - 1], USES_STATUS); \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 142 | if (RET == LY_EDENIED) { \ |
| 143 | LY_ARRAY_DECREMENT(ARRAY_C); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 144 | RET = LY_SUCCESS; \ |
| 145 | } else if (RET) { \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 146 | goto GOTO; \ |
| 147 | } \ |
| 148 | } \ |
| 149 | } |
| 150 | |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 151 | #define COMPILE_ARRAY_GOTO(CTX, ARRAY_P, ARRAY_C, FUNC, RET, GOTO) \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 152 | if (ARRAY_P) { \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 153 | LY_ARRAY_COUNT_TYPE __u = (ARRAY_C) ? LY_ARRAY_COUNT(ARRAY_C) : 0; \ |
| 154 | LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, __u + LY_ARRAY_COUNT(ARRAY_P), RET, GOTO); \ |
| 155 | LY_ARRAY_FOR(ARRAY_P, __u) { \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 156 | LY_ARRAY_INCREMENT(ARRAY_C); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 157 | RET = FUNC(CTX, &(ARRAY_P)[__u], &(ARRAY_C)[LY_ARRAY_COUNT(ARRAY_C) - 1]); \ |
| 158 | LY_CHECK_GOTO(RET, GOTO); \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 159 | } \ |
| 160 | } |
| 161 | |
| 162 | #define COMPILE_EXTS_GOTO(CTX, EXTS_P, EXT_C, PARENT, PARENT_TYPE, RET, GOTO) \ |
| 163 | if (EXTS_P) { \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 164 | LY_ARRAY_COUNT_TYPE __u = (EXT_C) ? LY_ARRAY_COUNT(EXT_C) : 0; \ |
| 165 | LY_ARRAY_CREATE_GOTO((CTX)->ctx, EXT_C, __u + LY_ARRAY_COUNT(EXTS_P), RET, GOTO); \ |
| 166 | LY_ARRAY_FOR(EXTS_P, __u) { \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 167 | LY_ARRAY_INCREMENT(EXT_C); \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 168 | RET = lys_compile_ext(CTX, &(EXTS_P)[__u], &(EXT_C)[LY_ARRAY_COUNT(EXT_C) - 1], PARENT, PARENT_TYPE, NULL); \ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 169 | if (RET == LY_ENOT) { \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 170 | LY_ARRAY_DECREMENT(EXT_C); \ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 171 | RET = LY_SUCCESS; \ |
Michal Vasko | 5347e3a | 2020-11-03 17:14:57 +0100 | [diff] [blame] | 172 | } else if (RET) { \ |
| 173 | goto GOTO; \ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 174 | } \ |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 175 | } \ |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * @brief Fill in the prepared compiled extension instance structure according to the parsed extension instance. |
| 180 | * |
| 181 | * @param[in] ctx Compilation context. |
| 182 | * @param[in] ext_p Parsed extension instance. |
| 183 | * @param[in,out] ext Prepared compiled extension instance. |
| 184 | * @param[in] parent Extension instance parent. |
| 185 | * @param[in] parent_type Extension instance parent type. |
| 186 | * @param[in] ext_mod Optional module with the extension instance extension definition, set only for internal annotations. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 187 | * @return LY_SUCCESS on success. |
| 188 | * @return LY_ENOT if the extension is disabled and should be ignored. |
| 189 | * @return LY_ERR on error. |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 190 | */ |
| 191 | LY_ERR lys_compile_ext(struct lysc_ctx *ctx, struct lysp_ext_instance *ext_p, struct lysc_ext_instance *ext, void *parent, |
| 192 | LYEXT_PARENT parent_type, const struct lys_module *ext_mod); |
| 193 | |
| 194 | /** |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 195 | * @brief Compile information from the identity statement |
| 196 | * |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 197 | * The backlinks to the identities derived from this one are supposed to be filled later via ::lys_compile_identity_bases(). |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 198 | * |
| 199 | * @param[in] ctx_sc Compile context - alternative to the combination of @p ctx and @p parsed_mod. |
| 200 | * @param[in] ctx libyang context. |
| 201 | * @param[in] parsed_mod Module with the identities. |
| 202 | * @param[in] identities_p Array of the parsed identity definitions to precompile. |
| 203 | * @param[in,out] identities Pointer to the storage of the (pre)compiled identities array where the new identities are |
| 204 | * supposed to be added. The storage is supposed to be initiated to NULL when the first parsed identities are going |
| 205 | * to be processed. |
| 206 | * @return LY_ERR value. |
| 207 | */ |
| 208 | LY_ERR lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lysp_module *parsed_mod, |
| 209 | struct lysp_ident *identities_p, struct lysc_ident **identities); |
| 210 | |
| 211 | /** |
| 212 | * @brief Find and process the referenced base identities from another identity or identityref |
| 213 | * |
| 214 | * For bases in identity set backlinks to them from the base identities. For identityref, store |
| 215 | * the array of pointers to the base identities. So one of the ident or bases parameter must be set |
| 216 | * to distinguish these two use cases. |
| 217 | * |
| 218 | * @param[in] ctx Compile context, not only for logging but also to get the current module to resolve prefixes. |
| 219 | * @param[in] base_pmod Module where to resolve @p bases_p prefixes. |
| 220 | * @param[in] bases_p Array of names (including prefix if necessary) of base identities. |
| 221 | * @param[in] ident Referencing identity to work with, NULL for identityref. |
| 222 | * @param[in] bases Array of bases of identityref to fill in. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 223 | * @param[in] enabled Whether the base is disabled, must be set if @p ident is set. |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 224 | * @return LY_ERR value. |
| 225 | */ |
| 226 | LY_ERR lys_compile_identity_bases(struct lysc_ctx *ctx, const struct lysp_module *base_pmod, const char **bases_p, |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 227 | struct lysc_ident *ident, struct lysc_ident ***bases, ly_bool *enabled); |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * @brief Check statement's status for invalid combination. |
| 231 | * |
| 232 | * The modX parameters are used just to determine if both flags are in the same module, |
| 233 | * so any of the schema module structure can be used, but both modules must be provided |
| 234 | * in the same type. |
| 235 | * |
| 236 | * @param[in] ctx Compile context for logging. |
| 237 | * @param[in] flags1 Flags of the referencing node. |
| 238 | * @param[in] mod1 Module of the referencing node, |
| 239 | * @param[in] name1 Schema node name of the referencing node. |
| 240 | * @param[in] flags2 Flags of the referenced node. |
| 241 | * @param[in] mod2 Module of the referenced node, |
| 242 | * @param[in] name2 Schema node name of the referenced node. |
| 243 | * @return LY_ERR value |
| 244 | */ |
| 245 | LY_ERR lysc_check_status(struct lysc_ctx *ctx, uint16_t flags1, void *mod1, const char *name1, uint16_t flags2, |
| 246 | void *mod2, const char *name2); |
| 247 | |
| 248 | /** |
Michal Vasko | 25d6ad0 | 2020-10-22 12:20:22 +0200 | [diff] [blame] | 249 | * @brief Check parsed expression for any prefixes of unimplemented modules. |
| 250 | * |
| 251 | * @param[in] ctx libyang context. |
| 252 | * @param[in] expr Parsed expression. |
| 253 | * @param[in] format Prefix format. |
| 254 | * @param[in] prefix_data Format-specific data (see ::ly_resolve_prefix()). |
| 255 | * @param[in] implement Whether all the non-implemented modules should are implemented or the first |
| 256 | * non-implemented module, if any, returned in @p mod_p. |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 257 | * @param[in,out] unres Global unres structure of newly implemented modules. |
Michal Vasko | 25d6ad0 | 2020-10-22 12:20:22 +0200 | [diff] [blame] | 258 | * @param[out] mod_p Module that is not implemented. |
| 259 | * @return LY_SUCCESS on success. |
| 260 | * @return LY_ERR on error. |
| 261 | */ |
| 262 | LY_ERR lys_compile_expr_implement(const struct ly_ctx *ctx, const struct lyxp_expr *expr, LY_PREFIX_FORMAT format, |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 263 | void *prefix_data, ly_bool implement, struct lys_glob_unres *unres, const struct lys_module **mod_p); |
| 264 | |
| 265 | /** |
| 266 | * @brief Finish compilation of all the global unres sets. |
| 267 | * |
| 268 | * @param[in] ctx libyang context. |
| 269 | * @param[in] unres Global unres structure with the sets to resolve. |
| 270 | * @return LY_ERR value. |
| 271 | */ |
| 272 | LY_ERR lys_compile_unres_glob(struct ly_ctx *ctx, struct lys_glob_unres *unres); |
| 273 | |
| 274 | /** |
| 275 | * @brief Revert a failed compilation (free new modules, unimplement newly implemented modules). |
| 276 | * |
| 277 | * @param[in] ctx libyang context. |
| 278 | * @param[in] unres Global unres set with newly implemented modules. |
| 279 | */ |
| 280 | void lys_compile_unres_glob_revert(struct ly_ctx *ctx, struct lys_glob_unres *unres); |
| 281 | |
| 282 | /** |
| 283 | * @brief Erase all the global unres sets. |
| 284 | * |
| 285 | * @param[in] ctx libyang context. |
| 286 | * @param[in] unres Global unres structure with the sets. |
| 287 | */ |
| 288 | void lys_compile_unres_glob_erase(const struct ly_ctx *ctx, struct lys_glob_unres *unres); |
Michal Vasko | 25d6ad0 | 2020-10-22 12:20:22 +0200 | [diff] [blame] | 289 | |
| 290 | /** |
Michal Vasko | 916aefb | 2020-11-02 15:43:16 +0100 | [diff] [blame] | 291 | * @brief Recompile the whole context based on the current flags. |
| 292 | * |
| 293 | * @param[in] ctx Context to recompile. |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 294 | * @param[in] log Whether to log all the errors. |
Michal Vasko | 916aefb | 2020-11-02 15:43:16 +0100 | [diff] [blame] | 295 | * @return LY_SUCCESS on success. |
| 296 | * @return LY_ERR on error. |
| 297 | */ |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 298 | LY_ERR lys_recompile(struct ly_ctx *ctx, ly_bool log); |
Michal Vasko | 916aefb | 2020-11-02 15:43:16 +0100 | [diff] [blame] | 299 | |
| 300 | /** |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 301 | * @brief Compile printable schema into a validated schema linking all the references. |
| 302 | * |
| 303 | * @param[in] mod Pointer to the schema structure holding pointers to both schema structure types. The ::lys_module#parsed |
| 304 | * member is used as input and ::lys_module#compiled is used to hold the result of the compilation. |
| 305 | * @param[in] options Various options to modify compiler behavior, see [compile flags](@ref scflags). |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 306 | * @param[in,out] unres Global unres structure for newly implemented modules. |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 307 | * @return LY_ERR value - LY_SUCCESS or LY_EVALID. |
| 308 | */ |
Michal Vasko | 405cc9e | 2020-12-01 12:01:27 +0100 | [diff] [blame] | 309 | LY_ERR lys_compile(struct lys_module *mod, uint32_t options, struct lys_glob_unres *unres); |
Michal Vasko | 1a7a7bd | 2020-10-16 14:39:15 +0200 | [diff] [blame] | 310 | |
| 311 | #endif /* LY_SCHEMA_COMPILE_H_ */ |