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> |
| 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á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 | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 32 | enum YIN_ARGUMENT { |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 33 | 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] | 34 | YIN_ARG_NAME, /**< argument name */ |
| 35 | YIN_ARG_TARGET_NODE, /**< argument target-node */ |
| 36 | YIN_ARG_MODULE, /**< argument module */ |
| 37 | YIN_ARG_VALUE, /**< argument value */ |
| 38 | YIN_ARG_TEXT, /**< argument text */ |
| 39 | YIN_ARG_CONDITION, /**< argument condition */ |
| 40 | YIN_ARG_URI, /**< argument uri */ |
| 41 | YIN_ARG_DATE, /**< argument data */ |
| 42 | YIN_ARG_TAG, /**< argument tag */ |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 43 | YIN_ARG_NONE, /**< empty (special value) */ |
David Sedlák | 7ff55a9 | 2019-06-17 11:11:41 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 46 | /** |
| 47 | * @brief structure to store instance of xml attribute |
| 48 | */ |
David Sedlák | 7ff55a9 | 2019-06-17 11:11:41 +0200 | [diff] [blame] | 49 | struct yin_arg_record { |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 50 | const char *prefix; /**< start of prefix */ |
| 51 | size_t prefix_len; /**< length of prefix */ |
| 52 | const char *name; /**< start of name */ |
| 53 | size_t name_len; /**< length of name */ |
| 54 | char *content; /**< start of content */ |
| 55 | size_t content_len; /**< length of content */ |
| 56 | 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] | 57 | }; |
| 58 | |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 59 | struct yin_parser_ctx { |
| 60 | struct lyxml_context xml_ctx; /**< context for xml parser */ |
| 61 | uint8_t mod_version; /**< module's version */ |
| 62 | }; |
| 63 | |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 64 | /* flags to encode cardinality of subelement */ |
| 65 | #define YIN_SUBELEM_MANDATORY 0x01 /**< is set when subelement is mandatory */ |
| 66 | #define YIN_SUBELEM_UNIQUE 0x02 /**< is set when subelement is unique */ |
David Sedlák | 21f87cd | 2019-07-03 16:53:23 +0200 | [diff] [blame] | 67 | #define YIN_SUBELEM_FIRST 0x08 /**< is set when subelement is actually yang argument mapped to yin element */ |
| 68 | |
| 69 | #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] | 70 | time to simply check validity of given constraints */ |
| 71 | |
| 72 | struct yin_subelement { |
| 73 | enum yang_keyword type; /**< type of keyword */ |
| 74 | void *dest; /**< meta infromation passed to responsible function (information about where parsed subelement should be stored) */ |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 75 | uint8_t flags; /**< describes cardianlity of subelement can be set to YIN_SUBELEM_MANDATORY and YIN_SUBELEM_UNIQUE and YIN_SUBELEM_FIRST */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 78 | /* helper structure just to make code look simpler */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 79 | struct sized_string { |
| 80 | const char *value; |
| 81 | size_t len; |
| 82 | }; |
| 83 | |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 84 | /* Meta information passed to yin_parse_argument function, |
| 85 | holds information about where content of argument element will be stored. */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 86 | struct yin_argument_meta { |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 87 | uint16_t *flags; /**< Argument flags */ |
| 88 | const char **argument; /**< Argument value */ |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 89 | }; |
| 90 | |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 91 | /** |
| 92 | * @brief Match argument name. |
| 93 | * |
| 94 | * @param[in] name String representing name. |
| 95 | * @param[in] len Lenght of the name. |
| 96 | * |
David Sedlák | b1ce3f8 | 2019-06-05 14:37:26 +0200 | [diff] [blame] | 97 | * @return YIN_ARGUMENT value. |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 98 | */ |
David Sedlák | 060b00e | 2019-06-19 11:12:06 +0200 | [diff] [blame] | 99 | 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] | 100 | |
| 101 | /** |
David Sedlák | 555c720 | 2019-07-04 12:14:12 +0200 | [diff] [blame] | 102 | * @brief Generic function for content parsing |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 103 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 104 | * @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] | 105 | * @param[in] subelem_info array of valid subelement types and meta information, |
| 106 | * array must be ordered by subelem_info->type in ascending order. |
| 107 | * @param[in] subelem_info_size Size of subelem_info array. |
| 108 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 109 | * @param[in] current_element Type of current element. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 110 | * @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ák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 111 | * @param[in,out] exts Extension instance to add to. Can be se to null if element cannot have extension as subelements. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 112 | |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 113 | * @return LY_ERR values. |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 114 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 115 | 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] | 116 | const char **data, enum yang_keyword current_element, const char **text_content, |
| 117 | struct lysp_ext_instance **exts); |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 118 | |
David Sedlák | d9d3a31 | 2019-06-04 09:47:10 +0200 | [diff] [blame] | 119 | /** |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 120 | * @brief Parse import element. |
David Sedlák | da63c08 | 2019-06-04 13:52:23 +0200 | [diff] [blame] | 121 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 122 | * @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] | 123 | * @param[in] attrs Sized array of attributes of import element. |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 124 | * @param[in,out] data Data to read from, always moved to currently handled character. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 125 | * @param[in,out] mod Structure of module that is being parsed. |
David Sedlák | da63c08 | 2019-06-04 13:52:23 +0200 | [diff] [blame] | 126 | * |
David Sedlák | 2b214ac | 2019-06-06 16:11:03 +0200 | [diff] [blame] | 127 | * @return LY_ERR values. |
David Sedlák | da63c08 | 2019-06-04 13:52:23 +0200 | [diff] [blame] | 128 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 129 | LY_ERR yin_parse_import(struct yin_parser_ctx *ctx, struct yin_arg_record **attrs, |
David Sedlák | 619db94 | 2019-07-03 14:47:30 +0200 | [diff] [blame] | 130 | const char **data, struct lysp_module *mod); |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 131 | |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 132 | /** |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 133 | * @brief Match yang keyword from yin data. |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 134 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 135 | * @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] | 136 | * @param[in] name Start of keyword name |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 137 | * @param[in] name_len Lenght of keyword name. |
| 138 | * @param[in] prefix Start of keyword prefix. |
| 139 | * @param[in] prefix_len lenght of prefix. |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 140 | * |
| 141 | * @return yang_keyword values. |
| 142 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 143 | enum yang_keyword yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len, |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 144 | const char *prefix, size_t prefix_len); |
David Sedlák | 1bccdfa | 2019-06-17 15:55:27 +0200 | [diff] [blame] | 145 | |
David Sedlák | b6e6597 | 2019-06-19 10:44:13 +0200 | [diff] [blame] | 146 | /** |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 147 | * @brief Parse status element. |
David Sedlák | b6e6597 | 2019-06-19 10:44:13 +0200 | [diff] [blame] | 148 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 149 | * @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] | 150 | * @param[in] attrs Atributes of status element. |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 151 | * @param[in,out] data Data to read from, always moved to currently handled character. |
David Sedlák | b6e6597 | 2019-06-19 10:44:13 +0200 | [diff] [blame] | 152 | * @param[in,out] flags Flags to add to. |
| 153 | * @param[in,out] exts Extension instances to add to. |
| 154 | * |
| 155 | * @return LY_ERR values. |
| 156 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 157 | LY_ERR yin_parse_status(struct yin_parser_ctx *ctx, struct yin_arg_record **attrs, const char **data, |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 158 | uint16_t *flags, struct lysp_ext_instance **exts); |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 159 | |
| 160 | /** |
David Sedlák | 32eee7b | 2019-07-09 12:38:44 +0200 | [diff] [blame^] | 161 | * @brief Parse when element. |
| 162 | * |
| 163 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
| 164 | * @param[in] attrs Attributes of when element. |
| 165 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 166 | * @param[out] when_p When pointer to parse to. |
| 167 | */ |
| 168 | LY_ERR yin_parse_when(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, struct lysp_when **when_p); |
| 169 | |
| 170 | /** |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 171 | * @brief Parse revision date element. |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 172 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 173 | * @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] | 174 | * @param[in] attrs Sized array of attributes of revision-date element. |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 175 | * @param[in,out] data Data to read from, always moved to currently handled character. |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 176 | * @param[in,out] rev Array to store the parsed value in. |
| 177 | * @param[in,out] exts Extension instances to add to. |
| 178 | * |
| 179 | * @return LY_ERR values. |
| 180 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 181 | LY_ERR yin_parse_revision_date(struct yin_parser_ctx *ctx, struct yin_arg_record **attrs, const char **data, |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 182 | char *rev, struct lysp_ext_instance **exts); |
| 183 | |
| 184 | /** |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 185 | * @brief Load all attributes from current element. Caller is supposed to free attrs array. |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 186 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 187 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
| 188 | * @param[in,out] data Data to read from, always moved to currently handled character. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 189 | * @param[out] attrs Sized array of attributes. |
David Sedlák | 8f7a117 | 2019-06-20 14:42:18 +0200 | [diff] [blame] | 190 | * |
| 191 | * @return LY_ERR values. |
| 192 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 193 | 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] | 194 | |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 195 | /** |
David Sedlák | 2721d3d | 2019-06-21 15:37:41 +0200 | [diff] [blame] | 196 | * @brief Parse yin-elemenet element. |
| 197 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 198 | * @param[in,out] ctx Yin parser context for logging and to store current state. |
David Sedlák | 2721d3d | 2019-06-21 15:37:41 +0200 | [diff] [blame] | 199 | * @param[in] attrs Sized array of element attributes. |
| 200 | * @param[in,out] data Data to read from, always moved to currently handled position. |
| 201 | * @param[in,out] flags Flags to add to. |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 202 | * @prama[in,out] exts Extension instance to add to. |
David Sedlák | 2721d3d | 2019-06-21 15:37:41 +0200 | [diff] [blame] | 203 | * |
| 204 | * @return LY_ERR values. |
| 205 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 206 | LY_ERR yin_parse_yin_element_element(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 207 | uint16_t *flags, struct lysp_ext_instance **exts); |
| 208 | |
| 209 | /** |
| 210 | * @brief Parse argument element. |
| 211 | * |
| 212 | * @param[in,out] xml_ctx Xml context. |
| 213 | * @param[in] attrs Attributes of this element. |
| 214 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 215 | * @param[in,out] arg_meta Meta information about destionation af prased data. |
| 216 | * @param[in,out] exts Extension instance to add to. |
| 217 | * |
| 218 | * @return LY_ERR values. |
| 219 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 220 | LY_ERR yin_parse_argument_element(struct yin_parser_ctx *ctx, struct yin_arg_record **attrs, const char **data, |
David Sedlák | 3ffbc52 | 2019-07-02 17:49:28 +0200 | [diff] [blame] | 221 | struct yin_argument_meta *arg_meta, struct lysp_ext_instance **exts); |
David Sedlák | 2721d3d | 2019-06-21 15:37:41 +0200 | [diff] [blame] | 222 | |
| 223 | /** |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 224 | * @brief Parse the extension statement. |
| 225 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 226 | * @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] | 227 | * @param[in] attrs Attributes of extension element. |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 228 | * @param[in,out] data Data to read from. |
| 229 | * @param[in,out] extensions Extensions to add to. |
| 230 | * |
| 231 | * @return LY_ERR values. |
| 232 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 233 | LY_ERR yin_parse_extension(struct yin_parser_ctx *ctx, struct yin_arg_record **attrs, |
David Sedlák | 554e36d | 2019-06-20 16:00:04 +0200 | [diff] [blame] | 234 | const char **data, struct lysp_ext **extensions); |
| 235 | |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 236 | /** |
| 237 | * @brief Parse instance of extension. |
| 238 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 239 | * @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] | 240 | * @param[in] attrs Sized array of attributes. |
| 241 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 242 | * @param[in] ext_name Name of the extension element. |
| 243 | * @param[in] ext_name_len Length of extension name. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 244 | * @param[in] subelem Type of the keyword this extension instance is a subelement of. |
| 245 | * @param[in] subelem_index Index of the keyword instance this extension instance is a subelement of |
| 246 | * @param[in,out] exts Extension instance to add to. |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 247 | * |
| 248 | * @return LY_ERR values. |
| 249 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 250 | 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] | 251 | const char *ext_name, int ext_name_len, LYEXT_SUBSTMT subelem, |
| 252 | uint32_t subelem_index, struct lysp_ext_instance **exts); |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * @brief Parse yin element into generic structure. |
| 256 | * |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 257 | * @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] | 258 | * @param[in] name Name of element. |
| 259 | * @param[in] name_len Length of elements Name. |
David Sedlák | b4e4456 | 2019-07-04 15:42:12 +0200 | [diff] [blame] | 260 | * @param[in] prefix Element prefix. |
| 261 | * @param[in] prefix_len Length of element prefix. |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 262 | * @param[in,out] data Data to read from, always moved to currently handled character. |
| 263 | * @param[out] element Where the element structure should be stored. |
| 264 | * |
| 265 | * @return LY_ERR values. |
| 266 | */ |
David Sedlák | da8ffa3 | 2019-07-08 14:17:10 +0200 | [diff] [blame] | 267 | LY_ERR yin_parse_element_generic(struct yin_parser_ctx *ctx, const char *name, size_t name_len, const char *prefix, |
| 268 | size_t prefix_len, const char **data, struct lysp_stmt **element); |
David Sedlák | b1a7835 | 2019-06-28 16:16:29 +0200 | [diff] [blame] | 269 | |
David Sedlák | 2b626ee | 2019-06-03 16:40:18 +0200 | [diff] [blame] | 270 | #endif /* LY_PARSER_YIN_H_*/ |