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 | */ |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 33 | LY_ERR lys_eval_iffeatures(const struct ly_ctx *ctx, const struct lysp_qname *iffeatures, ly_bool *enabled); |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 34 | |
| 35 | /** |
Michal Vasko | 6a4ef77 | 2022-02-08 15:07:44 +0100 | [diff] [blame] | 36 | * @brief Check whether all enabled features have their if-features satisfied. |
| 37 | * |
| 38 | * @param[in] pmod Parsed module features to check. |
| 39 | * @return LY_SUCCESS on success. |
| 40 | * @return LY_EDENIED if there was an enabled feature with disabled if-feature. |
| 41 | */ |
| 42 | LY_ERR lys_check_features(const struct lysp_module *pmod); |
| 43 | |
| 44 | /** |
| 45 | * @brief Set the specified features of a parsed module ignoring their own if-features. These are all checked before |
| 46 | * compiling the module(s). |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 47 | * |
| 48 | * @param[in] pmod Parsed module to modify. |
Radek Krejci | 2415f88 | 2021-01-20 16:27:09 +0100 | [diff] [blame] | 49 | * @param[in] features Array of features ended with NULL to be enabled if the module is being implemented. |
| 50 | * The feature string '*' enables all and array of length 1 with only the terminating NULL explicitly disables all |
| 51 | * the features. In case the parameter is NULL, the features are untouched - left disabled in newly loaded module or |
| 52 | * with the current features settings in case the module is already present in the context. |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 53 | * @return LY_SUCCESS on success. |
| 54 | * @return LY_EEXIST if the specified features were already set. |
| 55 | * @return LY_ERR on error. |
| 56 | */ |
| 57 | LY_ERR lys_set_features(struct lysp_module *pmod, const char **features); |
| 58 | |
| 59 | /** |
Radek Krejci | 84d7fd7 | 2021-07-14 18:32:21 +0200 | [diff] [blame] | 60 | * @brief Compile if-features of features in the provided module and all its submodules. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 61 | * |
Radek Krejci | 84d7fd7 | 2021-07-14 18:32:21 +0200 | [diff] [blame] | 62 | * @param[in] pmod Parsed module to process. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 63 | * @return LY_ERR value. |
| 64 | */ |
| 65 | LY_ERR lys_compile_feature_iffeatures(struct lysp_module *pmod); |
| 66 | |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 67 | #endif /* LY_SCHEMA_FEATURES_H_ */ |