1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
/**
* @file parser_internal.h
* @author Radek Krejci <rkrejci@cesnet.cz>
* @author Michal Vasko <mvasko@cesnet.cz>
* @brief Internal structures and functions for libyang parsers
*
* Copyright (c) 2020 - 2026 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*/
;
;
;
;
;
;
;
/**
* @brief Check data parser error taking into account multi-error validation.
*
* @param[in] r Local return value.
* @param[in] err_cmd Command to perform on any error.
* @param[in] lydctx Data parser context.
* @param[in] label Label to go to on fatal error.
*/
/**
* @brief Callback for ::lyd_ctx to free the structure
*
* @param[in] ctx Data parser context to free.
*/
typedef void ;
/**
* @brief Internal data parser flags.
*/
/**
* @brief Internal (common) context for YANG data parsers.
*
* Covers ::lyd_xml_ctx, ::lyd_json_ctx and ::lyd_lyb_ctx.
*/
;
/**
* @brief Internal context for XML data parser.
*/
;
/**
* @brief Internal context for JSON data parser.
*/
;
/**
* @brief Internal context for LYB data parser/printer.
*/
;
/**
* @brief Parsed extension instance data to validate.
*/
;
/**
* @brief Common part to supplement the specific ::lyd_ctx_free_clb callbacks.
*/
void ;
/**
* @brief Parse submodule from YANG data.
* @param[in,out] context Parser context.
* @param[in] ly_ctx Context of YANG schemas.
* @param[in] main_ctx Parser context of main module.
* @param[in] in Input structure.
* @param[out] submod Pointer to the parsed submodule structure.
* @return LY_ERR value - LY_SUCCESS, LY_EINVAL or LY_EVALID.
*/
LY_ERR ;
/**
* @brief Parse module from YANG data.
* @param[in] context Parser context.
* @param[in] in Input structure.
* @param[in,out] mod Prepared module structure where the parsed information, including the parsed
* module structure, will be filled in.
* @return LY_ERR values.
*/
LY_ERR ;
/**
* @brief Parse module from YIN data.
*
* @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_module after it's completly parsed.
* @param[in] in Input structure.
* @param[in,out] mod Prepared module structure where the parsed information, including the parsed
* module structure, will be filled in.
* @return LY_ERR values.
*/
LY_ERR ;
/**
* @brief Parse submodule from YIN data.
*
* @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_module after it's completly parsed.
* @param[in] ctx Libyang context.
* @param[in] main_ctx Parser context of main module.
* @param[in] in Input structure.
* @param[in,out] submod Submodule structure where the parsed information, will be filled in.
* @return LY_ERR values.
*/
LY_ERR ;
/**
* @brief Parse XML string as a YANG data tree.
*
* @param[in] ctx libyang context.
* @param[in] parent Parent to connect the parsed nodes to, if any.
* @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
* @param[in] in Input structure.
* @param[in] parse_opts Options for parser, see @ref dataparseroptions.
* @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
* @param[in] int_opts Internal data parser options.
* @param[out] parsed Set to add all the parsed siblings into.
* @param[out] lydctx_p Data parser context to finish validation.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Parse XML string as a NETCONF message.
*
* @param[in] ctx libyang context.
* @param[in] parent Parent to connect the parsed nodes to, if any.
* @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
* @param[in] in Input structure.
* @param[in] parse_opts Options for parser, see @ref dataparseroptions.
* @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
* @param[in] data_type Expected NETCONF data type of the data.
* @param[out] envp Individual parsed envelopes tree, may be returned possibly even on an error.
* @param[out] parsed Set to add all the parsed siblings into.
* @param[out] lydctx_p Data parser context to finish validation.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Parse JSON string as a YANG data tree.
*
* @param[in] ctx libyang context.
* @param[in] parent Parent to connect the parsed nodes to, if any.
* @param[in] schema Optional schema node of the parsed node (mandatory when parsing JSON value fragment).
* @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
* @param[in] in Input structure.
* @param[in] parse_opts Options for parser, see @ref dataparseroptions.
* @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
* @param[in] int_opts Internal data parser options.
* @param[out] parsed Set to add all the parsed siblings into.
* @param[out] lydctx_p Optional data parser context to finish validation.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Parse JSON string as a RESTCONF message.
*
* @param[in] ctx libyang context.
* @param[in] parent Parent to connect the parsed nodes to, if any.
* @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
* @param[in] in Input structure.
* @param[in] parse_opts Options for parser, see @ref dataparseroptions.
* @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
* @param[in] data_type Expected RESTCONF data type of the data.
* @param[out] envp Individual parsed envelopes tree, may be returned possibly even on an error.
* @param[out] parsed Set to add all the parsed siblings into.
* @param[out] lydctx_p Data parser context to finish validation.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Parse binary LYB data as a YANG data tree.
*
* @param[in] ctx libyang context.
* @param[in] parent Parent to connect the parsed nodes to, if any.
* @param[in,out] first_p Pointer to the first top-level parsed node, used only if @p parent is NULL.
* @param[in] in Input structure.
* @param[in] parse_opts Options for parser, see @ref dataparseroptions.
* @param[in] val_opts Options for the validation phase, see @ref datavalidationoptions.
* @param[in] int_opts Internal data parser options.
* @param[out] parsed Set to add all the parsed siblings into.
* @param[out] lydctx_p Data parser context to finish validation.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Validate eventTime date-and-time value.
*
* @param[in] node Opaque eventTime node.
* @return LY_SUCCESS on success.
* @return LY_ERR value on error.
*/
LY_ERR ;
/**
* @brief Search all the parents for an operation node, check validity based on internal parser flags.
*
* @param[in] parent Parent to connect the parsed nodes to.
* @param[in] int_opts Internal parser options.
* @param[out] op Found operation, if any.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Check that a data node representing the @p snode is suitable based on options.
*
* @param[in] lydctx Common data parsers context.
* @param[in] snode Schema node to check.
* @return LY_SUCCESS or LY_EVALID
*/
LY_ERR ;
/**
* @brief Wrapper around ::lyd_create_term() for data parsers.
*
* @param[in] lydctx Data parser context.
* @param[in] schema Schema node of the new data node.
* @param[in] lnode Parent data node for logging.
* @param[in] value String value to be parsed.
* @param[in] value_size_bits Size of @p value in bits, must be set correctly.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[in] hints [Data parser's hints](@ref lydvalhints) for the value's type.
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
* @return LY_ERR value if an error occurred.
*/
LY_ERR ;
/**
* @brief Wrapper around ::lyd_create_meta() for data parsers.
*
* @param[in] lydctx Data parser context.
* @param[in] parent Parent of the created meta. Must be set if @p meta is NULL.
* @param[in,out] meta First existing meta to connect to or empty pointer to set. Must be set if @p parent is NULL.
* @param[in] mod Module of the created metadata.
* @param[in] name Metadata name.
* @param[in] name_len Length of @p name.
* @param[in] value Metadata value.
* @param[in] value_size_bits Size of @p value in bits.
* @param[in,out] dynamic Whether the @p value is dynamically allocated, is adjusted once the value is assigned.
* @param[in] format Prefix format.
* @param[in] prefix_data Prefix format data (see ::ly_resolve_prefix()).
* @param[in] hints [Value hint](@ref lydvalhints) from the parser regarding the value type.
* @param[in] ctx_node Value context node.
* @param[in] lnode Data node for logging.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Check that a list has all its keys.
*
* @param[in] node List to check.
* @return LY_SUCCESS on success.
* @return LY_ENOT on a missing key.
*/
LY_ERR ;
/**
* @brief Set data flags for a newly parsed node.
*
* @param[in] node Node to use.
* @param[in,out] meta Node metadata, may be removed from.
* @param[in] lydctx Data parsing context.
* @param[in] ext Extension instance if @p node was parsed for one.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Validate a new parsed data node and add its implicit children.
*
* @param[in] lydctx Data parser context.
* @param[in] node Parsed node to validate.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Free safely a parsed node.
*
* @param[in,out] first_p Pointer to the first sibling on a level.
* @param[in,out] node Node to free, is zeroed.
*/
void ;
/**
* @brief Insert a parsed node.
*
* @param[in] parent Data node parent, if any.
* @param[in,out] first_p First sibling on the level, if any.
* @param[in] insert_anchor Optional insert anchor to use.
* @param[in] parse_opts Parser options.
* @param[in] node Node to insert.
* @return LY_ERR value.
*/
LY_ERR ;
/**
* @brief Parse an instance extension statement.
*
* @param[in] pctx Parse context.
* @param[in] substmt Parsed ext instance substatement info.
* @param[in] stmt Parsed generic statement to process.
* @return LY_ERR value.
*/
LY_ERR ;
/* LY_PARSER_INTERNAL_H_ */