David Sedlák | b1ce3f8 | 2019-06-05 14:37:26 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file parser_yin.h |
| 3 | * @author David Sedlák <xsedla1d@stud.fit.vutbr.cz> |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 4 | * @brief YIN parser header file. |
David Sedlák | b1ce3f8 | 2019-06-05 14:37:26 +0200 | [diff] [blame] | 5 | * |
| 6 | * Copyright (c) 2015 - 2019 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 | */ |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 14 | |
| 15 | #ifndef LY_PARSER_YIN_H_ |
| 16 | #define LY_PARSER_YIN_H_ |
| 17 | |
| 18 | #include <stdio.h> |
David Sedlák | b1ce3f8 | 2019-06-05 14:37:26 +0200 | [diff] [blame] | 19 | #include <stdlib.h> |
| 20 | |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 21 | #include "log.h" |
| 22 | #include "xml.h" |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 23 | |
David Sedlák | f625118 | 2019-06-06 10:22:13 +0200 | [diff] [blame] | 24 | /* list of yin attribute strings */ |
| 25 | extern const char *const yin_attr_list[]; |
| 26 | #define yin_attr2str(STMT) yin_attr_list[STMT] |
| 27 | |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 28 | #define YIN_NS_URI "urn:ietf:params:xml:ns:yang:yin:1" |
David Sedlák | d6e5689 | 2019-07-01 15:40:24 +0200 | [diff] [blame] | 29 | #define name2fullname(name, prefix_len) (prefix_len != 0 ? name - (prefix_len + 1) : name) |
David Sedlák | f250ecf | 2019-07-01 11:02:05 +0200 | [diff] [blame] | 30 | #define namelen2fulllen(name_len, prefix_len) (prefix_len != 0 ? name_len + prefix_len + 1 : name_len) |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 31 | |
David Sedlák | 4ffcec8 | 2019-07-25 15:10:21 +0200 | [diff] [blame] | 32 | /* shortcut to determin if keyword can in general be subelement of deviation regardles of it's type */ |
| 33 | #define isdevsub(kw) (kw == YANG_CONFIG || kw == YANG_DEFAULT || kw == YANG_MANDATORY || \ |
| 34 | kw == YANG_MAX_ELEMENTS || kw == YANG_MIN_ELEMENTS || \ |
| 35 | kw == YANG_MUST || kw == YANG_TYPE || kw == YANG_UNIQUE || \ |
| 36 | kw == YANG_UNITS || kw == YANG_CUSTOM) |
| 37 | |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 38 | enum yin_argument { |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 39 | YIN_ARG_UNKNOWN = 0, /**< parsed argument can not be matched with any supported yin argument keyword */ |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 40 | YIN_ARG_NAME, /**< argument name */ |
| 41 | YIN_ARG_TARGET_NODE, /**< argument target-node */ |
| 42 | YIN_ARG_MODULE, /**< argument module */ |
| 43 | YIN_ARG_VALUE, /**< argument value */ |
| 44 | YIN_ARG_TEXT, /**< argument text */ |
| 45 | YIN_ARG_CONDITION, /**< argument condition */ |
| 46 | YIN_ARG_URI, /**< argument uri */ |
| 47 | YIN_ARG_DATE, /**< argument data */ |
| 48 | YIN_ARG_TAG, /**< argument tag */ |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 49 | YIN_ARG_NONE, /**< empty (special value) */ |
David Sedlák | 7ff55a9 | 2019-06-17 11:11:41 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 52 | /** |
| 53 | * @brief structure to store instance of xml attribute |
| 54 | */ |
David Sedlák | 7ff55a9 | 2019-06-17 11:11:41 +0200 | [diff] [blame] | 55 | struct yin_arg_record { |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 56 | const char *prefix; /**< start of prefix */ |
| 57 | size_t prefix_len; /**< length of prefix */ |
| 58 | const char *name; /**< start of name */ |
| 59 | size_t name_len; /**< length of name */ |
| 60 | char *content; /**< start of content */ |
| 61 | size_t content_len; /**< length of content */ |
| 62 | int dynamic_content; /**< is set to 1 iff content is dynamically allocated 0 otherwise */ |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 63 | }; |
| 64 | |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 65 | /* flags to set constraints of subelements */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 66 | #define YIN_SUBELEM_MANDATORY 0x01 /**< is set when subelement is mandatory */ |
| 67 | #define YIN_SUBELEM_UNIQUE 0x02 /**< is set when subelement is unique */ |
David Sedlák | e1a3030 | 2019-07-10 13:49:38 +0200 | [diff] [blame] | 68 | #define YIN_SUBELEM_FIRST 0x04 /**< is set when subelement is actually yang argument mapped to yin element */ |
David Sedlák | 0c2bab9 | 2019-07-22 15:33:19 +0200 | [diff] [blame] | 69 | #define YIN_SUBELEM_VER2 0x08 /**< subelemnt is allowed only in modules with version at least 2 (YANG 1.1) */ |
David Sedlák | 21f87cd | 2019-07-03 16:53:23 +0200 | [diff] [blame] | 70 | |
| 71 | #define YIN_SUBELEM_PARSED 0x80 /**< is set during parsing when given subelement is encountered for the first |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 72 | time to simply check validity of given constraints */ |
| 73 | |
| 74 | struct yin_subelement { |
| 75 | enum yang_keyword type; /**< type of keyword */ |
David Sedlák | 4a65053 | 2019-07-10 11:55:18 +0200 | [diff] [blame] | 76 | void *dest; /**< meta infromation passed to responsible function (mostly information about where parsed subelement should be stored) */ |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 77 | uint8_t flags; /**< describes constraints of subelement can be set to YIN_SUBELEM_MANDATORY, YIN_SUBELEM_UNIQUE, YIN_SUBELEM_FIRST and YIN_SUBELEM_VER2 */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 78 | }; |
| 79 | |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 80 | /* Meta information passed to yin_parse_argument function, |
| 81 | holds information about where content of argument element will be stored. */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 82 | struct yin_argument_meta { |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 83 | uint16_t *flags; /**< Argument flags */ |
| 84 | const char **argument; /**< Argument value */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 85 | }; |
| 86 | |
David Sedlák | 04e17b2 | 2019-07-19 15:29:48 +0200 | [diff] [blame] | 87 | /* Meta information passed to functions working with tree schema such as yin_parse_any */ |
David Sedlák | 8a83bbb | 2019-07-18 14:46:00 +0200 | [diff] [blame] | 88 | struct tree_node_meta { |
| 89 | struct lysp_node *parent; /**< parent node */ |
| 90 | struct lysp_node **siblings; /**< linked list of siblings */ |
| 91 | }; |
| 92 | |
David Sedlák | 04e17b2 | 2019-07-19 15:29:48 +0200 | [diff] [blame] | 93 | /* Meta information passed to yin_parse_typedef */ |
| 94 | struct typedef_meta { |
| 95 | struct lysp_node *parent; /**< parent node */ |
David Sedlák | 0d6de5a | 2019-07-22 13:25:44 +0200 | [diff] [blame] | 96 | struct lysp_tpdf **typedefs; /**< [Sized array](@ref sizedarrays) of typedefs to add to */ |
| 97 | }; |
| 98 | |
David Sedlák | 0c2bab9 | 2019-07-22 15:33:19 +0200 | [diff] [blame] | 99 | /* Meta information passed to yin_parse_augment function */ |
David Sedlák | 0d6de5a | 2019-07-22 13:25:44 +0200 | [diff] [blame] | 100 | struct augment_meta { |
| 101 | struct lysp_node *parent; /**< parent node */ |
| 102 | struct lysp_augment **augments; /**< [Sized array](@ref sizedarrays) of augments to add to */ |
David Sedlák | 04e17b2 | 2019-07-19 15:29:48 +0200 | [diff] [blame] | 103 | }; |
| 104 | |
David Sedlák | 0c2bab9 | 2019-07-22 15:33:19 +0200 | [diff] [blame] | 105 | /* Meta information passed to yin_parse_include function */ |
| 106 | struct include_meta { |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 107 | const char *name; /**< Module/submodule name. */ |
| 108 | struct lysp_include **includes; /**< [Sized array](@ref sizedarrays) of parsed includes to add to. */ |
David Sedlák | 0c2bab9 | 2019-07-22 15:33:19 +0200 | [diff] [blame] | 109 | }; |
| 110 | |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 111 | /* Meta information passed to yin_parse_notification function */ |
David Sedlák | 031b9e7 | 2019-07-23 15:19:37 +0200 | [diff] [blame] | 112 | struct notif_meta { |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 113 | struct lysp_node *parent; /**< Parent node. */ |
| 114 | struct lysp_notif **notifs; /**< [Sized array](@ref sizedarrays) of notifications to add to. */ |
David Sedlák | e3ce9ef | 2019-07-23 16:34:30 +0200 | [diff] [blame] | 115 | }; |
| 116 | |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 117 | /* Meta information passed to yin_parse_grouping function */ |
David Sedlák | e3ce9ef | 2019-07-23 16:34:30 +0200 | [diff] [blame] | 118 | struct grouping_meta { |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 119 | struct lysp_node *parent; /**< Parent node. */ |
| 120 | struct lysp_grp **groupings; /**< [Sized array](@ref sizedarrays) of groupings to add to. */ |
| 121 | }; |
| 122 | |
| 123 | /* Meta information passed to yin_parse_grouping function */ |
| 124 | struct inout_meta { |
David Sedlák | 85d0eca | 2019-07-24 15:15:21 +0200 | [diff] [blame] | 125 | struct lysp_node *parent; /**< Parent node. */ |
David Sedlák | 05404f6 | 2019-07-24 14:11:53 +0200 | [diff] [blame] | 126 | struct lysp_action_inout *inout_p; /**< inout_p Input/output pointer to write to. */ |
David Sedlák | 031b9e7 | 2019-07-23 15:19:37 +0200 | [diff] [blame] | 127 | }; |
| 128 | |
David Sedlák | 992fb7c | 2019-07-24 16:51:01 +0200 | [diff] [blame] | 129 | /* Meta information passed to yin_parse_action function */ |
David Sedlák | 85d0eca | 2019-07-24 15:15:21 +0200 | [diff] [blame] | 130 | struct action_meta { |
| 131 | struct lysp_node *parent; /**< Parent node. */ |
| 132 | struct lysp_action **actions; /**< Actions to add to. */ |
| 133 | }; |
| 134 | |
David Sedlák | 298ff6d | 2019-07-26 14:29:03 +0200 | [diff] [blame] | 135 | /* Meta information passed to yin_parse_import function */ |
| 136 | struct import_meta { |
| 137 | const char *prefix; /**< module prefix. */ |
| 138 | struct lysp_import **imports; /**< imports to add to. */ |
| 139 | }; |
| 140 | |
David Sedlák | 4ffcec8 | 2019-07-25 15:10:21 +0200 | [diff] [blame] | 141 | struct minmax_dev_meta { |
| 142 | uint32_t *lim; |
| 143 | uint16_t *flags; |
| 144 | struct lysp_ext_instance **exts; |
| 145 | }; |
| 146 | |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 147 | /** |
| 148 | * @brief Match argument name. |
| 149 | * |
| 150 | * @param[in] name String representing name. |
| 151 | * @param[in] len Lenght of the name. |
| 152 | * |
David Sedlák | b1ce3f8 | 2019-06-05 14:37:26 +0200 | [diff] [blame] | 153 | * @return YIN_ARGUMENT value. |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 154 | */ |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 155 | enum yin_argument yin_match_argument_name(const char *name, size_t len); |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 156 | |
| 157 | /** |
David Sedlák | 555c720 | 2019-07-04 12:14:12 +0200 | [diff] [blame] | 158 | * @brief Generic function for content parsing |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 159 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 160 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
David Sedlák | 555c720 | 2019-07-04 12:14:12 +0200 | [diff] [blame] | 161 | * @param[in] subelem_info array of valid subelement types and meta information, |
| 162 | * array must be ordered by subelem_info->type in ascending order. |
| 163 | * @param[in] subelem_info_size Size of subelem_info array. |
| 164 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 165 | * @param[in] current_element Type of current element. |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 166 | * @param[out] text_content Where the text content of element should be stored if any. Text content is ignored if not set to NULL. |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 167 | * @param[in,out] exts Extension instance to add to. Can be se to null if element cannot have extension as subelements. |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 168 | * |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 169 | * @return LY_ERR values. |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 170 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 171 | LY_ERR yin_parse_content(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info, signed char subelem_info_size, |
David Sedlák | 555c720 | 2019-07-04 12:14:12 +0200 | [diff] [blame] | 172 | const char **data, enum yang_keyword current_element, const char **text_content, |
| 173 | struct lysp_ext_instance **exts); |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 174 | |
David Sedlák | d9d3a31 | 2019-06-04 09:47:10 +0200 | [diff] [blame] | 175 | /** |
David Sedlák | 4a65053 | 2019-07-10 11:55:18 +0200 | [diff] [blame] | 176 | * @brief Check that val is valid UTF8 character sequence of val_type. |
| 177 | * Doesn't check empty string, only character validity. |
| 178 | * |
| 179 | * @param[in] ctx Yin parser context for logging. |
| 180 | * @param[in] val_type Type of the input string to select method of checking character validity. |
| 181 | * @param[in] val Input to validate. |
| 182 | * @param[in] len Length of input. |
| 183 | * |
| 184 | * @return LY_ERR values. |
| 185 | */ |
| 186 | LY_ERR yin_validate_value(struct yin_parser_ctx *ctx, enum yang_arg val_type, char *val, size_t len); |
| 187 | |
| 188 | /** |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 189 | * @brief Match yang keyword from yin data. |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 190 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 191 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 192 | * @param[in] name Start of keyword name |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 193 | * @param[in] name_len Lenght of keyword name. |
| 194 | * @param[in] prefix Start of keyword prefix. |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 195 | * @param[in] prefix_len Lenght of prefix. |
David Sedlák | c1771b1 | 2019-07-10 15:55:46 +0200 | [diff] [blame] | 196 | * @param[in] parrent Identification of parrent element, use YANG_NONE for elements without parrent. |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 197 | * |
| 198 | * @return yang_keyword values. |
| 199 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 200 | enum yang_keyword yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len, |
David Sedlák | c1771b1 | 2019-07-10 15:55:46 +0200 | [diff] [blame] | 201 | const char *prefix, size_t prefix_len, enum yang_keyword parrent); |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 202 | |
David Sedlák | b6e6597 | 2019-06-19 10:44:13 +0200 | [diff] [blame] | 203 | /** |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 204 | * @brief Load all attributes of element into ([sized array](@ref sizedarrays)). Caller is suposed to free the array. |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 205 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 206 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
| 207 | * @param[in,out] data Data to read from, always moved to currently handled character. |
David Sedlák | bba38e5 | 2019-07-09 15:20:01 +0200 | [diff] [blame] | 208 | * @param[out] attrs ([Sized array](@ref sizedarrays)) of attributes. |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 209 | * |
| 210 | * @return LY_ERR values. |
| 211 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 212 | LY_ERR yin_load_attributes(struct yin_parser_ctx *ctx, const char **data, struct yin_arg_record **attrs); |
David Sedlák | b6e6597 | 2019-06-19 10:44:13 +0200 | [diff] [blame] | 213 | |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 214 | /** |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 215 | * @brief Parse instance of extension. |
| 216 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 217 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
David Sedlák | bba38e5 | 2019-07-09 15:20:01 +0200 | [diff] [blame] | 218 | * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of extension instance. |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 219 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 220 | * @param[in] ext_name Name of the extension element. |
| 221 | * @param[in] ext_name_len Length of extension name. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 222 | * @param[in] subelem Type of the keyword this extension instance is a subelement of. |
| 223 | * @param[in] subelem_index Index of the keyword instance this extension instance is a subelement of |
| 224 | * @param[in,out] exts Extension instance to add to. |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 225 | * |
| 226 | * @return LY_ERR values. |
| 227 | */ |
David Sedlák | 1f90d25 | 2019-07-10 17:09:32 +0200 | [diff] [blame] | 228 | LY_ERR yin_parse_extension_instance(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, |
David Sedlák | 619db94 | 2019-07-03 14:47:30 +0200 | [diff] [blame] | 229 | const char *ext_name, int ext_name_len, LYEXT_SUBSTMT subelem, |
| 230 | uint32_t subelem_index, struct lysp_ext_instance **exts); |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 231 | |
| 232 | /** |
| 233 | * @brief Parse yin element into generic structure. |
| 234 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 235 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 236 | * @param[in] name Name of element. |
| 237 | * @param[in] name_len Length of elements Name. |
| 238 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 239 | * @param[out] element Where the element structure should be stored. |
| 240 | * |
| 241 | * @return LY_ERR values. |
| 242 | */ |
David Sedlák | 4ffcec8 | 2019-07-25 15:10:21 +0200 | [diff] [blame] | 243 | LY_ERR yin_parse_element_generic(struct yin_parser_ctx *ctx, const char *name, size_t name_len, const char **data, |
| 244 | struct lysp_stmt **element); |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 245 | |
David Sedlák | 4f03b93 | 2019-07-26 13:01:47 +0200 | [diff] [blame] | 246 | /** |
David Sedlák | 298ff6d | 2019-07-26 14:29:03 +0200 | [diff] [blame] | 247 | * @brief Parse module element. |
David Sedlák | 4f03b93 | 2019-07-26 13:01:47 +0200 | [diff] [blame] | 248 | * |
| 249 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
| 250 | * @param[in] mod_attrs Attributes of module element. |
| 251 | * @param[in,out] data Data to read from. |
| 252 | * @param[out] mod Parsed module structure. |
| 253 | * |
| 254 | * @return LY_ERR values. |
| 255 | */ |
David Sedlák | 298ff6d | 2019-07-26 14:29:03 +0200 | [diff] [blame] | 256 | LY_ERR yin_parse_mod(struct yin_parser_ctx *ctx, struct yin_arg_record *mod_attrs, |
| 257 | const char **data, struct lysp_module *mod); |
David Sedlák | 4f03b93 | 2019-07-26 13:01:47 +0200 | [diff] [blame] | 258 | |
| 259 | |
| 260 | /** |
David Sedlák | 298ff6d | 2019-07-26 14:29:03 +0200 | [diff] [blame] | 261 | * @brief Parse submodule element. |
| 262 | * |
| 263 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
| 264 | * @param[in] mod_attrs Attributes of module element. |
| 265 | * @param[in,out] data Data to read from. |
| 266 | * @param[out] mod Parsed module structure. |
| 267 | * |
| 268 | * @return LY_ERR values. |
| 269 | */ |
| 270 | LY_ERR yin_parse_submod(struct yin_parser_ctx *ctx, struct yin_arg_record *mod_attrs, |
| 271 | const char **data, struct lysp_submodule *submod); |
| 272 | |
| 273 | /** |
David Sedlák | 4f03b93 | 2019-07-26 13:01:47 +0200 | [diff] [blame] | 274 | * @brief free argument record, content loaded from lyxml_get_string() can be |
| 275 | * dynamically allocated in some cases so it must be also freed. |
| 276 | * |
David Sedlák | c5b2084 | 2019-08-13 10:18:31 +0200 | [diff] [blame^] | 277 | * @param ctx unused just to fulfill signature of callback for FREE_ARRAY. |
| 278 | * @param[in] record Record to free. |
David Sedlák | 4f03b93 | 2019-07-26 13:01:47 +0200 | [diff] [blame] | 279 | */ |
| 280 | void free_arg_rec(struct yin_parser_ctx *ctx, struct yin_arg_record *record); |
| 281 | |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 282 | #endif /* LY_PARSER_YIN_H_*/ |