libyang 2.0.231
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
xpath1.0.c
Go to the documentation of this file.
1
15#define _GNU_SOURCE
16
17#include "plugins_types.h"
18
19#include <assert.h>
20#include <stdint.h>
21#include <stdlib.h>
22#include <string.h>
23
24#include "libyang.h"
25
26#include "common.h"
27#include "compat.h"
28
29/* internal headers */
30#include "xml.h"
31#include "xpath.h"
32
42LIBYANG_API_DEF LY_ERR
43lyplg_type_xpath10_print_token(const char *token, uint16_t tok_len, ly_bool is_nametest, const struct lys_module **context_mod,
44 const struct ly_ctx *resolve_ctx, LY_VALUE_FORMAT resolve_format, const void *resolve_prefix_data,
45 LY_VALUE_FORMAT get_format, void *get_prefix_data, char **token_p, struct ly_err_item **err)
46{
47 LY_ERR ret = LY_SUCCESS;
48 const char *str_begin, *str_next, *prefix;
49 ly_bool is_prefix, has_prefix = 0;
50 char *str = NULL;
51 void *mem;
52 uint32_t len, str_len = 0, pref_len;
53 const struct lys_module *mod;
54
55 str_begin = token;
56
57 while (!(ret = ly_value_prefix_next(str_begin, token + tok_len, &len, &is_prefix, &str_next)) && len) {
58 if (!is_prefix) {
59 if (!has_prefix && is_nametest && (get_format == LY_VALUE_XML) && *context_mod) {
60 /* prefix is always needed, get it in the target format */
61 prefix = lyplg_type_get_prefix(*context_mod, get_format, get_prefix_data);
62 if (!prefix) {
63 ret = ly_err_new(err, LY_EINT, LYVE_DATA, NULL, NULL, "Internal error.");
64 goto cleanup;
65 }
66
67 /* append the nametest and prefix */
68 mem = realloc(str, str_len + strlen(prefix) + 1 + len + 1);
69 LY_CHECK_ERR_GOTO(!mem, ret = ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, "No memory."), cleanup);
70 str = mem;
71 str_len += sprintf(str + str_len, "%s:%.*s", prefix, len, str_begin);
72 } else {
73 /* just append the string, we may get the first expression node without a prefix but since this
74 * is not strictly forbidden, allow it */
75 mem = realloc(str, str_len + len + 1);
76 LY_CHECK_ERR_GOTO(!mem, ret = ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, "No memory."), cleanup);
77 str = mem;
78 str_len += sprintf(str + str_len, "%.*s", len, str_begin);
79 }
80 } else {
81 /* remember there was a prefix found */
82 has_prefix = 1;
83
84 /* resolve the module in the original format */
85 mod = lyplg_type_identity_module(resolve_ctx, NULL, str_begin, len, resolve_format, resolve_prefix_data);
86 if (!mod && is_nametest) {
87 ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Failed to resolve prefix \"%.*s\".", len, str_begin);
88 goto cleanup;
89 }
90
91 if (is_nametest && ((get_format == LY_VALUE_JSON) || (get_format == LY_VALUE_LYB)) && (*context_mod == mod)) {
92 /* inherit the prefix and do not print it again */
93 } else {
94 if (mod) {
95 /* get the prefix in the target format */
96 prefix = lyplg_type_get_prefix(mod, get_format, get_prefix_data);
97 if (!prefix) {
98 ret = ly_err_new(err, LY_EINT, LYVE_DATA, NULL, NULL, "Internal error.");
99 goto cleanup;
100 }
101 pref_len = strlen(prefix);
102 } else {
103 /* invalid prefix, just copy it */
104 prefix = str_begin;
105 pref_len = len;
106 }
107
108 /* append the prefix */
109 mem = realloc(str, str_len + pref_len + 2);
110 LY_CHECK_ERR_GOTO(!mem, ret = ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, "No memory."), cleanup);
111 str = mem;
112 str_len += sprintf(str + str_len, "%.*s:", (int)pref_len, prefix);
113 }
114
115 if (is_nametest) {
116 /* update context module */
117 *context_mod = mod;
118 }
119 }
120
121 str_begin = str_next;
122 }
123
124cleanup:
125 if (ret) {
126 free(str);
127 } else {
128 *token_p = str;
129 }
130 return ret;
131}
132
148static LY_ERR
149xpath10_print_subexpr_r(uint16_t *cur_idx, enum lyxp_token end_tok, const struct lys_module *context_mod,
150 const struct lyd_value_xpath10 *xp_val, LY_VALUE_FORMAT format, void *prefix_data, char **str_value,
151 uint32_t *str_len, struct ly_err_item **err)
152{
153 enum lyxp_token cur_tok, sub_end_tok;
154 char *str_tok;
155 void *mem;
156 const char *cur_exp_ptr;
157 ly_bool is_nt;
158 const struct lys_module *orig_context_mod = context_mod;
159
160 while (*cur_idx < xp_val->exp->used) {
161 cur_tok = xp_val->exp->tokens[*cur_idx];
162 cur_exp_ptr = xp_val->exp->expr + xp_val->exp->tok_pos[*cur_idx];
163
164 if ((cur_tok == LYXP_TOKEN_NAMETEST) || (cur_tok == LYXP_TOKEN_LITERAL)) {
165 /* tokens that may include prefixes, get them in the target format */
166 is_nt = (cur_tok == LYXP_TOKEN_NAMETEST) ? 1 : 0;
167 LY_CHECK_RET(lyplg_type_xpath10_print_token(cur_exp_ptr, xp_val->exp->tok_len[*cur_idx], is_nt, &context_mod,
168 xp_val->ctx, xp_val->format, xp_val->prefix_data, format, prefix_data, &str_tok, err));
169
170 /* append the converted token */
171 mem = realloc(*str_value, *str_len + strlen(str_tok) + 1);
172 LY_CHECK_ERR_GOTO(!mem, free(str_tok), error_mem);
173 *str_value = mem;
174 *str_len += sprintf(*str_value + *str_len, "%s", str_tok);
175 free(str_tok);
176
177 /* token processed */
178 ++(*cur_idx);
179 } else {
180 if ((cur_tok == LYXP_TOKEN_OPER_LOG) || (cur_tok == LYXP_TOKEN_OPER_UNI) || (cur_tok == LYXP_TOKEN_OPER_MATH)) {
181 /* copy the token with spaces around */
182 mem = realloc(*str_value, *str_len + 1 + xp_val->exp->tok_len[*cur_idx] + 2);
183 LY_CHECK_GOTO(!mem, error_mem);
184 *str_value = mem;
185 *str_len += sprintf(*str_value + *str_len, " %.*s ", (int)xp_val->exp->tok_len[*cur_idx], cur_exp_ptr);
186
187 /* reset context mod */
188 context_mod = orig_context_mod;
189 } else {
190 /* just copy the token */
191 mem = realloc(*str_value, *str_len + xp_val->exp->tok_len[*cur_idx] + 1);
192 LY_CHECK_GOTO(!mem, error_mem);
193 *str_value = mem;
194 *str_len += sprintf(*str_value + *str_len, "%.*s", (int)xp_val->exp->tok_len[*cur_idx], cur_exp_ptr);
195 }
196
197 /* token processed but keep it in cur_tok */
198 ++(*cur_idx);
199
200 if (end_tok && (cur_tok == end_tok)) {
201 /* end token found */
202 break;
203 } else if ((cur_tok == LYXP_TOKEN_BRACK1) || (cur_tok == LYXP_TOKEN_PAR1)) {
204 sub_end_tok = (cur_tok == LYXP_TOKEN_BRACK1) ? LYXP_TOKEN_BRACK2 : LYXP_TOKEN_PAR2;
205
206 /* parse the subexpression separately, use the current context mod */
207 LY_CHECK_RET(xpath10_print_subexpr_r(cur_idx, sub_end_tok, context_mod, xp_val, format, prefix_data,
208 str_value, str_len, err));
209 }
210 }
211 }
212
213 return LY_SUCCESS;
214
215error_mem:
216 return ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, "No memory.");
217}
218
219LIBYANG_API_DEF LY_ERR
220lyplg_type_print_xpath10_value(const struct lyd_value_xpath10 *xp_val, LY_VALUE_FORMAT format, void *prefix_data,
221 char **str_value, struct ly_err_item **err)
222{
223 LY_ERR ret = LY_SUCCESS;
224 uint16_t expr_idx = 0;
225 uint32_t str_len = 0;
226
227 *str_value = NULL;
228 *err = NULL;
229
230 /* recursively print the expression */
231 ret = xpath10_print_subexpr_r(&expr_idx, 0, NULL, xp_val, format, prefix_data, str_value, &str_len, err);
232
233 if (ret) {
234 free(*str_value);
235 *str_value = NULL;
236 }
237 return ret;
238}
239
240LIBYANG_API_DEF LY_ERR
241lyplg_type_store_xpath10(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
242 uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node,
243 struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
244{
245 LY_ERR ret = LY_SUCCESS;
246 struct lysc_type_str *type_str = (struct lysc_type_str *)type;
247 struct lyd_value_xpath10 *val;
248 char *canon;
249
250 /* init storage */
251 memset(storage, 0, sizeof *storage);
252 LYPLG_TYPE_VAL_INLINE_PREPARE(storage, val);
253 LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
254 storage->realtype = type;
255
256 /* check hints */
257 ret = lyplg_type_check_hints(hints, value, value_len, type->basetype, NULL, err);
258 LY_CHECK_GOTO(ret, cleanup);
259
260 /* length restriction of the string */
261 if (type_str->length) {
262 /* value_len is in bytes, but we need number of characters here */
263 ret = lyplg_type_validate_range(LY_TYPE_STRING, type_str->length, ly_utf8len(value, value_len), value, value_len, err);
264 LY_CHECK_GOTO(ret, cleanup);
265 }
266
267 /* pattern restrictions */
268 ret = lyplg_type_validate_patterns(type_str->patterns, value, value_len, err);
269 LY_CHECK_GOTO(ret, cleanup);
270
271 /* parse */
272 ret = lyxp_expr_parse(ctx, value_len ? value : "", value_len, 1, &val->exp);
273 LY_CHECK_GOTO(ret, cleanup);
274 val->ctx = ctx;
275
276 if (ctx_node && !strcmp(ctx_node->name, "parent-reference") && !strcmp(ctx_node->module->name, "ietf-yang-schema-mount")) {
277 /* special case, this type uses prefix-namespace mapping provided directly in data, keep empty for now */
279 ret = ly_set_new((struct ly_set **)&val->prefix_data);
280 LY_CHECK_GOTO(ret, cleanup);
281 } else {
282 /* store format-specific data and context for later prefix resolution */
283 ret = lyplg_type_prefix_data_new(ctx, value, value_len, format, prefix_data, &val->format, &val->prefix_data);
284 LY_CHECK_GOTO(ret, cleanup);
285 }
286
287 switch (format) {
288 case LY_VALUE_CANON:
289 case LY_VALUE_JSON:
290 case LY_VALUE_LYB:
291 case LY_VALUE_STR_NS:
292 /* store canonical value */
293 if (options & LYPLG_TYPE_STORE_DYNAMIC) {
294 ret = lydict_insert_zc(ctx, (char *)value, &storage->_canonical);
295 options &= ~LYPLG_TYPE_STORE_DYNAMIC;
296 LY_CHECK_GOTO(ret, cleanup);
297 } else {
298 ret = lydict_insert(ctx, value_len ? value : "", value_len, &storage->_canonical);
299 LY_CHECK_GOTO(ret, cleanup);
300 }
301 break;
302 case LY_VALUE_SCHEMA:
304 case LY_VALUE_XML:
305 /* JSON format with prefix is the canonical one */
306 ret = lyplg_type_print_xpath10_value(val, LY_VALUE_JSON, NULL, &canon, err);
307 LY_CHECK_GOTO(ret, cleanup);
308
309 ret = lydict_insert_zc(ctx, canon, &storage->_canonical);
310 LY_CHECK_GOTO(ret, cleanup);
311 break;
312 }
313
314cleanup:
315 if (options & LYPLG_TYPE_STORE_DYNAMIC) {
316 free((void *)value);
317 }
318
319 if (ret) {
321 } else if (val->format == LY_VALUE_STR_NS) {
322 /* needs validation */
323 return LY_EINCOMPLETE;
324 }
325 return ret;
326}
327
331static LY_ERR
332lyplg_type_validate_xpath10(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *UNUSED(type),
333 const struct lyd_node *ctx_node, const struct lyd_node *UNUSED(tree), struct lyd_value *storage,
334 struct ly_err_item **err)
335{
336 LY_ERR ret = LY_SUCCESS;
337 struct lyd_value_xpath10 *val;
338 struct ly_set *set = NULL;
339 uint32_t i;
340 const char *pref, *uri;
341 struct lyxml_ns *ns;
342
343 *err = NULL;
344 LYD_VALUE_GET(storage, val);
345
346 if (val->format != LY_VALUE_STR_NS) {
347 /* nothing to validate */
348 return LY_SUCCESS;
349 }
350
351 /* the XML namespace set must exist */
352 assert(val->prefix_data);
353
354 /* special handling of this particular node */
355 assert(!strcmp(LYD_NAME(ctx_node), "parent-reference") &&
356 !strcmp(ctx_node->schema->module->name, "ietf-yang-schema-mount"));
357
358 /* get all the prefix mappings */
359 if ((ret = lyd_find_xpath(ctx_node, "../../../namespace", &set))) {
360 goto cleanup;
361 }
362
363 for (i = 0; i < set->count; ++i) {
364 assert(!strcmp(LYD_NAME(lyd_child(set->dnodes[i])), "prefix"));
365 pref = lyd_get_value(lyd_child(set->dnodes[i]));
366
367 if (!lyd_child(set->dnodes[i])->next) {
368 /* missing URI - invalid mapping, skip */
369 continue;
370 }
371 assert(!strcmp(LYD_NAME(lyd_child(set->dnodes[i])->next), "uri"));
372 uri = lyd_get_value(lyd_child(set->dnodes[i])->next);
373
374 /* create new ns */
375 ns = calloc(1, sizeof *ns);
376 if (!ns) {
377 ret = LY_EMEM;
378 goto cleanup;
379 }
380 ns->prefix = strdup(pref);
381 ns->uri = strdup(uri);
382 if (!ns->prefix || !ns->uri) {
383 free(ns->prefix);
384 free(ns->uri);
385 free(ns);
386 ret = LY_EMEM;
387 goto cleanup;
388 }
389 ns->depth = 1;
390
391 /* add into the XML namespace set */
392 if ((ret = ly_set_add(val->prefix_data, ns, 1, NULL))) {
393 free(ns->prefix);
394 free(ns->uri);
395 free(ns);
396 goto cleanup;
397 }
398 }
399
400cleanup:
401 ly_set_free(set, NULL);
402 if (ret == LY_EMEM) {
403 ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, LY_EMEM_MSG);
404 } else if (ret) {
405 ly_err_new(err, ret, LYVE_DATA, NULL, NULL, "%s", ly_errmsg(LYD_CTX(ctx_node)));
406 }
407 return ret;
408}
409
410LIBYANG_API_DEF const void *
411lyplg_type_print_xpath10(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
412 void *prefix_data, ly_bool *dynamic, size_t *value_len)
413{
414 struct lyd_value_xpath10 *val;
415 char *ret;
416 struct ly_err_item *err = NULL;
417
418 LYD_VALUE_GET(value, val);
419
420 /* LY_VALUE_STR_NS should never be transformed */
421 if ((val->format == LY_VALUE_STR_NS) || (format == LY_VALUE_CANON) || (format == LY_VALUE_JSON) ||
422 (format == LY_VALUE_LYB)) {
423 /* canonical */
424 if (dynamic) {
425 *dynamic = 0;
426 }
427 if (value_len) {
428 *value_len = strlen(value->_canonical);
429 }
430 return value->_canonical;
431 }
432
433 /* print in the specific format */
434 if (lyplg_type_print_xpath10_value(val, format, prefix_data, &ret, &err)) {
435 if (err) {
436 LOGVAL_ERRITEM(ctx, err);
437 ly_err_free(err);
438 }
439 return NULL;
440 }
441
442 *dynamic = 1;
443 if (value_len) {
444 *value_len = strlen(ret);
445 }
446 return ret;
447}
448
449LIBYANG_API_DEF LY_ERR
450lyplg_type_dup_xpath10(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
451{
452 LY_ERR ret = LY_SUCCESS;
453 struct lyd_value_xpath10 *orig_val, *dup_val;
454
455 /* init dup value */
456 memset(dup, 0, sizeof *dup);
457 dup->realtype = original->realtype;
458
459 ret = lydict_insert(ctx, original->_canonical, 0, &dup->_canonical);
460 LY_CHECK_GOTO(ret, cleanup);
461
462 LYPLG_TYPE_VAL_INLINE_PREPARE(dup, dup_val);
463 LY_CHECK_ERR_GOTO(!dup_val, LOGMEM(ctx); ret = LY_EMEM, cleanup);
464 dup_val->ctx = ctx;
465
466 LYD_VALUE_GET(original, orig_val);
467 ret = lyxp_expr_dup(ctx, orig_val->exp, &dup_val->exp);
468 LY_CHECK_GOTO(ret, cleanup);
469
470 ret = lyplg_type_prefix_data_dup(ctx, orig_val->format, orig_val->prefix_data, &dup_val->prefix_data);
471 LY_CHECK_GOTO(ret, cleanup);
472 dup_val->format = orig_val->format;
473
474cleanup:
475 if (ret) {
477 }
478 return ret;
479}
480
481LIBYANG_API_DEF void
482lyplg_type_free_xpath10(const struct ly_ctx *ctx, struct lyd_value *value)
483{
484 struct lyd_value_xpath10 *val;
485
487 value->_canonical = NULL;
488 LYD_VALUE_GET(value, val);
489 if (val) {
490 lyxp_expr_free(ctx, val->exp);
492
494 }
495}
496
505 {
506 .module = "ietf-yang-types",
507 .revision = "2013-07-15",
508 .name = "xpath1.0",
509
510 .plugin.id = "libyang 2 - xpath1.0, version 1",
511 .plugin.store = lyplg_type_store_xpath10,
512 .plugin.validate = lyplg_type_validate_xpath10,
513 .plugin.compare = lyplg_type_compare_simple,
514 .plugin.sort = NULL,
515 .plugin.print = lyplg_type_print_xpath10,
516 .plugin.duplicate = lyplg_type_dup_xpath10,
517 .plugin.free = lyplg_type_free_xpath10,
518 .plugin.lyb_data_len = -1,
519 },
520 {0}
521};
libyang context handler.
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:527
LIBYANG_API_DECL LY_ERR lydict_insert(const struct ly_ctx *ctx, const char *value, size_t len, const char **str_p)
Insert string into dictionary. If the string is already present, only a reference counter is incremen...
LIBYANG_API_DECL LY_ERR lydict_remove(const struct ly_ctx *ctx, const char *value)
Remove specified string from the dictionary. It decrement reference counter for the string and if it ...
LIBYANG_API_DECL LY_ERR lydict_insert_zc(const struct ly_ctx *ctx, char *value, const char **str_p)
Insert string into dictionary - zerocopy version. If the string is already present,...
LIBYANG_API_DECL const char * ly_errmsg(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error message. If the coresponding module defined a specific ...
LY_ERR
libyang's error codes returned by the libyang functions.
Definition: log.h:244
@ LYVE_DATA
Definition: log.h:281
@ LY_EMEM
Definition: log.h:246
@ LY_EVALID
Definition: log.h:252
@ LY_EINT
Definition: log.h:251
@ LY_SUCCESS
Definition: log.h:245
@ LY_EINCOMPLETE
Definition: log.h:254
Libyang full error structure.
Definition: log.h:289
uint32_t count
Definition: set.h:48
LIBYANG_API_DECL void ly_set_free(struct ly_set *set, void(*destructor)(void *obj))
Free the ly_set data. If the destructor is not provided, it frees only the set structure content,...
LIBYANG_API_DECL LY_ERR ly_set_add(struct ly_set *set, void *object, ly_bool list, uint32_t *index_p)
Add an object into the set.
LIBYANG_API_DECL LY_ERR ly_set_new(struct ly_set **set_p)
Create and initiate new ly_set structure.
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Definition: set.h:46
const char * module
#define LYPLG_TYPE_VAL_INLINE_PREPARE(storage, type_val)
Prepare value memory for storing a specific type value, may be allocated dynamically.
LIBYANG_API_DECL LY_ERR lyplg_type_validate_patterns(struct lysc_pattern **patterns, const char *str, size_t str_len, struct ly_err_item **err)
Data type validator for pattern-restricted string values.
LIBYANG_API_DEF LY_ERR lyplg_type_xpath10_print_token(const char *token, uint16_t tok_len, ly_bool is_nametest, const struct lys_module **context_mod, const struct ly_ctx *resolve_ctx, LY_VALUE_FORMAT resolve_format, const void *resolve_prefix_data, LY_VALUE_FORMAT get_format, void *get_prefix_data, char **token_p, struct ly_err_item **err)
Print xpath1.0 token in the specific format.
Definition: xpath1.0.c:43
LIBYANG_API_DECL LY_ERR ly_err_new(struct ly_err_item **err, LY_ERR ecode, LY_VECODE vecode, char *path, char *apptag, const char *err_format,...) _FORMAT_PRINTF(6
Create and fill error structure.
LIBYANG_API_DEF LY_ERR lyplg_type_print_xpath10_value(const struct lyd_value_xpath10 *xp_val, LY_VALUE_FORMAT format, void *prefix_data, char **str_value, struct ly_err_item **err)
Print xpath1.0 value in the specific format.
Definition: xpath1.0.c:220
LIBYANG_API_DECL LY_ERR LIBYANG_API_DECL void ly_err_free(void *ptr)
Destructor for the error records created with ly_err_new().
#define LYPLG_TYPE_VAL_INLINE_DESTROY(type_val)
Destroy a prepared value.
LIBYANG_API_DECL LY_ERR lyplg_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64_t value, const char *strval, size_t strval_len, struct ly_err_item **err)
Data type validator for a range/length-restricted values.
LIBYANG_API_DECL const char * lyplg_type_get_prefix(const struct lys_module *mod, LY_VALUE_FORMAT format, void *prefix_data)
Get format-specific prefix for a module.
LIBYANG_API_DECL LY_ERR lyplg_type_check_hints(uint32_t hints, const char *value, size_t value_len, LY_DATA_TYPE type, int *base, struct ly_err_item **err)
Check that the type is suitable for the parser's hints (if any) in the specified format.
LIBYANG_API_DECL LY_ERR lyplg_type_prefix_data_new(const struct ly_ctx *ctx, const void *value, size_t value_len, LY_VALUE_FORMAT format, const void *prefix_data, LY_VALUE_FORMAT *format_p, void **prefix_data_p)
Store used prefixes in a string into an internal libyang structure used in lyd_value.
LIBYANG_API_DECL LY_ERR lyplg_type_prefix_data_dup(const struct ly_ctx *ctx, LY_VALUE_FORMAT format, const void *orig, void **dup)
Duplicate prefix data.
LIBYANG_API_DECL void lyplg_type_prefix_data_free(LY_VALUE_FORMAT format, void *prefix_data)
Free internal prefix data.
LIBYANG_API_DECL const struct lys_module * lyplg_type_identity_module(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *prefix, size_t prefix_len, LY_VALUE_FORMAT format, const void *prefix_data)
Get the corresponding module for the identity value.
LIBYANG_API_DECL LY_ERR lyplg_type_compare_simple(const struct lyd_value *val1, const struct lyd_value *val2)
Implementation of lyplg_type_compare_clb for a generic simple type.
LIBYANG_API_DEF LY_ERR lyplg_type_dup_xpath10(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
Implementation of lyplg_type_dup_clb for the ietf-yang-types xpath1.0 type.
Definition: xpath1.0.c:450
LIBYANG_API_DEF void lyplg_type_free_xpath10(const struct ly_ctx *ctx, struct lyd_value *value)
Implementation of lyplg_type_free_clb for the ietf-yang-types xpath1.0 type.
Definition: xpath1.0.c:482
LIBYANG_API_DEF const void * lyplg_type_print_xpath10(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data, ly_bool *dynamic, size_t *value_len)
Implementation of lyplg_type_print_clb for the ietf-yang-types xpath1.0 type.
Definition: xpath1.0.c:411
#define LYPLG_TYPE_STORE_DYNAMIC
const char * name
Definition: tree_schema.h:2343
LY_DATA_TYPE basetype
Definition: tree_schema.h:1536
struct lys_module * module
Definition: tree_schema.h:1654
struct lysc_pattern ** patterns
Definition: tree_schema.h:1564
const char * name
Definition: tree_schema.h:1661
struct lysc_range * length
Definition: tree_schema.h:1563
const char * prefix
Definition: tree_schema.h:2346
struct ly_ctx * ctx
Definition: tree_schema.h:2342
Available YANG schema tree structures representing YANG module.
Definition: tree_schema.h:2341
Compiled YANG data node.
Definition: tree_schema.h:1650
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: tree.h:235
@ LY_TYPE_STRING
Definition: tree.h:210
@ LY_VALUE_JSON
Definition: tree.h:240
@ LY_VALUE_SCHEMA
Definition: tree.h:237
@ LY_VALUE_CANON
Definition: tree.h:236
@ LY_VALUE_XML
Definition: tree.h:239
@ LY_VALUE_STR_NS
Definition: tree.h:242
@ LY_VALUE_SCHEMA_RESOLVED
Definition: tree.h:238
@ LY_VALUE_LYB
Definition: tree.h:241
The main libyang public header.
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:34
API for (user) types plugins.
LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
const struct lysc_type * realtype
Definition: tree_data.h:564
const struct lysc_node * schema
Definition: tree_data.h:804
struct lyxp_expr * exp
Definition: tree_data.h:706
#define LYD_NAME(node)
Get the name (associated with) of a data node. Works for opaque nodes as well.
Definition: tree_data.h:920
LY_VALUE_FORMAT format
Definition: tree_data.h:709
const struct ly_ctx * ctx
Definition: tree_data.h:707
#define LYD_VALUE_GET(value, type_val)
Get the value in format specific to the type.
Definition: tree_data.h:603
const char * _canonical
Definition: tree_data.h:561
void * prefix_data
Definition: tree_data.h:708
Generic structure for a data node.
Definition: tree_data.h:798
YANG data representation.
Definition: tree_data.h:560
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:705
#define LOGMEM(CTX)
Definition: tree_edit.h:22
LIBYANG_API_DEF LY_ERR lyplg_type_store_xpath10(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len, uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
Definition: xpath1.0.c:241
const struct lyplg_type_record plugins_xpath10[]
Plugin information for xpath1.0 type implementation.
Definition: xpath1.0.c:504