blob: 7bfe9fd30f162ee84c0f46c215f1366ac2ae0073 [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/**
aPiecekd8f002f2023-06-21 10:40:41 +020060 * @brief Print all features of a single module.
61 *
62 * @param[in] out The output handler for printing.
aPiecek6fde6d02023-06-21 15:06:45 +020063 * @param[in] mod Module which can contains the features.
aPiecekd8f002f2023-06-21 10:40:41 +020064 */
aPiecek6fde6d02023-06-21 15:06:45 +020065void print_features(struct ly_out *out, const struct lys_module *mod);
aPiecekd8f002f2023-06-21 10:40:41 +020066
67/**
aPiecek6fde6d02023-06-21 15:06:45 +020068 * @brief Print all features in the 'feature-param' format.
aPiecekd8f002f2023-06-21 10:40:41 +020069 *
aPiecek6fde6d02023-06-21 15:06:45 +020070 * @param[in] out The output handler for printing.
71 * @param[in] mod Module which can contains the features.
aPiecekd8f002f2023-06-21 10:40:41 +020072 */
aPiecek6fde6d02023-06-21 15:06:45 +020073void print_feature_param(struct ly_out *out, const struct lys_module *mod);
aPiecekd8f002f2023-06-21 10:40:41 +020074
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.
aPiecek6fde6d02023-06-21 15:06:45 +020080 * @param[in] feature_param Flag expressing whether to print features parameter.
aPiecekd8f002f2023-06-21 10:40:41 +020081 */
aPiecek6fde6d02023-06-21 15:06:45 +020082void print_all_features(struct ly_out *out, const struct ly_ctx *ctx, uint8_t feature_param);
aPiecekd8f002f2023-06-21 10:40:41 +020083
84#endif /* YL_SCHEMA_FEATURES_H_ */