blob: f6b0d6ba865173ca877a0e42c061ed2d910c1174 [file] [log] [blame]
David Sedlákb1ce3f82019-06-05 14:37:26 +02001/**
2 * @file parser_yin.h
3 * @author David Sedlák <xsedla1d@stud.fit.vutbr.cz>
4 * @brief YIN parser.
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ák2b626ee2019-06-03 16:40:18 +020014
15#ifndef LY_PARSER_YIN_H_
16#define LY_PARSER_YIN_H_
17
18#include <stdio.h>
David Sedlákb1ce3f82019-06-05 14:37:26 +020019#include <stdlib.h>
20
David Sedlák2b626ee2019-06-03 16:40:18 +020021#include "log.h"
22#include "xml.h"
David Sedlák2b626ee2019-06-03 16:40:18 +020023
David Sedlákf6251182019-06-06 10:22:13 +020024/* list of yin attribute strings */
25extern const char *const yin_attr_list[];
26#define yin_attr2str(STMT) yin_attr_list[STMT]
27
David Sedlák2b214ac2019-06-06 16:11:03 +020028#define YIN_NS_URI "urn:ietf:params:xml:ns:yang:yin:1"
David Sedlákd6e56892019-07-01 15:40:24 +020029#define name2fullname(name, prefix_len) (prefix_len != 0 ? name - (prefix_len + 1) : name)
David Sedlákf250ecf2019-07-01 11:02:05 +020030#define namelen2fulllen(name_len, prefix_len) (prefix_len != 0 ? name_len + prefix_len + 1 : name_len)
David Sedlák2b214ac2019-06-06 16:11:03 +020031
David Sedlák4ffcec82019-07-25 15:10:21 +020032/* 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
38/* get deviate type from */
39
David Sedlák2b626ee2019-06-03 16:40:18 +020040enum YIN_ARGUMENT {
David Sedlák1bccdfa2019-06-17 15:55:27 +020041 YIN_ARG_UNKNOWN = 0, /**< parsed argument can not be matched with any supported yin argument keyword */
David Sedlák2b626ee2019-06-03 16:40:18 +020042 YIN_ARG_NAME, /**< argument name */
43 YIN_ARG_TARGET_NODE, /**< argument target-node */
44 YIN_ARG_MODULE, /**< argument module */
45 YIN_ARG_VALUE, /**< argument value */
46 YIN_ARG_TEXT, /**< argument text */
47 YIN_ARG_CONDITION, /**< argument condition */
48 YIN_ARG_URI, /**< argument uri */
49 YIN_ARG_DATE, /**< argument data */
50 YIN_ARG_TAG, /**< argument tag */
David Sedlák1bccdfa2019-06-17 15:55:27 +020051 YIN_ARG_NONE, /**< empty (special value) */
David Sedlák7ff55a92019-06-17 11:11:41 +020052};
53
David Sedlák1bccdfa2019-06-17 15:55:27 +020054/**
55 * @brief structure to store instance of xml attribute
56 */
David Sedlák7ff55a92019-06-17 11:11:41 +020057struct yin_arg_record {
David Sedlák1bccdfa2019-06-17 15:55:27 +020058 const char *prefix; /**< start of prefix */
59 size_t prefix_len; /**< length of prefix */
60 const char *name; /**< start of name */
61 size_t name_len; /**< length of name */
62 char *content; /**< start of content */
63 size_t content_len; /**< length of content */
64 int dynamic_content; /**< is set to 1 iff content is dynamically allocated 0 otherwise */
David Sedlák2b626ee2019-06-03 16:40:18 +020065};
66
David Sedlákda8ffa32019-07-08 14:17:10 +020067struct yin_parser_ctx {
David Sedlák04e17b22019-07-19 15:29:48 +020068 struct ly_set tpdfs_nodes;
69 struct ly_set grps_nodes;
David Sedlákbba38e52019-07-09 15:20:01 +020070 uint8_t mod_version; /**< module's version */
David Sedlák04e17b22019-07-19 15:29:48 +020071 struct lyxml_context xml_ctx; /**< context for xml parser */
David Sedlákda8ffa32019-07-08 14:17:10 +020072};
73
David Sedlák3ffbc522019-07-02 17:49:28 +020074/* flags to encode cardinality of subelement */
75#define YIN_SUBELEM_MANDATORY 0x01 /**< is set when subelement is mandatory */
76#define YIN_SUBELEM_UNIQUE 0x02 /**< is set when subelement is unique */
David Sedláke1a30302019-07-10 13:49:38 +020077#define YIN_SUBELEM_FIRST 0x04 /**< is set when subelement is actually yang argument mapped to yin element */
David Sedlák0c2bab92019-07-22 15:33:19 +020078#define YIN_SUBELEM_VER2 0x08 /**< subelemnt is allowed only in modules with version at least 2 (YANG 1.1) */
David Sedlák21f87cd2019-07-03 16:53:23 +020079
80#define YIN_SUBELEM_PARSED 0x80 /**< is set during parsing when given subelement is encountered for the first
David Sedlák3ffbc522019-07-02 17:49:28 +020081 time to simply check validity of given constraints */
82
83struct yin_subelement {
84 enum yang_keyword type; /**< type of keyword */
David Sedlák4a650532019-07-10 11:55:18 +020085 void *dest; /**< meta infromation passed to responsible function (mostly information about where parsed subelement should be stored) */
David Sedlákb4e44562019-07-04 15:42:12 +020086 uint8_t flags; /**< describes cardianlity of subelement can be set to YIN_SUBELEM_MANDATORY and YIN_SUBELEM_UNIQUE and YIN_SUBELEM_FIRST */
David Sedlák3ffbc522019-07-02 17:49:28 +020087};
88
David Sedlákb4e44562019-07-04 15:42:12 +020089/* helper structure just to make code look simpler */
David Sedlák3ffbc522019-07-02 17:49:28 +020090struct sized_string {
91 const char *value;
92 size_t len;
93};
94
David Sedlákb4e44562019-07-04 15:42:12 +020095/* Meta information passed to yin_parse_argument function,
96 holds information about where content of argument element will be stored. */
David Sedlák3ffbc522019-07-02 17:49:28 +020097struct yin_argument_meta {
David Sedlákb4e44562019-07-04 15:42:12 +020098 uint16_t *flags; /**< Argument flags */
99 const char **argument; /**< Argument value */
David Sedlák3ffbc522019-07-02 17:49:28 +0200100};
101
David Sedlák04e17b22019-07-19 15:29:48 +0200102/* Meta information passed to functions working with tree schema such as yin_parse_any */
David Sedlák8a83bbb2019-07-18 14:46:00 +0200103struct tree_node_meta {
104 struct lysp_node *parent; /**< parent node */
105 struct lysp_node **siblings; /**< linked list of siblings */
106};
107
David Sedlák04e17b22019-07-19 15:29:48 +0200108/* Meta information passed to yin_parse_typedef */
109struct typedef_meta {
110 struct lysp_node *parent; /**< parent node */
David Sedlák0d6de5a2019-07-22 13:25:44 +0200111 struct lysp_tpdf **typedefs; /**< [Sized array](@ref sizedarrays) of typedefs to add to */
112};
113
David Sedlák0c2bab92019-07-22 15:33:19 +0200114/* Meta information passed to yin_parse_augment function */
David Sedlák0d6de5a2019-07-22 13:25:44 +0200115struct augment_meta {
116 struct lysp_node *parent; /**< parent node */
117 struct lysp_augment **augments; /**< [Sized array](@ref sizedarrays) of augments to add to */
David Sedlák04e17b22019-07-19 15:29:48 +0200118};
119
David Sedlák0c2bab92019-07-22 15:33:19 +0200120/* Meta information passed to yin_parse_include function */
121struct include_meta {
David Sedlák05404f62019-07-24 14:11:53 +0200122 const char *name; /**< Module/submodule name. */
123 struct lysp_include **includes; /**< [Sized array](@ref sizedarrays) of parsed includes to add to. */
David Sedlák0c2bab92019-07-22 15:33:19 +0200124};
125
David Sedlák05404f62019-07-24 14:11:53 +0200126/* Meta information passed to yin_parse_notification function */
David Sedlák031b9e72019-07-23 15:19:37 +0200127struct notif_meta {
David Sedlák05404f62019-07-24 14:11:53 +0200128 struct lysp_node *parent; /**< Parent node. */
129 struct lysp_notif **notifs; /**< [Sized array](@ref sizedarrays) of notifications to add to. */
David Sedláke3ce9ef2019-07-23 16:34:30 +0200130};
131
David Sedlák05404f62019-07-24 14:11:53 +0200132/* Meta information passed to yin_parse_grouping function */
David Sedláke3ce9ef2019-07-23 16:34:30 +0200133struct grouping_meta {
David Sedlák05404f62019-07-24 14:11:53 +0200134 struct lysp_node *parent; /**< Parent node. */
135 struct lysp_grp **groupings; /**< [Sized array](@ref sizedarrays) of groupings to add to. */
136};
137
138/* Meta information passed to yin_parse_grouping function */
139struct inout_meta {
David Sedlák85d0eca2019-07-24 15:15:21 +0200140 struct lysp_node *parent; /**< Parent node. */
David Sedlák05404f62019-07-24 14:11:53 +0200141 struct lysp_action_inout *inout_p; /**< inout_p Input/output pointer to write to. */
David Sedlák031b9e72019-07-23 15:19:37 +0200142};
143
David Sedlák992fb7c2019-07-24 16:51:01 +0200144/* Meta information passed to yin_parse_action function */
David Sedlák85d0eca2019-07-24 15:15:21 +0200145struct action_meta {
146 struct lysp_node *parent; /**< Parent node. */
147 struct lysp_action **actions; /**< Actions to add to. */
148};
149
David Sedlák4ffcec82019-07-25 15:10:21 +0200150struct minmax_dev_meta {
151 uint32_t *lim;
152 uint16_t *flags;
153 struct lysp_ext_instance **exts;
154};
155
David Sedlák2b626ee2019-06-03 16:40:18 +0200156/**
157 * @brief Match argument name.
158 *
159 * @param[in] name String representing name.
160 * @param[in] len Lenght of the name.
161 *
David Sedlákb1ce3f82019-06-05 14:37:26 +0200162 * @return YIN_ARGUMENT value.
David Sedlák2b626ee2019-06-03 16:40:18 +0200163 */
David Sedlák060b00e2019-06-19 11:12:06 +0200164enum YIN_ARGUMENT yin_match_argument_name(const char *name, size_t len);
David Sedlák2b626ee2019-06-03 16:40:18 +0200165
166/**
David Sedlák555c7202019-07-04 12:14:12 +0200167 * @brief Generic function for content parsing
David Sedlák2b626ee2019-06-03 16:40:18 +0200168 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200169 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlák555c7202019-07-04 12:14:12 +0200170 * @param[in] subelem_info array of valid subelement types and meta information,
171 * array must be ordered by subelem_info->type in ascending order.
172 * @param[in] subelem_info_size Size of subelem_info array.
173 * @param[in,out] data Data to read from, always moved to currently handled character.
174 * @param[in] current_element Type of current element.
David Sedlákb4e44562019-07-04 15:42:12 +0200175 * @param[out] text_content Where the text content of element should be stored if any. Text content is ignored if set to NULL.
David Sedlákda8ffa32019-07-08 14:17:10 +0200176 * @param[in,out] exts Extension instance to add to. Can be se to null if element cannot have extension as subelements.
David Sedlákb4e44562019-07-04 15:42:12 +0200177
David Sedlák2b214ac2019-06-06 16:11:03 +0200178 * @return LY_ERR values.
David Sedlák2b626ee2019-06-03 16:40:18 +0200179 */
David Sedlákda8ffa32019-07-08 14:17:10 +0200180LY_ERR yin_parse_content(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info, signed char subelem_info_size,
David Sedlák555c7202019-07-04 12:14:12 +0200181 const char **data, enum yang_keyword current_element, const char **text_content,
182 struct lysp_ext_instance **exts);
David Sedlák2b626ee2019-06-03 16:40:18 +0200183
David Sedlákd9d3a312019-06-04 09:47:10 +0200184/**
David Sedlák92147b02019-07-09 14:01:01 +0200185 * @brief Parse yang-version element.
186 *
187 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200188 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of yang-version element.
David Sedlák92147b02019-07-09 14:01:01 +0200189 * @param[in] data Data to read from, always moved to currently handled character.
190 * @param[out] version Storage for the parsed information.
191 * @param[in,out] exts Extension instance to add to.
192 *
193 * @return LY_ERR values.
194 */
195LY_ERR yin_parse_yangversion(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, uint8_t *version,
196 struct lysp_ext_instance **exts);
197
198/**
David Sedlák4a650532019-07-10 11:55:18 +0200199 * @brief Check that val is valid UTF8 character sequence of val_type.
200 * Doesn't check empty string, only character validity.
201 *
202 * @param[in] ctx Yin parser context for logging.
203 * @param[in] val_type Type of the input string to select method of checking character validity.
204 * @param[in] val Input to validate.
205 * @param[in] len Length of input.
206 *
207 * @return LY_ERR values.
208 */
209LY_ERR yin_validate_value(struct yin_parser_ctx *ctx, enum yang_arg val_type, char *val, size_t len);
210
211/**
David Sedlák2b214ac2019-06-06 16:11:03 +0200212 * @brief Parse import element.
David Sedlákda63c082019-06-04 13:52:23 +0200213 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200214 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200215 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of import element.
David Sedlákda8ffa32019-07-08 14:17:10 +0200216 * @param[in,out] data Data to read from, always moved to currently handled character.
David Sedlákb4e44562019-07-04 15:42:12 +0200217 * @param[in,out] mod Structure of module that is being parsed.
David Sedlákda63c082019-06-04 13:52:23 +0200218 *
David Sedlák2b214ac2019-06-06 16:11:03 +0200219 * @return LY_ERR values.
David Sedlákda63c082019-06-04 13:52:23 +0200220 */
David Sedlák1f90d252019-07-10 17:09:32 +0200221LY_ERR yin_parse_import(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs,
David Sedlák619db942019-07-03 14:47:30 +0200222 const char **data, struct lysp_module *mod);
David Sedlák2b626ee2019-06-03 16:40:18 +0200223
David Sedlák1bccdfa2019-06-17 15:55:27 +0200224/**
David Sedlákb4e44562019-07-04 15:42:12 +0200225 * @brief Match yang keyword from yin data.
David Sedlák1bccdfa2019-06-17 15:55:27 +0200226 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200227 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákb4e44562019-07-04 15:42:12 +0200228 * @param[in] name Start of keyword name
David Sedlák8f7a1172019-06-20 14:42:18 +0200229 * @param[in] name_len Lenght of keyword name.
230 * @param[in] prefix Start of keyword prefix.
231 * @param[in] prefix_len lenght of prefix.
David Sedlákc1771b12019-07-10 15:55:46 +0200232 * @param[in] parrent Identification of parrent element, use YANG_NONE for elements without parrent.
David Sedlák1bccdfa2019-06-17 15:55:27 +0200233 *
234 * @return yang_keyword values.
235 */
David Sedlákda8ffa32019-07-08 14:17:10 +0200236enum yang_keyword yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len,
David Sedlákc1771b12019-07-10 15:55:46 +0200237 const char *prefix, size_t prefix_len, enum yang_keyword parrent);
David Sedlák1bccdfa2019-06-17 15:55:27 +0200238
David Sedlákb6e65972019-06-19 10:44:13 +0200239/**
David Sedlák1fdb2522019-07-09 16:22:57 +0200240 * @brief Parse mandatory element.
241 *
242 * @param[in,out] ctx Yin parser context for logging and to store current state.
243 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of status element.
244 * @param[in,out] data Data to read from, always moved to currently handled character.
245 * @param[in,out] flags Flags to add to.
246 * @param[in,out] exts Extension instances to add to.
247 *
248 * @return LY_ERR values.
249 */
250LY_ERR yin_parse_mandatory(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
251 uint16_t *flags, struct lysp_ext_instance **exts);
252
253/**
David Sedlákb4e44562019-07-04 15:42:12 +0200254 * @brief Parse status element.
David Sedlákb6e65972019-06-19 10:44:13 +0200255 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200256 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200257 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of status element.
David Sedlákda8ffa32019-07-08 14:17:10 +0200258 * @param[in,out] data Data to read from, always moved to currently handled character.
David Sedlákb6e65972019-06-19 10:44:13 +0200259 * @param[in,out] flags Flags to add to.
260 * @param[in,out] exts Extension instances to add to.
261 *
262 * @return LY_ERR values.
263 */
David Sedlák1f90d252019-07-10 17:09:32 +0200264LY_ERR yin_parse_status(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
David Sedlák554e36d2019-06-20 16:00:04 +0200265 uint16_t *flags, struct lysp_ext_instance **exts);
David Sedlák8f7a1172019-06-20 14:42:18 +0200266
267/**
David Sedlák32eee7b2019-07-09 12:38:44 +0200268 * @brief Parse when element.
269 *
270 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200271 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of when element.
David Sedlák32eee7b2019-07-09 12:38:44 +0200272 * @param[in,out] data Data to read from, always moved to currently handled character.
273 * @param[out] when_p When pointer to parse to.
274 */
David Sedlákbba38e52019-07-09 15:20:01 +0200275LY_ERR yin_parse_when(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
276 struct lysp_when **when_p);
David Sedlák32eee7b2019-07-09 12:38:44 +0200277
278/**
David Sedlákb4e44562019-07-04 15:42:12 +0200279 * @brief Parse revision date element.
David Sedlák3ffbc522019-07-02 17:49:28 +0200280 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200281 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200282 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of revision-date element.
David Sedlákda8ffa32019-07-08 14:17:10 +0200283 * @param[in,out] data Data to read from, always moved to currently handled character.
David Sedlák3ffbc522019-07-02 17:49:28 +0200284 * @param[in,out] rev Array to store the parsed value in.
285 * @param[in,out] exts Extension instances to add to.
286 *
287 * @return LY_ERR values.
288 */
David Sedlák1f90d252019-07-10 17:09:32 +0200289LY_ERR yin_parse_revision_date(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
David Sedlák3ffbc522019-07-02 17:49:28 +0200290 char *rev, struct lysp_ext_instance **exts);
291
292/**
David Sedlákbba38e52019-07-09 15:20:01 +0200293 * @brief load all attributes of element into ([sized array](@ref sizedarrays)). Caller is suposed to free the array.
David Sedlák8f7a1172019-06-20 14:42:18 +0200294 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200295 * @param[in,out] ctx Yin parser context for logging and to store current state.
296 * @param[in,out] data Data to read from, always moved to currently handled character.
David Sedlákbba38e52019-07-09 15:20:01 +0200297 * @param[out] attrs ([Sized array](@ref sizedarrays)) of attributes.
David Sedlák8f7a1172019-06-20 14:42:18 +0200298 *
299 * @return LY_ERR values.
300 */
David Sedlákda8ffa32019-07-08 14:17:10 +0200301LY_ERR yin_load_attributes(struct yin_parser_ctx *ctx, const char **data, struct yin_arg_record **attrs);
David Sedlákb6e65972019-06-19 10:44:13 +0200302
David Sedlák554e36d2019-06-20 16:00:04 +0200303/**
David Sedlák2721d3d2019-06-21 15:37:41 +0200304 * @brief Parse yin-elemenet element.
305 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200306 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200307 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of yin-element element.
David Sedlák2721d3d2019-06-21 15:37:41 +0200308 * @param[in,out] data Data to read from, always moved to currently handled position.
309 * @param[in,out] flags Flags to add to.
David Sedlák3ffbc522019-07-02 17:49:28 +0200310 * @prama[in,out] exts Extension instance to add to.
David Sedlák2721d3d2019-06-21 15:37:41 +0200311 *
312 * @return LY_ERR values.
313 */
David Sedlákda8ffa32019-07-08 14:17:10 +0200314LY_ERR yin_parse_yin_element_element(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
David Sedlák3ffbc522019-07-02 17:49:28 +0200315 uint16_t *flags, struct lysp_ext_instance **exts);
316
317/**
318 * @brief Parse argument element.
319 *
320 * @param[in,out] xml_ctx Xml context.
David Sedlákbba38e52019-07-09 15:20:01 +0200321 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of argument element.
David Sedlák3ffbc522019-07-02 17:49:28 +0200322 * @param[in,out] data Data to read from, always moved to currently handled character.
323 * @param[in,out] arg_meta Meta information about destionation af prased data.
324 * @param[in,out] exts Extension instance to add to.
325 *
326 * @return LY_ERR values.
327 */
David Sedlák1f90d252019-07-10 17:09:32 +0200328LY_ERR yin_parse_argument_element(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
David Sedlák3ffbc522019-07-02 17:49:28 +0200329 struct yin_argument_meta *arg_meta, struct lysp_ext_instance **exts);
David Sedlák2721d3d2019-06-21 15:37:41 +0200330
331/**
David Sedlák554e36d2019-06-20 16:00:04 +0200332 * @brief Parse the extension statement.
333 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200334 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200335 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of extension element.
David Sedlák554e36d2019-06-20 16:00:04 +0200336 * @param[in,out] data Data to read from.
337 * @param[in,out] extensions Extensions to add to.
338 *
339 * @return LY_ERR values.
340 */
David Sedlák1f90d252019-07-10 17:09:32 +0200341LY_ERR yin_parse_extension(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs,
David Sedlák554e36d2019-06-20 16:00:04 +0200342 const char **data, struct lysp_ext **extensions);
343
David Sedlákb1a78352019-06-28 16:16:29 +0200344/**
345 * @brief Parse instance of extension.
346 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200347 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákbba38e52019-07-09 15:20:01 +0200348 * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of extension instance.
David Sedlákb1a78352019-06-28 16:16:29 +0200349 * @param[in,out] data Data to read from, always moved to currently handled character.
350 * @param[in] ext_name Name of the extension element.
351 * @param[in] ext_name_len Length of extension name.
David Sedlákb4e44562019-07-04 15:42:12 +0200352 * @param[in] subelem Type of the keyword this extension instance is a subelement of.
353 * @param[in] subelem_index Index of the keyword instance this extension instance is a subelement of
354 * @param[in,out] exts Extension instance to add to.
David Sedlákb1a78352019-06-28 16:16:29 +0200355 *
356 * @return LY_ERR values.
357 */
David Sedlák1f90d252019-07-10 17:09:32 +0200358LY_ERR yin_parse_extension_instance(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
David Sedlák619db942019-07-03 14:47:30 +0200359 const char *ext_name, int ext_name_len, LYEXT_SUBSTMT subelem,
360 uint32_t subelem_index, struct lysp_ext_instance **exts);
David Sedlákb1a78352019-06-28 16:16:29 +0200361
362/**
363 * @brief Parse yin element into generic structure.
364 *
David Sedlákda8ffa32019-07-08 14:17:10 +0200365 * @param[in,out] ctx Yin parser context for logging and to store current state.
David Sedlákb1a78352019-06-28 16:16:29 +0200366 * @param[in] name Name of element.
367 * @param[in] name_len Length of elements Name.
368 * @param[in,out] data Data to read from, always moved to currently handled character.
369 * @param[out] element Where the element structure should be stored.
370 *
371 * @return LY_ERR values.
372 */
David Sedlák4ffcec82019-07-25 15:10:21 +0200373LY_ERR yin_parse_element_generic(struct yin_parser_ctx *ctx, const char *name, size_t name_len, const char **data,
374 struct lysp_stmt **element);
David Sedlákb1a78352019-06-28 16:16:29 +0200375
David Sedlák2b626ee2019-06-03 16:40:18 +0200376#endif /* LY_PARSER_YIN_H_*/