blob: 486314562f9efc5a2bc06d298ac91358c075dcdd [file] [log] [blame]
Radek Krejcif0e1ba52020-05-22 15:14:35 +02001/**
2 * @file parser_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief Internal structures and functions for libyang parsers
5 *
6 * Copyright (c) 2020 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 LY_PARSER_INTERNAL_H_
16#define LY_PARSER_INTERNAL_H_
17
Michal Vaskoe0665742021-02-11 11:08:44 +010018#include "parser_data.h"
aPiecek704f8e92021-08-25 13:35:05 +020019#include "set.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020020
Radek Krejci1798aae2020-07-14 13:26:06 +020021struct lyd_ctx;
Michal Vaskoafac7822020-10-20 14:22:26 +020022struct ly_in;
Michal Vasko193dacd2022-10-13 08:43:05 +020023struct lysp_ext_substmt;
24struct lysp_stmt;
Michal Vaskod0625d72022-10-06 15:02:50 +020025struct lysp_yang_ctx;
26struct lysp_yin_ctx;
27struct lysp_ctx;
Michal Vaskoc8a230d2020-08-14 12:17:10 +020028
Radek Krejci1798aae2020-07-14 13:26:06 +020029/**
Radek Krejci84d7fd72021-07-14 18:32:21 +020030 * @brief Callback for ::lyd_ctx to free the structure
Radek Krejci1798aae2020-07-14 13:26:06 +020031 *
32 * @param[in] ctx Data parser context to free.
33 */
34typedef void (*lyd_ctx_free_clb)(struct lyd_ctx *ctx);
35
36/**
Michal Vaskoe0665742021-02-11 11:08:44 +010037 * @brief Internal data parser flags.
38 */
39#define LYD_INTOPT_RPC 0x01 /**< RPC request is being parsed. */
40#define LYD_INTOPT_ACTION 0x02 /**< Action request is being parsed. */
41#define LYD_INTOPT_REPLY 0x04 /**< RPC/action reply is being parsed. */
42#define LYD_INTOPT_NOTIF 0x08 /**< Notification is being parsed. */
Michal Vasko02ed9d82021-07-15 14:58:04 +020043#define LYD_INTOPT_ANY 0x10 /**< Anydata/anyxml content is being parsed, there can be anything. */
44#define LYD_INTOPT_WITH_SIBLINGS 0x20 /**< Parse the whole input with any siblings. */
45#define LYD_INTOPT_NO_SIBLINGS 0x40 /**< If there are any siblings, return an error. */
Michal Vaskoe0665742021-02-11 11:08:44 +010046
47/**
Radek Krejci1798aae2020-07-14 13:26:06 +020048 * @brief Internal (common) context for YANG data parsers.
Radek Krejci4f2e3e52021-03-30 14:20:28 +020049 *
Radek Krejci84d7fd72021-07-14 18:32:21 +020050 * Covers ::lyd_xml_ctx, ::lyd_json_ctx and ::lyd_lyb_ctx.
Radek Krejci1798aae2020-07-14 13:26:06 +020051 */
52struct lyd_ctx {
Radek Krejcif16e2542021-02-17 15:39:23 +010053 const struct lysc_ext_instance *ext; /**< extension instance possibly changing document root context of the data being parsed */
Michal Vaskoe0665742021-02-11 11:08:44 +010054 uint32_t parse_opts; /**< various @ref dataparseroptions. */
55 uint32_t val_opts; /**< various @ref datavalidationoptions. */
56 uint32_t int_opts; /**< internal parser options */
Radek Krejci1798aae2020-07-14 13:26:06 +020057 uint32_t path_len; /**< used bytes in the path buffer */
Michal Vasko26bbb272022-08-02 14:54:33 +020058
Radek Krejci1798aae2020-07-14 13:26:06 +020059#define LYD_PARSER_BUFSIZE 4078
60 char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
Michal Vaskoc43c8ab2021-03-05 13:32:44 +010061 struct ly_set node_when; /**< set of nodes with "when" conditions */
Michal Vasko32711382020-12-03 14:14:31 +010062 struct ly_set node_types; /**< set of nodes validated with LY_EINCOMPLETE result */
63 struct ly_set meta_types; /**< set of metadata validated with LY_EINCOMPLETE result */
Michal Vasko135719f2022-08-25 12:18:17 +020064 struct ly_set ext_node; /**< set of nodes with extension instances to validate */
65 struct ly_set ext_val; /**< set of nested subtrees parsed by extensions to validate */
Radek Krejci1798aae2020-07-14 13:26:06 +020066 struct lyd_node *op_node; /**< if an RPC/action/notification is being parsed, store the pointer to it */
67
68 /* callbacks */
Radek Krejci0bff0b12020-08-15 18:37:50 +020069 lyd_ctx_free_clb free; /**< destructor */
Radek Krejci1798aae2020-07-14 13:26:06 +020070
71 struct {
Radek Krejci0bff0b12020-08-15 18:37:50 +020072 const struct ly_ctx *ctx; /**< libyang context */
73 uint64_t line; /**< current line */
74 struct ly_in *in; /**< input structure */
75 } *data_ctx; /**< generic pointer supposed to map to and access (common part of) XML/JSON/... parser contexts */
Radek Krejci1798aae2020-07-14 13:26:06 +020076};
77
Radek Krejci7931b192020-06-25 17:05:03 +020078/**
Michal Vasko03fbaed2021-07-15 09:18:32 +020079 * @brief Internal context for XML data parser.
80 */
81struct lyd_xml_ctx {
82 const struct lysc_ext_instance *ext;
83 uint32_t parse_opts;
84 uint32_t val_opts;
85 uint32_t int_opts;
86 uint32_t path_len;
87 char path[LYD_PARSER_BUFSIZE];
88 struct ly_set node_when;
Michal Vasko03fbaed2021-07-15 09:18:32 +020089 struct ly_set node_types;
90 struct ly_set meta_types;
Michal Vasko135719f2022-08-25 12:18:17 +020091 struct ly_set ext_node;
Michal Vaskoddd76592022-01-17 13:34:48 +010092 struct ly_set ext_val;
Michal Vasko03fbaed2021-07-15 09:18:32 +020093 struct lyd_node *op_node;
94
95 /* callbacks */
96 lyd_ctx_free_clb free;
97
98 struct lyxml_ctx *xmlctx; /**< XML context */
99};
100
101/**
102 * @brief Internal context for JSON data parser.
103 */
104struct lyd_json_ctx {
105 const struct lysc_ext_instance *ext;
106 uint32_t parse_opts;
107 uint32_t val_opts;
108 uint32_t int_opts;
109 uint32_t path_len;
110 char path[LYD_PARSER_BUFSIZE];
111 struct ly_set node_when;
Michal Vasko03fbaed2021-07-15 09:18:32 +0200112 struct ly_set node_types;
113 struct ly_set meta_types;
Michal Vasko135719f2022-08-25 12:18:17 +0200114 struct ly_set ext_node;
Michal Vaskoddd76592022-01-17 13:34:48 +0100115 struct ly_set ext_val;
Michal Vasko03fbaed2021-07-15 09:18:32 +0200116 struct lyd_node *op_node;
117
118 /* callbacks */
119 lyd_ctx_free_clb free;
120
121 struct lyjson_ctx *jsonctx; /**< JSON context */
122};
123
124/**
125 * @brief Internal context for LYB data parser/printer.
126 */
127struct lyd_lyb_ctx {
128 const struct lysc_ext_instance *ext;
Michal Vasko26bbb272022-08-02 14:54:33 +0200129
Michal Vasko03fbaed2021-07-15 09:18:32 +0200130 union {
131 struct {
132 uint32_t parse_opts;
133 uint32_t val_opts;
134 };
135 uint32_t print_options;
136 };
137 uint32_t int_opts;
138 uint32_t path_len;
139 char path[LYD_PARSER_BUFSIZE];
140 struct ly_set node_when;
Michal Vasko03fbaed2021-07-15 09:18:32 +0200141 struct ly_set node_types;
142 struct ly_set meta_types;
Michal Vasko135719f2022-08-25 12:18:17 +0200143 struct ly_set ext_node;
Michal Vaskoddd76592022-01-17 13:34:48 +0100144 struct ly_set ext_val;
Michal Vasko03fbaed2021-07-15 09:18:32 +0200145 struct lyd_node *op_node;
146
147 /* callbacks */
148 lyd_ctx_free_clb free;
149
150 struct lylyb_ctx *lybctx; /* LYB context */
151};
152
153/**
Michal Vaskoddd76592022-01-17 13:34:48 +0100154 * @brief Parsed extension instance data to validate.
155 */
156struct lyd_ctx_ext_val {
157 struct lysc_ext_instance *ext;
158 struct lyd_node *sibling;
159};
160
161/**
Michal Vasko135719f2022-08-25 12:18:17 +0200162 * @brief Parsed data node with extension instance to validate.
163 */
164struct lyd_ctx_ext_node {
165 struct lysc_ext_instance *ext;
166 struct lyd_node *node;
167};
168
169/**
Radek Krejci84d7fd72021-07-14 18:32:21 +0200170 * @brief Common part to supplement the specific ::lyd_ctx_free_clb callbacks.
Radek Krejci1798aae2020-07-14 13:26:06 +0200171 */
Michal Vaskoddd76592022-01-17 13:34:48 +0100172void lyd_ctx_free(struct lyd_ctx *ctx);
Radek Krejci1798aae2020-07-14 13:26:06 +0200173
174/**
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200175 * @brief Parse submodule from YANG data.
Radek Krejci84d7fd72021-07-14 18:32:21 +0200176 * @param[in,out] context Parser context.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200177 * @param[in] ly_ctx Context of YANG schemas.
178 * @param[in] main_ctx Parser context of main module.
Michal Vasko63f3d842020-07-08 10:10:14 +0200179 * @param[in] in Input structure.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200180 * @param[out] submod Pointer to the parsed submodule structure.
181 * @return LY_ERR value - LY_SUCCESS, LY_EINVAL or LY_EVALID.
182 */
Michal Vaskod0625d72022-10-06 15:02:50 +0200183LY_ERR yang_parse_submodule(struct lysp_yang_ctx **context, struct ly_ctx *ly_ctx, struct lysp_ctx *main_ctx,
Radek Krejci0f969882020-08-21 16:56:47 +0200184 struct ly_in *in, struct lysp_submodule **submod);
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200185
186/**
187 * @brief Parse module from YANG data.
Radek Krejci84d7fd72021-07-14 18:32:21 +0200188 * @param[in] context Parser context.
Michal Vasko63f3d842020-07-08 10:10:14 +0200189 * @param[in] in Input structure.
190 * @param[in,out] mod Prepared module structure where the parsed information, including the parsed
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200191 * module structure, will be filled in.
Michal Vasko405cc9e2020-12-01 12:01:27 +0100192 * @return LY_ERR values.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200193 */
Michal Vaskod0625d72022-10-06 15:02:50 +0200194LY_ERR yang_parse_module(struct lysp_yang_ctx **context, struct ly_in *in, struct lys_module *mod);
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200195
196/**
197 * @brief Parse module from YIN data.
198 *
199 * @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_model after it's completly parsed.
Michal Vasko63f3d842020-07-08 10:10:14 +0200200 * @param[in] in Input structure.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200201 * @param[in,out] mod Prepared module structure where the parsed information, including the parsed
202 * module structure, will be filled in.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200203 * @return LY_ERR values.
204 */
Michal Vaskod0625d72022-10-06 15:02:50 +0200205LY_ERR yin_parse_module(struct lysp_yin_ctx **yin_ctx, struct ly_in *in, struct lys_module *mod);
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200206
207/**
208 * @brief Parse submodule from YIN data.
209 *
210 * @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_model after it's completly parsed.
211 * @param[in] ctx Libyang context.
212 * @param[in] main_ctx Parser context of main module.
Michal Vasko63f3d842020-07-08 10:10:14 +0200213 * @param[in] in Input structure.
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200214 * @param[in,out] submod Submodule structure where the parsed information, will be filled in.
215 * @return LY_ERR values.
216 */
Michal Vaskod0625d72022-10-06 15:02:50 +0200217LY_ERR yin_parse_submodule(struct lysp_yin_ctx **yin_ctx, struct ly_ctx *ctx, struct lysp_ctx *main_ctx,
Radek Krejci0f969882020-08-21 16:56:47 +0200218 struct ly_in *in, struct lysp_submodule **submod);
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200219
Radek Krejci1798aae2020-07-14 13:26:06 +0200220/**
Michal Vaskoe0665742021-02-11 11:08:44 +0100221 * @brief Parse XML string as a YANG data tree.
Michal Vaskoafac7822020-10-20 14:22:26 +0200222 *
Michal Vaskoe0665742021-02-11 11:08:44 +0100223 * @param[in] ctx libyang context.
aPiecekb0445f22021-06-24 11:34:07 +0200224 * @param[in] ext Optional extension instance to parse data following the schema tree specified in the extension instance
Michal Vaskoe0665742021-02-11 11:08:44 +0100225 * @param[in] parent Parent to connect the parsed nodes to, if any.
226 * @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
Michal Vaskoafac7822020-10-20 14:22:26 +0200227 * @param[in] in Input structure.
Michal Vaskoe0665742021-02-11 11:08:44 +0100228 * @param[in] parse_opts Options for parser, see @ref dataparseroptions.
229 * @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
230 * @param[in] data_type Expected data type of the data.
Michal Vasko299d5d12021-02-16 16:36:37 +0100231 * @param[out] envp Individual parsed envelopes tree, returned only by specific @p data_type and possibly even if
232 * an error occurs later.
Michal Vaskoe0665742021-02-11 11:08:44 +0100233 * @param[out] parsed Set to add all the parsed siblings into.
Michal Vaskoddd76592022-01-17 13:34:48 +0100234 * @param[out] subtree_sibling Set if ::LYD_PARSE_SUBTREE is used and another subtree is following in @p in.
Michal Vaskoafac7822020-10-20 14:22:26 +0200235 * @param[out] lydctx_p Data parser context to finish validation.
236 * @return LY_ERR value.
237 */
Radek Krejcif16e2542021-02-17 15:39:23 +0100238LY_ERR lyd_parse_xml(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, struct lyd_node *parent,
239 struct lyd_node **first_p, struct ly_in *in, uint32_t parse_opts, uint32_t val_opts, enum lyd_type data_type,
Michal Vaskoddd76592022-01-17 13:34:48 +0100240 struct lyd_node **envp, struct ly_set *parsed, ly_bool *subtree_sibling, struct lyd_ctx **lydctx_p);
Michal Vaskoafac7822020-10-20 14:22:26 +0200241
242/**
Michal Vaskoe0665742021-02-11 11:08:44 +0100243 * @brief Parse JSON string as a YANG data tree.
Michal Vaskoafac7822020-10-20 14:22:26 +0200244 *
Michal Vaskoafac7822020-10-20 14:22:26 +0200245 * @param[in] ctx libyang context.
aPiecekb0445f22021-06-24 11:34:07 +0200246 * @param[in] ext Optional extension instance to parse data following the schema tree specified in the extension instance
Michal Vaskoe0665742021-02-11 11:08:44 +0100247 * @param[in] parent Parent to connect the parsed nodes to, if any.
248 * @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
Michal Vaskoafac7822020-10-20 14:22:26 +0200249 * @param[in] in Input structure.
Michal Vaskoe0665742021-02-11 11:08:44 +0100250 * @param[in] parse_opts Options for parser, see @ref dataparseroptions.
251 * @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
252 * @param[in] data_type Expected data type of the data.
253 * @param[out] parsed Set to add all the parsed siblings into.
Michal Vaskoddd76592022-01-17 13:34:48 +0100254 * @param[out] subtree_sibling Set if ::LYD_PARSE_SUBTREE is used and another subtree is following in @p in.
Michal Vaskoafac7822020-10-20 14:22:26 +0200255 * @param[out] lydctx_p Data parser context to finish validation.
256 * @return LY_ERR value.
257 */
Radek Krejcif16e2542021-02-17 15:39:23 +0100258LY_ERR lyd_parse_json(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, struct lyd_node *parent,
259 struct lyd_node **first_p, struct ly_in *in, uint32_t parse_opts, uint32_t val_opts, enum lyd_type data_type,
Michal Vaskoddd76592022-01-17 13:34:48 +0100260 struct ly_set *parsed, ly_bool *subtree_sibling, struct lyd_ctx **lydctx_p);
Michal Vaskoafac7822020-10-20 14:22:26 +0200261
262/**
Michal Vaskoe0665742021-02-11 11:08:44 +0100263 * @brief Parse binary LYB data as a YANG data tree.
Michal Vaskoafac7822020-10-20 14:22:26 +0200264 *
Michal Vaskoafac7822020-10-20 14:22:26 +0200265 * @param[in] ctx libyang context.
aPiecekb0445f22021-06-24 11:34:07 +0200266 * @param[in] ext Optional extension instance to parse data following the schema tree specified in the extension instance
Michal Vaskoe0665742021-02-11 11:08:44 +0100267 * @param[in] parent Parent to connect the parsed nodes to, if any.
268 * @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
Michal Vaskoafac7822020-10-20 14:22:26 +0200269 * @param[in] in Input structure.
Michal Vaskoe0665742021-02-11 11:08:44 +0100270 * @param[in] parse_opts Options for parser, see @ref dataparseroptions.
271 * @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
272 * @param[in] data_type Expected data type of the data.
273 * @param[out] parsed Set to add all the parsed siblings into.
Michal Vaskoddd76592022-01-17 13:34:48 +0100274 * @param[out] subtree_sibling Set if ::LYD_PARSE_SUBTREE is used and another subtree is following in @p in.
Michal Vaskoafac7822020-10-20 14:22:26 +0200275 * @param[out] lydctx_p Data parser context to finish validation.
276 * @return LY_ERR value.
277 */
Radek Krejcif16e2542021-02-17 15:39:23 +0100278LY_ERR lyd_parse_lyb(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, struct lyd_node *parent,
279 struct lyd_node **first_p, struct ly_in *in, uint32_t parse_opts, uint32_t val_opts, enum lyd_type data_type,
Michal Vaskoddd76592022-01-17 13:34:48 +0100280 struct ly_set *parsed, ly_bool *subtree_sibling, struct lyd_ctx **lydctx_p);
Michal Vaskoafac7822020-10-20 14:22:26 +0200281
282/**
Michal Vaskoe0665742021-02-11 11:08:44 +0100283 * @brief Search all the parents for an operation node, check validity based on internal parser flags.
Michal Vaskoafac7822020-10-20 14:22:26 +0200284 *
Michal Vaskoe0665742021-02-11 11:08:44 +0100285 * @param[in] parent Parent to connect the parsed nodes to.
Radek Krejci84d7fd72021-07-14 18:32:21 +0200286 * @param[in] int_opts Internal parser options.
Michal Vaskoe0665742021-02-11 11:08:44 +0100287 * @param[out] op Found operation, if any.
Michal Vaskoafac7822020-10-20 14:22:26 +0200288 * @return LY_ERR value.
289 */
Michal Vaskoe0665742021-02-11 11:08:44 +0100290LY_ERR lyd_parser_find_operation(const struct lyd_node *parent, uint32_t int_opts, struct lyd_node **op);
Michal Vaskoafac7822020-10-20 14:22:26 +0200291
292/**
Radek Krejci1798aae2020-07-14 13:26:06 +0200293 * @brief Check that a data node representing the @p snode is suitable based on options.
294 *
295 * @param[in] lydctx Common data parsers context.
296 * @param[in] snode Schema node to check.
297 * @return LY_SUCCESS or LY_EVALID
298 */
299LY_ERR lyd_parser_check_schema(struct lyd_ctx *lydctx, const struct lysc_node *snode);
300
301/**
Radek Krejci8678fa42020-08-18 16:07:28 +0200302 * @brief Wrapper around ::lyd_create_term() for data parsers.
Radek Krejci1798aae2020-07-14 13:26:06 +0200303 *
304 * @param[in] lydctx Data parser context.
Radek Krejci84d7fd72021-07-14 18:32:21 +0200305 * @param[in] schema Schema node of the new data node.
306 * @param[in] value String value to be parsed.
307 * @param[in] value_len Length of @p value, must be set correctly.
308 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
309 * @param[in] format Input format of @p value.
310 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
311 * @param[in] hints [Data parser's hints](@ref lydvalhints) for the value's type.
312 * @param[out] node Created node.
313 * @return LY_SUCCESS on success.
314 * @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
315 * @return LY_ERR value if an error occurred.
Radek Krejci1798aae2020-07-14 13:26:06 +0200316 */
Radek Krejci09c77442021-04-26 11:10:34 +0200317LY_ERR lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, const void *value, size_t value_len,
Radek Krejci8df109d2021-04-23 12:19:08 +0200318 ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, struct lyd_node **node);
Radek Krejci1798aae2020-07-14 13:26:06 +0200319
320/**
Radek Krejci8678fa42020-08-18 16:07:28 +0200321 * @brief Wrapper around ::lyd_create_meta() for data parsers.
Radek Krejci1798aae2020-07-14 13:26:06 +0200322 *
323 * @param[in] lydctx Data parser context.
Michal Vaskob68571a2020-11-06 17:18:41 +0100324 * @param[in] parent Parent of the created meta. Must be set if @p meta is NULL.
325 * @param[in,out] meta First existing meta to connect to or empty pointer to set. Must be set if @p parent is NULL.
326 * @param[in] mod Module of the created metadata.
327 * @param[in] name Metadata name.
328 * @param[in] name_len Length of @p name.
329 * @param[in] value Metadata value.
330 * @param[in] value_len Length of @p value.
331 * @param[in,out] dynamic Whether the @p value is dynamically allocated, is adjusted once the value is assigned.
332 * @param[in] format Prefix format.
333 * @param[in] prefix_data Prefix format data (see ::ly_resolve_prefix()).
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200334 * @param[in] hints [Value hint](@ref lydvalhints) from the parser regarding the value type.
Michal Vaskoddd76592022-01-17 13:34:48 +0100335 * @param[in] ctx_node Value context node.
Michal Vaskob68571a2020-11-06 17:18:41 +0100336 * @return LY_ERR value.
Radek Krejci1798aae2020-07-14 13:26:06 +0200337 */
Michal Vaskoc8a230d2020-08-14 12:17:10 +0200338LY_ERR lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct lyd_meta **meta,
Michal Vaskoddd76592022-01-17 13:34:48 +0100339 const struct lys_module *mod, const char *name, size_t name_len, const void *value, size_t value_len,
340 ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node);
Radek Krejci1798aae2020-07-14 13:26:06 +0200341
Michal Vasko95c6d5c2022-05-20 10:33:39 +0200342/**
343 * @brief Check that a list has all its keys.
344 *
345 * @param[in] node List to check.
346 * @return LY_SUCCESS on success.
347 * @return LY_ENOT on a missing key.
348 */
349LY_ERR lyd_parse_check_keys(struct lyd_node *node);
350
351/**
352 * @brief Set data flags for a newly parsed node.
353 *
354 * @param[in] node Node to use.
355 * @param[in,out] meta Node metadata, may be removed from.
356 * @param[in] lydctx Data parsing context.
357 * @param[in] ext Extension instance if @p node was parsed for one.
358 * @return LY_ERR value.
359 */
360LY_ERR lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
361 struct lysc_ext_instance *ext);
362
Michal Vasko193dacd2022-10-13 08:43:05 +0200363/**
364 * @brief Parse an instance extension statement.
365 *
366 * @param[in] pctx Parse context.
367 * @param[in] substmt Parsed ext instance substatement info.
368 * @param[in] stmt Parsed generic statement to process.
369 * @return LY_ERR value.
370 */
371LY_ERR lys_parse_ext_instance_stmt(struct lysp_ctx *pctx, struct lysp_ext_substmt *substmt, struct lysp_stmt *stmt);
372
Radek Krejcif0e1ba52020-05-22 15:14:35 +0200373#endif /* LY_PARSER_INTERNAL_H_ */