libyang CHANGE add LY_VALUE_LYB
Add a separate value format of the LYB representation of the type.
Some of the callbacks API of the type plugins was modified to reflect the
need of passing generic (binary) data representation of the value.
diff --git a/src/in.c b/src/in.c
index b175994..1dda5d9 100644
--- a/src/in.c
+++ b/src/in.c
@@ -509,7 +509,7 @@
LY_ERR
lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod,
- const char *name, size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format,
+ const char *name, size_t name_len, const void *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format,
void *prefix_data, uint32_t hints)
{
ly_bool incomplete;
diff --git a/src/parser_internal.h b/src/parser_internal.h
index ed37c91..6d47489 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -228,7 +228,7 @@
* @return LY_ERR value.
*/
LY_ERR lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct lyd_meta **meta,
- const struct lys_module *mod, const char *name, size_t name_len, const char *value,
+ const struct lys_module *mod, const char *name, size_t name_len, const void *value,
size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints);
#endif /* LY_PARSER_INTERNAL_H_ */
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index f588bd6..c6a2674 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -456,6 +456,7 @@
*prefix_data = set;
break;
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* nothing stored */
break;
default:
diff --git a/src/path.c b/src/path.c
index 7ca8616..a4db50c 100644
--- a/src/path.c
+++ b/src/path.c
@@ -453,7 +453,8 @@
break;
case LY_VALUE_CANON:
case LY_VALUE_XML:
- /* not really defined */
+ case LY_VALUE_LYB:
+ /* not really defined or accepted */
LOGINT_RET(ctx);
}
}
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 5493c98..7383373 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -120,7 +120,7 @@
}
const struct lys_module *
-ly_resolve_prefix(const struct ly_ctx *ctx, const char *prefix, size_t prefix_len, LY_VALUE_FORMAT format,
+ly_resolve_prefix(const struct ly_ctx *ctx, const void *prefix, size_t prefix_len, LY_VALUE_FORMAT format,
const void *prefix_data)
{
const struct lys_module *mod = NULL;
@@ -139,6 +139,7 @@
break;
case LY_VALUE_CANON:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
mod = ly_json_resolve_prefix(ctx, prefix, prefix_len, prefix_data);
break;
}
@@ -160,6 +161,7 @@
return ctx_node->module;
case LY_VALUE_CANON:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* use context node module (as specified) */
return ctx_node->module;
case LY_VALUE_XML:
@@ -254,6 +256,7 @@
break;
case LY_VALUE_CANON:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
prefix = ly_json_get_prefix(mod, prefix_data);
break;
}
@@ -281,7 +284,7 @@
return LY_ENOT;
}
-API const char *
+API const void *
lyplg_type_print_simple(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *value, LY_VALUE_FORMAT UNUSED(format),
void *UNUSED(prefix_data), ly_bool *dynamic, size_t *value_len)
{
@@ -567,7 +570,7 @@
}
API LY_ERR
-lyplg_type_prefix_data_new(const struct ly_ctx *ctx, const char *value, size_t value_len, LY_VALUE_FORMAT format,
+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)
{
LY_CHECK_ARG_RET(ctx, value, format_p, prefix_data_p, LY_EINVAL);
@@ -700,6 +703,7 @@
case LY_VALUE_SCHEMA:
case LY_VALUE_SCHEMA_RESOLVED:
case LY_VALUE_XML:
+ case LY_VALUE_LYB:
prefix_opt = LY_PATH_PREFIX_MANDATORY;
break;
case LY_VALUE_JSON:
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 9b1ac71..95e089b 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -268,15 +268,15 @@
* prefixes are simply added. This way it is possible to store prefix data for several strings together.
*
* @param[in] ctx libyang context.
- * @param[in] value Value string to be parsed.
- * @param[in] value_len Length of the @p value string.
+ * @param[in] value Value to be parsed.
+ * @param[in] value_len Length of @p value.
* @param[in] format Format of the prefixes in the value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ly_resolve_prefix()).
* @param[in,out] format_p Resulting format of the prefixes.
* @param[in,out] prefix_data_p Resulting prefix data for the value in format @p format_p.
* @return LY_ERR value.
*/
-LY_ERR lyplg_type_prefix_data_new(const struct ly_ctx *ctx, const char *value, size_t value_len, LY_VALUE_FORMAT format,
+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);
/**
* @brief Duplicate prefix data.
@@ -378,7 +378,7 @@
* @return LY_EINCOMPLETE in case the ::lyplg_type_validate_clb should be called to finish value validation in data,
* @return LY_ERR value on error.
*/
-typedef LY_ERR (*lyplg_type_store_clb)(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value,
+typedef LY_ERR (*lyplg_type_store_clb)(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 *unres, struct ly_err_item **err);
@@ -435,7 +435,7 @@
* can be responsible for freeing allocated memory.
* @return NULL in case of error.
*/
-typedef const char *(*lyplg_type_print_clb)(const struct ly_ctx *ctx, const struct lyd_value *value,
+typedef const void *(*lyplg_type_print_clb)(const struct ly_ctx *ctx, const struct lyd_value *value,
LY_VALUE_FORMAT format, void *prefix_data, ly_bool *dynamic, size_t *value_len);
/**
@@ -511,7 +511,7 @@
* @brief Generic simple printer callback of the canonized value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_simple(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+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, size_t *value_len);
/**
@@ -533,14 +533,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement binary built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement binary built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in binary type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_binary(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 *unres, struct ly_err_item **err);
@@ -551,14 +551,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement bits built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement bits built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in bits type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_bits(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_bits(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 *unres, struct ly_err_item **err);
@@ -581,14 +581,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement boolean built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement boolean built-in type.
*/
/**
* @brief Validate and store value of the YANG built-in boolean type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_boolean(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_boolean(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 *unres, struct ly_err_item **err);
@@ -599,14 +599,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement decimal64 built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement decimal64 built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in decimal64 types.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_decimal64(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 *unres, struct ly_err_item **err);
@@ -617,14 +617,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement empty built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement empty built-in type.
*/
/**
* @brief Validate and store value of the YANG built-in empty type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_empty(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_empty(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 *unres, struct ly_err_item **err);
@@ -641,14 +641,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement enumeration built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement enumeration built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in enumeration type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_enum(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_enum(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 *unres, struct ly_err_item **err);
@@ -659,14 +659,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement identityref built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement identityref built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in identiytref type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_identityref(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_identityref(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 *unres, struct ly_err_item **err);
@@ -680,8 +680,8 @@
* @brief Printer callback printing identityref value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_identityref(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data,
- ly_bool *dynamic, size_t *value_len);
+const void *lyplg_type_print_identityref(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *prefix_data, ly_bool *dynamic, size_t *value_len);
/** @} pluginsTypesIdentityref */
@@ -690,14 +690,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement instance-identifier built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement instance-identifier built-in type.
*/
/**
* @brief Validate and store value of the YANG built-in instance-identifier type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_instanceid(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_instanceid(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 *unres, struct ly_err_item **err);
@@ -711,8 +711,8 @@
* @brief Printer callback printing the instance-identifier value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_instanceid(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data,
- ly_bool *dynamic, size_t *value_len);
+const void *lyplg_type_print_instanceid(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *prefix_data, ly_bool *dynamic, size_t *value_len);
/**
* @brief Duplication callback of the instance-identifier values.
@@ -740,14 +740,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement integer built-in types.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement integer built-in types.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in signed integer types.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_int(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 *unres, struct ly_err_item **err);
@@ -755,7 +755,7 @@
* @brief Validate and canonize value of the YANG built-in unsigned integer types.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_uint(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 *unres, struct ly_err_item **err);
@@ -766,14 +766,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement leafref built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement leafref built-in type.
*/
/**
* @brief Validate, canonize and store value of the YANG built-in leafref type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_leafref(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_leafref(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 *unres, struct ly_err_item **err);
@@ -787,8 +787,8 @@
* @brief Printer callback printing the leafref value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_leafref(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data,
- ly_bool *dynamic, size_t *value_len);
+const void *lyplg_type_print_leafref(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *prefix_data, ly_bool *dynamic, size_t *value_len);
/**
* @brief Duplication callback of the leafref values.
@@ -816,14 +816,14 @@
* @ingroup pluginsTypes
* @{
*
- * Callbacs used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement string built-in type.
+ * Callbacks used (besides the [simple callbacks](@ref pluginsTypesSimple)) to implement string built-in type.
*/
/**
* @brief Validate and store value of the YANG built-in string type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_string(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_string(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 *unres, struct ly_err_item **err);
@@ -841,7 +841,7 @@
* @brief Validate, canonize and store value of the YANG built-in union type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_union(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+LY_ERR lyplg_type_store_union(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 *unres, struct ly_err_item **err);
@@ -855,8 +855,8 @@
* @brief Printer callback printing the union value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_union(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data,
- ly_bool *dynamic, size_t *value_len);
+const void *lyplg_type_print_union(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *prefix_data, ly_bool *dynamic, size_t *value_len);
/**
* @brief Duplication callback of the union values.
@@ -891,7 +891,7 @@
* @brief Validate, canonize and store value of the ietf-yang-types xpath1.0 type.
* Implementation of the ::lyplg_type_store_clb.
*/
-LY_ERR lyplg_type_store_xpath10(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+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 *unres, struct ly_err_item **err);
@@ -905,7 +905,7 @@
* @brief Printer callback printing the xpath1.0 value.
* Implementation of the ::lyplg_type_print_clb.
*/
-const char *lyplg_type_print_xpath10(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+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);
/**
diff --git a/src/plugins_types/binary.c b/src/plugins_types/binary.c
index 0a18d83..16833ea 100644
--- a/src/plugins_types/binary.c
+++ b/src/plugins_types/binary.c
@@ -29,13 +29,14 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
{
LY_ERR ret = LY_SUCCESS;
size_t base64_start, base64_end, base64_count, base64_terminated, value_end;
+ const char *value_str = value;
struct lysc_type_bin *type_bin = (struct lysc_type_bin *)type;
LY_CHECK_ARG_RET(ctx, value, LY_EINVAL);
@@ -49,12 +50,12 @@
/* validate characters and remember the number of octets for length validation */
/* silently skip leading whitespaces */
base64_start = 0;
- while (base64_start < value_len && isspace(value[base64_start])) {
+ while (base64_start < value_len && isspace(value_str[base64_start])) {
base64_start++;
}
/* silently skip trailing whitespace */
value_end = value_len;
- while (base64_start < value_end && isspace(value[value_end - 1])) {
+ while (base64_start < value_end && isspace(value_str[value_end - 1])) {
value_end--;
}
@@ -63,14 +64,14 @@
base64_count = 0;
while ((base64_end < value_len) &&
/* check correct character in base64 */
- ((('A' <= value[base64_end]) && (value[base64_end] <= 'Z')) ||
- (('a' <= value[base64_end]) && (value[base64_end] <= 'z')) ||
- (('0' <= value[base64_end]) && (value[base64_end] <= '9')) ||
- ('+' == value[base64_end]) ||
- ('/' == value[base64_end]) ||
- ('\n' == value[base64_end]))) {
+ ((('A' <= value_str[base64_end]) && (value_str[base64_end] <= 'Z')) ||
+ (('a' <= value_str[base64_end]) && (value_str[base64_end] <= 'z')) ||
+ (('0' <= value_str[base64_end]) && (value_str[base64_end] <= '9')) ||
+ ('+' == value_str[base64_end]) ||
+ ('/' == value_str[base64_end]) ||
+ ('\n' == value_str[base64_end]))) {
- if ('\n' != value[base64_end]) {
+ if ('\n' != value_str[base64_end]) {
base64_count++;
}
base64_end++;
@@ -80,10 +81,10 @@
base64_terminated = 0;
while (((base64_end < value_len) && (base64_terminated < 2)) &&
/* check padding on end of string */
- (('=' == value[base64_end]) ||
- ('\n' == value[base64_end]))) {
+ (('=' == value_str[base64_end]) ||
+ ('\n' == value_str[base64_end]))) {
- if ('\n' != value[base64_end]) {
+ if ('\n' != value_str[base64_end]) {
base64_terminated++;
}
base64_end++;
@@ -91,7 +92,7 @@
/* check if value is valid base64 value */
if (value_end != base64_end) {
- ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid Base64 character (%c).", value[base64_end]);
+ ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid Base64 character (%c).", value_str[base64_end]);
goto cleanup;
}
@@ -101,15 +102,15 @@
goto cleanup;
}
- /* check if value meets the type requirments */
+ /* check if value meets the type requirements */
if (type_bin->length) {
const uint32_t value_length = ((base64_count + base64_terminated) / 4) * 3 - base64_terminated;
- ret = lyplg_type_validate_range(LY_TYPE_BINARY, type_bin->length, value_length, value, err);
+ ret = lyplg_type_validate_range(LY_TYPE_BINARY, type_bin->length, value_length, value_str, err);
LY_CHECK_GOTO(ret != LY_SUCCESS, cleanup);
}
if (base64_count != 0) {
- ret = lydict_insert(ctx, &value[base64_start], base64_end - base64_start, &storage->_canonical);
+ ret = lydict_insert(ctx, &value_str[base64_start], base64_end - base64_start, &storage->_canonical);
LY_CHECK_GOTO(ret != LY_SUCCESS, cleanup);
} else {
ret = lydict_insert(ctx, "", 0, &storage->_canonical);
diff --git a/src/plugins_types/bits.c b/src/plugins_types/bits.c
index ca2d3cc..c59de75 100644
--- a/src/plugins_types/bits.c
+++ b/src/plugins_types/bits.c
@@ -30,7 +30,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_bits(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_bits(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -39,6 +39,7 @@
struct lysc_type_bits *type_bits = (struct lysc_type_bits *)type;
struct lysc_type_bitenum_item **bits_items = NULL;
struct ly_set *items = NULL;
+ const char *value_str = value;
uint32_t index_start; /* start index of bit name */
uint32_t index_end = 0; /* end index of bit name */
@@ -67,18 +68,18 @@
while (index_end < value_len) {
/* skip leading spaces */
index_start = index_end;
- while ((index_start < value_len) && isspace(value[index_start])) {
+ while ((index_start < value_len) && isspace(value_str[index_start])) {
index_start++;
}
index_end = index_start;
/* find end of word */
- while ((index_end < value_len) && !isspace(value[index_end])) {
+ while ((index_end < value_len) && !isspace(value_str[index_end])) {
index_end++;
}
/* check if name of bit is valid */
- item = &value[index_start];
+ item = &value_str[index_start];
item_len = index_end - index_start;
if (item_len == 0) {
/* loop read all bits names*/
diff --git a/src/plugins_types/boolean.c b/src/plugins_types/boolean.c
index a212bf8..4a8b20c 100644
--- a/src/plugins_types/boolean.c
+++ b/src/plugins_types/boolean.c
@@ -29,7 +29,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_boolean(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_boolean(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -48,7 +48,8 @@
} else if ((value_len == ly_strlen_const("false")) && !strncmp(value, "false", ly_strlen_const("false"))) {
i = 0;
} else {
- ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid boolean value \"%.*s\".", (int)value_len, value);
+ ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid boolean value \"%.*s\".", (int)value_len,
+ (char *)value);
goto cleanup;
}
diff --git a/src/plugins_types/date_and_time.c b/src/plugins_types/date_and_time.c
index ab89092..31ec7c7 100644
--- a/src/plugins_types/date_and_time.c
+++ b/src/plugins_types/date_and_time.c
@@ -96,7 +96,7 @@
* Implementation of the ::lyplg_type_store_clb.
*/
static LY_ERR
-lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_date_and_time(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 *unres, struct ly_err_item **err)
{
diff --git a/src/plugins_types/decimal64.c b/src/plugins_types/decimal64.c
index 9ac33c5..ea7d5c4 100644
--- a/src/plugins_types/decimal64.c
+++ b/src/plugins_types/decimal64.c
@@ -30,7 +30,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -42,7 +42,7 @@
*err = NULL;
- if (!value || !value[0] || !value_len) {
+ if (!value || !((char *)value)[0] || !value_len) {
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid empty decimal64 value.");
goto cleanup;
}
diff --git a/src/plugins_types/empty.c b/src/plugins_types/empty.c
index 27ea094..172c3ad 100644
--- a/src/plugins_types/empty.c
+++ b/src/plugins_types/empty.c
@@ -28,7 +28,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_empty(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_empty(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -42,7 +42,8 @@
LY_CHECK_GOTO(ret != LY_SUCCESS, cleanup);
if (value_len) {
- ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid empty value \"%.*s\".", (int)value_len, value);
+ ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid empty value \"%.*s\".", (int)value_len,
+ (char *)value);
goto cleanup;
}
diff --git a/src/plugins_types/enumeration.c b/src/plugins_types/enumeration.c
index bdb3c65..da24316 100644
--- a/src/plugins_types/enumeration.c
+++ b/src/plugins_types/enumeration.c
@@ -28,7 +28,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_enum(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_enum(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -51,7 +51,8 @@
}
}
/* enum not found */
- ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid enumeration value \"%.*s\".", (int)value_len, value);
+ ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, "Invalid enumeration value \"%.*s\".", (int)value_len,
+ (char *)value);
goto cleanup;
match:
diff --git a/src/plugins_types/hex_string.c b/src/plugins_types/hex_string.c
index b28b7d3..1a29d3e 100644
--- a/src/plugins_types/hex_string.c
+++ b/src/plugins_types/hex_string.c
@@ -33,7 +33,7 @@
* Implementation of the ::lyplg_type_store_clb.
*/
static LY_ERR
-lyplg_type_store_hex_string(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_hex_string(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 *unres, struct ly_err_item **err)
{
diff --git a/src/plugins_types/identityref.c b/src/plugins_types/identityref.c
index 849720b..3b40c28 100644
--- a/src/plugins_types/identityref.c
+++ b/src/plugins_types/identityref.c
@@ -43,13 +43,13 @@
}
API LY_ERR
-lyplg_type_store_identityref(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_identityref(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 *unres, struct ly_err_item **err)
{
LY_ERR ret = LY_SUCCESS;
struct lysc_type_identityref *type_ident = (struct lysc_type_identityref *)type;
- const char *id_name, *prefix = value;
+ const char *id_name, *prefix = value, *value_str = value;
size_t id_len, prefix_len, str_len;
char *str;
const struct lys_module *mod = NULL;
@@ -63,13 +63,13 @@
LY_CHECK_GOTO(ret != LY_SUCCESS, cleanup);
/* locate prefix if any */
- for (prefix_len = 0; (prefix_len < value_len) && (value[prefix_len] != ':'); ++prefix_len) {}
+ for (prefix_len = 0; (prefix_len < value_len) && (value_str[prefix_len] != ':'); ++prefix_len) {}
if (prefix_len < value_len) {
- id_name = &value[prefix_len + 1];
+ id_name = &value_str[prefix_len + 1];
id_len = value_len - (prefix_len + 1);
} else {
prefix_len = 0;
- id_name = value;
+ id_name = value_str;
id_len = value_len;
}
@@ -81,7 +81,7 @@
mod = lyplg_type_identity_module(ctx, ctx_node, prefix, prefix_len, format, prefix_data);
if (!mod) {
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
- "Invalid identityref \"%.*s\" value - unable to map prefix to YANG schema.", (int)value_len, value);
+ "Invalid identityref \"%.*s\" value - unable to map prefix to YANG schema.", (int)value_len, value_str);
goto cleanup;
}
@@ -97,7 +97,7 @@
/* no match */
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
"Invalid identityref \"%.*s\" value - identity not found in module \"%s\".",
- (int)value_len, value, mod->name);
+ (int)value_len, value_str, mod->name);
goto cleanup;
} else if (!mod->implemented) {
/* non-implemented module */
@@ -107,7 +107,7 @@
} else {
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
"Invalid identityref \"%.*s\" value - identity found in non-implemented module \"%s\".",
- (int)value_len, value, mod->name);
+ (int)value_len, value_str, mod->name);
goto cleanup;
}
}
@@ -133,11 +133,11 @@
if (u == 1) {
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
"Invalid identityref \"%.*s\" value - identity not derived from the base %s.",
- (int)value_len, value, str);
+ (int)value_len, value_str, str);
} else {
ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
"Invalid identityref \"%.*s\" value - identity not derived from all the bases %s.",
- (int)value_len, value, str);
+ (int)value_len, value_str, str);
}
free(str);
goto cleanup;
@@ -159,7 +159,7 @@
return ret;
}
-API const char *
+API const void *
lyplg_type_print_identityref(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *value, LY_VALUE_FORMAT format,
void *prefix_data, ly_bool *dynamic, size_t *value_len)
{
diff --git a/src/plugins_types/instanceid.c b/src/plugins_types/instanceid.c
index 8aca701..f9f4707 100644
--- a/src/plugins_types/instanceid.c
+++ b/src/plugins_types/instanceid.c
@@ -31,7 +31,7 @@
#include "path.h"
#include "plugins_internal.h" /* LY_TYPE_*_STR */
-API const char *
+API const void *
lyplg_type_print_instanceid(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
void *prefix_data, ly_bool *dynamic, size_t *value_len)
{
@@ -90,8 +90,9 @@
}
}
}
+
*dynamic = 1;
- } else if ((format == LY_VALUE_CANON) || (format == LY_VALUE_JSON)) {
+ } else if ((format == LY_VALUE_CANON) || (format == LY_VALUE_JSON) || (format == LY_VALUE_LYB)) {
/* generate canonical, only the first node or the node changing module is prefixed */
if (!value->_canonical) {
struct lys_module *mod = NULL;
@@ -164,7 +165,7 @@
}
API LY_ERR
-lyplg_type_store_instanceid(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_instanceid(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 *unres, struct ly_err_item **err)
{
diff --git a/src/plugins_types/integer.c b/src/plugins_types/integer.c
index 2d8d424..d1a5b1f 100644
--- a/src/plugins_types/integer.c
+++ b/src/plugins_types/integer.c
@@ -29,7 +29,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
@@ -103,7 +103,7 @@
}
API LY_ERR
-lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
diff --git a/src/plugins_types/ip_address.c b/src/plugins_types/ip_address.c
index 7ee0d5d..4f51ed1 100644
--- a/src/plugins_types/ip_address.c
+++ b/src/plugins_types/ip_address.c
@@ -68,7 +68,7 @@
* Implementation of the ::lyplg_type_store_clb.
*/
static LY_ERR
-lyplg_type_store_ip_address(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_ip_address(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 *unres, struct ly_err_item **err)
{
diff --git a/src/plugins_types/ip_prefix.c b/src/plugins_types/ip_prefix.c
index 124a31d..9eef670 100644
--- a/src/plugins_types/ip_prefix.c
+++ b/src/plugins_types/ip_prefix.c
@@ -193,7 +193,7 @@
* Implementation of the ::lyplg_type_store_clb.
*/
static LY_ERR
-lyplg_type_store_ipv4_prefix(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_ipv4_prefix(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 *unres, struct ly_err_item **err)
{
@@ -230,7 +230,7 @@
* Implementation of the ::lyplg_type_store_clb.
*/
static LY_ERR
-lyplg_type_store_ipv6_prefix(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_ipv6_prefix(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 *unres, struct ly_err_item **err)
{
diff --git a/src/plugins_types/leafref.c b/src/plugins_types/leafref.c
index a704687..03190ba 100644
--- a/src/plugins_types/leafref.c
+++ b/src/plugins_types/leafref.c
@@ -31,7 +31,7 @@
const struct lyplg_type_record plugins_leafref[];
API LY_ERR
-lyplg_type_store_leafref(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_leafref(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 *unres, struct ly_err_item **err)
{
@@ -89,7 +89,7 @@
return val1->realtype->plugin->compare(val1, val2);
}
-API const char *
+API const void *
lyplg_type_print_leafref(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
void *prefix_data, ly_bool *dynamic, size_t *value_len)
{
diff --git a/src/plugins_types/string.c b/src/plugins_types/string.c
index be60043..1d67cfa 100644
--- a/src/plugins_types/string.c
+++ b/src/plugins_types/string.c
@@ -28,7 +28,7 @@
#include "plugins_internal.h" /* LY_TYPE_*_STR */
API LY_ERR
-lyplg_type_store_string(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_string(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len,
uint32_t options, LY_VALUE_FORMAT UNUSED(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)
diff --git a/src/plugins_types/union.c b/src/plugins_types/union.c
index 118def6..9b11dd8 100644
--- a/src/plugins_types/union.c
+++ b/src/plugins_types/union.c
@@ -81,7 +81,7 @@
}
API LY_ERR
-lyplg_type_store_union(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+lyplg_type_store_union(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 *unres, struct ly_err_item **err)
{
@@ -191,7 +191,7 @@
return val1->subvalue->value.realtype->plugin->compare(&val1->subvalue->value, &val2->subvalue->value);
}
-API const char *
+API const void *
lyplg_type_print_union(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
void *prefix_data, ly_bool *dynamic, size_t *value_len)
{
diff --git a/src/plugins_types/xpath1.0.c b/src/plugins_types/xpath1.0.c
index b30ac4c..3ebad18 100644
--- a/src/plugins_types/xpath1.0.c
+++ b/src/plugins_types/xpath1.0.c
@@ -198,7 +198,7 @@
}
API LY_ERR
-lyplg_type_store_xpath10(const struct ly_ctx *ctx, const struct lysc_type *type, const char *value, size_t value_len,
+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 *unres, struct ly_err_item **err)
{
@@ -243,7 +243,7 @@
return ret;
}
-API const char *
+API const void *
lyplg_type_print_xpath10(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *value, LY_VALUE_FORMAT format,
void *prefix_data, ly_bool *dynamic, size_t *value_len)
{
@@ -317,7 +317,6 @@
lyplg_type_prefix_data_free(xp_val->format, xp_val->prefix_data);
free(xp_val);
- value->ptr = NULL;
}
}
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index c1e80df..5592fa0 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -593,6 +593,7 @@
}
break;
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* nothing to print */
break;
default:
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index 1c33c60..32f26fd 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2870,6 +2870,7 @@
mod = cur_mod;
break;
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
if (!ctx_node) {
LOGINT_RET(ctx->ctx);
}
diff --git a/src/tree.h b/src/tree.h
index eb0fd71..135bcad 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -237,7 +237,8 @@
LY_VALUE_SCHEMA, /**< YANG schema value, prefixes map to YANG import prefixes */
LY_VALUE_SCHEMA_RESOLVED, /**< resolved YANG schema value, prefixes map to module structures directly */
LY_VALUE_XML, /**< XML data value, prefixes map to XML namespace prefixes */
- LY_VALUE_JSON /**< JSON data value, prefixes map to module names */
+ LY_VALUE_JSON, /**< JSON data value, prefixes map to module names */
+ LY_VALUE_LYB /**< LYB data binary value, prefix mapping is type-specific (but usually like JSON) */
} LY_VALUE_FORMAT;
/** @} trees */
diff --git a/src/tree_data.c b/src/tree_data.c
index 03db1cb..919920f 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -55,7 +55,7 @@
struct lyd_node **match);
LY_ERR
-lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const char *value,
+lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
const struct lysc_node *ctx_node, ly_bool *incomplete)
{
diff --git a/src/tree_data.h b/src/tree_data.h
index f32343f..4992b02 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -79,6 +79,7 @@
* - @subpage howtoDataWD
* - @subpage howtoDataManipulation
* - @subpage howtoDataPrinters
+ * - @subpage howtoDataLYB
*
* \note API for this group of functions is described in the [Data Instances module](@ref datatree).
*
@@ -357,6 +358,16 @@
*/
/**
+ * @page howtoDataLYB LYB Binary Format
+ *
+ * LYB (LibYang Binary) is a proprietary libyang binary data and file format. Its primary purpose is efficient
+ * serialization (printing) and deserialization (parsing). With this goal in mind, every term node value is stored
+ * in its new binary format specification according to its type. Following is the format for all types with explicit
+ * support out-of-the-box (meaning that have a special type plugin). Any derived types inherit the format of its
+ * closest type with explicit support (up to a built-in type).
+ */
+
+/**
* @ingroup trees
* @defgroup datatree Data Tree
* @{
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 1d6c0f0..c317be2 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -451,6 +451,7 @@
case LY_VALUE_CANON:
case LY_VALUE_SCHEMA:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
break;
}
}
@@ -508,6 +509,7 @@
break;
case LY_VALUE_CANON:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
assert(!prefix_data);
*prefix_data_p = NULL;
break;
@@ -522,7 +524,7 @@
}
LY_ERR
-ly_store_prefix_data(const struct ly_ctx *ctx, const char *value, size_t value_len, LY_VALUE_FORMAT format,
+ly_store_prefix_data(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)
{
LY_ERR ret = LY_SUCCESS;
@@ -612,6 +614,7 @@
case LY_VALUE_CANON:
case LY_VALUE_SCHEMA_RESOLVED:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
if (!*prefix_data_p) {
/* new prefix data - simply copy all the prefix data */
*format_p = format;
@@ -642,6 +645,8 @@
return "XML prefixes";
case LY_VALUE_JSON:
return "JSON module names";
+ case LY_VALUE_LYB:
+ return "LYB prefixes";
default:
break;
}
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 8e084d5..2c3e89b 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -282,7 +282,7 @@
* @param[in] ctx libyang context.
* @param[in,out] val Storage for the value.
* @param[in] type Type of the value.
- * @param[in] value String value to be parsed, must not be NULL.
+ * @param[in] value Value to be parsed, must not be NULL.
* @param[in] value_len Length of the give @p value, must be set correctly.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
@@ -293,7 +293,7 @@
* @return LY_SUCCESS on success,
* @return LY_ERR value on error.
*/
-LY_ERR lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const char *value,
+LY_ERR lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
const struct lysc_node *ctx_node, ly_bool *incomplete);
@@ -449,15 +449,15 @@
* prefixes are simply added. This way it is possible to store prefix data for several strings together.
*
* @param[in] ctx libyang context.
- * @param[in] value Value string to be parsed.
- * @param[in] value_len Length of the @p value string.
+ * @param[in] value Value to be parsed.
+ * @param[in] value_len Length of the @p value.
* @param[in] format Format of the prefixes in the value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[in,out] format_p Resulting format of the prefixes.
* @param[in,out] prefix_data_p Resulting prefix data for the value in format @p format_p.
* @return LY_ERR value.
*/
-LY_ERR ly_store_prefix_data(const struct ly_ctx *ctx, const char *value, size_t value_len, LY_VALUE_FORMAT format,
+LY_ERR ly_store_prefix_data(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);
/**
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 0956dc2..9847099 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -787,6 +787,7 @@
* LY_VALUE_SCHEMA_RESOLVED - struct lyd_value_prefix * (sized array of pairs: prefix - module)
* LY_VALUE_XML - struct ly_set * (set of all returned modules as ::struct lys_module)
* LY_VALUE_JSON - NULL
+ * LY_VALUE_LYB - NULL
* @return Module prefix to print.
* @return NULL on error.
*/
@@ -801,15 +802,17 @@
* @param[in] prefix Prefix to resolve.
* @param[in] prefix_len Length of @p prefix.
* @param[in] format Format of the prefix.
- * @param[in] prefix_data Format-specific data:
- * LY_PREF_SCHEMA - const struct lysp_module * (module used for resolving prefixes from imports)
- * LY_PREF_SCHEMA_RESOLVED - struct lyd_value_prefix * (sized array of pairs: prefix - module)
- * LY_PREF_XML - const struct ly_set * (set with defined namespaces stored as ::lyxml_ns)
- * LY_PREF_JSON - NULL
+ * @param[in] prefix_data Format-specific data based on @p format:
+ * LY_VALUE_CANON - NULL
+ * LY_VALUE_SCHEMA - const struct lysp_module * (module used for resolving prefixes from imports)
+ * LY_VALUE_SCHEMA_RESOLVED - struct lyd_value_prefix * (sized array of pairs: prefix - module)
+ * LY_VALUE_XML - const struct ly_set * (set with defined namespaces stored as ::lyxml_ns)
+ * LY_VALUE_JSON - NULL
+ * LY_VALUE_LYB - NULL
* @return Resolved prefix module,
* @return NULL otherwise.
*/
-const struct lys_module *ly_resolve_prefix(const struct ly_ctx *ctx, const char *prefix, size_t prefix_len,
+const struct lys_module *ly_resolve_prefix(const struct ly_ctx *ctx, const void *prefix, size_t prefix_len,
LY_VALUE_FORMAT format, const void *prefix_data);
#endif /* LY_TREE_SCHEMA_INTERNAL_H_ */
diff --git a/src/xpath.c b/src/xpath.c
index e5bcb25..5b558f1 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -5321,6 +5321,7 @@
break;
case LY_VALUE_CANON:
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* inherit parent (context node) module */
if (ctx_scnode) {
mod = ctx_scnode->module;
@@ -5390,6 +5391,7 @@
moveto_mod = set->cur_mod;
break;
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* inherit module of the context node, if any */
if (ctx_node) {
moveto_mod = ctx_node->schema->module;
@@ -5452,6 +5454,7 @@
moveto_mod = set->cur_mod;
break;
case LY_VALUE_JSON:
+ case LY_VALUE_LYB:
/* inherit module of the context node, if any */
if (ctx_scnode) {
moveto_mod = ctx_scnode->module;