29#include "plugins_internal.h"
42 uint32_t options,
LY_VALUE_FORMAT format,
void *UNUSED(prefix_data), uint32_t hints,
43 const struct lysc_node *UNUSED(ctx_node),
struct lyd_value *storage,
struct lys_glob_unres *UNUSED(unres),
47 uint32_t value_size, i;
50 memset(storage, 0,
sizeof *storage);
56 LY_CHECK_GOTO(ret, cleanup);
60 LY_CHECK_GOTO(ret, cleanup);
64 value = strndup(value, value_size);
65 LY_CHECK_ERR_GOTO(!value, ret =
LY_EMEM, cleanup);
72 for (i = 0; i < value_size; ++i) {
73 ((
char *)value)[i] = tolower(((
char *)value)[i]);
77 options &= ~LYPLG_TYPE_STORE_DYNAMIC;
78 LY_CHECK_GOTO(ret, cleanup);
85 LY_CHECK_GOTO(ret, cleanup);
91 LY_CHECK_GOTO(ret, cleanup);
114 .module =
"ietf-yang-types",
116 .name =
"phys-address",
118 .plugin.id =
"ly2 hex-string",
122 .plugin.validate_tree = NULL,
130 .module =
"ietf-yang-types",
132 .name =
"mac-address",
134 .plugin.id =
"ly2 hex-string",
138 .plugin.validate_tree = NULL,
146 .module =
"ietf-yang-types",
148 .name =
"hex-string",
150 .plugin.id =
"ly2 hex-string",
154 .plugin.validate_tree = NULL,
162 .module =
"ietf-yang-types",
166 .plugin.id =
"ly2 hex-string",
170 .plugin.validate_tree = NULL,
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_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,...
LY_ERR
libyang's error codes returned by the libyang functions.
Libyang full error structure.
const char *const char * revision
LIBYANG_API_DECL LY_ERR lyplg_type_validate_value_string(const struct ly_ctx *ctx, const struct lysc_type *type, struct lyd_value *storage, struct ly_err_item **err)
Implementation of lyplg_type_validate_value_clb for the string type.
LIBYANG_API_DECL LY_ERR lyplg_type_check_hints(uint32_t hints, const char *value, uint32_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_check_value_size(const char *type_name, LY_VALUE_FORMAT format, uint64_t value_size_bits, enum lyplg_lyb_size_type lyb_size_type, uint64_t lyb_fixed_size_bits, uint32_t *value_size, struct ly_err_item **err)
Check a value type in bits is correct and as expected.
@ LYPLG_LYB_SIZE_VARIABLE_BYTES
LIBYANG_API_DECL const void * lyplg_type_print_simple(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data, ly_bool *dynamic, uint64_t *value_size_bits)
Implementation of lyplg_type_print_clb for a generic simple type.
LIBYANG_API_DEF int lyplg_type_sort_simple(const struct ly_ctx *ctx, const struct lyd_value *val1, const struct lyd_value *val2)
Implementation of lyplg_type_sort_clb for a generic simple type.
LIBYANG_API_DECL LY_ERR lyplg_type_dup_simple(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
Implementation of lyplg_type_dup_clb for a generic simple type.
LIBYANG_API_DECL void lyplg_type_free_simple(const struct ly_ctx *ctx, struct lyd_value *value)
Implementation of lyplg_type_free_clb for a generic simple type.
LIBYANG_API_DECL LY_ERR lyplg_type_compare_simple(const struct ly_ctx *ctx, const struct lyd_value *val1, const struct lyd_value *val2)
Implementation of lyplg_type_compare_clb for a generic simple type.
LIBYANG_API_DECL void lyplg_type_lyb_size_variable_bytes(const struct lysc_type *type, enum lyplg_lyb_size_type *size_type, uint64_t *fixed_size_bits)
Implementation of lyplg_type_lyb_size_clb for a type with variable length rounded to bytes.
#define LYPLG_TYPE_STORE_DYNAMIC
#define LYPLG_TYPE_STORE_ONLY
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
LIBYANG_API_DEF LY_ERR lyplg_type_store_hex_string(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, uint64_t value_size_bits, uint32_t options, LY_VALUE_FORMAT format, void *UNUSED(prefix_data), uint32_t hints, const struct lysc_node *UNUSED(ctx_node), struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
const struct lyplg_type_record plugins_hex_string[]
Plugin information for string type implementation.
The main libyang public header.
API for (user) types plugins.
const struct lysc_type * realtype
YANG data representation.