Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file schema_features.h |
| 3 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * @brief Header for schema features. |
| 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_FEATURES_H_ |
| 16 | #define LY_SCHEMA_FEATURES_H_ |
| 17 | |
| 18 | #include "log.h" |
| 19 | |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 20 | struct ly_ctx; |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 21 | struct lysp_module; |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 22 | struct lysp_qname; |
| 23 | |
| 24 | /** |
| 25 | * @brief Evaluate if-features array. |
| 26 | * |
| 27 | * @param[in] ctx libyang context. |
| 28 | * @param[in] iffeatures Sized array of if-features to evaluate. |
| 29 | * @param[out] enabled Whether if-features evaluated to true or false. |
| 30 | * @return LY_SUCCESS on success. |
| 31 | * @return LY_ERR on error. |
| 32 | */ |
| 33 | LY_ERR lys_eval_iffeatures(const struct ly_ctx *ctx, struct lysp_qname *iffeatures, ly_bool *enabled); |
| 34 | |
| 35 | /** |
| 36 | * @brief Enable features in a parsed module with their consolidation and checking that they really |
| 37 | * can be enabled and have all their if-features true. |
| 38 | * |
| 39 | * @param[in] pmod Parsed module to modify. |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 40 | * @param[in] features Array of features ended with NULL to enable. NULL for all features disabled, '*' for all enabled. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 41 | * @return LY_SUCCESS on success. |
| 42 | * @return LY_ERR on error. |
| 43 | */ |
| 44 | LY_ERR lys_enable_features(struct lysp_module *pmod, const char **features); |
| 45 | |
| 46 | /** |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 47 | * @brief Set the specified features of a parsed module, with all the checks. |
| 48 | * |
| 49 | * @param[in] pmod Parsed module to modify. |
| 50 | * @param[in] features Array of features ended with NULL to set. NULL for all features disabled, '*' for all enabled. |
| 51 | * @return LY_SUCCESS on success. |
| 52 | * @return LY_EEXIST if the specified features were already set. |
| 53 | * @return LY_ERR on error. |
| 54 | */ |
| 55 | LY_ERR lys_set_features(struct lysp_module *pmod, const char **features); |
| 56 | |
| 57 | /** |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 58 | * @brief Compile if-features of features in the current module and all its submodules. |
| 59 | * |
| 60 | * @param[in] ctx Compile context. |
| 61 | * @return LY_ERR value. |
| 62 | */ |
| 63 | LY_ERR lys_compile_feature_iffeatures(struct lysp_module *pmod); |
| 64 | |
| 65 | /** |
| 66 | * @brief Free all auxiliary if-feature structures in a parsed module used for compilation. |
| 67 | * |
| 68 | * @param[in] pmod Module to update. |
| 69 | */ |
| 70 | void lys_free_feature_iffeatures(struct lysp_module *pmod); |
| 71 | |
| 72 | #endif /* LY_SCHEMA_FEATURES_H_ */ |