blob: 7c96ba8a8b699d2dd9302c59f7550b40fefcdd7e [file] [log] [blame]
aPiecekd8f002f2023-06-21 10:40:41 +02001/**
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
20struct ly_set;
21struct lys_module;
22struct ly_out;
23struct ly_ctx;
24
25/**
26 * @brief Storage for the list of the features (their names) in a specific YANG module.
27 */
aPiecekceae6332023-06-21 10:46:08 +020028struct yl_schema_features {
aPiecekd8f002f2023-06-21 10:40:41 +020029 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 */
38void 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 */
47void 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 */
57int parse_features(const char *fstring, struct ly_set *fset);
58
59/**
60 * @brief Collect all features of a module.
61 *
62 * @param[in] mod Module to be searched for features.
63 * @param[out] set Set in which the features will be stored.
64 * @return 0 on success.
65 * @return 1 on error.
66 */
67int collect_features(const struct lys_module *mod, struct ly_set *set);
68
69/**
70 * @brief Print all features of a single module.
71 *
72 * @param[in] out The output handler for printing.
73 * @param[in] mod Module which contains the features.
74 * @param[in] set Set which holds the features.
75 */
76void print_features(struct ly_out *out, const struct lys_module *mod, const struct ly_set *set);
77
78/**
79 * @brief Generate a string, which will contain features paramater.
80 *
81 * @param[in] mod Module, for which the string will be generated.
82 * @param[in] set Set containing the features.
83 * @param[out] features_param String which will contain the output.
84 * @return 0 on success.
85 * @return 1 on error.
86 */
87int generate_features_output(const struct lys_module *mod, const struct ly_set *set, char **features_param);
88
89/**
90 * @brief Print all features of all implemented modules.
91 *
92 * @param[in] out The output handler for printing.
93 * @param[in] ctx Libyang context.
94 * @param[in] generate_features Flag expressing whether to generate features parameter.
95 * @param[out] features_param String, which will contain the output if the above flag is set.
96 * @return 0 on success.
97 * @return 1 on error.
98 */
99int print_all_features(struct ly_out *out, const struct ly_ctx *ctx, uint8_t generate_features, char **features_param);
100
101
102#endif /* YL_SCHEMA_FEATURES_H_ */