libyang FEATURE introduce and use new ly_bool type
To indicate simple flags or true/false return values, use a standalone
ly_bool type.
We do not use stdbool's bool type to avoid need to mimic all its
features on platforms that do not provide it. ly_bool is just a simple
rename for uint8_t and the reason to use it is only a better readability
of the meaning of the variables or function's return values.
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 07c4134..bbd2692 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -15,6 +15,7 @@
#ifndef LY_TREE_DATA_INTERNAL_H_
#define LY_TREE_DATA_INTERNAL_H_
+#include "log.h"
#include "lyb.h"
#include "plugins_types.h"
#include "set.h"
@@ -42,15 +43,14 @@
LYB_HASH lyb_hash(struct lysc_node *sibling, uint8_t collision_id);
/**
- * @brief Check whether a sibling module is in a module array.
+ * @brief Check whether a sibling's module is in a module array.
*
* @param[in] sibling Sibling to check.
* @param[in] models Modules in a sized array.
* @return non-zero if the module was found,
- * @return 0 if not found.
- * @return 1 if found.
+ * @return Boolean value whether @p sibling's module found in the given @p models array.
*/
-uint8_t lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models);
+ly_bool lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models);
/**
* @brief Check whether a node to be deleted is the first top-level sibling.
@@ -103,7 +103,7 @@
* @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, uint8_t *dynamic, uint32_t value_hint,
+LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool *dynamic, uint32_t value_hint,
LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node);
/**
@@ -182,7 +182,7 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *value, size_t value_len,
- uint8_t *dynamic, uint32_t value_hint, LYD_FORMAT format, struct ly_prefix *val_prefs, const char *prefix,
+ ly_bool *dynamic, uint32_t value_hint, LYD_FORMAT format, struct ly_prefix *val_prefs, const char *prefix,
size_t pref_len, const char *module_key, size_t module_key_len, struct lyd_node **node);
/**
@@ -249,7 +249,7 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_meta(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, uint8_t *dynamic, uint32_t value_hint,
+ size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, uint32_t value_hint,
LY_PREFIX_FORMAT format, void *prefix_data, const struct lysc_node *ctx_snode);
/**
@@ -282,7 +282,7 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const struct ly_ctx *ctx, const char *name,
- size_t name_len, const char *value, size_t value_len, uint8_t *dynamic, uint32_t value_hint, LYD_FORMAT format,
+ size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, uint32_t value_hint, LYD_FORMAT format,
struct ly_prefix *val_prefs, const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len);
/**
@@ -316,12 +316,12 @@
* @return LY_EINCOMPLETE in case the @p trees is not provided and it was needed to finish the validation.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_value_parse(struct lyd_node_term *node, const char *value, size_t value_len, uint8_t *dynamic, uint8_t second,
+LY_ERR lyd_value_parse(struct lyd_node_term *node, const char *value, size_t value_len, ly_bool *dynamic, ly_bool second,
uint32_t value_hint, LY_PREFIX_FORMAT format, void *prefix_data, const struct lyd_node *tree);
/* similar to lyd_value_parse except can be used just to store the value, hence does also not support a second call */
LY_ERR lyd_value_store(struct lyd_value *val, const struct lysc_node *schema, const char *value, size_t value_len,
- uint8_t *dynamic, LY_PREFIX_FORMAT format, void *prefix_data);
+ ly_bool *dynamic, LY_PREFIX_FORMAT format, void *prefix_data);
/**
* @brief Validate, canonize and store the given @p value into the metadata according to the annotation type's rules.
@@ -344,7 +344,7 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_value_parse_meta(const struct ly_ctx *ctx, struct lyd_meta *meta, const char *value, size_t value_len,
- uint8_t *dynamic, uint8_t second, uint32_t value_hint, LY_PREFIX_FORMAT format, void *prefix_data,
+ ly_bool *dynamic, ly_bool second, uint32_t value_hint, LY_PREFIX_FORMAT format, void *prefix_data,
const struct lysc_node *ctx_snode, const struct lyd_node *tree);
/* generic function lys_value_validate */
@@ -604,6 +604,6 @@
* @param[in] is_static Whether buffer is static or can be reallocated.
* @return LY_ERR
*/
-LY_ERR lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, uint8_t is_static);
+LY_ERR lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static);
#endif /* LY_TREE_DATA_INTERNAL_H_ */