blob: a174aa09160c15abcee828a94caeb380e42a8263 [file] [log] [blame]
Radek Krejcib1646a92018-11-02 16:08:26 +01001/**
2 * @file xpath.h
3 * @author Michal Vasko <mvasko@cesnet.cz>
4 * @brief YANG XPath evaluation functions header
5 *
Michal Vasko519fd602020-05-26 12:17:39 +02006 * Copyright (c) 2015 - 2020 CESNET, z.s.p.o.
Radek Krejcib1646a92018-11-02 16:08:26 +01007 *
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
Michal Vasko14676352020-05-29 11:35:55 +020015#ifndef LY_XPATH_H
16#define LY_XPATH_H
Radek Krejcib1646a92018-11-02 16:08:26 +010017
18#include <stdint.h>
19
Radek Krejci535ea9f2020-05-29 16:01:05 +020020#include "config.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020021#include "log.h"
Radek Krejci535ea9f2020-05-29 16:01:05 +020022#include "tree_data.h"
23#include "tree_schema.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020024
25struct ly_ctx;
Radek Krejcie7b95092019-05-15 11:03:07 +020026
Radek Krejcib1646a92018-11-02 16:08:26 +010027/*
28 * XPath evaluator fully compliant with http://www.w3.org/TR/1999/REC-xpath-19991116/
29 * except the following restrictions in the grammar.
30 *
31 * PARSED GRAMMAR
32 *
33 * Full axes are not supported, abbreviated forms must be used,
34 * variables are not supported, "id()" function is not supported,
35 * and processing instruction and comment nodes are not supported,
36 * which is also reflected in the grammar. Undefined rules and
37 * constants are tokens.
38 *
39 * Modified full grammar:
40 *
41 * [1] Expr ::= OrExpr // just an alias
42 *
43 * [2] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath
44 * [3] AbsoluteLocationPath ::= '/' RelativeLocationPath? | '//' RelativeLocationPath
45 * [4] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | RelativeLocationPath '//' Step
46 * [5] Step ::= '@'? NodeTest Predicate* | '.' | '..'
47 * [6] NodeTest ::= NameTest | NodeType '(' ')'
Michal Vaskod3678892020-05-21 10:06:58 +020048 * [7] NameTest ::= '*' | NCName ':' '*' | QName
49 * [8] NodeType ::= 'text' | 'node'
50 * [9] Predicate ::= '[' Expr ']'
51 * [10] PrimaryExpr ::= '(' Expr ')' | Literal | Number | FunctionCall
52 * [11] FunctionCall ::= FunctionName '(' ( Expr ( ',' Expr )* )? ')'
53 * [12] PathExpr ::= LocationPath | PrimaryExpr Predicate*
Radek Krejcib1646a92018-11-02 16:08:26 +010054 * | PrimaryExpr Predicate* '/' RelativeLocationPath
55 * | PrimaryExpr Predicate* '//' RelativeLocationPath
Michal Vaskod3678892020-05-21 10:06:58 +020056 * [13] OrExpr ::= AndExpr | OrExpr 'or' AndExpr
57 * [14] AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr
58 * [15] EqualityExpr ::= RelationalExpr | EqualityExpr '=' RelationalExpr
Radek Krejcib1646a92018-11-02 16:08:26 +010059 * | EqualityExpr '!=' RelationalExpr
Michal Vaskod3678892020-05-21 10:06:58 +020060 * [16] RelationalExpr ::= AdditiveExpr
Radek Krejcib1646a92018-11-02 16:08:26 +010061 * | RelationalExpr '<' AdditiveExpr
62 * | RelationalExpr '>' AdditiveExpr
63 * | RelationalExpr '<=' AdditiveExpr
64 * | RelationalExpr '>=' AdditiveExpr
Michal Vaskod3678892020-05-21 10:06:58 +020065 * [17] AdditiveExpr ::= MultiplicativeExpr
Radek Krejcib1646a92018-11-02 16:08:26 +010066 * | AdditiveExpr '+' MultiplicativeExpr
67 * | AdditiveExpr '-' MultiplicativeExpr
Michal Vaskod3678892020-05-21 10:06:58 +020068 * [18] MultiplicativeExpr ::= UnaryExpr
Radek Krejcib1646a92018-11-02 16:08:26 +010069 * | MultiplicativeExpr '*' UnaryExpr
70 * | MultiplicativeExpr 'div' UnaryExpr
71 * | MultiplicativeExpr 'mod' UnaryExpr
Michal Vaskod3678892020-05-21 10:06:58 +020072 * [19] UnaryExpr ::= UnionExpr | '-' UnaryExpr
73 * [20] UnionExpr ::= PathExpr | UnionExpr '|' PathExpr
Radek Krejcib1646a92018-11-02 16:08:26 +010074 */
75
76/* expression tokens allocation */
77#define LYXP_EXPR_SIZE_START 10
78#define LYXP_EXPR_SIZE_STEP 5
79
80/* XPath matches allocation */
81#define LYXP_SET_SIZE_START 2
82#define LYXP_SET_SIZE_STEP 2
83
84/* building string when casting */
85#define LYXP_STRING_CAST_SIZE_START 64
86#define LYXP_STRING_CAST_SIZE_STEP 16
87
88/**
89 * @brief Tokens that can be in an XPath expression.
90 */
91enum lyxp_token {
92 LYXP_TOKEN_NONE = 0,
93 LYXP_TOKEN_PAR1, /* '(' */
94 LYXP_TOKEN_PAR2, /* ')' */
95 LYXP_TOKEN_BRACK1, /* '[' */
96 LYXP_TOKEN_BRACK2, /* ']' */
97 LYXP_TOKEN_DOT, /* '.' */
98 LYXP_TOKEN_DDOT, /* '..' */
99 LYXP_TOKEN_AT, /* '@' */
100 LYXP_TOKEN_COMMA, /* ',' */
101 /* LYXP_TOKEN_DCOLON, * '::' * axes not supported */
102 LYXP_TOKEN_NAMETEST, /* NameTest */
103 LYXP_TOKEN_NODETYPE, /* NodeType */
104 LYXP_TOKEN_FUNCNAME, /* FunctionName */
105 LYXP_TOKEN_OPERATOR_LOG, /* Operator 'and', 'or' */
106 LYXP_TOKEN_OPERATOR_COMP, /* Operator '=', '!=', '<', '<=', '>', '>=' */
107 LYXP_TOKEN_OPERATOR_MATH, /* Operator '+', '-', '*', 'div', 'mod', '-' (unary) */
108 LYXP_TOKEN_OPERATOR_UNI, /* Operator '|' */
Michal Vasko14676352020-05-29 11:35:55 +0200109 LYXP_TOKEN_OPERATOR_PATH, /* Operator '/' */
110 LYXP_TOKEN_OPERATOR_RPATH,/* Operator '//' (recursive path) */
Radek Krejcib1646a92018-11-02 16:08:26 +0100111 /* LYXP_TOKEN_AXISNAME, * AxisName * axes not supported */
112 LYXP_TOKEN_LITERAL, /* Literal - with either single or double quote */
113 LYXP_TOKEN_NUMBER /* Number */
114};
115
116/**
117 * @brief XPath (sub)expressions that can be repeated.
118 */
119enum lyxp_expr_type {
120 LYXP_EXPR_NONE = 0,
121 LYXP_EXPR_OR,
122 LYXP_EXPR_AND,
123 LYXP_EXPR_EQUALITY,
124 LYXP_EXPR_RELATIONAL,
125 LYXP_EXPR_ADDITIVE,
126 LYXP_EXPR_MULTIPLICATIVE,
127 LYXP_EXPR_UNARY,
128 LYXP_EXPR_UNION,
129};
130
131/**
Michal Vasko03ff5a72019-09-11 13:49:33 +0200132 * @brief Types of context nodes, #LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
133 */
134enum lyxp_node_type {
Michal Vasko2caefc12019-11-14 16:07:56 +0100135 LYXP_NODE_NONE, /* invalid node type */
136
Michal Vasko03ff5a72019-09-11 13:49:33 +0200137 /* XML document roots */
138 LYXP_NODE_ROOT, /* access to all the data (node value first top-level node) */
139 LYXP_NODE_ROOT_CONFIG, /* <running> data context, no state data (node value first top-level node) */
140
141 /* XML elements */
Michal Vasko9f96a052020-03-10 09:41:45 +0100142 LYXP_NODE_ELEM, /* YANG data element (most common) */
143 LYXP_NODE_TEXT, /* YANG data text element (extremely specific use, unlikely to be ever needed) */
144 LYXP_NODE_META /* YANG metadata (do not use for the context node) */
Michal Vasko03ff5a72019-09-11 13:49:33 +0200145};
146
147/**
Radek Krejcib1646a92018-11-02 16:08:26 +0100148 * @brief Structure holding a parsed XPath expression.
149 */
150struct lyxp_expr {
151 enum lyxp_token *tokens; /* array of tokens */
152 uint16_t *tok_pos; /* array of the token offsets in expr */
153 uint16_t *tok_len; /* array of token lengths in expr */
154 enum lyxp_expr_type **repeat; /* array of expression types that this token begins and is repeated ended with 0,
155 more in the comment after this declaration */
156 uint16_t used; /* used array items */
157 uint16_t size; /* allocated array items */
158
159 const char *expr; /* the original XPath expression */
160};
161
162/*
163 * lyxp_expr repeat
164 *
165 * This value is NULL for all the tokens that do not begin an
166 * expression which can be repeated. Otherwise it is an array
167 * of expression types that this token begins. These values
168 * are used during evaluation to know whether we need to
169 * duplicate the current context or not and to decide what
170 * the current expression is (for example, if we are only
171 * starting the parsing and the first token has no repeat,
172 * we do not parse it as an OrExpr but directly as PathExpr).
173 * Examples:
174 *
175 * Expression: "/ *[key1 and key2 or key1 < key2]"
176 * Tokens: '/', '*', '[', NameTest, 'and', NameTest, 'or', NameTest, '<', NameTest, ']'
177 * Repeat: NULL, NULL, NULL, [AndExpr, NULL, NULL, NULL, [RelationalExpr, NULL, NULL, NULL
178 * OrExpr, 0],
179 * 0],
180 *
181 * Expression: "//node[key and node2]/key | /cont"
182 * Tokens: '//', 'NameTest', '[', 'NameTest', 'and', 'NameTest', ']', '/', 'NameTest', '|', '/', 'NameTest'
183 * Repeat: [UnionExpr, NULL, NULL, [AndExpr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
184 * 0], 0],
185 *
186 * Operators between expressions which this concerns:
187 * 'or', 'and', '=', '!=', '<', '>', '<=', '>=', '+', '-', '*', 'div', 'mod', '|'
188 */
189
190/**
191 * @brief Supported types of (partial) XPath results.
192 */
193enum lyxp_set_type {
Michal Vaskod3678892020-05-21 10:06:58 +0200194 LYXP_SET_NODE_SET = 0,
Michal Vasko03ff5a72019-09-11 13:49:33 +0200195 LYXP_SET_SCNODE_SET,
Radek Krejcib1646a92018-11-02 16:08:26 +0100196 LYXP_SET_BOOLEAN,
197 LYXP_SET_NUMBER,
198 LYXP_SET_STRING
199};
Radek Krejcib1646a92018-11-02 16:08:26 +0100200
201/**
202 * @brief Item stored in an XPath set hash table.
203 */
204struct lyxp_set_hash_node {
205 struct lyd_node *node;
206 enum lyxp_node_type type;
207} _PACKED;
208
Radek Krejcib1646a92018-11-02 16:08:26 +0100209/**
210 * @brief XPath set - (partial) result.
211 */
212struct lyxp_set {
213 enum lyxp_set_type type;
214 union {
215 struct lyxp_set_node {
216 struct lyd_node *node;
217 enum lyxp_node_type type;
218 uint32_t pos;
219 } *nodes;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200220 struct lyxp_set_scnode {
221 struct lysc_node *scnode;
Radek Krejcib1646a92018-11-02 16:08:26 +0100222 enum lyxp_node_type type;
Michal Vasko5c4e5892019-11-14 12:31:38 +0100223 /* -2 - scnode not traversed, currently (the only node) in context;
224 * -1 - scnode not traversed except for the eval start, not currently in the context;
225 * 0 - scnode was traversed, but not currently in the context;
226 * 1 - scnode currently in context;
227 * 2 - scnode in context and just added, so skip it for the current operation;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200228 * >=3 - scnode is not in context because we are in a predicate and this scnode was used/will be used later */
Michal Vasko5c4e5892019-11-14 12:31:38 +0100229 int32_t in_ctx;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200230 } *scnodes;
Michal Vasko9f96a052020-03-10 09:41:45 +0100231 struct lyxp_set_meta {
232 struct lyd_meta *meta;
Radek Krejcib1646a92018-11-02 16:08:26 +0100233 enum lyxp_node_type type;
Michal Vasko9f96a052020-03-10 09:41:45 +0100234 uint32_t pos; /* if node_type is LYXP_SET_NODE_META, it is the parent node position */
235 } *meta;
Radek Krejcib1646a92018-11-02 16:08:26 +0100236 char *str;
237 long double num;
238 int bool;
239 } val;
240
Michal Vasko03ff5a72019-09-11 13:49:33 +0200241 /* this is valid only for type LYXP_SET_NODE_SET and LYXP_SET_SCNODE_SET */
Radek Krejcib1646a92018-11-02 16:08:26 +0100242 uint32_t used;
243 uint32_t size;
Radek Krejcib1646a92018-11-02 16:08:26 +0100244 struct hash_table *ht;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200245
246 /* XPath context information, this is valid only for type LYXP_SET_NODE_SET */
Radek Krejcib1646a92018-11-02 16:08:26 +0100247 uint32_t ctx_pos;
248 uint32_t ctx_size;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200249
250 /* general context */
251 struct ly_ctx *ctx;
252 union {
253 const struct lyd_node *ctx_node;
254 const struct lysc_node *ctx_scnode;
255 };
Michal Vasko5e0e6eb2019-11-06 15:47:50 +0100256 enum lyxp_node_type root_type;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200257 const struct lys_module *local_mod;
Michal Vaskof03ed032020-03-04 13:31:44 +0100258 const struct lyd_node *tree;
Michal Vasko03ff5a72019-09-11 13:49:33 +0200259 LYD_FORMAT format;
Radek Krejcib1646a92018-11-02 16:08:26 +0100260};
261
262/**
Michal Vasko24cddf82020-06-01 08:17:01 +0200263 * @brief Print an XPath token \p tok type.
264 *
265 * @param[in] tok Token to print.
266 * @return Token type string.
267 */
268const char *lyxp_print_token(enum lyxp_token tok);
269
270/**
Michal Vasko03ff5a72019-09-11 13:49:33 +0200271 * @brief Evaluate an XPath expression on data. Be careful when using this function, the result can often
272 * be confusing without thorough understanding of XPath evaluation rules defined in RFC 7950.
Radek Krejcib1646a92018-11-02 16:08:26 +0100273 *
Michal Vaskoecd62de2019-11-13 12:35:11 +0100274 * @param[in] exp Parsed XPath expression to be evaluated.
Michal Vasko03ff5a72019-09-11 13:49:33 +0200275 * @param[in] format Format of the XPath expression (more specifcally, of any used prefixes).
276 * @param[in] local_mod Local module relative to the @p expr.
Michal Vaskod0aa1a82019-11-07 08:58:42 +0100277 * @param[in] ctx_node Current (context) data node, NULL for root node.
Michal Vasko03ff5a72019-09-11 13:49:33 +0200278 * @param[in] ctx_node_type Current (context) data node type. For every standard case use #LYXP_NODE_ELEM. But there are
279 * cases when the context node @p ctx_node is actually supposed to be the XML root, there is no such data node. So, in
Michal Vaskod0aa1a82019-11-07 08:58:42 +0100280 * this case just pass NULL for @p ctx_node and use an enum value for this kind of root (#LYXP_NODE_ROOT_CONFIG if
281 * @p ctx_node has config true, otherwise #LYXP_NODE_ROOT). #LYXP_NODE_TEXT and #LYXP_NODE_ATTR can also be used,
Radek Krejcib1646a92018-11-02 16:08:26 +0100282 * but there are no use-cases in YANG.
Michal Vaskof03ed032020-03-04 13:31:44 +0100283 * @param[in] tree Data tree on which to perform the evaluation, it must include all the available data (including
Michal Vaskod0aa1a82019-11-07 08:58:42 +0100284 * the tree of @p ctx_node).
Michal Vasko03ff5a72019-09-11 13:49:33 +0200285 * @param[out] set Result set. Must be valid and in the same libyang context as @p ctx_node.
286 * To be safe, always either zero or cast the @p set to empty. After done using, either cast
287 * the @p set to empty (if allocated statically) or free it (if allocated dynamically) to
Radek Krejcib1646a92018-11-02 16:08:26 +0100288 * prevent memory leaks.
289 * @param[in] options Whether to apply some evaluation restrictions.
Michal Vaskoecd62de2019-11-13 12:35:11 +0100290 * @return LY_ERR (LY_EINVAL, LY_EMEM, LY_EINT, LY_EVALID for invalid argument types/count,
291 * LY_EINCOMPLETE for unresolved when).
Radek Krejcib1646a92018-11-02 16:08:26 +0100292 */
Michal Vaskoecd62de2019-11-13 12:35:11 +0100293LY_ERR lyxp_eval(struct lyxp_expr *exp, LYD_FORMAT format, const struct lys_module *local_mod, const struct lyd_node *ctx_node,
Michal Vaskof03ed032020-03-04 13:31:44 +0100294 enum lyxp_node_type ctx_node_type, const struct lyd_node *tree, struct lyxp_set *set, int options);
Michal Vasko03ff5a72019-09-11 13:49:33 +0200295
296#define LYXP_SCHEMA 0x01 /**< Apply data node access restrictions defined for 'when' and 'must' evaluation. */
Radek Krejcib1646a92018-11-02 16:08:26 +0100297
298/**
Michal Vasko03ff5a72019-09-11 13:49:33 +0200299 * @brief Get all the partial XPath nodes (atoms) that are required for @p exp to be evaluated.
Radek Krejcib1646a92018-11-02 16:08:26 +0100300 *
Michal Vasko03ff5a72019-09-11 13:49:33 +0200301 * @param[in] exp Parsed XPath expression to be evaluated.
302 * @param[in] format Format of the XPath expression (more specifcally, of any used prefixes).
303 * @param[in] local_mod Local module relative to the @p exp.
Michal Vaskod0aa1a82019-11-07 08:58:42 +0100304 * @param[in] ctx_scnode Current (context) schema node, NULL for root node.
Michal Vasko03ff5a72019-09-11 13:49:33 +0200305 * @param[in] ctx_scnode_type Current (context) schema node type.
306 * @param[out] set Result set. Must be valid and in the same libyang context as @p ctx_scnode.
307 * To be safe, always either zero or cast the @p set to empty. After done using, either cast
308 * the @p set to empty (if allocated statically) or free it (if allocated dynamically) to
Radek Krejcib1646a92018-11-02 16:08:26 +0100309 * prevent memory leaks.
310 * @param[in] options Whether to apply some evaluation restrictions, one flag must always be used.
Michal Vaskoecd62de2019-11-13 12:35:11 +0100311 * @return LY_ERR (same as lyxp_eval()).
Radek Krejcib1646a92018-11-02 16:08:26 +0100312 */
Michal Vasko03ff5a72019-09-11 13:49:33 +0200313LY_ERR lyxp_atomize(struct lyxp_expr *exp, LYD_FORMAT format, const struct lys_module *local_mod, const struct lysc_node *ctx_scnode,
314 enum lyxp_node_type ctx_scnode_type, struct lyxp_set *set, int options);
Radek Krejcib1646a92018-11-02 16:08:26 +0100315
Michal Vasko519fd602020-05-26 12:17:39 +0200316/* used only internally */
Michal Vasko03ff5a72019-09-11 13:49:33 +0200317#define LYXP_SCNODE_ALL 0x0E
Radek Krejcib1646a92018-11-02 16:08:26 +0100318
319/**
Radek Krejcib1646a92018-11-02 16:08:26 +0100320 * @brief Cast XPath set to another type.
321 * Indirectly context position aware.
322 *
323 * @param[in] set Set to cast.
324 * @param[in] target Target type to cast \p set into.
Michal Vasko03ff5a72019-09-11 13:49:33 +0200325 * @return LY_ERR
Radek Krejcib1646a92018-11-02 16:08:26 +0100326 */
Michal Vasko5e0e6eb2019-11-06 15:47:50 +0100327LY_ERR lyxp_set_cast(struct lyxp_set *set, enum lyxp_set_type target);
Michal Vasko03ff5a72019-09-11 13:49:33 +0200328
Radek Krejcib1646a92018-11-02 16:08:26 +0100329/**
Michal Vaskod3678892020-05-21 10:06:58 +0200330 * @brief Free dynamic content of a set.
331 *
332 * @param[in] set Set to modify.
333 */
334void lyxp_set_free_content(struct lyxp_set *set);
335
336/**
Michal Vaskoecd62de2019-11-13 12:35:11 +0100337 * @brief Insert schema node into set.
338 *
339 * @param[in] set Set to insert into.
340 * @param[in] node Node to insert.
341 * @param[in] node_type Node type of @p node.
342 * @return Index of the inserted node in set.
343 */
344int lyxp_set_scnode_insert_node(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type);
345
346/**
347 * @brief Check for duplicates in a schema node set.
348 *
349 * @param[in] set Set to check.
350 * @param[in] node Node to look for in @p set.
351 * @param[in] node_type Type of @p node.
352 * @param[in] skip_idx Index from @p set to skip.
353 * @return Index of the found node, -1 if not found.
354 */
355int lyxp_set_scnode_dup_node_check(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type,
356 int skip_idx);
357
358/**
359 * @brief Merge 2 schema node sets.
360 *
361 * @param[in] set1 Set to merge into.
362 * @param[in] set2 Set to merge. Its content is freed.
363 */
364void lyxp_set_scnode_merge(struct lyxp_set *set1, struct lyxp_set *set2);
365
366/**
Radek Krejcib1646a92018-11-02 16:08:26 +0100367 * @brief Parse an XPath expression into a structure of tokens.
368 * Logs directly.
369 *
Michal Vasko03ff5a72019-09-11 13:49:33 +0200370 * https://www.w3.org/TR/1999/REC-xpath-19991116/#exprlex
Radek Krejcib1646a92018-11-02 16:08:26 +0100371 *
372 * @param[in] ctx Context for errors.
373 * @param[in] expr XPath expression to parse. It is duplicated.
Radek Krejcib1646a92018-11-02 16:08:26 +0100374 * @return Filled expression structure or NULL on error.
375 */
Michal Vasko14676352020-05-29 11:35:55 +0200376struct lyxp_expr *lyxp_expr_parse(const struct ly_ctx *ctx, const char *expr);
377
378/**
379 * @brief Look at the next token and check its kind.
380 *
381 * @param[in] ctx Context for logging, not logged if NULL.
382 * @param[in] exp Expression to use.
383 * @param[in] exp_idx Position in the expression \p exp.
384 * @param[in] want_tok Expected token.
385 * @return LY_EINCOMPLETE on EOF,
386 * @return LY_ENOT on non-matching token,
387 * @return LY_SUCCESS on success.
388 */
Michal Vasko24cddf82020-06-01 08:17:01 +0200389LY_ERR lyxp_check_token(const struct ly_ctx *ctx, const struct lyxp_expr *exp, uint16_t exp_idx, enum lyxp_token want_tok);
Radek Krejcib1646a92018-11-02 16:08:26 +0100390
391/**
Michal Vasko03ff5a72019-09-11 13:49:33 +0200392 * @brief Frees a parsed XPath expression. @p expr should not be used afterwards.
Radek Krejcib1646a92018-11-02 16:08:26 +0100393 *
394 * @param[in] ctx libyang context of the expression.
395 * @param[in] expr Expression to free.
396 */
Michal Vasko14676352020-05-29 11:35:55 +0200397void lyxp_expr_free(const struct ly_ctx *ctx, struct lyxp_expr *expr);
Radek Krejcib1646a92018-11-02 16:08:26 +0100398
Michal Vasko14676352020-05-29 11:35:55 +0200399#endif /* LY_XPATH_H */