aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file yl_schema_features.h |
| 3 | * @author Adam Piecek <piecek@cesnet.cz> |
| 4 | * @brief Control features for the schema. |
| 5 | * |
| 6 | * Copyright (c) 2023 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 YL_SCHEMA_FEATURES_H_ |
| 16 | #define YL_SCHEMA_FEATURES_H_ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | struct ly_set; |
| 21 | struct lys_module; |
| 22 | struct ly_out; |
| 23 | struct ly_ctx; |
| 24 | |
| 25 | /** |
| 26 | * @brief Storage for the list of the features (their names) in a specific YANG module. |
| 27 | */ |
aPiecek | ceae633 | 2023-06-21 10:46:08 +0200 | [diff] [blame] | 28 | struct yl_schema_features { |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 29 | char *mod_name; |
| 30 | char **features; |
| 31 | uint8_t applied; |
| 32 | }; |
| 33 | |
| 34 | /** |
| 35 | * @brief Free the schema features list (struct schema_features *) |
| 36 | * @param[in,out] flist The (struct schema_features *) to free. |
| 37 | */ |
| 38 | void yl_schema_features_free(void *flist); |
| 39 | |
| 40 | /** |
| 41 | * @brief Get the list of features connected with the specific YANG module. |
| 42 | * |
| 43 | * @param[in] fset The set of features information (struct schema_features *). |
| 44 | * @param[in] module Name of the YANG module which features should be found. |
| 45 | * @param[out] features Pointer to the list of features being returned. |
| 46 | */ |
| 47 | void get_features(const struct ly_set *fset, const char *module, const char ***features); |
| 48 | |
| 49 | /** |
| 50 | * @brief Parse features being specified for the specific YANG module. |
| 51 | * |
| 52 | * Format of the input @p fstring is as follows: "<module_name>:[<feature>,]*" |
| 53 | * |
| 54 | * @param[in] fstring Input string to be parsed. |
| 55 | * @param[in, out] fset Features information set (of struct schema_features *). The set is being filled. |
| 56 | */ |
| 57 | int parse_features(const char *fstring, struct ly_set *fset); |
| 58 | |
| 59 | /** |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 60 | * @brief Print all features of a single module. |
| 61 | * |
| 62 | * @param[in] out The output handler for printing. |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 63 | * @param[in] mod Module which can contains the features. |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 64 | */ |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 65 | void print_features(struct ly_out *out, const struct lys_module *mod); |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 66 | |
| 67 | /** |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 68 | * @brief Print all features in the 'feature-param' format. |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 69 | * |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 70 | * @param[in] out The output handler for printing. |
| 71 | * @param[in] mod Module which can contains the features. |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 72 | */ |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 73 | void print_feature_param(struct ly_out *out, const struct lys_module *mod); |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * @brief Print all features of all implemented modules. |
| 77 | * |
| 78 | * @param[in] out The output handler for printing. |
| 79 | * @param[in] ctx Libyang context. |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 80 | * @param[in] feature_param Flag expressing whether to print features parameter. |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 81 | */ |
aPiecek | 6fde6d0 | 2023-06-21 15:06:45 +0200 | [diff] [blame] | 82 | void print_all_features(struct ly_out *out, const struct ly_ctx *ctx, uint8_t feature_param); |
aPiecek | d8f002f | 2023-06-21 10:40:41 +0200 | [diff] [blame] | 83 | |
| 84 | #endif /* YL_SCHEMA_FEATURES_H_ */ |