blob: b4a8d251963fe4f683ecab6f93594e8a541a16af [file] [log] [blame]
Radek Krejcie7b95092019-05-15 11:03:07 +02001/**
2 * @file tree_data_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskodbf3e652022-10-21 08:46:25 +02004 * @author Michal Vasko <mvasko@cesnet.cz>
Radek Krejcie7b95092019-05-15 11:03:07 +02005 * @brief internal functions for YANG schema trees.
6 *
Michal Vasko88b965b2024-10-23 12:26:20 +02007 * Copyright (c) 2015 - 2024 CESNET, z.s.p.o.
Radek Krejcie7b95092019-05-15 11:03:07 +02008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef LY_TREE_DATA_INTERNAL_H_
17#define LY_TREE_DATA_INTERNAL_H_
18
Ondrej Kusnirik747486a2024-08-19 10:52:44 +020019#include "compat.h"
Radek Krejci857189e2020-09-01 13:26:36 +020020#include "log.h"
Radek Krejciaca74032019-06-04 08:53:06 +020021#include "plugins_types.h"
Michal Vasko60ea6352020-06-29 13:39:39 +020022#include "tree_data.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020023
Michal Vasko52927e22020-03-16 17:26:14 +010024#include <stddef.h>
25
Michal Vasko004d3152020-06-11 19:59:22 +020026struct ly_path_predicate;
Michal Vasko8cc3f662022-03-29 11:25:51 +020027struct lyd_ctx;
Michal Vaskoa6669ba2020-08-06 16:14:26 +020028struct lysc_module;
Michal Vasko004d3152020-06-11 19:59:22 +020029
Radek Krejcif13b87b2020-12-01 22:02:17 +010030#define LY_XML_SUFFIX ".xml"
31#define LY_XML_SUFFIX_LEN 4
32#define LY_JSON_SUFFIX ".json"
33#define LY_JSON_SUFFIX_LEN 5
34#define LY_LYB_SUFFIX ".lyb"
35#define LY_LYB_SUFFIX_LEN 4
36
Radek Krejcie7b95092019-05-15 11:03:07 +020037/**
Michal Vasko271d2e32023-01-31 15:43:19 +010038 * @brief Internal item structure for remembering "used" instances of duplicate node instances.
Michal Vaskod7c048c2021-05-18 16:12:55 +020039 */
40struct lyd_dup_inst {
Michal Vasko271d2e32023-01-31 15:43:19 +010041 struct ly_set *set;
Michal Vaskod7c048c2021-05-18 16:12:55 +020042 uint32_t used;
43};
44
45/**
Michal Vasko271d2e32023-01-31 15:43:19 +010046 * @brief Update a found inst using a duplicate instance cache hash table. Needs to be called for every "used"
Michal Vaskod7c048c2021-05-18 16:12:55 +020047 * (that should not be considered next time) instance.
48 *
49 * @param[in,out] inst Found instance, is updated so that the same instance is not returned twice.
50 * @param[in] siblings Siblings where @p inst was found.
Michal Vasko271d2e32023-01-31 15:43:19 +010051 * @param[in] dup_inst_ht Duplicate instance cache hash table.
Michal Vaskod7c048c2021-05-18 16:12:55 +020052 * @return LY_ERR value.
53 */
Michal Vasko8efac242023-03-30 08:24:56 +020054LY_ERR lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings, struct ly_ht **dup_inst_ht);
Michal Vaskod7c048c2021-05-18 16:12:55 +020055
56/**
57 * @brief Free duplicate instance cache.
58 *
Michal Vasko271d2e32023-01-31 15:43:19 +010059 * @param[in] dup_inst Duplicate instance cache hash table to free.
Michal Vaskod7c048c2021-05-18 16:12:55 +020060 */
Michal Vasko8efac242023-03-30 08:24:56 +020061void lyd_dup_inst_free(struct ly_ht *dup_inst_ht);
Michal Vaskod7c048c2021-05-18 16:12:55 +020062
63/**
Radek Krejci8678fa42020-08-18 16:07:28 +020064 * @brief Just like ::lys_getnext() but iterates over all data instances of the schema nodes.
Michal Vaskoa6669ba2020-08-06 16:14:26 +020065 *
66 * @param[in] last Last returned data node.
67 * @param[in] sibling Data node sibling to search in.
68 * @param[in,out] slast Schema last node, set to NULL for first call and do not change afterwards.
69 * May not be set if the function is used only for any suitable node existence check (such as the existence
70 * of any choice case data).
71 * @param[in] parent Schema parent of the iterated children nodes.
72 * @param[in] module Schema module of the iterated top-level nodes.
73 * @return Next matching data node,
74 * @return NULL if last data node was already returned.
75 */
76struct lyd_node *lys_getnext_data(const struct lyd_node *last, const struct lyd_node *sibling,
Michal Vasko106f0862021-11-02 11:49:27 +010077 const struct lysc_node **slast, const struct lysc_node *parent, const struct lysc_module *module);
78
79/**
80 * @brief Get address of a node's child pointer if any.
81 *
82 * @param[in] node Node to check.
83 * @return Address of the node's child member,
84 * @return NULL if there is no child pointer.
85 */
86struct lyd_node **lyd_node_child_p(struct lyd_node *node);
87
88/**
89 * @brief Update node pointer to point to the first data node of a module, leave unchanged if there is none.
90 *
91 * @param[in,out] node Node pointer, may be updated.
92 * @param[in] mod Module whose data to search for.
93 */
94void lyd_first_module_sibling(struct lyd_node **node, const struct lys_module *mod);
95
96/**
97 * @brief Iterate over implemented modules for functions that accept specific modules or the whole context.
98 *
99 * @param[in] tree Data tree.
100 * @param[in] module Selected module, NULL for all.
101 * @param[in] ctx Context, NULL for selected modules.
102 * @param[in,out] i Iterator, set to 0 on first call.
103 * @param[out] first First sibling of the returned module.
104 * @return Next module.
105 * @return NULL if all modules were traversed.
106 */
107const struct lys_module *lyd_mod_next_module(struct lyd_node *tree, const struct lys_module *module,
108 const struct ly_ctx *ctx, uint32_t *i, struct lyd_node **first);
109
110/**
111 * @brief Iterate over modules for functions that want to traverse all the top-level data.
112 *
113 * @param[in,out] next Pointer to the next module data, set to first top-level sibling on first call.
114 * @param[out] first First sibling of the returned module.
115 * @return Next module.
116 * @return NULL if all modules were traversed.
117 */
118const struct lys_module *lyd_data_next_module(struct lyd_node **next, struct lyd_node **first);
119
120/**
Michal Vasko59892dd2022-05-13 11:02:30 +0200121 * @brief Search in the given siblings (NOT recursively) for the first schema node data instance.
122 * Uses hashes - should be used whenever possible for best performance.
123 *
124 * @param[in] siblings Siblings to search in including preceding and succeeding nodes.
125 * @param[in] schema Target data node schema to find.
126 * @param[out] match Can be NULL, otherwise the found data node.
127 * @return LY_SUCCESS on success, @p match set.
128 * @return LY_ENOTFOUND if not found, @p match set to NULL.
129 * @return LY_ERR value if another error occurred.
130 */
131LY_ERR lyd_find_sibling_schema(const struct lyd_node *siblings, const struct lysc_node *schema, struct lyd_node **match);
132
133/**
Michal Vasko106f0862021-11-02 11:49:27 +0100134 * @brief Check whether a node to be deleted is the root node, move it if it is.
135 *
136 * @param[in] root Root sibling.
137 * @param[in] to_del Node to be deleted.
138 * @param[in] mod If set, it is expected @p tree should point to the first node of @p mod. Otherwise it will simply be
139 * the first top-level sibling.
140 */
141void lyd_del_move_root(struct lyd_node **root, const struct lyd_node *to_del, const struct lys_module *mod);
142
143/**
Michal Vasko88b965b2024-10-23 12:26:20 +0200144 * @brief After adding a default child, check the node and all of its parent NP containers and set their dflt flag.
145 *
146 * @param[in] parent Changed first parent to check.
147 */
148void lyd_np_cont_dflt_set(struct lyd_node *parent);
149
150/**
151 * @brief After adding a non-default child, remove the dflt flag from parent and other parent NP containers.
152 *
153 * @param[in] parent Changed first parent to update.
154 */
155void lyd_np_cont_dflt_del(struct lyd_node *parent);
156
157/**
Michal Vasko8cc3f662022-03-29 11:25:51 +0200158 * @brief Try to get schema node for data with a parent based on an extension instance.
159 *
160 * @param[in] parent Parsed parent data node. Set if @p sparent is NULL.
161 * @param[in] sparent Schema parent node. Set if @p sparent is NULL.
162 * @param[in] prefix Element prefix, if any.
163 * @param[in] prefix_len Length of @p prefix.
164 * @param[in] format Format of @p prefix.
165 * @param[in] prefix_data Format-specific data.
166 * @param[in] name Element name.
167 * @param[in] name_len Length of @p name.
168 * @param[out] snode Found schema node, NULL if no suitable was found.
Michal Vasko66330fc2022-11-21 15:52:24 +0100169 * @param[out] ext Optional extension instance that provided @p snode.
Michal Vasko8cc3f662022-03-29 11:25:51 +0200170 * @return LY_SUCCESS on success;
171 * @return LY_ENOT if no extension instance parsed the data;
172 * @return LY_ERR on error.
173 */
174LY_ERR ly_nested_ext_schema(const struct lyd_node *parent, const struct lysc_node *sparent, const char *prefix,
175 size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data, const char *name, size_t name_len,
176 const struct lysc_node **snode, struct lysc_ext_instance **ext);
177
178/**
Michal Vasko106f0862021-11-02 11:49:27 +0100179 * @brief Free stored prefix data.
180 *
181 * @param[in] format Format of the prefixes.
182 * @param[in] prefix_data Format-specific data to free:
183 * LY_PREF_SCHEMA - const struct lysp_module * (module used for resolving prefixes from imports)
184 * LY_PREF_SCHEMA_RESOLVED - struct lyd_value_prefix * (sized array of pairs: prefix - module)
185 * LY_PREF_XML - const struct ly_set * (set with defined namespaces stored as ::lyxml_ns)
186 * LY_PREF_JSON - NULL
187 */
188void ly_free_prefix_data(LY_VALUE_FORMAT format, void *prefix_data);
189
190/**
191 * @brief Duplicate prefix data.
192 *
193 * @param[in] ctx libyang context.
194 * @param[in] format Format of the prefixes in the value.
195 * @param[in] prefix_data Prefix data to duplicate.
196 * @param[out] prefix_data_p Duplicated prefix data.
197 * @return LY_ERR value.
198 */
199LY_ERR ly_dup_prefix_data(const struct ly_ctx *ctx, LY_VALUE_FORMAT format, const void *prefix_data, void **prefix_data_p);
200
201/**
202 * @brief Store used prefixes in a string.
203 *
204 * If @p prefix_data_p are non-NULL, they are treated as valid according to the @p format_p and new possible
205 * prefixes are simply added. This way it is possible to store prefix data for several strings together.
206 *
207 * @param[in] ctx libyang context.
208 * @param[in] value Value to be parsed.
209 * @param[in] value_len Length of the @p value.
210 * @param[in] format Format of the prefixes in the value.
211 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
212 * @param[in,out] format_p Resulting format of the prefixes.
213 * @param[in,out] prefix_data_p Resulting prefix data for the value in format @p format_p.
214 * @return LY_ERR value.
215 */
216LY_ERR ly_store_prefix_data(const struct ly_ctx *ctx, const void *value, size_t value_len, LY_VALUE_FORMAT format,
217 const void *prefix_data, LY_VALUE_FORMAT *format_p, void **prefix_data_p);
218
219/**
220 * @brief Get string name of the format.
221 *
222 * @param[in] format Format whose name to get.
223 * @return Format string name.
224 */
225const char *ly_format2str(LY_VALUE_FORMAT format);
Michal Vaskoa6669ba2020-08-06 16:14:26 +0200226
227/**
Michal Vasko9b368d32020-02-14 13:53:31 +0100228 * @brief Create a term (leaf/leaf-list) node from a string value.
229 *
230 * Hash is calculated and new node flag is set.
Michal Vasko90932a92020-02-12 14:33:03 +0100231 *
232 * @param[in] schema Schema node of the new data node.
233 * @param[in] value String value to be parsed.
Michal Vaskof03ed032020-03-04 13:31:44 +0100234 * @param[in] value_len Length of @p value, must be set correctly.
Michal Vasko989cdb42023-10-06 15:32:37 +0200235 * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
stewegd4cde642024-02-21 08:34:16 +0100236 * @param[in] store_only Whether to perform storing operation only.
Michal Vasko90932a92020-02-12 14:33:03 +0100237 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
Michal Vasko90932a92020-02-12 14:33:03 +0100238 * @param[in] format Input format of @p value.
Michal Vaskoc8a230d2020-08-14 12:17:10 +0200239 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200240 * @param[in] hints [Value hints](@ref lydvalhints) from the parser regarding the value type.
241 * @param[out] incomplete Whether the value needs to be resolved.
Michal Vasko90932a92020-02-12 14:33:03 +0100242 * @param[out] node Created node.
243 * @return LY_SUCCESS on success.
244 * @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
245 * @return LY_ERR value if an error occurred.
246 */
Michal Vasko989cdb42023-10-06 15:32:37 +0200247LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool is_utf8,
stewegd4cde642024-02-21 08:34:16 +0100248 ly_bool store_only, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
249 ly_bool *incomplete, struct lyd_node **node);
Michal Vasko90932a92020-02-12 14:33:03 +0100250
251/**
Michal Vasko9b368d32020-02-14 13:53:31 +0100252 * @brief Create a term (leaf/leaf-list) node from a parsed value by duplicating it.
253 *
254 * Hash is calculated and new node flag is set.
255 *
256 * @param[in] schema Schema node of the new data node.
257 * @param[in] val Parsed value to use.
258 * @param[out] node Created node.
259 * @return LY_SUCCESS on success.
260 * @return LY_ERR value if an error occurred.
261 */
262LY_ERR lyd_create_term2(const struct lysc_node *schema, const struct lyd_value *val, struct lyd_node **node);
263
264/**
265 * @brief Create an inner (container/list/RPC/action/notification) node.
266 *
267 * Hash is calculated and new node flag is set except
268 * for list with keys, when the hash is not calculated!
269 * Also, non-presence container has its default flag set.
Michal Vasko90932a92020-02-12 14:33:03 +0100270 *
271 * @param[in] schema Schema node of the new data node.
272 * @param[out] node Created node.
273 * @return LY_SUCCESS on success.
274 * @return LY_ERR value if an error occurred.
275 */
276LY_ERR lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node);
277
278/**
Michal Vasko9b368d32020-02-14 13:53:31 +0100279 * @brief Create a list with all its keys (cannot be used for key-less list).
280 *
281 * Hash is calculated and new node flag is set.
Michal Vasko90932a92020-02-12 14:33:03 +0100282 *
283 * @param[in] schema Schema node of the new data node.
Michal Vasko004d3152020-06-11 19:59:22 +0200284 * @param[in] predicates Compiled key list predicates.
Michal Vasko90189962023-02-28 12:10:34 +0100285 * @param[in] vars Array of defined variables to use in predicates, may be NULL.
stewegd4cde642024-02-21 08:34:16 +0100286 * @param[in] store_only Whether to perform storing operation only.
Michal Vasko90932a92020-02-12 14:33:03 +0100287 * @param[out] node Created node.
288 * @return LY_SUCCESS on success.
289 * @return LY_ERR value if an error occurred.
290 */
Michal Vasko90189962023-02-28 12:10:34 +0100291LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates,
stewegd4cde642024-02-21 08:34:16 +0100292 const struct lyxp_var *vars, ly_bool store_only, struct lyd_node **node);
Michal Vasko90932a92020-02-12 14:33:03 +0100293
294/**
Michal Vasko59892dd2022-05-13 11:02:30 +0200295 * @brief Create a list with all its keys (cannot be used for key-less list).
296 *
297 * Hash is calculated and new node flag is set.
298 *
299 * @param[in] schema Schema node of the new data node.
300 * @param[in] keys Key list predicates.
301 * @param[in] keys_len Length of @p keys.
stewegd4cde642024-02-21 08:34:16 +0100302 * @param[in] store_only Whether to perform storing operation only.
Michal Vasko59892dd2022-05-13 11:02:30 +0200303 * @param[out] node Created node.
304 * @return LY_SUCCESS on success.
305 * @return LY_ERR value if an error occurred.
306 */
stewegd4cde642024-02-21 08:34:16 +0100307LY_ERR lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, ly_bool store_only,
308 struct lyd_node **node);
Michal Vasko59892dd2022-05-13 11:02:30 +0200309
310/**
Michal Vasko9b368d32020-02-14 13:53:31 +0100311 * @brief Create an anyxml/anydata node.
312 *
313 * Hash is calculated and flags are properly set based on @p is_valid.
Michal Vasko90932a92020-02-12 14:33:03 +0100314 *
315 * @param[in] schema Schema node of the new data node.
Michal Vasko366a4a12020-12-04 16:23:57 +0100316 * @param[in] value Value of the any node.
Michal Vasko90932a92020-02-12 14:33:03 +0100317 * @param[in] value_type Value type of the value.
Michal Vasko742a5b12022-02-24 16:07:27 +0100318 * @param[in] use_value Whether to use dynamic @p value or duplicate it.
Michal Vasko90932a92020-02-12 14:33:03 +0100319 * @param[out] node Created node.
320 * @return LY_SUCCESS on success.
321 * @return LY_ERR value if an error occurred.
322 */
Michal Vasko9b368d32020-02-14 13:53:31 +0100323LY_ERR lyd_create_any(const struct lysc_node *schema, const void *value, LYD_ANYDATA_VALUETYPE value_type,
Michal Vasko366a4a12020-12-04 16:23:57 +0100324 ly_bool use_value, struct lyd_node **node);
Michal Vasko90932a92020-02-12 14:33:03 +0100325
326/**
Michal Vasko52927e22020-03-16 17:26:14 +0100327 * @brief Create an opaque node.
328 *
329 * @param[in] ctx libyang context.
330 * @param[in] name Element name.
331 * @param[in] name_len Length of @p name, must be set correctly.
Michal Vasko52927e22020-03-16 17:26:14 +0100332 * @param[in] prefix Element prefix.
333 * @param[in] pref_len Length of @p prefix, must be set correctly.
Radek Krejci1798aae2020-07-14 13:26:06 +0200334 * @param[in] module_key Mandatory key to reference module, can be namespace or name.
335 * @param[in] module_key_len Length of @p module_key, must be set correctly.
Michal Vasko501af032020-11-11 20:27:44 +0100336 * @param[in] value String value to be parsed.
337 * @param[in] value_len Length of @p value, must be set correctly.
338 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
339 * @param[in] format Input format of @p value and @p ns.
Radek Krejciec9ad602021-01-04 10:46:30 +0100340 * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails):
341 * LY_PREF_SCHEMA - const struct lysp_module * (module used for resolving prefixes from imports)
342 * LY_PREF_SCHEMA_RESOLVED - struct lyd_value_prefix * (sized array of pairs: prefix - module)
343 * LY_PREF_XML - const struct ly_set * (set with defined namespaces stored as ::lyxml_ns)
344 * LY_PREF_JSON - NULL
Michal Vasko501af032020-11-11 20:27:44 +0100345 * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
Michal Vasko52927e22020-03-16 17:26:14 +0100346 * @param[out] node Created node.
347 * @return LY_SUCCESS on success.
348 * @return LY_ERR value if an error occurred.
349 */
Michal Vasko501af032020-11-11 20:27:44 +0100350LY_ERR lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t pref_len,
351 const char *module_key, size_t module_key_len, const char *value, size_t value_len, ly_bool *dynamic,
Radek Krejci8df109d2021-04-23 12:19:08 +0200352 LY_VALUE_FORMAT format, void *val_prefix_data, uint32_t hints, struct lyd_node **node);
Michal Vasko52927e22020-03-16 17:26:14 +0100353
354/**
Michal Vasko88b965b2024-10-23 12:26:20 +0200355 * @brief Change the value of a term (leaf or leaf-list) node.
356 *
357 * Node changed this way is always considered explicitly set, meaning its default flag
358 * is always cleared.
359 *
360 * @param[in] term Term node to change.
361 * @param[in] val New value to use.
362 * @param[in] use_val Whether @p val can be used and spent or should only be duplicated.
363 * @param[in] is_dflt Whether @p val is a default value or not.
364 * @return LY_SUCCESS if value was changed,
365 * @return LY_EEXIST if value was the same and only the default flag was cleared,
366 * @return LY_ENOT if the values were equal and no change occured,
367 * @return LY_ERR value on other errors.
368 */
369LY_ERR lyd_change_term_val(struct lyd_node *term, struct lyd_value *val, ly_bool use_val, ly_bool is_dflt);
370
371/**
Michal Vasko361391d2024-10-08 14:55:50 +0200372 * @brief Check the existence and create any non-existing implicit children.
373 *
374 * @param[in] parent Parent of the potential default values, NULL for top-level siblings.
375 * @param[in,out] first First sibling.
376 * @param[in] sparent Schema parent of the siblings, NULL if schema of @p parent can be used.
377 * @param[in] mod Module of the default values, NULL for nested siblings.
378 * @param[in] node_when Optional set to add nodes with "when" conditions into.
379 * @param[in] node_types Optional set to add nodes with unresolved types into.
380 * @param[in] ext_node Optional set to add nodes with extension instance node callbacks into.
381 * @param[in] impl_opts Implicit options (@ref implicitoptions).
382 * @param[in,out] diff Validation diff.
383 * @return LY_ERR value.
384 */
385LY_ERR lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
386 const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, struct ly_set *ext_node,
387 uint32_t impl_opts, struct lyd_node **diff);
388
389/**
390 * @brief Check the existence and create any non-existing implicit children, recursively for containers.
Michal Vaskoa6669ba2020-08-06 16:14:26 +0200391 *
392 * @param[in] parent Parent of the potential default values, NULL for top-level siblings.
393 * @param[in,out] first First sibling.
394 * @param[in] sparent Schema parent of the siblings, NULL if schema of @p parent can be used.
395 * @param[in] mod Module of the default values, NULL for nested siblings.
Michal Vaskoa6669ba2020-08-06 16:14:26 +0200396 * @param[in] node_when Optional set to add nodes with "when" conditions into.
Michal Vaskoc43c8ab2021-03-05 13:32:44 +0100397 * @param[in] node_types Optional set to add nodes with unresolved types into.
Michal Vaskofcbd78f2022-08-26 08:34:15 +0200398 * @param[in] ext_node Optional set to add nodes with extension instance node callbacks into.
Michal Vaskoa6669ba2020-08-06 16:14:26 +0200399 * @param[in] impl_opts Implicit options (@ref implicitoptions).
400 * @param[in,out] diff Validation diff.
401 * @return LY_ERR value.
402 */
403LY_ERR lyd_new_implicit_r(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
Michal Vaskofcbd78f2022-08-26 08:34:15 +0200404 const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, struct ly_set *ext_node,
405 uint32_t impl_opts, struct lyd_node **diff);
Michal Vaskoa6669ba2020-08-06 16:14:26 +0200406
407/**
Michal Vaskob104f112020-07-17 09:54:54 +0200408 * @brief Find the next node, before which to insert the new node.
Michal Vasko90932a92020-02-12 14:33:03 +0100409 *
Michal Vaskob104f112020-07-17 09:54:54 +0200410 * @param[in] first_sibling First sibling of the nodes to consider.
411 * @param[in] new_node Node that will be inserted.
412 * @return Node to insert after.
413 * @return NULL if the new node should be first.
Michal Vasko90932a92020-02-12 14:33:03 +0100414 */
Michal Vaskob104f112020-07-17 09:54:54 +0200415struct lyd_node *lyd_insert_get_next_anchor(const struct lyd_node *first_sibling, const struct lyd_node *new_node);
Michal Vasko90932a92020-02-12 14:33:03 +0100416
417/**
Michal Vaskoc61dd062022-06-07 11:01:28 +0200418 * @brief Insert node after a sibling.
419 *
420 * Handles inserting into NP containers and key-less lists.
421 *
aPiecek743184b2024-02-01 13:25:56 +0100422 * @param[in,out] first_sibling Optional, useful for optimization. The function operates with the first sibling
423 * only if the node is inserted last. It is optimal when the first sibling is set. If it is set to NULL or
424 * if it points to a NULL pointer, then the function will find the first sibling itself.
Michal Vaskoc61dd062022-06-07 11:01:28 +0200425 * @param[in] sibling Sibling to insert after.
426 * @param[in] node Node to insert.
427 */
aPiecek743184b2024-02-01 13:25:56 +0100428void lyd_insert_after_node(struct lyd_node **first_sibling, struct lyd_node *sibling, struct lyd_node *node);
Michal Vaskoc61dd062022-06-07 11:01:28 +0200429
430/**
431 * @brief Insert node before a sibling.
432 *
433 * Handles inserting into NP containers and key-less lists.
434 *
435 * @param[in] sibling Sibling to insert before.
436 * @param[in] node Node to insert.
437 */
438void lyd_insert_before_node(struct lyd_node *sibling, struct lyd_node *node);
439
440/**
aPiecek1462ab12024-02-07 09:13:29 +0100441 * @defgroup insertorder Data insert order.
442 *
443 * Various options for optimal node insertion.
444 * Flags that cause the order of nodes not to be checked are adapted to fast insertion but can cause
445 * nodes for (leaf-)lists with LYS_ORDBY_SYSTEM flag set to be out of order, which is an undesirable state,
446 * so these flags must be set carefully. In such exceptional cases, (leaf-)list instances may remain unsorted,
447 * in which case inserting a new node causes sorting to be invoked.
448 * @{
449 */
450
451#define LYD_INSERT_NODE_DEFAULT 0x00 /**< Default behavior. Node is inserted to preserve order. */
452#define LYD_INSERT_NODE_LAST 0x01 /**< Node inserted as last sibling. Node ordering is checked only
453 in Debug build, to detect misuse of the LYD_PARSE_ORDERED flag. */
454#define LYD_INSERT_NODE_LAST_BY_SCHEMA 0x02 /**< The node is inserted according to the schema as a last instance.
455 Node order not checked. */
456
457/** @} insertorder */
458
459/**
Michal Vaskob104f112020-07-17 09:54:54 +0200460 * @brief Insert a node into parent/siblings. Order and hashes are fully handled.
Michal Vasko90932a92020-02-12 14:33:03 +0100461 *
Michal Vasko9b368d32020-02-14 13:53:31 +0100462 * @param[in] parent Parent to insert into, NULL for top-level sibling.
463 * @param[in,out] first_sibling First sibling, NULL if no top-level sibling exist yet. Can be also NULL if @p parent is set.
Michal Vasko90932a92020-02-12 14:33:03 +0100464 * @param[in] node Individual node (without siblings) to insert.
aPiecek1462ab12024-02-07 09:13:29 +0100465 * @param[in] order Options for inserting (sorting) the node (@ref insertorder).
Michal Vasko90932a92020-02-12 14:33:03 +0100466 */
aPiecek1462ab12024-02-07 09:13:29 +0100467void lyd_insert_node(struct lyd_node *parent, struct lyd_node **first_sibling, struct lyd_node *node,
468 uint32_t order);
Michal Vasko90932a92020-02-12 14:33:03 +0100469
470/**
aPieceke6955f42024-01-19 14:01:54 +0100471 * @brief Insert a node into parent/siblings, either before the 'anchor' or as the last sibling.
472 *
473 * @param[in] parent Parent to insert into, NULL for top-level sibling.
aPiecek743184b2024-02-01 13:25:56 +0100474 * @param[in,out] first_sibling First sibling, pointing to NULL pointer if no top-level sibling exist yet
475 * or if @p parent is set.
aPieceke6955f42024-01-19 14:01:54 +0100476 * @param[in] node Individual node (without siblings) to insert.
477 */
aPiecek743184b2024-02-01 13:25:56 +0100478void lyd_insert_node_ordby_schema(struct lyd_node *parent, struct lyd_node **first_sibling, struct lyd_node *node);
aPieceke6955f42024-01-19 14:01:54 +0100479
480/**
Michal Vasko2e784f82024-01-11 09:51:22 +0100481 * @brief Unlink the specified data subtree.
482 *
483 * @param[in] node Data tree node to be unlinked (together with all the children).
484 */
485void lyd_unlink(struct lyd_node *node);
486
487/**
Michal Vaskoa5da3292020-08-12 13:10:50 +0200488 * @brief Insert a metadata (last) into a parent
489 *
490 * @param[in] parent Parent of the metadata.
491 * @param[in] meta Metadata (list) to be added into the @p parent.
Michal Vasko871a0252020-11-11 18:35:24 +0100492 * @param[in] clear_dflt Whether to clear dflt flag starting from @p parent, recursively all NP containers.
Michal Vaskoa5da3292020-08-12 13:10:50 +0200493 */
Michal Vasko871a0252020-11-11 18:35:24 +0100494void lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool clear_dflt);
Michal Vaskoa5da3292020-08-12 13:10:50 +0200495
496/**
aPiecek0e92afc2023-11-08 10:48:02 +0100497 * @brief Unlink a single metadata instance.
498 *
499 * @param[in] meta Metadata to unlink.
500 */
501void lyd_unlink_meta_single(struct lyd_meta *meta);
502
503/**
Michal Vasko52927e22020-03-16 17:26:14 +0100504 * @brief Create and insert a metadata (last) into a parent.
Michal Vasko90932a92020-02-12 14:33:03 +0100505 *
Michal Vasko52927e22020-03-16 17:26:14 +0100506 * @param[in] parent Parent of the metadata, can be NULL.
Michal Vasko9f96a052020-03-10 09:41:45 +0100507 * @param[in,out] meta Metadata list to add at its end if @p parent is NULL, returned created attribute.
508 * @param[in] mod Metadata module (with the annotation definition).
Michal Vasko90932a92020-02-12 14:33:03 +0100509 * @param[in] name Attribute name.
Michal Vaskof03ed032020-03-04 13:31:44 +0100510 * @param[in] name_len Length of @p name, must be set correctly.
Michal Vasko90932a92020-02-12 14:33:03 +0100511 * @param[in] value String value to be parsed.
Michal Vaskof03ed032020-03-04 13:31:44 +0100512 * @param[in] value_len Length of @p value, must be set correctly.
Michal Vasko989cdb42023-10-06 15:32:37 +0200513 * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
stewegd4cde642024-02-21 08:34:16 +0100514 * @param[in] store_only Whether to perform storing operation only.
Michal Vasko90932a92020-02-12 14:33:03 +0100515 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
Michal Vasko90932a92020-02-12 14:33:03 +0100516 * @param[in] format Input format of @p value.
Michal Vaskoc8a230d2020-08-14 12:17:10 +0200517 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200518 * @param[in] hints [Value hints](@ref lydvalhints) from the parser regarding the value type.
Michal Vaskoddd76592022-01-17 13:34:48 +0100519 * @param[in] ctx_node Value context node, may be NULL for metadata.
Michal Vasko871a0252020-11-11 18:35:24 +0100520 * @param[in] clear_dflt Whether to clear dflt flag starting from @p parent, recursively all NP containers.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200521 * @param[out] incomplete Whether the value needs to be resolved.
Michal Vasko90932a92020-02-12 14:33:03 +0100522 * @return LY_SUCCESS on success.
523 * @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
524 * @return LY_ERR value if an error occurred.
525 */
Michal Vasko9f96a052020-03-10 09:41:45 +0100526LY_ERR lyd_create_meta(struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod, const char *name,
stewegd4cde642024-02-21 08:34:16 +0100527 size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic,
528 LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt,
529 ly_bool *incomplete);
Radek Krejci1798aae2020-07-14 13:26:06 +0200530
531/**
aPiecek41680342023-11-08 10:19:44 +0100532 * @brief Create a copy of the metadata.
533 *
534 * @param[in] parent_ctx Target context for duplicated nodes.
535 * @param[in] meta Metadata to copy.
536 * @param[in] parent Node where to append the new metadata.
537 * @param[out] dup Optional created metadata copy.
538 * @return LY_ERR value.
539 */
540LY_ERR lyd_dup_meta_single_to_ctx(const struct ly_ctx *parent_ctx, const struct lyd_meta *meta, struct lyd_node *parent,
541 struct lyd_meta **dup);
542
543/**
Michal Vaskoa5da3292020-08-12 13:10:50 +0200544 * @brief Insert an attribute (last) into a parent
Radek Krejci1798aae2020-07-14 13:26:06 +0200545 *
Michal Vaskoa5da3292020-08-12 13:10:50 +0200546 * @param[in] parent Parent of the attributes.
547 * @param[in] attr Attribute (list) to be added into the @p parent.
Radek Krejci1798aae2020-07-14 13:26:06 +0200548 */
Michal Vaskoa5da3292020-08-12 13:10:50 +0200549void lyd_insert_attr(struct lyd_node *parent, struct lyd_attr *attr);
Michal Vasko90932a92020-02-12 14:33:03 +0100550
551/**
Michal Vasko52927e22020-03-16 17:26:14 +0100552 * @brief Create and insert a generic attribute (last) into a parent.
553 *
554 * @param[in] parent Parent of the attribute, can be NULL.
555 * @param[in,out] attr Attribute list to add at its end if @p parent is NULL, returned created attribute.
556 * @param[in] ctx libyang context.
557 * @param[in] name Attribute name.
558 * @param[in] name_len Length of @p name, must be set correctly.
Michal Vasko52927e22020-03-16 17:26:14 +0100559 * @param[in] prefix Attribute prefix.
560 * @param[in] prefix_len Attribute prefix length.
Radek Krejci1798aae2020-07-14 13:26:06 +0200561 * @param[in] module_key Mandatory key to reference module, can be namespace or name.
562 * @param[in] module_key_len Length of @p module_key, must be set correctly.
Michal Vasko501af032020-11-11 20:27:44 +0100563 * @param[in] value String value to be parsed.
564 * @param[in] value_len Length of @p value, must be set correctly.
565 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
566 * @param[in] format Input format of @p value and @p ns.
567 * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails).
568 * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200569 * @return LY_SUCCESS on success,
570 * @return LY_ERR value on error.
Michal Vasko52927e22020-03-16 17:26:14 +0100571 */
Radek Krejci1798aae2020-07-14 13:26:06 +0200572LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const struct ly_ctx *ctx, const char *name,
Michal Vasko501af032020-11-11 20:27:44 +0100573 size_t name_len, const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len,
Radek Krejci8df109d2021-04-23 12:19:08 +0200574 const char *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *val_prefix_data, uint32_t hints);
Radek Krejci1798aae2020-07-14 13:26:06 +0200575
576/**
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200577 * @brief Store and canonize the given @p value into @p val according to the schema node type rules.
Radek Krejci38d85362019-09-05 16:26:38 +0200578 *
Michal Vasko8d544252020-03-02 10:19:52 +0100579 * @param[in] ctx libyang context.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200580 * @param[in,out] val Storage for the value.
581 * @param[in] type Type of the value.
Radek Krejcif9943642021-04-26 10:18:21 +0200582 * @param[in] value Value to be parsed, must not be NULL.
Michal Vaskof03ed032020-03-04 13:31:44 +0100583 * @param[in] value_len Length of the give @p value, must be set correctly.
Michal Vasko989cdb42023-10-06 15:32:37 +0200584 * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
stewegd4cde642024-02-21 08:34:16 +0100585 * @param[in] store_only Whether to perform storing operation only.
Michal Vasko90932a92020-02-12 14:33:03 +0100586 * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200587 * @param[in] format Input format of @p value.
Michal Vaskoc8a230d2020-08-14 12:17:10 +0200588 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200589 * @param[in] hints [Value hints](@ref lydvalhints) from the parser.
590 * @param[in] ctx_node Context schema node.
591 * @param[out] incomplete Optional, set if the value also needs to be resolved.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200592 * @return LY_SUCCESS on success,
593 * @return LY_ERR value on error.
Radek Krejci38d85362019-09-05 16:26:38 +0200594 */
Radek Krejcif9943642021-04-26 10:18:21 +0200595LY_ERR lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
stewegd4cde642024-02-21 08:34:16 +0100596 size_t value_len, ly_bool is_utf8, ly_bool store_only, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data,
597 uint32_t hints, const struct lysc_node *ctx_node, ly_bool *incomplete);
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200598
599/**
600 * @brief Validate previously incompletely stored value.
601 *
602 * @param[in] ctx libyang context.
603 * @param[in] type Schema type of the value (not the stored one, but the original one).
604 * @param[in,out] val Stored value to resolve.
605 * @param[in] ctx_node Context node for the resolution.
606 * @param[in] tree Data tree for the resolution.
Michal Vaskofeca4fb2020-10-05 08:58:40 +0200607 * @return LY_SUCCESS on success,
608 * @return LY_ERR value on error.
609 */
610LY_ERR lyd_value_validate_incomplete(const struct ly_ctx *ctx, const struct lysc_type *type, struct lyd_value *val,
Radek Krejci2efc45b2020-12-22 16:25:44 +0100611 const struct lyd_node *ctx_node, const struct lyd_node *tree);
Radek Krejci38d85362019-09-05 16:26:38 +0200612
Michal Vaskoaebbce02021-04-06 09:23:37 +0200613/**
Michal Vasko583b4642023-05-25 10:39:34 +0200614 * @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value.
Michal Vaskoaebbce02021-04-06 09:23:37 +0200615 *
616 * This function check just the type's restriction, if you want to check also the data tree context (e.g. in case of
617 * require-instance restriction), use ::lyd_value_validate().
618 *
619 * @param[in] ctx libyang context for logging (function does not log errors when @p ctx is NULL)
620 * @param[in] node Schema node for the @p value.
621 * @param[in] value String value to be checked, expected to be in JSON format.
622 * @param[in] value_len Length of the given @p value (mandatory).
623 * @param[in] format Value prefix format.
624 * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
Michal Vasko583b4642023-05-25 10:39:34 +0200625 * @param[in] hints Value encoding hints.
Michal Vaskoaebbce02021-04-06 09:23:37 +0200626 * @return LY_SUCCESS on success
627 * @return LY_ERR value if an error occurred.
628 */
Michal Vasko583b4642023-05-25 10:39:34 +0200629LY_ERR ly_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
630 LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints);
Michal Vaskof937cfe2020-08-03 16:07:12 +0200631
Radek Krejci38d85362019-09-05 16:26:38 +0200632/**
Radek Krejcie7b95092019-05-15 11:03:07 +0200633 * @defgroup datahash Data nodes hash manipulation
634 * @ingroup datatree
Michal Vasko8081a812021-07-15 09:19:43 +0200635 * @{
Radek Krejcie7b95092019-05-15 11:03:07 +0200636 */
637
638/**
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200639 * @brief Generate hash for the node.
640 *
641 * @param[in] node Data node to (re)generate hash value.
642 * @return LY_ERR value.
643 */
644LY_ERR lyd_hash(struct lyd_node *node);
645
646/**
Ondrej Kusnirik747486a2024-08-19 10:52:44 +0200647 * @brief Compare callback for values in hash table.
648 *
649 * Implementation of ::lyht_value_equal_cb.
650 */
651ly_bool lyd_hash_table_val_equal(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
652
653/**
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200654 * @brief Insert hash of the node into the hash table of its parent.
655 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200656 * @param[in] node Data node which hash will be inserted into the ::lyd_node_inner.children_ht hash table of its parent.
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200657 * @return LY_ERR value.
658 */
659LY_ERR lyd_insert_hash(struct lyd_node *node);
660
661/**
Radek Krejcie7b95092019-05-15 11:03:07 +0200662 * @brief Maintain node's parent's children hash table when unlinking the node.
663 *
664 * When completely freeing data tree, it is expected to free the parent's children hash table first, at once.
665 *
666 * @param[in] node The data node being unlinked from its parent.
667 */
668void lyd_unlink_hash(struct lyd_node *node);
669
670/** @} datahash */
671
Radek Krejci084289f2019-07-09 17:35:30 +0200672/**
Michal Vaskod59035b2020-07-08 12:00:06 +0200673 * @brief Append all list key predicates to path.
674 *
675 * @param[in] node Node with keys to print.
676 * @param[in,out] buffer Buffer to print to.
677 * @param[in,out] buflen Current buffer length.
678 * @param[in,out] bufused Current number of characters used in @p buffer.
679 * @param[in] is_static Whether buffer is static or can be reallocated.
Michal Vaskodbf3e652022-10-21 08:46:25 +0200680 * @return LY_ERR value.
Michal Vaskod59035b2020-07-08 12:00:06 +0200681 */
Radek Krejci857189e2020-09-01 13:26:36 +0200682LY_ERR lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static);
Michal Vaskod59035b2020-07-08 12:00:06 +0200683
Michal Vasko413af592021-12-13 11:50:51 +0100684/**
Michal Vaskodbf3e652022-10-21 08:46:25 +0200685 * @brief Generate a path similar to ::lyd_path() except read the parents from a set.
686 *
687 * @param[in] dnodes Set with the data nodes, from parent to the last descendant.
688 * @param[in] pathtype Type of data path to generate.
689 * @return Generated data path.
690 */
691char *lyd_path_set(const struct ly_set *dnodes, LYD_PATH_TYPE pathtype);
692
693/**
Michal Vasko413af592021-12-13 11:50:51 +0100694 * @brief Remove an object on the specific set index keeping the order of the other objects.
695 *
696 * @param[in] set Set from which a node will be removed.
697 * @param[in] index Index of the object to remove in the \p set.
698 * @param[in] destructor Optional function to free the objects being removed.
Michal Vaskodbf3e652022-10-21 08:46:25 +0200699 * @return LY_ERR value.
Michal Vasko413af592021-12-13 11:50:51 +0100700 */
701LY_ERR ly_set_rm_index_ordered(struct ly_set *set, uint32_t index, void (*destructor)(void *obj));
702
stewegf9041a22024-01-18 13:29:12 +0100703/**
704 * @brief Frees data within leafref links record
705 *
706 * @param[in] rec The leafref links record
707 */
708void lyd_free_leafref_links_rec(struct lyd_leafref_links_rec *rec);
709
710/**
711 * @brief Frees all leafref nodes and target node of given data node
712 *
713 * @param[in] node The data node, which leafref nodes and/or target node should be cleared.
714 */
715void lyd_free_leafref_nodes(const struct lyd_node_term *node);
716
717/**
718 * @brief Gets or creates the leafref links record.
719 *
720 * @param[in] node The term data node.
721 * @param[out] record The leafref links record.
722 * @param[in] create Whether to create record if not exists.
723 * @return LY_SUCCESS on success.
724 * @return LY_ERR value on error.
725 */
726LY_ERR lyd_get_or_create_leafref_links_record(const struct lyd_node_term *node, struct lyd_leafref_links_rec **record, ly_bool create);
727
728/**
steweg67388952024-01-25 12:14:50 +0100729 * @brief Adds links between leafref and data node.
stewegf9041a22024-01-18 13:29:12 +0100730 *
731 * If the links were already added, it will not be added again.
732 * This API requires usage of LY_CTX_LEAFREF_LINKING context flag.
733 *
734 * @param[in] node Data node to which, the leafref is pointing to.
735 * @param[in] leafref_node The leafref, which points to given node.
736 * @return LY_SUCCESS on success.
737 * @return LY_ERR value on error.
738 */
739LY_ERR lyd_link_leafref_node(const struct lyd_node_term *node, const struct lyd_node_term *leafref_node);
740
741/**
steweg67388952024-01-25 12:14:50 +0100742 * @brief Removes links between leafref and data node.
stewegf9041a22024-01-18 13:29:12 +0100743 *
744 * If the links were never added, it will be silently ignored.
745 * This API requires usage of LY_CTX_LEAFREF_LINKING context flag.
746 *
747 * @param[in] node Data node to which, the leafref is pointing to.
748 * @param[in] leafref_node The leafref, which points to given node.
749 * @return LY_SUCCESS on success.
750 * @return LY_ERR value on error.
751 */
752LY_ERR lyd_unlink_leafref_node(const struct lyd_node_term *node, const struct lyd_node_term *leafref_node);
753
aPiecekcada0d72024-01-11 15:04:12 +0100754/**
755 * @brief Unlink the specified data subtree.
756 *
757 * The lyds_unlink() is NOT called in this function.
758 *
aPiecek743184b2024-02-01 13:25:56 +0100759 * @param[in,out] first_sibling Optional, performs an update if @p node is first or @p sibling is last.
aPiecekcada0d72024-01-11 15:04:12 +0100760 * @param[in] node Data tree node to be unlinked (together with all the children).
761 */
aPiecek743184b2024-02-01 13:25:56 +0100762void lyd_unlink_ignore_lyds(struct lyd_node **first_sibling, struct lyd_node *node);
aPiecekcada0d72024-01-11 15:04:12 +0100763
Radek Krejcie7b95092019-05-15 11:03:07 +0200764#endif /* LY_TREE_DATA_INTERNAL_H_ */