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/common.c b/src/common.c
index d473e3f..163119b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -573,7 +573,7 @@
LY_ERR ret = LY_EVALID;
const char *in = *pred;
size_t offset = 1;
- uint8_t expr = 0;
+ uint8_t expr = 0; /* 0 - position predicate; 1 - leaf-list-predicate; 2 - key-predicate */
char quot;
assert(in[0] == '\[');
diff --git a/src/context.c b/src/context.c
index 250c0e9..3769a0c 100644
--- a/src/context.c
+++ b/src/context.c
@@ -51,7 +51,7 @@
const char *name;
const char *revision;
const char *data;
- uint8_t implemented;
+ ly_bool implemented;
LYS_INFORMAT format;
} internal_modules[] = {
{"ietf-yang-metadata", "2016-08-05", (const char *)ietf_yang_metadata_2016_08_05_yang, 1, LYS_IN_YANG},
@@ -532,7 +532,7 @@
}
API const struct lysc_node *
-ly_ctx_get_node(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *data_path, uint8_t output)
+ly_ctx_get_node(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *data_path, ly_bool output)
{
const struct lysc_node *snode = NULL;
struct lyxp_expr *exp = NULL;
@@ -621,7 +621,7 @@
}
static LY_ERR
-ylib_deviation(struct lyd_node *parent, const struct lys_module *cur_mod, uint8_t bis)
+ylib_deviation(struct lyd_node *parent, const struct lys_module *cur_mod, ly_bool bis)
{
LY_ARRAY_COUNT_TYPE i;
struct lys_module *mod;
@@ -646,7 +646,7 @@
}
static LY_ERR
-ylib_submodules(struct lyd_node *parent, const struct lys_module *cur_mod, uint8_t bis)
+ylib_submodules(struct lyd_node *parent, const struct lys_module *cur_mod, ly_bool bis)
{
LY_ERR ret;
LY_ARRAY_COUNT_TYPE i;
@@ -693,7 +693,7 @@
{
LY_ERR ret;
uint32_t i;
- uint8_t bis = 0;
+ ly_bool bis = 0;
int r;
char id[8], *str;
const struct lys_module *mod;
diff --git a/src/context.h b/src/context.h
index 122ca8c..585c9da 100644
--- a/src/context.h
+++ b/src/context.h
@@ -418,7 +418,7 @@
* @return Found schema node or NULL.
*/
const struct lysc_node *ly_ctx_get_node(const struct ly_ctx *ctx, const struct lysc_node *ctx_node,
- const char *data_path, uint8_t output);
+ const char *data_path, ly_bool output);
/**
* @brief Reset cached latest revision information of the schemas in the context.
diff --git a/src/diff.c b/src/diff.c
index a02c5dd..3e3dfbc 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -516,7 +516,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyd_diff_siblings_r(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, uint8_t nosiblings,
+lyd_diff_siblings_r(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, ly_bool nosiblings,
struct lyd_node **diff)
{
LY_ERR ret = LY_SUCCESS;
@@ -669,7 +669,7 @@
}
static LY_ERR
-lyd_diff(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, uint8_t nosiblings, struct lyd_node **diff)
+lyd_diff(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, ly_bool nosiblings, struct lyd_node **diff)
{
const struct ly_ctx *ctx;
diff --git a/src/hash_table.c b/src/hash_table.c
index bc6ec8b..9d34ca9 100644
--- a/src/hash_table.c
+++ b/src/hash_table.c
@@ -23,9 +23,15 @@
#include "compat.h"
#include "common.h"
#include "dict.h"
+#include "log.h"
-static uint8_t
-lydict_val_eq(void *val1_p, void *val2_p, uint8_t UNUSED(mod), void *cb_data)
+/**
+ * @brief Comparison callback for dictionary's hash table
+ *
+ * Implementation of ::values_equal_cb.
+ */
+static ly_bool
+lydict_val_eq(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *cb_data)
{
LY_CHECK_ARG_RET(NULL, val1_p, val2_p, cb_data, 0);
@@ -173,7 +179,7 @@
}
static char *
-dict_insert(const struct ly_ctx *ctx, char *value, size_t len, uint8_t zerocopy)
+dict_insert(const struct ly_ctx *ctx, char *value, size_t len, ly_bool zerocopy)
{
LY_ERR ret = 0;
struct dict_rec *match = NULL, rec;
@@ -332,7 +338,7 @@
}
static LY_ERR
-lyht_resize(struct hash_table *ht, uint8_t enlarge)
+lyht_resize(struct hash_table *ht, ly_bool enlarge)
{
struct ht_rec *rec;
unsigned char *old_recs;
@@ -477,7 +483,7 @@
* @param[in] ht Hash table to search in.
* @param[in] val_p Pointer to the value to find.
* @param[in] hash Hash to find.
- * @param[in] mod Operation kind for the val_equal callback.
+ * @param[in] mod Whether the operation modifies the hash table (insert or remove) or not (find).
* @param[out] crec_p Optional found first record.
* @param[out] col Optional collision number of @p rec_p, 0 for no collision.
* @param[out] rec_p Found exact matching record, may be a collision of @p crec_p.
@@ -485,7 +491,7 @@
* @return LY_SUCCESS if record was found.
*/
static LY_ERR
-lyht_find_rec(struct hash_table *ht, void *val_p, uint32_t hash, uint8_t mod, struct ht_rec **crec_p, uint32_t *col,
+lyht_find_rec(struct hash_table *ht, void *val_p, uint32_t hash, ly_bool mod, struct ht_rec **crec_p, uint32_t *col,
struct ht_rec **rec_p)
{
struct ht_rec *rec, *crec;
@@ -682,7 +688,7 @@
{
struct ht_rec *rec, *crec;
int32_t i;
- uint8_t first_matched = 0;
+ ly_bool first_matched = 0;
LY_ERR r, ret = LY_SUCCESS;
LY_CHECK_ERR_RET(lyht_find_first(ht, hash, &rec), LOGARG(NULL, hash), LY_ENOTFOUND); /* hash not found */
diff --git a/src/hash_table.h b/src/hash_table.h
index 6c44d6c..ae4008d 100644
--- a/src/hash_table.h
+++ b/src/hash_table.h
@@ -45,9 +45,9 @@
* @param[in] val2_p Pointer to the second value, the one stored in the hash table.
* @param[in] mod Whether the operation modifies the hash table (insert or remove) or not (find).
* @param[in] cb_data User callback data.
- * @return 0 on non-equal, non-zero on equal.
+ * @return false (non-equal) or true (equal).
*/
-typedef uint8_t (*values_equal_cb)(void *val1_p, void *val2_p, uint8_t mod, void *cb_data);
+typedef ly_bool (*values_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
/** when the table is at least this much percent full, it is enlarged (double the size) */
#define LYHT_ENLARGE_PERCENTAGE 75
diff --git a/src/json.c b/src/json.c
index 7656d5c..e1ec822 100644
--- a/src/json.c
+++ b/src/json.c
@@ -87,7 +87,7 @@
* @brief Set value corresponding to the current context's status
*/
static void
-lyjson_ctx_set_value(struct lyjson_ctx *jsonctx, const char *value, size_t value_len, uint8_t dynamic)
+lyjson_ctx_set_value(struct lyjson_ctx *jsonctx, const char *value, size_t value_len, ly_bool dynamic)
{
assert(jsonctx);
@@ -437,7 +437,7 @@
}
}
/* copy the value */
- uint8_t dp_placed;
+ ly_bool dp_placed;
size_t j;
for (dp_placed = dp_position ? 0 : 1, j = minus; j < exponent; j++) {
if (in[j] == '.') {
@@ -681,7 +681,7 @@
lyjson_ctx_next(struct lyjson_ctx *jsonctx, enum LYJSON_PARSER_STATUS *status)
{
LY_ERR ret = LY_SUCCESS;
- uint8_t toplevel = 0;
+ ly_bool toplevel = 0;
enum LYJSON_PARSER_STATUS prev;
assert(jsonctx);
diff --git a/src/json.h b/src/json.h
index 8948969..2f32b28 100644
--- a/src/json.h
+++ b/src/json.h
@@ -60,14 +60,14 @@
const char *value; /* LYJSON_STRING, LYJSON_NUMBER, LYJSON_OBJECT */
size_t value_len; /* LYJSON_STRING, LYJSON_NUMBER, LYJSON_OBJECT */
- uint8_t dynamic; /* LYJSON_STRING, LYJSON_NUMBER, LYJSON_OBJECT */
+ ly_bool dynamic; /* LYJSON_STRING, LYJSON_NUMBER, LYJSON_OBJECT */
struct {
enum LYJSON_PARSER_STATUS status;
uint32_t status_count;
const char *value;
size_t value_len;
- uint8_t dynamic;
+ ly_bool dynamic;
const char *input;
} backup;
};
diff --git a/src/log.c b/src/log.c
index 53a5726..d551095 100644
--- a/src/log.c
+++ b/src/log.c
@@ -34,7 +34,7 @@
volatile LY_LOG_LEVEL ly_log_level = LY_LLWRN;
volatile uint32_t ly_log_opts = LY_LOLOG | LY_LOSTORE_LAST;
static ly_log_clb log_clb;
-static volatile uint8_t path_flag = 1;
+static volatile ly_bool path_flag = 1;
#ifndef NDEBUG
volatile uint32_t ly_log_dbg_groups = 0;
#endif
@@ -210,7 +210,7 @@
}
API void
-ly_set_log_clb(ly_log_clb clb, uint8_t path)
+ly_set_log_clb(ly_log_clb clb, ly_bool path)
{
log_clb = clb;
path_flag = path;
@@ -294,7 +294,7 @@
const char *format, va_list args)
{
char *msg = NULL;
- uint8_t free_strs;
+ ly_bool free_strs;
if (level > ly_log_level) {
/* do not print or store the message */
diff --git a/src/log.h b/src/log.h
index 00eb55c..8fcb424 100644
--- a/src/log.h
+++ b/src/log.h
@@ -25,6 +25,13 @@
struct ly_ctx;
/**
+ * @brief Type to indicate boolean value.
+ *
+ * Do not test for actual value. Instead, handle it as true/false value in condition.
+ */
+typedef uint8_t ly_bool;
+
+/**
* @defgroup log Logger
* @{
*
@@ -131,7 +138,7 @@
* presence) or it can be NULL, so consider it as an optional parameter. If the flag is 0, libyang will
* not bother with resolving the path.
*/
-void ly_set_log_clb(ly_log_clb clb, uint8_t path);
+void ly_set_log_clb(ly_log_clb clb, ly_bool path);
/**
* @brief Get logger callback.
diff --git a/src/parser.c b/src/parser.c
index 2a5c7eb..7c483c4 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -288,7 +288,7 @@
}
API void
-ly_in_free(struct ly_in *in, uint8_t destroy)
+ly_in_free(struct ly_in *in, ly_bool destroy)
{
if (!in) {
return;
@@ -407,7 +407,7 @@
LY_ERR
lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, const char *value, size_t value_len,
- uint8_t *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node)
+ ly_bool *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node)
{
LY_ERR ret;
@@ -423,7 +423,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, uint8_t *dynamic, uint32_t value_hints,
+ const char *name, size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, uint32_t value_hints,
LY_PREFIX_FORMAT format, void *prefix_data, const struct lysc_node *ctx_snode)
{
LY_ERR ret;
diff --git a/src/parser.h b/src/parser.h
index 2c35f24..9375bef 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -167,7 +167,7 @@
* @param[in] destroy Flag to free the input data buffer (for LY_IN_MEMORY) or to
* close stream/file descriptor (for LY_IN_FD and LY_IN_FILE)
*/
-void ly_in_free(struct ly_in *in, uint8_t destroy);
+void ly_in_free(struct ly_in *in, ly_bool destroy);
#ifdef __cplusplus
}
diff --git a/src/parser_internal.h b/src/parser_internal.h
index 03199f8..87553f9 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -171,7 +171,7 @@
* @param[in] value_hints Data parser's hint for the value's type.
*/
LY_ERR lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, const char *value, size_t value_len,
- uint8_t *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node);
+ ly_bool *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node);
/**
* @brief Wrapper around lyd_create_meta() for data parsers.
@@ -181,7 +181,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, uint8_t *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format,
+ size_t value_len, ly_bool *dynamic, uint32_t value_hints, LY_PREFIX_FORMAT format,
void *prefix_data, const struct lysc_node *ctx_snode);
#endif /* LY_PARSER_INTERNAL_H_ */
diff --git a/src/parser_json.c b/src/parser_json.c
index ffbcc4a..8a9d280 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -86,11 +86,11 @@
*/
static void
lydjson_parse_name(const char *value, size_t value_len, const char **name_p, size_t *name_len_p, const char **prefix_p,
- size_t *prefix_len_p, uint8_t *is_meta_p)
+ size_t *prefix_len_p, ly_bool *is_meta_p)
{
const char *name, *prefix = NULL;
size_t name_len, prefix_len = 0;
- uint8_t is_meta = 0;
+ ly_bool is_meta = 0;
name = memchr(value, ':', value_len);
if (name != NULL) {
@@ -183,7 +183,7 @@
* @return LY_ENOT in case the input data are expected to be skipped
*/
static LY_ERR
-lydjson_get_snode(const struct lyd_json_ctx *lydctx, uint8_t is_attr, const char *prefix, size_t prefix_len, const char *name,
+lydjson_get_snode(const struct lyd_json_ctx *lydctx, ly_bool is_attr, const char *prefix, size_t prefix_len, const char *name,
size_t name_len, const struct lyd_node_inner *parent, const struct lysc_node **snode_p)
{
struct lys_module *mod = NULL;
@@ -372,7 +372,7 @@
while (key_set.count && status != LYJSON_OBJECT_CLOSED) {
const char *name, *prefix;
size_t name_len, prefix_len;
- uint8_t is_attr;
+ ly_bool is_attr;
/* match the key */
snode = NULL;
@@ -556,7 +556,7 @@
LY_LIST_FOR_SAFE(*first_p, next, attr) {
struct lyd_node_opaq *meta_container = (struct lyd_node_opaq *)attr;
uint64_t match = 0;
- uint8_t is_attr;
+ ly_bool is_attr;
const char *name, *prefix;
size_t name_len, prefix_len;
const struct lysc_node *snode;
@@ -600,7 +600,7 @@
/* convert opaq node to a attribute of the opaq node */
struct lyd_node_opaq *meta = (struct lyd_node_opaq *)meta_iter;
struct ly_prefix *val_prefs = NULL;
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
/* get value prefixes */
LY_CHECK_GOTO(ret = lydjson_get_value_prefixes(lydctx->jsonctx->ctx, lydctx->jsonctx->value, lydctx->jsonctx->value_len, &val_prefs), cleanup);
@@ -635,7 +635,7 @@
/* convert opaq node to a metadata of the node */
struct lyd_node_opaq *meta = (struct lyd_node_opaq *)meta_iter;
struct lys_module *mod = NULL;
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
mod = ly_ctx_get_module_implemented(lydctx->jsonctx->ctx, meta->prefix.id);
if (mod) {
@@ -702,13 +702,13 @@
LY_ERR ret = LY_SUCCESS;
enum LYJSON_PARSER_STATUS status;
const char *expected;
- uint8_t in_parent = 0;
+ ly_bool in_parent = 0;
const char *name, *prefix = NULL;
size_t name_len, prefix_len = 0;
struct lys_module *mod;
struct lyd_meta *meta = NULL;
const struct ly_ctx *ctx = lydctx->jsonctx->ctx;
- uint8_t is_attr = 0;
+ ly_bool is_attr = 0;
struct lyd_node *prev = node;
uint32_t instance = 0;
uint16_t nodetype;
@@ -929,7 +929,7 @@
const char *value = NULL, *module_name;
size_t value_len = 0, module_name_len = 0;
struct ly_prefix *val_prefs = NULL;
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
uint32_t type_hint = 0;
if (*status_inner_p != LYJSON_OBJECT && *status_inner_p != LYJSON_OBJECT_EMPTY) {
@@ -1200,7 +1200,7 @@
enum LYJSON_PARSER_STATUS status_inner = 0;
const char *name, *prefix = NULL;
size_t name_len, prefix_len = 0;
- uint8_t is_meta = 0;
+ ly_bool is_meta = 0;
const struct lysc_node *snode = NULL;
struct lyd_node *node = NULL, *attr_node = NULL;
const struct ly_ctx *ctx = lydctx->jsonctx->ctx;
@@ -1465,7 +1465,7 @@
LY_ERR ret = LY_ENOT, r;
const char *name, *prefix, *value = NULL;
size_t name_len, prefix_len, value_len;
- uint8_t is_attr, dynamic = 0;
+ ly_bool is_attr, dynamic = 0;
enum LYJSON_PARSER_STATUS status;
struct lyd_node *et;
@@ -1632,7 +1632,7 @@
LY_ERR ret = LY_ENOT, r;
const char *name, *prefix;
size_t name_len, prefix_len;
- uint8_t is_attr;
+ ly_bool is_attr;
enum LYJSON_PARSER_STATUS status;
*envp_p = NULL;
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index e084458..12a6911 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -171,9 +171,9 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_read_string(char **str, uint8_t with_length, struct lylyb_ctx *lybctx)
+lyb_read_string(char **str, ly_bool with_length, struct lylyb_ctx *lybctx)
{
- uint8_t next_chunk = 0;
+ ly_bool next_chunk = 0;
size_t len = 0, cur_len;
*str = NULL;
@@ -345,7 +345,7 @@
lyb_parse_metadata(struct lyd_lyb_ctx *lybctx, const struct lysc_node *sparent, struct lyd_meta **meta)
{
LY_ERR ret = LY_SUCCESS;
- uint8_t dynamic;
+ ly_bool dynamic;
uint8_t i, count = 0;
char *meta_name = NULL, *meta_value;
const struct lys_module *mod;
@@ -464,7 +464,7 @@
uint8_t count, i;
struct lyd_attr *attr2;
char *prefix = NULL, *module_name = NULL, *name = NULL, *value = NULL;
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
LYD_FORMAT format = 0;
struct ly_prefix *val_prefs = NULL;
@@ -688,7 +688,7 @@
struct ly_prefix *val_prefs = NULL;
LYD_ANYDATA_VALUETYPE value_type;
char *value = NULL, *name = NULL, *prefix = NULL, *module_key = NULL;
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
LYD_FORMAT format = 0;
uint32_t prev_lo;
const struct ly_ctx *ctx = lybctx->lybctx->ctx;
diff --git a/src/parser_schema.h b/src/parser_schema.h
index 6be8f6f..22b49bf 100644
--- a/src/parser_schema.h
+++ b/src/parser_schema.h
@@ -107,7 +107,7 @@
* file suffix.
* @return LY_ERR value (LY_SUCCESS is returned even if the file is not found, then the *localfile is NULL).
*/
-LY_ERR lys_search_localfile(const char * const *searchpaths, uint8_t cwd, const char *name, const char *revision,
+LY_ERR lys_search_localfile(const char * const *searchpaths, ly_bool cwd, const char *name, const char *revision,
char **localfile, LYS_INFORMAT *format);
/** @} schematree */
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index af0feee..3c36fbd 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -32,7 +32,8 @@
static LY_ERR
lysp_stmt_validate_value(struct lys_parser_ctx *ctx, enum yang_arg val_type, const char *val)
{
- uint8_t prefix = 0, first = 1;
+ uint8_t prefix = 0;
+ ly_bool first = 1;
uint32_t c;
size_t utf8_char_len;
diff --git a/src/parser_yang.c b/src/parser_yang.c
index b8b39e2..e82557d 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -139,7 +139,7 @@
*/
LY_ERR
buf_store_char(struct lys_yang_parser_ctx *ctx, struct ly_in *in, enum yang_arg arg, char **word_p, size_t *word_len,
- char **word_b, size_t *buf_len, uint8_t need_buf, uint8_t *prefix)
+ char **word_b, size_t *buf_len, ly_bool need_buf, uint8_t *prefix)
{
uint32_t c;
size_t len;
@@ -297,7 +297,8 @@
* 5 - string continues after +, skipping whitespaces */
uint8_t string;
uint64_t block_indent = 0, current_indent = 0;
- uint8_t need_buf = 0, prefix = 0;
+ ly_bool need_buf = 0;
+ uint8_t prefix = 0;
const char *c;
uint64_t trailing_ws = 0; /* current number of stored trailing whitespace characters */
diff --git a/src/plugins_types.c b/src/plugins_types.c
index f61bdc2..db236d2 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -174,7 +174,7 @@
*/
static const char *
ly_type_print_simple(const struct lyd_value *value, LY_PREFIX_FORMAT UNUSED(format),
- void *UNUSED(prefix_data), uint8_t *dynamic)
+ void *UNUSED(prefix_data), ly_bool *dynamic)
{
*dynamic = 0;
return (char *)value->canonical;
@@ -850,7 +850,7 @@
LY_ARRAY_COUNT_TYPE u, v;
char *errmsg = NULL;
struct lysc_type_bits *type_bits = (struct lysc_type_bits *)type;
- uint8_t iscanonical = 1;
+ ly_bool iscanonical = 1;
size_t ws_count;
size_t lws_count; /* leading whitespace count */
const char *can = NULL;
@@ -1186,7 +1186,7 @@
}
static const char *ly_type_print_identityref(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data,
- uint8_t *dynamic);
+ ly_bool *dynamic);
/**
* @brief Validate, canonize and store value of the YANG built-in identiytref type.
@@ -1206,7 +1206,7 @@
LY_ARRAY_COUNT_TYPE u;
struct lysc_ident *ident = NULL, *identities;
int rc = 0;
- uint8_t dyn;
+ ly_bool dyn;
if (options & LY_TYPE_OPTS_SECOND_CALL) {
return LY_SUCCESS;
@@ -1313,7 +1313,7 @@
* Implementation of the ly_type_print_clb.
*/
static const char *
-ly_type_print_identityref(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, uint8_t *dynamic)
+ly_type_print_identityref(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, ly_bool *dynamic)
{
char *result = NULL;
@@ -1326,7 +1326,7 @@
}
static const char *ly_type_print_instanceid(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data,
- uint8_t *dynamic);
+ ly_bool *dynamic);
/**
* @brief Validate and store value of the YANG built-in instance-identifier type.
@@ -1347,7 +1347,7 @@
const struct lysc_node *ctx_scnode;
int rc = 0;
uint32_t prefix_opt = 0;
- uint8_t dyn;
+ ly_bool dyn;
/* init */
*err = NULL;
@@ -1376,7 +1376,7 @@
if (ly_path_eval(storage->target, tree, NULL)) {
/* in error message we print the JSON format of the instance-identifier - in case of XML, it is not possible
* to get the exactly same string as original, JSON is less demanding and still well readable/understandable. */
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
const char *id = storage->realtype->plugin->print(storage, LY_PREF_JSON, NULL, &dynamic);
rc = asprintf(&errmsg, "Invalid instance-identifier \"%s\" value - required instance not found.", id);
if (dynamic) {
@@ -1523,7 +1523,7 @@
* Implementation of the ly_type_print_clb.
*/
static const char *
-ly_type_print_instanceid(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, uint8_t *dynamic)
+ly_type_print_instanceid(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, ly_bool *dynamic)
{
LY_ARRAY_COUNT_TYPE u, v;
char *result = NULL;
@@ -1550,7 +1550,7 @@
case LY_PATH_PREDTYPE_LIST:
{
/* key-predicate */
- uint8_t d = 0;
+ ly_bool d = 0;
const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
char quot = '\'';
if (strchr(value, quot)) {
@@ -1566,7 +1566,7 @@
case LY_PATH_PREDTYPE_LEAFLIST:
{
/* leaf-list-predicate */
- uint8_t d = 0;
+ ly_bool d = 0;
const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
char quot = '\'';
if (strchr(value, quot)) {
@@ -1603,7 +1603,7 @@
case LY_PATH_PREDTYPE_LIST:
{
/* key-predicate */
- uint8_t d = 0;
+ ly_bool d = 0;
const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
char quot = '\'';
if (strchr(value, quot)) {
@@ -1618,7 +1618,7 @@
case LY_PATH_PREDTYPE_LEAFLIST:
{
/* leaf-list-predicate */
- uint8_t d = 0;
+ ly_bool d = 0;
const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
char quot = '\'';
if (strchr(value, quot)) {
@@ -1676,7 +1676,7 @@
LY_ERR ret;
struct lyxp_set set = {0};
const char *val_str;
- uint8_t dynamic;
+ ly_bool dynamic;
uint32_t i;
/* find all target data instances */
@@ -1813,7 +1813,7 @@
* Implementation of the ly_type_print_clb.
*/
static const char *
-ly_type_print_leafref(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, uint8_t *dynamic)
+ly_type_print_leafref(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, ly_bool *dynamic)
{
return value->realtype->plugin->print(value, format, prefix_data, dynamic);
}
@@ -2189,7 +2189,7 @@
* Implementation of the ly_type_print_clb.
*/
static const char *
-ly_type_print_union(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, uint8_t *dynamic)
+ly_type_print_union(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data, ly_bool *dynamic)
{
return value->subvalue->value->realtype->plugin->print(value->subvalue->value, format, prefix_data, dynamic);
}
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 885b6b0..34dec40 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -234,7 +234,7 @@
* @return NULL in case of error.
*/
typedef const char *(*ly_type_print_clb)(const struct lyd_value *value, LY_PREFIX_FORMAT format, void *prefix_data,
- uint8_t *dynamic);
+ ly_bool *dynamic);
/**
* @brief Callback to duplicate data in data structure. Note that callback is even responsible for duplicating lyd_value::canonized.
diff --git a/src/printer.c b/src/printer.c
index 4b07b8b..def1fa8 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -71,7 +71,7 @@
{"unique", "tag", 0}, /**< LYEXT_SUBSTMT_UNIQUE */
};
-uint8_t
+ly_bool
ly_is_default(const struct lyd_node *node)
{
const struct lysc_node_leaf *leaf;
@@ -109,7 +109,7 @@
return 1;
}
-uint8_t
+ly_bool
ly_should_print(const struct lyd_node *node, uint32_t options)
{
const struct lyd_node *elem;
@@ -429,7 +429,7 @@
}
API void
-ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), uint8_t destroy)
+ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), ly_bool destroy)
{
if (!out) {
return;
diff --git a/src/printer.h b/src/printer.h
index 3ffbef1..eabad42 100644
--- a/src/printer.h
+++ b/src/printer.h
@@ -237,7 +237,7 @@
* @param[in] destroy Flag to free allocated buffer (for LY_OUT_MEMORY) or to
* close stream/file descriptor (for LY_OUT_FD, LY_OUT_FDSTREAM and LY_OUT_FILE)
*/
-void ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), uint8_t destroy);
+void ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), ly_bool destroy);
#ifdef __cplusplus
}
diff --git a/src/printer_internal.h b/src/printer_internal.h
index 3703ad0..5894923 100644
--- a/src/printer_internal.h
+++ b/src/printer_internal.h
@@ -188,20 +188,18 @@
* @brief Check whether a node value equals to its default one.
*
* @param[in] node Term node to test.
- * @return 0 if no,
- * @return 1 if yes.
+ * @return false (no, it is not a default node) or true (yes, it is default)
*/
-uint8_t ly_is_default(const struct lyd_node *node);
+ly_bool ly_is_default(const struct lyd_node *node);
/**
* @brief Check whether the node should even be printed.
*
* @param[in] node Node to check.
* @param[in] options Printer options.
- * @return 0 if no.
- * @return 1 if yes.
+ * @return false (no, it should not be printed) or true (yes, it is supposed to be printed)
*/
-uint8_t ly_should_print(const struct lyd_node *node, uint32_t options);
+ly_bool ly_should_print(const struct lyd_node *node, uint32_t options);
/**
* @brief Generic printer of the given format string into the specified output.
diff --git a/src/printer_json.c b/src/printer_json.c
index 3abb3e8..3119853 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -261,7 +261,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-json_print_member(struct jsonpr_ctx *ctx, const struct lyd_node *node, uint8_t is_attr)
+json_print_member(struct jsonpr_ctx *ctx, const struct lyd_node *node, ly_bool is_attr)
{
PRINT_COMMA;
if (LEVEL == 1 || json_nscmp(node, (const struct lyd_node *)node->parent)) {
@@ -289,7 +289,7 @@
*/
static LY_ERR
json_print_member2(struct jsonpr_ctx *ctx, const struct lyd_node *parent, LYD_FORMAT format,
- const struct ly_prefix *prefix, const char *name, uint8_t is_attr)
+ const struct ly_prefix *prefix, const char *name, ly_bool is_attr)
{
const char *module_name = NULL;
@@ -336,7 +336,7 @@
static LY_ERR
json_print_value(struct jsonpr_ctx *ctx, const struct lyd_value *val)
{
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
const char *value = val->realtype->plugin->print(val, LY_PREF_JSON, NULL, &dynamic);
/* leafref is not supported */
@@ -447,11 +447,11 @@
*
* @param[in] ctx JSON printer context.
* @param[in] node Data node where the attributes/metadata are placed.
- * @param[in] wdmod With-defaults module to mark that default attribute is supposed to be printed.
+ * @param[in] inner Flag if the @p node is an inner node in the tree.
* @return LY_ERR value.
*/
static LY_ERR
-json_print_attributes(struct jsonpr_ctx *ctx, const struct lyd_node *node, uint8_t inner)
+json_print_attributes(struct jsonpr_ctx *ctx, const struct lyd_node *node, ly_bool inner)
{
const struct lys_module *wdmod = NULL;
@@ -592,7 +592,7 @@
{
struct lyd_node *child;
struct lyd_node *children = lyd_node_children(node, 0);
- uint8_t has_content = 0;
+ ly_bool has_content = 0;
if (node->meta || children) {
has_content = 1;
@@ -752,7 +752,7 @@
static LY_ERR
json_print_opaq(struct jsonpr_ctx *ctx, const struct lyd_node_opaq *node)
{
- uint8_t first = 1, last = 1;
+ ly_bool first = 1, last = 1;
if (node->hint & LYD_NODE_OPAQ_ISLIST) {
const struct lyd_node_opaq *prev = (const struct lyd_node_opaq *)node->prev;
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index 0f5cf76..e45a919 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -38,9 +38,11 @@
/**
* @brief Hash table equal callback for checking hash equality only.
+ *
+ * Implementation of ::values_equal_cb.
*/
-static uint8_t
-lyb_hash_equal_cb(void *UNUSED(val1_p), void *UNUSED(val2_p), uint8_t UNUSED(mod), void *UNUSED(cb_data))
+static ly_bool
+lyb_hash_equal_cb(void *UNUSED(val1_p), void *UNUSED(val2_p), ly_bool UNUSED(mod), void *UNUSED(cb_data))
{
/* for this purpose, if hash matches, the value does also, we do not want 2 values to have the same hash */
return 1;
@@ -48,9 +50,11 @@
/**
* @brief Hash table equal callback for checking value pointer equality only.
+ *
+ * Implementation of ::values_equal_cb.
*/
-static uint8_t
-lyb_ptr_equal_cb(void *val1_p, void *val2_p, uint8_t UNUSED(mod), void *UNUSED(cb_data))
+static ly_bool
+lyb_ptr_equal_cb(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
{
struct lysc_node *val1 = *(struct lysc_node **)val1_p;
struct lysc_node *val2 = *(struct lysc_node **)val2_p;
@@ -379,7 +383,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_write_string(const char *str, size_t str_len, uint8_t with_length, struct ly_out *out, struct lylyb_ctx *lybctx)
+lyb_write_string(const char *str, size_t str_len, ly_bool with_length, struct ly_out *out, struct lylyb_ctx *lybctx)
{
if (!str) {
str = "";
diff --git a/src/printer_xml.c b/src/printer_xml.c
index a90b012..3b92a9f 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -140,11 +140,11 @@
const char **prefs, **nss;
const char *xml_expr = NULL, *mod_name;
uint32_t ns_count, i;
- uint8_t rpc_filter = 0;
+ ly_bool rpc_filter = 0;
char *p;
size_t len;
#endif
- uint8_t dynamic;
+ ly_bool dynamic;
/* with-defaults */
if (node->schema->nodetype & LYD_NODE_TERM) {
@@ -288,7 +288,7 @@
xml_print_term(struct xmlpr_ctx *ctx, const struct lyd_node_term *node)
{
struct ly_set ns_list = {0};
- uint8_t dynamic;
+ ly_bool dynamic;
const char *value;
xml_print_node_open(ctx, (struct lyd_node *)node);
diff --git a/src/printer_yang.c b/src/printer_yang.c
index a13b3d8..1c3a196 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -122,7 +122,7 @@
}
static void
-ypr_open(struct ly_out *out, uint8_t *flag)
+ypr_open(struct ly_out *out, ly_bool *flag)
{
if (flag && !*flag) {
*flag = 1;
@@ -131,7 +131,7 @@
}
static void
-ypr_close(struct ypr_ctx *ctx, uint8_t flag)
+ypr_close(struct ypr_ctx *ctx, ly_bool flag)
{
if (flag) {
ly_print_(ctx->out, "%*s}\n", INDENT);
@@ -141,7 +141,7 @@
}
static void
-ypr_text(struct ypr_ctx *ctx, const char *name, const char *text, uint8_t singleline, uint8_t closed)
+ypr_text(struct ypr_ctx *ctx, const char *name, const char *text, ly_bool singleline, ly_bool closed)
{
const char *s, *t;
@@ -219,11 +219,11 @@
*/
static void
yprp_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
- struct lysp_ext_instance *ext, uint8_t *flag, LY_ARRAY_COUNT_TYPE count)
+ struct lysp_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_stmt *stmt;
- uint8_t child_presence;
+ ly_bool child_presence;
const char *argument;
if (!count && ext) {
@@ -285,7 +285,7 @@
*/
static void
yprc_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
- struct lysc_ext_instance *ext, uint8_t *flag, LY_ARRAY_COUNT_TYPE count)
+ struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)
{
LY_ARRAY_COUNT_TYPE u;
@@ -310,7 +310,7 @@
ypr_substmt(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t extflag = 0;
+ ly_bool extflag = 0;
if (!text) {
/* nothing to print */
@@ -340,7 +340,7 @@
}
static void
-ypr_unsigned(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, uint8_t *flag)
+ypr_unsigned(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)
{
char *str;
@@ -354,7 +354,7 @@
}
static void
-ypr_signed(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, signed long int attr_value, uint8_t *flag)
+ypr_signed(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)
{
char *str;
@@ -384,7 +384,7 @@
}
static void
-ypr_mandatory(struct ypr_ctx *ctx, uint16_t flags, void *exts, uint8_t *flag)
+ypr_mandatory(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
{
if (flags & LYS_MAND_MASK) {
ypr_open(ctx->out, flag);
@@ -393,7 +393,7 @@
}
static void
-ypr_config(struct ypr_ctx *ctx, uint16_t flags, void *exts, uint8_t *flag)
+ypr_config(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
{
if (flags & LYS_CONFIG_MASK) {
ypr_open(ctx->out, flag);
@@ -402,7 +402,7 @@
}
static void
-ypr_status(struct ypr_ctx *ctx, uint16_t flags, void *exts, uint8_t *flag)
+ypr_status(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)
{
const char *status = NULL;
@@ -421,7 +421,7 @@
}
static void
-ypr_description(struct ypr_ctx *ctx, const char *dsc, void *exts, uint8_t *flag)
+ypr_description(struct ypr_ctx *ctx, const char *dsc, void *exts, ly_bool *flag)
{
if (dsc) {
ypr_open(ctx->out, flag);
@@ -430,7 +430,7 @@
}
static void
-ypr_reference(struct ypr_ctx *ctx, const char *ref, void *exts, uint8_t *flag)
+ypr_reference(struct ypr_ctx *ctx, const char *ref, void *exts, ly_bool *flag)
{
if (ref) {
ypr_open(ctx->out, flag);
@@ -439,10 +439,10 @@
}
static void
-yprp_iffeatures(struct ypr_ctx *ctx, const char **iff, struct lysp_ext_instance *exts, uint8_t *flag)
+yprp_iffeatures(struct ypr_ctx *ctx, const char **iff, struct lysp_ext_instance *exts, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t extflag;
+ ly_bool extflag;
LY_ARRAY_FOR(iff, u) {
ypr_open(ctx->out, flag);
@@ -466,7 +466,7 @@
static void
yprc_iffeature(struct ypr_ctx *ctx, struct lysc_iffeature *feat, size_t *index_e, size_t *index_f)
{
- uint8_t brackets_flag = *index_e ? 1 : 0;
+ ly_bool brackets_flag = *index_e ? 1 : 0;
uint8_t op;
op = lysc_iff_getop(feat->expr, *index_e);
@@ -507,10 +507,10 @@
}
static void
-yprc_iffeatures(struct ypr_ctx *ctx, struct lysc_iffeature *iff, struct lysc_ext_instance *exts, uint8_t *flag)
+yprc_iffeatures(struct ypr_ctx *ctx, struct lysc_iffeature *iff, struct lysc_ext_instance *exts, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u, v;
- uint8_t extflag;
+ ly_bool extflag;
LY_ARRAY_FOR(iff, u) {
size_t index_e = 0, index_f = 0;
@@ -538,7 +538,7 @@
static void
yprp_extension(struct ypr_ctx *ctx, const struct lysp_ext *ext)
{
- uint8_t flag = 0, flag2 = 0;
+ ly_bool flag = 0, flag2 = 0;
LY_ARRAY_COUNT_TYPE u;
ly_print_(ctx->out, "%*sextension %s", INDENT, ext->name);
@@ -578,7 +578,7 @@
static void
yprp_feature(struct ypr_ctx *ctx, const struct lysp_feature *feat)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "\n%*sfeature %s", INDENT, feat->name);
LEVEL++;
@@ -594,7 +594,7 @@
static void
yprc_feature(struct ypr_ctx *ctx, const struct lysc_feature *feat)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "\n%*sfeature %s", INDENT, feat->name);
LEVEL++;
@@ -610,7 +610,7 @@
static void
yprp_identity(struct ypr_ctx *ctx, const struct lysp_ident *ident)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
LY_ARRAY_COUNT_TYPE u;
ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
@@ -635,7 +635,7 @@
static void
yprc_identity(struct ypr_ctx *ctx, const struct lysc_ident *ident)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
LY_ARRAY_COUNT_TYPE u;
ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
@@ -662,9 +662,9 @@
}
static void
-yprp_restr(struct ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, uint8_t *flag)
+yprp_restr(struct ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
if (!restr) {
return;
@@ -698,9 +698,9 @@
}
static void
-yprc_must(struct ypr_ctx *ctx, const struct lysc_must *must, uint8_t *flag)
+yprc_must(struct ypr_ctx *ctx, const struct lysc_must *must, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
ypr_open(ctx->out, flag);
ly_print_(ctx->out, "%*smust \"", INDENT);
@@ -725,9 +725,9 @@
}
static void
-yprc_range(struct ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE basetype, uint8_t *flag)
+yprc_range(struct ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE basetype, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
LY_ARRAY_COUNT_TYPE u;
if (!range) {
@@ -774,9 +774,9 @@
}
static void
-yprc_pattern(struct ypr_ctx *ctx, const struct lysc_pattern *pattern, uint8_t *flag)
+yprc_pattern(struct ypr_ctx *ctx, const struct lysc_pattern *pattern, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
ypr_open(ctx->out, flag);
ly_print_(ctx->out, "%*spattern \"", INDENT);
@@ -806,9 +806,9 @@
}
static void
-yprp_when(struct ypr_ctx *ctx, struct lysp_when *when, uint8_t *flag)
+yprp_when(struct ypr_ctx *ctx, struct lysp_when *when, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
if (!when) {
return;
@@ -828,9 +828,9 @@
}
static void
-yprc_when(struct ypr_ctx *ctx, struct lysc_when *when, uint8_t *flag)
+yprc_when(struct ypr_ctx *ctx, struct lysc_when *when, ly_bool *flag)
{
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
if (!when) {
return;
@@ -850,10 +850,10 @@
}
static void
-yprp_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, uint8_t *flag)
+yprp_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t inner_flag;
+ ly_bool inner_flag;
LY_ARRAY_FOR(items, u) {
ypr_open(ctx->out, flag);
@@ -887,7 +887,7 @@
yprp_type(struct ypr_ctx *ctx, const struct lysp_type *type)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "%*stype %s", INDENT, type->name);
LEVEL++;
@@ -929,7 +929,7 @@
static void
yprc_dflt_value(struct ypr_ctx *ctx, const struct lyd_value *value, struct lysc_ext_instance *exts)
{
- uint8_t dynamic;
+ ly_bool dynamic;
const char *str;
str = value->realtype->plugin->print(value, LY_PREF_JSON, NULL, &dynamic);
@@ -943,7 +943,7 @@
yprc_type(struct ypr_ctx *ctx, const struct lysc_type *type)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));
LEVEL++;
@@ -982,7 +982,7 @@
struct lysc_type_bits *bits = (struct lysc_type_bits *)type;
LY_ARRAY_FOR(bits->bits, u) {
struct lysc_type_bitenum_item *item = &bits->bits[u];
- uint8_t inner_flag = 0;
+ ly_bool inner_flag = 0;
ypr_open(ctx->out, &flag);
ly_print_(ctx->out, "%*s%s \"", INDENT, type->basetype == LY_TYPE_BITS ? "bit" : "enum");
@@ -1086,7 +1086,7 @@
yprp_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *data;
ly_print_(ctx->out, "\n%*sgrouping %s", INDENT, grp->name);
@@ -1121,7 +1121,7 @@
}
static void
-yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, uint8_t *flag)
+yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
@@ -1155,7 +1155,7 @@
}
static void
-yprc_inout(struct ypr_ctx *ctx, const struct lysc_action *action, const struct lysc_action_inout *inout, uint8_t *flag)
+yprc_inout(struct ypr_ctx *ctx, const struct lysc_action *action, const struct lysc_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_node *data;
@@ -1188,7 +1188,7 @@
yprp_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *data;
ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
@@ -1227,7 +1227,7 @@
yprc_notification(struct ypr_ctx *ctx, const struct lysc_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node *data;
ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
@@ -1258,7 +1258,7 @@
yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
@@ -1289,7 +1289,7 @@
static void
yprc_action(struct ypr_ctx *ctx, const struct lysc_action *action)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
@@ -1308,7 +1308,7 @@
}
static void
-yprp_node_common1(struct ypr_ctx *ctx, const struct lysp_node *node, uint8_t *flag)
+yprp_node_common1(struct ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag)
{
ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
LEVEL++;
@@ -1319,7 +1319,7 @@
}
static void
-yprc_node_common1(struct ypr_ctx *ctx, const struct lysc_node *node, uint8_t *flag)
+yprc_node_common1(struct ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
@@ -1344,13 +1344,13 @@
ypr_reference(ctx, node->ref, node->exts, flag)
static void
-yprp_node_common2(struct ypr_ctx *ctx, const struct lysp_node *node, uint8_t *flag)
+yprp_node_common2(struct ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag)
{
YPR_NODE_COMMON2;
}
static void
-yprc_node_common2(struct ypr_ctx *ctx, const struct lysc_node *node, uint8_t *flag)
+yprc_node_common2(struct ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag)
{
YPR_NODE_COMMON2;
}
@@ -1361,7 +1361,7 @@
yprp_container(struct ypr_ctx *ctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_container *cont = (struct lysp_node_container *)node;
@@ -1410,7 +1410,7 @@
yprc_container(struct ypr_ctx *ctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node *child;
struct lysc_node_container *cont = (struct lysc_node_container *)node;
@@ -1450,7 +1450,7 @@
static void
yprp_case(struct ypr_ctx *ctx, const struct lysp_node *node)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_case *cas = (struct lysp_node_case *)node;
@@ -1469,7 +1469,7 @@
static void
yprc_case(struct ypr_ctx *ctx, const struct lysc_node_case *cs)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node *child;
yprc_node_common1(ctx, (struct lysc_node *)cs, &flag);
@@ -1489,7 +1489,7 @@
static void
yprp_choice(struct ypr_ctx *ctx, const struct lysp_node *node)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_choice *choice = (struct lysp_node_choice *)node;
@@ -1514,7 +1514,7 @@
static void
yprc_choice(struct ypr_ctx *ctx, const struct lysc_node *node)
{
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node_case *cs;
struct lysc_node_choice *choice = (struct lysc_node_choice *)node;
@@ -1663,7 +1663,7 @@
yprp_list(struct ypr_ctx *ctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node *child;
struct lysp_node_list *list = (struct lysp_node_list *)node;
@@ -1735,7 +1735,7 @@
yprc_list(struct ypr_ctx *ctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u, v;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node *child;
struct lysc_node_list *list = (struct lysc_node_list *)node;
@@ -1801,7 +1801,7 @@
yprp_refine(struct ypr_ctx *ctx, struct lysp_refine *refine)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
ly_print_(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid);
LEVEL++;
@@ -1883,7 +1883,7 @@
yprp_uses(struct ypr_ctx *ctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
yprp_node_common1(ctx, node, &flag);
@@ -1907,7 +1907,7 @@
yprp_anydata(struct ypr_ctx *ctx, const struct lysp_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysp_node_anydata *any = (struct lysp_node_anydata *)node;
yprp_node_common1(ctx, node, &flag);
@@ -1927,7 +1927,7 @@
yprc_anydata(struct ypr_ctx *ctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u;
- uint8_t flag = 0;
+ ly_bool flag = 0;
struct lysc_node_anydata *any = (struct lysc_node_anydata *)node;
yprc_node_common1(ctx, node, &flag);
diff --git a/src/set.c b/src/set.c
index dcb3334..2249494 100644
--- a/src/set.c
+++ b/src/set.c
@@ -75,7 +75,7 @@
free(set);
}
-API uint8_t
+API ly_bool
ly_set_contains(const struct ly_set *set, void *object, uint32_t *index_p)
{
LY_CHECK_ARG_RET(NULL, set, 0);
diff --git a/src/set.h b/src/set.h
index eebc7b3..1a2269d 100644
--- a/src/set.h
+++ b/src/set.h
@@ -121,9 +121,9 @@
* @param[in] set Set to explore.
* @param[in] object Object to be found in the set.
* @param[out] index_p Optional pointer to return index of the searched @p object.
- * @return Boolean value (0 is false) if the @p object was found in the @p set.
+ * @return Boolean value whether the @p object was found in the @p set.
*/
-uint8_t ly_set_contains(const struct ly_set *set, void *object, uint32_t *index_p);
+ly_bool ly_set_contains(const struct ly_set *set, void *object, uint32_t *index_p);
/**
* @brief Remove all objects from the set, but keep the set container for further use.
diff --git a/src/tree_data.c b/src/tree_data.c
index 9b8d953..23f85ef 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -54,7 +54,7 @@
struct lyd_node **match);
LY_ERR
-lyd_value_parse(struct lyd_node_term *node, const char *value, size_t value_len, uint8_t *dynamic, uint8_t second,
+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)
{
LY_ERR ret = LY_SUCCESS;
@@ -91,7 +91,7 @@
/* similar to lyd_value_parse except can be used just to store the value, hence also does 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,
+lyd_value_store(struct lyd_value *val, const struct lysc_node *schema, const char *value, size_t value_len, ly_bool *dynamic,
LY_PREFIX_FORMAT format, void *prefix_data)
{
LY_ERR ret = LY_SUCCESS;
@@ -122,8 +122,8 @@
}
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, const struct lysc_node *ctx_snode,
+lyd_value_parse_meta(const struct ly_ctx *ctx, struct lyd_meta *meta, 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 lysc_node *ctx_snode,
const struct lyd_node *tree)
{
LY_ERR ret = LY_SUCCESS;
@@ -533,7 +533,7 @@
}
LY_ERR
-lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, uint8_t *dynamic, uint32_t value_hint,
+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)
{
LY_ERR ret;
@@ -693,7 +693,7 @@
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, size_t pref_len,
+ 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)
{
struct lyd_node_opaq *opaq;
@@ -1087,7 +1087,7 @@
struct lyd_node_term *t;
struct lyd_node *parent;
struct lyd_value val = {0};
- uint8_t dflt_change, val_change;
+ ly_bool dflt_change, val_change;
LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
@@ -1163,7 +1163,7 @@
LY_ERR ret = LY_SUCCESS;
struct lyd_meta *m2;
struct lyd_value val;
- uint8_t val_change;
+ ly_bool val_change;
LY_CHECK_ARG_RET(NULL, meta, LY_EINVAL);
@@ -1601,7 +1601,7 @@
{
const struct lysc_node *schema, *sparent;
struct lyd_node *match = NULL;
- uint8_t found;
+ ly_bool found;
assert(new_node);
@@ -2118,7 +2118,7 @@
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, LY_PREFIX_FORMAT format,
+ 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)
{
LY_ERR ret;
@@ -2196,7 +2196,7 @@
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)
{
struct lyd_attr *at, *last;
@@ -2614,7 +2614,7 @@
struct lyd_node_inner **local_parent)
{
const struct lyd_node_inner *orig_parent, *iter;
- uint8_t repeat = 1;
+ ly_bool repeat = 1;
*dup_parent = NULL;
*local_parent = NULL;
@@ -2660,7 +2660,7 @@
}
static LY_ERR
-lyd_dup(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, uint8_t nosiblings, struct lyd_node **dup)
+lyd_dup(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, ly_bool nosiblings, struct lyd_node **dup)
{
LY_ERR rc;
const struct lyd_node *orig; /* original node to be duplicated */
@@ -2828,10 +2828,10 @@
}
static LY_ERR
-lyd_merge(struct lyd_node **target, const struct lyd_node *source, uint16_t options, uint8_t nosiblings)
+lyd_merge(struct lyd_node **target, const struct lyd_node *source, uint16_t options, ly_bool nosiblings)
{
const struct lyd_node *sibling_src, *tmp;
- uint8_t first;
+ ly_bool first;
LY_CHECK_ARG_RET(NULL, target, LY_EINVAL);
@@ -2846,7 +2846,7 @@
}
LY_LIST_FOR_SAFE(source, tmp, sibling_src) {
- first = sibling_src == source ? 1 : 0;
+ first = (sibling_src == source) ? 1 : 0;
LY_CHECK_RET(lyd_merge_sibling_r(target, NULL, &sibling_src, options));
if (first && !sibling_src) {
/* source was spent (unlinked), move to the next node */
@@ -2879,7 +2879,7 @@
}
static LY_ERR
-lyd_path_str_enlarge(char **buffer, size_t *buflen, size_t reqlen, uint8_t is_static)
+lyd_path_str_enlarge(char **buffer, size_t *buflen, size_t reqlen, ly_bool is_static)
{
/* ending \0 */
++reqlen;
@@ -2901,7 +2901,7 @@
}
LY_ERR
-lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, uint8_t is_static)
+lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static)
{
const struct lyd_node *key;
size_t len;
@@ -2934,7 +2934,7 @@
* @return LY_ERR
*/
static LY_ERR
-lyd_path_leaflist_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, uint8_t is_static)
+lyd_path_leaflist_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static)
{
size_t len;
const char *val;
@@ -2964,7 +2964,7 @@
* @return LY_ERR
*/
static LY_ERR
-lyd_path_position_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, uint8_t is_static)
+lyd_path_position_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static)
{
const struct lyd_node *first, *iter;
size_t len;
@@ -3003,7 +3003,7 @@
API char *
lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen)
{
- uint8_t is_static = 0;
+ ly_bool is_static = 0;
uint32_t i, depth;
size_t bufused = 0, len;
const struct lyd_node *iter;
@@ -3192,8 +3192,15 @@
return LY_SUCCESS;
}
-static uint8_t
-lyd_hash_table_schema_val_equal(void *val1_p, void *val2_p, uint8_t UNUSED(mod), void *UNUSED(cb_data))
+/**
+ * @brief Comparison callback to match schema node with a schema of a data node.
+ *
+ * @param[in] val1_p Pointer to the schema node
+ * @param[in] val2_p Pointer to the data node
+ * Implementation of ::values_equal_cb.
+ */
+static ly_bool
+lyd_hash_table_schema_val_equal(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
{
struct lysc_node *val1;
struct lyd_node *val2;
diff --git a/src/tree_data.h b/src/tree_data.h
index e5d75d3..33855ec 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -89,7 +89,7 @@
* @param ELEM Iterator intended for use in the block.
*/
#define LYD_TREE_DFS_BEGIN(START, ELEM) \
- { uint8_t LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
+ { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
(ELEM); \
(ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index 7c0a52a..176d39f 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -23,7 +23,7 @@
#include "plugins_types.h"
static void
-lyd_free_meta(struct lyd_meta *meta, uint8_t siblings)
+lyd_free_meta(struct lyd_meta *meta, ly_bool siblings)
{
struct lyd_meta *iter;
@@ -77,7 +77,7 @@
}
static void
-ly_free_attr(const struct ly_ctx *ctx, struct lyd_attr *attr, uint8_t siblings)
+ly_free_attr(const struct ly_ctx *ctx, struct lyd_attr *attr, ly_bool siblings)
{
struct lyd_attr *iter;
LY_ARRAY_COUNT_TYPE u;
@@ -157,7 +157,7 @@
* @param[in] top Recursion flag to unlink the root of the subtree being freed.
*/
static void
-lyd_free_subtree(struct lyd_node *node, uint8_t top)
+lyd_free_subtree(struct lyd_node *node, ly_bool top)
{
struct lyd_node *iter, *next;
struct lyd_node *children;
@@ -222,7 +222,7 @@
}
static void
-lyd_free_(struct lyd_node *node, uint8_t top)
+lyd_free_(struct lyd_node *node, ly_bool top)
{
struct lyd_node *iter, *next;
diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c
index 177a394..482ce15 100644
--- a/src/tree_data_hash.c
+++ b/src/tree_data_hash.c
@@ -83,8 +83,13 @@
return LY_SUCCESS;
}
-static uint8_t
-lyd_hash_table_val_equal(void *val1_p, void *val2_p, uint8_t mod, void *UNUSED(cb_data))
+/**
+ * @brief Compare callback for values in hash table.
+ *
+ * Implementation of ::values_equal_cb.
+ */
+static ly_bool
+lyd_hash_table_val_equal(void *val1_p, void *val2_p, ly_bool mod, void *UNUSED(cb_data))
{
struct lyd_node *val1, *val2;
@@ -120,7 +125,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyd_insert_hash_add(struct hash_table *ht, struct lyd_node *node, uint8_t empty_ht)
+lyd_insert_hash_add(struct hash_table *ht, struct lyd_node *node, ly_bool empty_ht)
{
uint32_t hash;
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 905eadc..a8da204 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -339,7 +339,7 @@
return hash;
}
-uint8_t
+ly_bool
lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models)
{
LY_ARRAY_COUNT_TYPE u;
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_ */
diff --git a/src/tree_schema.c b/src/tree_schema.c
index a4f81e3..dd5a031 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -44,7 +44,7 @@
{
const struct lysc_node *next = NULL;
struct lysc_node **snode;
- uint8_t action_flag = 0, notif_flag = 0;
+ ly_bool action_flag = 0, notif_flag = 0;
const struct lysc_action *actions;
const struct lysc_notif *notifs;
LY_ARRAY_COUNT_TYPE u;
@@ -549,13 +549,14 @@
* @param[in] name Name of the feature to set. Asterisk ('*') can be used to
* set all the features in the module.
* @param[in] value Desired value of the feature: 1 (enable) or 0 (disable).
+ * @param[in] skip_checks Flag to skip checking of if-features and just set @p value of the feature.
* @return LY_ERR value.
*/
static LY_ERR
-lys_feature_change(const struct lys_module *mod, const char *name, uint8_t value, uint8_t skip_checks)
+lys_feature_change(const struct lys_module *mod, const char *name, ly_bool value, ly_bool skip_checks)
{
LY_ERR ret = LY_SUCCESS;
- uint8_t all = 0;
+ ly_bool all = 0;
LY_ARRAY_COUNT_TYPE u, disabled_count;
uint32_t changed_count;
struct lysc_feature *f, **df;
@@ -774,7 +775,7 @@
}
API const struct lysc_node *
-lysc_node_is_disabled(const struct lysc_node *node, uint8_t recursive)
+lysc_node_is_disabled(const struct lysc_node *node, ly_bool recursive)
{
LY_ARRAY_COUNT_TYPE u;
@@ -972,7 +973,7 @@
}
LY_ERR
-lys_parse_mem_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, uint8_t implement,
+lys_parse_mem_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool implement,
LY_ERR (*custom_check)(const struct ly_ctx *ctx, struct lysp_module *mod, struct lysp_submodule *submod, void *data),
void *check_data, struct lys_module **module)
{
@@ -1240,12 +1241,12 @@
}
API LY_ERR
-lys_search_localfile(const char * const *searchpaths, uint8_t cwd, const char *name, const char *revision,
+lys_search_localfile(const char * const *searchpaths, ly_bool cwd, const char *name, const char *revision,
char **localfile, LYS_INFORMAT *format)
{
LY_ERR ret = LY_EMEM;
size_t len, flen, match_len = 0, dir_len;
- uint8_t implicit_cwd = 0;
+ ly_bool implicit_cwd = 0;
char *wd, *wn = NULL;
DIR *dir = NULL;
struct dirent *file;
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 12aa93d..75cbfca 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -69,7 +69,7 @@
* @param ELEM Iterator intended for use in the block.
*/
#define LYSC_TREE_DFS_BEGIN(START, ELEM) \
- { uint8_t LYSC_TREE_DFS_continue = 0; struct lysc_node *LYSC_TREE_DFS_next; \
+ { ly_bool LYSC_TREE_DFS_continue = 0; struct lysc_node *LYSC_TREE_DFS_next; \
for ((ELEM) = (LYSC_TREE_DFS_next) = (struct lysc_node*)(START); \
(ELEM); \
(ELEM) = (LYSC_TREE_DFS_next), LYSC_TREE_DFS_continue = 0)
@@ -1724,10 +1724,9 @@
*
* @param[in] node Node to examine.
* @return non-zero if it is,
- * @return 0 if not.
- * @return 1 if the @p node is user-ordered
+ * @return Boolean value whether the @p node is user-ordered or not.
*/
-uint8_t lysc_is_userordered(const struct lysc_node *schema);
+ly_bool lysc_is_userordered(const struct lysc_node *schema);
/**
* @brief Set a schema private pointer to a user pointer.
@@ -2016,7 +2015,7 @@
* @return NULL if enabled,
* @return pointer to the node with the unsatisfied (disabled) if-feature expression.
*/
-const struct lysc_node *lysc_node_is_disabled(const struct lysc_node *node, uint8_t recursive);
+const struct lysc_node *lysc_node_is_disabled(const struct lysc_node *node, ly_bool recursive);
/**
* @brief Set a schema private pointer to a user pointer.
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 6c2446d..87a5734 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -1500,7 +1500,7 @@
* @return LY_SUCCESS or LY_EEXIST for invalid order.
*/
static LY_ERR
-range_part_check_ascendancy(uint8_t unsigned_value, uint8_t max, int64_t value, int64_t prev_value)
+range_part_check_ascendancy(ly_bool unsigned_value, ly_bool max, int64_t value, int64_t prev_value)
{
if (unsigned_value) {
if ((max && (uint64_t)prev_value > (uint64_t)value) || (!max && (uint64_t)prev_value >= (uint64_t)value)) {
@@ -1531,8 +1531,8 @@
* frdigits value), LY_EMEM.
*/
static LY_ERR
-range_part_minmax(struct lysc_ctx *ctx, struct lysc_range_part *part, uint8_t max, int64_t prev, LY_DATA_TYPE basetype,
- uint8_t first, uint8_t length_restr, uint8_t frdigits, struct lysc_range *base_range, const char **value)
+range_part_minmax(struct lysc_ctx *ctx, struct lysc_range_part *part, ly_bool max, int64_t prev, LY_DATA_TYPE basetype,
+ ly_bool first, ly_bool length_restr, uint8_t frdigits, struct lysc_range *base_range, const char **value)
{
LY_ERR ret = LY_SUCCESS;
char *valcopy = NULL;
@@ -1694,13 +1694,13 @@
* @return LY_ERR value.
*/
static LY_ERR
-lys_compile_type_range(struct lysc_ctx *ctx, struct lysp_restr *range_p, LY_DATA_TYPE basetype, uint8_t length_restr,
+lys_compile_type_range(struct lysc_ctx *ctx, struct lysp_restr *range_p, LY_DATA_TYPE basetype, ly_bool length_restr,
uint8_t frdigits, struct lysc_range *base_range, struct lysc_range **range)
{
LY_ERR ret = LY_EVALID;
const char *expr;
struct lysc_range_part *parts = NULL, *part;
- uint8_t range_expected = 0, uns;
+ ly_bool range_expected = 0, uns;
LY_ARRAY_COUNT_TYPE parts_done = 0, u, v;
assert(range);
@@ -2401,7 +2401,7 @@
*/
LY_ERR
lys_path_token(const char **path, const char **prefix, size_t *prefix_len, const char **name, size_t *name_len,
- int32_t *parent_times, uint8_t *has_predicate)
+ int32_t *parent_times, ly_bool *has_predicate)
{
int32_t par_times = 0;
@@ -2921,7 +2921,7 @@
struct lysc_type **type, const char **units, const char **dflt, struct lys_module **dflt_mod)
{
LY_ERR ret = LY_SUCCESS;
- uint8_t dummyloops = 0;
+ ly_bool dummyloops = 0;
struct type_context {
const struct lysp_tpdf *tpdf;
struct lysp_node *node;
@@ -4247,7 +4247,7 @@
*/
static LY_ERR
lys_compile_change_config(struct lysc_ctx *ctx, struct lysc_node *node, uint16_t config_flag,
- uint8_t inheriting, uint8_t refine_flag)
+ ly_bool inheriting, ly_bool refine_flag)
{
struct lysc_node *child;
uint16_t config = config_flag & LYS_CONFIG_MASK;
@@ -4302,7 +4302,7 @@
* (mandatory children was removed).
*/
static void
-lys_compile_mandatory_parents(struct lysc_node *parent, uint8_t add)
+lys_compile_mandatory_parents(struct lysc_node *parent, ly_bool add)
{
struct lysc_node *iter;
@@ -4427,7 +4427,7 @@
struct lysc_node *node;
struct lysc_when **when, *when_shared;
struct lys_module **aug_mod;
- uint8_t allow_mandatory = 0;
+ ly_bool allow_mandatory = 0;
uint16_t flags = 0;
LY_ARRAY_COUNT_TYPE u, v;
uint32_t opt_prev = ctx->options;
@@ -4594,7 +4594,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lys_compile_change_mandatory(struct lysc_ctx *ctx, struct lysc_node *node, uint16_t mandatory_flag, uint8_t refine_flag)
+lys_compile_change_mandatory(struct lysc_ctx *ctx, struct lysc_node *node, uint16_t mandatory_flag, ly_bool refine_flag)
{
if (!(node->nodetype & (LYS_LEAF | LYS_ANYDATA | LYS_ANYXML | LYS_CHOICE))) {
LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
@@ -4653,7 +4653,7 @@
struct lysp_node *node_p;
struct lysp_grp *grp;
LY_ARRAY_COUNT_TYPE u, v;
- uint8_t found = 0;
+ ly_bool found = 0;
const char *id, *name, *prefix;
size_t prefix_len, name_len;
struct lys_module *mod;
@@ -5500,7 +5500,7 @@
struct lysc_node *target; /* target node of the deviation */
struct lysp_deviate **deviates;/* sized array of pointers to parsed deviate statements to apply on target */
uint16_t flags; /* target's flags from lysc_resolve_schema_nodeid() */
- uint8_t not_supported; /* flag if deviates contains not-supported deviate */
+ ly_bool not_supported; /* flag if deviates contains not-supported deviate */
};
/* MACROS for deviates checking */
@@ -5550,7 +5550,7 @@
#define DEV_CHECK_NONPRESENCE_VALUE(TYPE, COND, MEMBER, PROPERTY, VALUEMEMBER) \
if (((TYPE)target)->MEMBER && (COND)) { \
- uint8_t dynamic_ = 0; const char *val_; \
+ ly_bool dynamic_ = 0; const char *val_; \
val_ = ((TYPE)target)->VALUEMEMBER->realtype->plugin->print(((TYPE)target)->VALUEMEMBER, LY_PREF_SCHEMA, \
ctx->mod_def, &dynamic_); \
LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE, \
@@ -5749,7 +5749,7 @@
lys_apply_deviate_delete_leaf_dflt(struct lysc_ctx *ctx, struct lysc_node *target, const char *dflt)
{
struct lysc_node_leaf *leaf = (struct lysc_node_leaf *)target;
- uint8_t dyn = 0;
+ ly_bool dyn = 0;
const char *orig_dflt;
uint32_t i;
@@ -5812,7 +5812,7 @@
lys_apply_deviate_delete_llist_dflts(struct lysc_ctx *ctx, struct lysc_node *target, const char **dflts)
{
struct lysc_node_leaflist *llist = (struct lysc_node_leaflist *)target;
- uint8_t dyn = 0, found;
+ ly_bool dyn = 0, found;
const char *orig_dflt, **orig_dflts;
uint32_t i;
LY_ARRAY_COUNT_TYPE x, y;
@@ -6098,7 +6098,7 @@
struct ly_err_item *err = NULL;
LY_ARRAY_COUNT_TYPE x;
const char *dflt;
- uint8_t dyn;
+ ly_bool dyn;
if (target->module != ctx->mod) {
/* foreign deviation */
@@ -6553,7 +6553,7 @@
/* apply deviations */
for (u = 0; u < devs_p.count && devs[u]; ++u) {
- uint8_t match = 0;
+ ly_bool match = 0;
if (devs[u]->flags & LYSC_OPT_INTERNAL) {
/* fix the target pointer in case of RPC's/action's input/output */
@@ -6681,7 +6681,7 @@
/* keep order of the processing the same as the order in the defined substmts,
* the order is important for some of the statements depending on others (e.g. type needs status and units) */
for (u = 0; substmts[u].stmt; ++u) {
- uint8_t stmt_present = 0;
+ ly_bool stmt_present = 0;
for (stmt = ext->child; stmt; stmt = stmt->next) {
if (substmts[u].stmt != stmt->kw) {
@@ -6882,7 +6882,7 @@
uint32_t i;
LY_ARRAY_COUNT_TYPE u;
uint32_t opts;
- uint8_t input_done = 0;
+ ly_bool input_done = 0;
struct lysc_when **when = NULL;
struct lysc_must *musts = NULL;
LY_ERR ret = LY_SUCCESS;
@@ -7215,7 +7215,7 @@
for (u = orig_count; u < LY_ARRAY_COUNT(llist->dflts); ++u) {
for (v = 0; v < u; ++v) {
if (!llist->dflts[u]->realtype->plugin->compare(llist->dflts[u], llist->dflts[v])) {
- uint8_t dynamic = 0;
+ ly_bool dynamic = 0;
const char *val = llist->type->plugin->print(llist->dflts[u], LY_PREF_SCHEMA, (void *)dflt_mod, &dynamic);
lysc_update_path(ctx, llist->parent, llist->name);
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index f239fe1..c169359 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -36,7 +36,7 @@
LY_ERR
lysc_resolve_schema_nodeid(struct lysc_ctx *ctx, const char *nodeid, size_t nodeid_len, const struct lysc_node *context_node,
- const struct lys_module *context_module, uint16_t nodetype, uint8_t implement,
+ const struct lys_module *context_module, uint16_t nodetype, ly_bool implement,
const struct lysc_node **target, uint16_t *result_flag)
{
LY_ERR ret = LY_EVALID;
@@ -242,7 +242,7 @@
void
lysp_sort_revisions(struct lysp_revision *revs)
{
- uint8_t i, r;
+ LY_ARRAY_COUNT_TYPE i, r;
struct lysp_revision rev;
for (i = 1, r = 0; revs && i < LY_ARRAY_COUNT(revs); i++) {
@@ -523,8 +523,12 @@
return LY_SUCCESS;
}
-static uint8_t
-lysp_id_cmp(void *val1, void *val2, uint8_t UNUSED(mod), void *UNUSED(cb_data))
+/**
+ * @brief Compare identifiers.
+ * Implementation of ::values_equal_cb.
+ */
+static ly_bool
+lysp_id_cmp(void *val1, void *val2, ly_bool UNUSED(mod), void *UNUSED(cb_data))
{
return strcmp(val1, val2) == 0 ? 1 : 0;
}
@@ -744,8 +748,8 @@
}
LY_ERR
-lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, uint8_t implement,
- struct lys_parser_ctx *main_ctx, const char *main_name, uint8_t required, void **result)
+lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement,
+ struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required, void **result)
{
struct ly_in *in;
char *filepath = NULL;
@@ -803,7 +807,7 @@
}
LY_ERR
-lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, uint8_t implement, uint8_t require_parsed,
+lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement, ly_bool require_parsed,
struct lys_module **mod)
{
const char *module_data = NULL;
@@ -939,7 +943,7 @@
}
LY_ERR
-lysp_check_identifierchar(struct lys_parser_ctx *ctx, uint32_t c, uint8_t first, uint8_t *prefix)
+lysp_check_identifierchar(struct lys_parser_ctx *ctx, uint32_t c, ly_bool first, uint8_t *prefix)
{
if (first || (prefix && (*prefix) == 1)) {
if (!is_yangidentstartchar(c)) {
@@ -1644,7 +1648,7 @@
return parent;
}
-uint8_t
+ly_bool
lysc_is_output(const struct lysc_node *schema)
{
const struct lysc_node *parent;
@@ -1658,7 +1662,7 @@
return 0;
}
-API uint8_t
+API ly_bool
lysc_is_userordered(const struct lysc_node *schema)
{
if (!schema || !(schema->nodetype & (LYS_LEAFLIST | LYS_LIST)) || !(schema->flags & LYS_ORDBY_USER)) {
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 86ec511..3764664 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -213,7 +213,7 @@
* If the identifier cannot be prefixed, NULL is expected.
* @return LY_ERR values.
*/
-LY_ERR lysp_check_identifierchar(struct lys_parser_ctx *ctx, uint32_t c, uint8_t first, uint8_t *prefix);
+LY_ERR lysp_check_identifierchar(struct lys_parser_ctx *ctx, uint32_t c, ly_bool first, uint8_t *prefix);
/**
* @brief Check the currently present prefixes in the module for collision with the new one.
@@ -304,7 +304,7 @@
* @param[out] mod Parsed module structure.
* @return LY_ERR value.
*/
-LY_ERR lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, uint8_t implement, uint8_t require_parsed, struct lys_module **mod);
+LY_ERR lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement, ly_bool require_parsed, struct lys_module **mod);
/**
* @brief Parse included submodule into the simply parsed YANG module.
@@ -443,7 +443,7 @@
* @return LY_ERR values - LY_ENOTFOUND, LY_EVALID, LY_EDENIED or LY_SUCCESS.
*/
LY_ERR lysc_resolve_schema_nodeid(struct lysc_ctx *ctx, const char *nodeid, size_t nodeid_len, const struct lysc_node *context_node,
- const struct lys_module *context_module, uint16_t nodetype, uint8_t implement,
+ const struct lys_module *context_module, uint16_t nodetype, ly_bool implement,
const struct lysc_node **target, uint16_t *result_flag);
/**
@@ -496,7 +496,7 @@
* @param[out] module Parsed module.
* @return LY_ERR value.
*/
-LY_ERR lys_parse_mem_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, uint8_t implement,
+LY_ERR lys_parse_mem_module(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, ly_bool implement,
lys_custom_check custom_check, void *check_data, struct lys_module **module);
/**
@@ -545,8 +545,8 @@
* If it is a module, it is already in the context!
* @return LY_ERR value, in case of LY_SUCCESS, the \arg result is always provided.
*/
-LY_ERR lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, uint8_t implement,
- struct lys_parser_ctx *main_ctx, const char *main_name, uint8_t required, void **result);
+LY_ERR lys_module_localfile(struct ly_ctx *ctx, const char *name, const char *revision, ly_bool implement,
+ struct lys_parser_ctx *main_ctx, const char *main_name, ly_bool required, void **result);
/**
* @brief Compile information from the identity statement
@@ -750,7 +750,7 @@
* @brief Make the specific module implemented, use the provided value as flag.
*
* @param[in] mod Module to make implemented. It is not an error to provide already implemented module, it just does nothing.
- * @param[in] implemented Flag value for the ::lys_module#implemented item.
+ * @param[in] implemented Flag value for the ::lys_module::implemented item.
* @return LY_SUCCESS or LY_EDENIED in case the context contains some other revision of the
* same module which is already implemented.
*/
@@ -792,9 +792,8 @@
* @brief Learn whether a node is inside an operation output.
*
* @param[in] schema Schema node to examine.
- * @return 0 if it is not.
- * @return 1 if the node is under an operation output
+ * @return Boolean value whether the node is under an operation output or not.
*/
-uint8_t lysc_is_output(const struct lysc_node *schema);
+ly_bool lysc_is_output(const struct lysc_node *schema);
#endif /* LY_TREE_SCHEMA_INTERNAL_H_ */
diff --git a/src/validation.c b/src/validation.c
index e06df09..d00ad46 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -126,7 +126,7 @@
/* evaluate all when expressions that affect this node's existence */
struct lyd_node *node = (struct lyd_node *)node_when->objs[i];
const struct lysc_node *schema = node->schema;
- uint8_t unres_when = 0;
+ ly_bool unres_when = 0;
do {
LY_ARRAY_COUNT_TYPE u;
@@ -213,7 +213,7 @@
lyd_validate_duplicates(const struct lyd_node *first, const struct lyd_node *node)
{
struct lyd_node **match_p;
- uint8_t fail = 0;
+ ly_bool fail = 0;
if ((node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) && (node->schema->flags & LYS_CONFIG_R)) {
/* duplicate instances allowed */
@@ -263,7 +263,7 @@
{
const struct lysc_node *scase, *iter, *old_case = NULL, *new_case = NULL;
struct lyd_node *match, *to_del;
- uint8_t found;
+ ly_bool found;
LY_LIST_FOR((struct lysc_node *)choic->cases, scase) {
found = 0;
@@ -563,10 +563,12 @@
/**
* @brief Callback for comparing 2 list unique leaf values.
*
+ * Implementation of ::values_equal_cb.
+ *
* @param[in] cb_data 0 to compare all uniques, n to compare only n-th unique.
*/
-static uint8_t
-lyd_val_uniq_list_equal(void *val1_p, void *val2_p, uint8_t UNUSED(mod), void *cb_data)
+static ly_bool
+lyd_val_uniq_list_equal(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *cb_data)
{
struct ly_ctx *ctx;
struct lysc_node_list *slist;
@@ -677,7 +679,7 @@
LY_ARRAY_COUNT_TYPE u, v, x = 0;
LY_ERR ret = LY_SUCCESS;
uint32_t hash, i, size = 0;
- uint8_t dynamic;
+ ly_bool dynamic;
const char *str;
struct hash_table **uniqtables = NULL;
struct lyd_value *val;
diff --git a/src/xml.c b/src/xml.c
index 1cbc17a..8cb3a8c 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -38,16 +38,16 @@
/* Ignore whitespaces in the input string p */
#define ign_xmlws(c) while (is_xmlws(*(c)->in->current)) {if (*(c)->in->current == '\n') {++c->line;} ly_in_skip(c->in, 1);}
-static LY_ERR lyxml_next_attr_content(struct lyxml_ctx *xmlctx, const char **value, size_t *value_len, uint8_t *ws_only,
- uint8_t *dynamic);
+static LY_ERR lyxml_next_attr_content(struct lyxml_ctx *xmlctx, const char **value, size_t *value_len, ly_bool *ws_only,
+ ly_bool *dynamic);
/**
* @brief Ignore any characters until the delim of the size delim_len is read
*
* Detects number of read new lines.
- * Returns 0 if delim was found, 1 if was not.
+ * Returns Boolean value whether delim was found or not.
*/
-static uint8_t
+static ly_bool
ign_todelim(register const char *input, const char *delim, size_t delim_len, size_t *newlines, size_t *parsed)
{
size_t i;
@@ -229,7 +229,7 @@
const struct ly_ctx *ctx = xmlctx->ctx; /* shortcut */
const char *endtag, *sectname;
size_t endtag_len, newlines, parsed;
- uint8_t rc;
+ ly_bool rc;
while (1) {
ign_xmlws(xmlctx);
@@ -335,7 +335,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyxml_parse_value(struct lyxml_ctx *xmlctx, char endchar, char **value, size_t *length, uint8_t *ws_only, uint8_t *dynamic)
+lyxml_parse_value(struct lyxml_ctx *xmlctx, char endchar, char **value, size_t *length, ly_bool *ws_only, ly_bool *dynamic)
{
#define BUFSIZE 24
#define BUFSIZE_STEP 128
@@ -349,7 +349,7 @@
void *p;
uint32_t n;
size_t u;
- uint8_t ws = 1;
+ ly_bool ws = 1;
assert(xmlctx);
@@ -518,7 +518,7 @@
*/
static LY_ERR
lyxml_close_element(struct lyxml_ctx *xmlctx, const char *prefix, size_t prefix_len, const char *name, size_t name_len,
- uint8_t empty)
+ ly_bool empty)
{
struct lyxml_elem *e;
@@ -584,7 +584,7 @@
const char *prev_input;
char *value;
size_t parsed, value_len;
- uint8_t ws_only, dynamic, is_ns;
+ ly_bool ws_only, dynamic, is_ns;
uint32_t c;
/* store element opening tag information */
@@ -651,7 +651,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyxml_next_attr_content(struct lyxml_ctx *xmlctx, const char **value, size_t *value_len, uint8_t *ws_only, uint8_t *dynamic)
+lyxml_next_attr_content(struct lyxml_ctx *xmlctx, const char **value, size_t *value_len, ly_bool *ws_only, ly_bool *dynamic)
{
char quot;
@@ -712,7 +712,7 @@
char *value;
uint32_t c;
size_t parsed, value_len;
- uint8_t ws_only, dynamic;
+ ly_bool ws_only, dynamic;
/* skip WS */
ign_xmlws(xmlctx);
@@ -763,7 +763,7 @@
*/
static LY_ERR
lyxml_next_element(struct lyxml_ctx *xmlctx, const char **prefix, size_t *prefix_len, const char **name, size_t *name_len,
- uint8_t *closing)
+ ly_bool *closing)
{
/* skip WS until EOF or after opening tag '<' */
LY_CHECK_RET(lyxml_skip_until_end_or_after_otag(xmlctx));
@@ -795,7 +795,7 @@
{
LY_ERR ret = LY_SUCCESS;
struct lyxml_ctx *xmlctx;
- uint8_t closing;
+ ly_bool closing;
/* new context */
xmlctx = calloc(1, sizeof *xmlctx);
@@ -837,7 +837,7 @@
lyxml_ctx_next(struct lyxml_ctx *xmlctx)
{
LY_ERR ret = LY_SUCCESS;
- uint8_t closing;
+ ly_bool closing;
struct lyxml_elem *e;
/* if the value was not used, free it */
@@ -967,7 +967,7 @@
LY_ERR ret = LY_SUCCESS;
const char *prefix, *name, *prev_input;
size_t prefix_len, name_len;
- uint8_t closing;
+ ly_bool closing;
prev_input = xmlctx->in->current;
@@ -1040,7 +1040,7 @@
}
LY_ERR
-lyxml_dump_text(struct ly_out *out, const char *text, uint8_t attribute)
+lyxml_dump_text(struct ly_out *out, const char *text, ly_bool attribute)
{
LY_ERR ret;
diff --git a/src/xml.h b/src/xml.h
index 2be61b1..aef80b3 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -92,11 +92,11 @@
};
union {
const char *name; /* LYXML_ELEMENT, LYXML_ATTRIBUTE - elem/attr name */
- uint8_t ws_only; /* LYXML_ELEM_CONTENT, LYXML_ATTR_CONTENT - whether elem/attr value is empty/white-space only */
+ ly_bool ws_only; /* LYXML_ELEM_CONTENT, LYXML_ATTR_CONTENT - whether elem/attr value is empty/white-space only */
};
union {
size_t name_len; /* LYXML_ELEMENT, LYXML_ATTRIBUTE - elem/attr name length */
- uint8_t dynamic; /* LYXML_ELEM_CONTENT, LYXML_ATTR_CONTENT - whether elem/attr value is dynamically allocated */
+ ly_bool dynamic; /* LYXML_ELEM_CONTENT, LYXML_ATTR_CONTENT - whether elem/attr value is dynamically allocated */
};
struct ly_set elements; /* list of not-yet-closed elements */
@@ -153,7 +153,7 @@
* @param[in] attribute Flag for attribute's value where a double quotes must be replaced.
* @return LY_ERR values.
*/
-LY_ERR lyxml_dump_text(struct ly_out *out, const char *text, uint8_t attribute);
+LY_ERR lyxml_dump_text(struct ly_out *out, const char *text, ly_bool attribute);
/**
* @brief Remove the allocated working memory of the context.
diff --git a/src/xpath.c b/src/xpath.c
index ea436e4..c20a384 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -318,7 +318,7 @@
* @return LY_ERR
*/
static LY_ERR
-cast_string_recursive(const struct lyd_node *node, uint8_t fake_cont, enum lyxp_node_type root_type, uint16_t indent, char **str,
+cast_string_recursive(const struct lyd_node *node, ly_bool fake_cont, enum lyxp_node_type root_type, uint16_t indent, char **str,
uint16_t *used, uint16_t *size)
{
char *buf, *line, *ptr = NULL;
@@ -464,7 +464,7 @@
* @return LY_ERR
*/
static LY_ERR
-cast_string_elem(struct lyd_node *node, uint8_t fake_cont, enum lyxp_node_type root_type, char **str)
+cast_string_elem(struct lyd_node *node, ly_bool fake_cont, enum lyxp_node_type root_type, char **str)
{
uint16_t used, size;
LY_ERR rc;
@@ -543,14 +543,16 @@
/**
* @brief Callback for checking value equality.
*
+ * Implementation of ::values_equal_cb.
+ *
* @param[in] val1_p First value.
* @param[in] val2_p Second value.
* @param[in] mod Whether hash table is being modified.
* @param[in] cb_data Callback data.
- * @return 0 if not equal, non-zero if equal.
+ * @return Boolean value whether values are equal or not.
*/
-static uint8_t
-set_values_equal_cb(void *val1_p, void *val2_p, uint8_t UNUSED(mod), void *UNUSED(cb_data))
+static ly_bool
+set_values_equal_cb(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
{
struct lyxp_set_hash_node *val1, *val2;
@@ -850,7 +852,7 @@
* @param[in] boolean Boolean to fill into \p set.
*/
static void
-set_fill_boolean(struct lyxp_set *set, uint8_t boolean)
+set_fill_boolean(struct lyxp_set *set, ly_bool boolean)
{
lyxp_set_free_content(set);
@@ -1054,7 +1056,7 @@
return LY_SUCCESS;
}
-uint8_t
+ly_bool
lyxp_set_scnode_contains(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type, int skip_idx,
uint32_t *index_p)
{
@@ -1517,7 +1519,7 @@
struct lyd_value val;
struct ly_err_item *err = NULL;
char *str, *ptr;
- uint8_t dynamic;
+ ly_bool dynamic;
LY_ERR rc;
/* is there anything to canonize even? */
@@ -1592,7 +1594,7 @@
{
uint32_t i, j;
int ret = 0, cmp;
- uint8_t inverted, change;
+ ly_bool inverted, change;
const struct lyd_node *root;
struct lyxp_set_node item;
struct lyxp_set_hash_node hnode;
@@ -2272,7 +2274,7 @@
LY_CHECK_RET(rc);
++(*tok_idx);
- if ((arg_count < (uint8_t)min_arg_count) || (arg_count > max_arg_count)) {
+ if ((arg_count < (uint32_t)min_arg_count) || (arg_count > max_arg_count)) {
LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INARGCOUNT, arg_count, exp->tok_len[func_tok_idx],
&exp->expr[exp->tok_pos[func_tok_idx]]);
return LY_EVALID;
@@ -2652,12 +2654,12 @@
}
struct lyxp_expr *
-lyxp_expr_parse(const struct ly_ctx *ctx, const char *expr, size_t expr_len, uint8_t reparse)
+lyxp_expr_parse(const struct ly_ctx *ctx, const char *expr, size_t expr_len, ly_bool reparse)
{
struct lyxp_expr *ret;
size_t parsed = 0, tok_len;
enum lyxp_token tok_type;
- uint8_t prev_function_check = 0;
+ ly_bool prev_function_check = 0;
uint16_t tok_idx = 0;
if (!expr[0]) {
@@ -3023,13 +3025,13 @@
* @brief Test whether a type is numeric - integer type or decimal64.
*
* @param[in] type Type to test.
- * @return 1 if numeric, 0 otherwise.
+ * @return Boolean value whether @p type is numeric type or not.
*/
-static uint8_t
+static ly_bool
warn_is_numeric_type(struct lysc_type *type)
{
struct lysc_type_union *uni;
- uint8_t ret;
+ ly_bool ret;
LY_ARRAY_COUNT_TYPE u;
switch (type->basetype) {
@@ -3049,7 +3051,7 @@
ret = warn_is_numeric_type(uni->types[u]);
if (ret) {
/* found a suitable type */
- return 1;
+ return ret;
}
}
/* did not find any suitable type */
@@ -3065,13 +3067,13 @@
* @brief Test whether a type is string-like - no integers, decimal64 or binary.
*
* @param[in] type Type to test.
- * @return 1 if string, 0 otherwise.
+ * @return Boolean value whether @p type's basetype is string type or not.
*/
-static uint8_t
+static ly_bool
warn_is_string_type(struct lysc_type *type)
{
struct lysc_type_union *uni;
- uint8_t ret;
+ ly_bool ret;
LY_ARRAY_COUNT_TYPE u;
switch (type->basetype) {
@@ -3087,7 +3089,7 @@
ret = warn_is_string_type(uni->types[u]);
if (ret) {
/* found a suitable type */
- return 1;
+ return ret;
}
}
/* did not find any suitable type */
@@ -3104,13 +3106,13 @@
*
* @param[in] type Type to test.
* @param[in] base Expected type.
- * @return 1 if it is, 0 otherwise.
+ * @return Boolean value whether the given @p type is of the specific basetype @p base.
*/
-static uint8_t
+static ly_bool
warn_is_specific_type(struct lysc_type *type, LY_DATA_TYPE base)
{
struct lysc_type_union *uni;
- uint8_t ret;
+ ly_bool ret;
LY_ARRAY_COUNT_TYPE u;
if (type->basetype == base) {
@@ -3121,7 +3123,7 @@
ret = warn_is_specific_type(uni->types[u], base);
if (ret) {
/* found a suitable type */
- return 1;
+ return ret;
}
}
/* did not find any suitable type */
@@ -3144,7 +3146,7 @@
warn_is_equal_type_next_type(struct lysc_type *type, struct lysc_type *prev_type)
{
struct lysc_type_union *uni;
- uint8_t found = 0;
+ ly_bool found = 0;
LY_ARRAY_COUNT_TYPE u;
switch (type->basetype) {
@@ -3221,10 +3223,10 @@
* @param[in] tok_pos Token position.
*/
static void
-warn_operands(struct ly_ctx *ctx, struct lyxp_set *set1, struct lyxp_set *set2, uint8_t numbers_only, const char *expr, uint16_t tok_pos)
+warn_operands(struct ly_ctx *ctx, struct lyxp_set *set1, struct lyxp_set *set2, ly_bool numbers_only, const char *expr, uint16_t tok_pos)
{
struct lysc_node_leaf *node1, *node2;
- uint8_t leaves = 1, warning = 0;
+ ly_bool leaves = 1, warning = 0;
node1 = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(set1);
node2 = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(set2);
@@ -3727,7 +3729,7 @@
}
static LY_ERR
-xpath_derived_(struct lyxp_set **args, struct lyxp_set *set, uint32_t options, uint8_t self_match, const char *func)
+xpath_derived_(struct lyxp_set **args, struct lyxp_set *set, uint32_t options, ly_bool self_match, const char *func)
{
uint16_t i;
LY_ARRAY_COUNT_TYPE u;
@@ -3737,7 +3739,7 @@
struct lyd_value data = {0}, *val;
struct ly_err_item *err = NULL;
LY_ERR rc = LY_SUCCESS;
- uint8_t found;
+ ly_bool found;
if (options & LYXP_SCNODE_ALL) {
if ((args[0]->type != LYXP_SET_SCNODE_SET) || !(sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[0]))) {
@@ -4363,7 +4365,7 @@
{
uint16_t i, new_used;
char *new;
- uint8_t have_spaces = 0, space_before = 0;
+ ly_bool have_spaces = 0, space_before = 0;
struct lysc_node_leaf *sleaf;
LY_ERR rc = LY_SUCCESS;
@@ -5121,7 +5123,7 @@
{
uint16_t i, j, new_used;
char *new;
- uint8_t have_removed;
+ ly_bool have_removed;
struct lysc_node_leaf *sleaf;
LY_ERR rc = LY_SUCCESS;
@@ -5166,7 +5168,7 @@
have_removed = 0;
for (i = 0; args[0]->val.str[i]; ++i) {
- uint8_t found = 0;
+ ly_bool found = 0;
for (j = 0; args[1]->val.str[j]; ++j) {
if (args[0]->val.str[i] == args[1]->val.str[j]) {
@@ -5438,7 +5440,7 @@
}
for (i = 0; i < set->used; ) {
- uint8_t replaced = 0;
+ ly_bool replaced = 0;
if ((set->val.nodes[i].type == LYXP_NODE_ROOT_CONFIG) || (set->val.nodes[i].type == LYXP_NODE_ROOT)) {
assert(!set->val.nodes[i].node);
@@ -5573,7 +5575,7 @@
static LY_ERR
moveto_scnode(struct lyxp_set *set, const struct lys_module *mod, const char *ncname, uint32_t options)
{
- uint8_t temp_ctx = 0;
+ ly_bool temp_ctx = 0;
uint32_t getnext_opts;
uint32_t orig_used, i;
uint32_t mod_idx;
@@ -5868,7 +5870,7 @@
}
for (uint32_t i = 0; i < set->used; ) {
- uint8_t replaced = 0;
+ ly_bool replaced = 0;
/* only attributes of an elem (not dummy) can be in the result, skip all the rest;
* our attributes are always qualified */
@@ -5991,7 +5993,7 @@
lyxp_set_free(set_all_desc);
for (uint32_t i = 0; i < set->used; ) {
- uint8_t replaced = 0;
+ ly_bool replaced = 0;
/* only attributes of an elem can be in the result, skip all the rest,
* we have all attributes qualified in lyd tree */
@@ -6103,7 +6105,7 @@
* @return LY_ERR (LY_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-moveto_self(struct lyxp_set *set, uint8_t all_desc, uint32_t options)
+moveto_self(struct lyxp_set *set, ly_bool all_desc, uint32_t options)
{
struct lyxp_set ret_set;
LY_ERR rc;
@@ -6161,7 +6163,7 @@
* @return LY_ERR
*/
static LY_ERR
-moveto_scnode_self(struct lyxp_set *set, uint8_t all_desc, uint32_t options)
+moveto_scnode_self(struct lyxp_set *set, ly_bool all_desc, uint32_t options)
{
uint32_t getnext_opts;
uint32_t mod_idx;
@@ -6246,7 +6248,7 @@
* @return LY_ERR (LY_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-moveto_parent(struct lyxp_set *set, uint8_t all_desc, uint32_t options)
+moveto_parent(struct lyxp_set *set, ly_bool all_desc, uint32_t options)
{
LY_ERR rc;
struct lyd_node *node, *new_node;
@@ -6322,10 +6324,10 @@
* @return LY_ERR
*/
static LY_ERR
-moveto_scnode_parent(struct lyxp_set *set, uint8_t all_desc, uint32_t options)
+moveto_scnode_parent(struct lyxp_set *set, ly_bool all_desc, uint32_t options)
{
uint32_t i, orig_used, idx;
- uint8_t temp_ctx = 0;
+ ly_bool temp_ctx = 0;
const struct lysc_node *node, *new_node;
enum lyxp_node_type new_type;
@@ -6661,7 +6663,7 @@
* @return LY_ERR (LY_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-eval_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, struct lyxp_set *set, uint32_t options, uint8_t parent_pos_pred)
+eval_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, struct lyxp_set *set, uint32_t options, ly_bool parent_pos_pred)
{
LY_ERR rc;
uint16_t i, orig_exp;
@@ -6930,7 +6932,7 @@
* @return LY_ERR (LY_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-eval_name_test_with_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, uint8_t attr_axis, uint8_t all_desc, struct lyxp_set *set,
+eval_name_test_with_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, ly_bool attr_axis, ly_bool all_desc, struct lyxp_set *set,
uint32_t options)
{
char *path;
@@ -7082,7 +7084,7 @@
* @return LY_ERR (LY_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-eval_node_type_with_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, uint8_t attr_axis, uint8_t all_desc,
+eval_node_type_with_predicate(struct lyxp_expr *exp, uint16_t *tok_idx, ly_bool attr_axis, ly_bool all_desc,
struct lyxp_set *set, uint32_t options)
{
LY_ERR rc;
@@ -7147,9 +7149,9 @@
* @return LY_ERR (YL_EINCOMPLETE on unresolved when)
*/
static LY_ERR
-eval_relative_location_path(struct lyxp_expr *exp, uint16_t *tok_idx, uint8_t all_desc, struct lyxp_set *set, uint32_t options)
+eval_relative_location_path(struct lyxp_expr *exp, uint16_t *tok_idx, ly_bool all_desc, struct lyxp_set *set, uint32_t options)
{
- uint8_t attr_axis;
+ ly_bool attr_axis;
LY_ERR rc;
goto step;
@@ -7239,7 +7241,7 @@
static LY_ERR
eval_absolute_location_path(struct lyxp_expr *exp, uint16_t *tok_idx, struct lyxp_set *set, uint32_t options)
{
- uint8_t all_desc;
+ ly_bool all_desc;
if (set) {
/* no matter what tokens follow, we need to be at the root */
@@ -7561,7 +7563,7 @@
static LY_ERR
eval_path_expr(struct lyxp_expr *exp, uint16_t *tok_idx, struct lyxp_set *set, uint32_t options)
{
- uint8_t all_desc, parent_pos_pred;
+ ly_bool all_desc, parent_pos_pred;
LY_ERR rc;
switch (exp->tokens[*tok_idx]) {
diff --git a/src/xpath.h b/src/xpath.h
index 2d35dde..e74f48b 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -238,7 +238,7 @@
} *meta;
char *str;
long double num;
- uint8_t bln; /* boolean */
+ ly_bool bln; /* boolean */
} val;
/* this is valid only for type LYXP_SET_NODE_SET and LYXP_SET_SCNODE_SET */
@@ -354,10 +354,9 @@
* @param[in] node_type Type of @p node.
* @param[in] skip_idx Index from @p set to skip.
* @param[out] index_p Optional pointer to store index if the node is found.
- * @return 0 if not found
- * @return 1 if the @p node found.
+ * @return Boolean value whether the @p node found or not.
*/
-uint8_t lyxp_set_scnode_contains(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type,
+ly_bool lyxp_set_scnode_contains(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type,
int skip_idx, uint32_t *index_p);
/**
@@ -381,7 +380,7 @@
* information about expressions and their operators (fill repeat).
* @return Filled expression structure or NULL on error.
*/
-struct lyxp_expr *lyxp_expr_parse(const struct ly_ctx *ctx, const char *expr, size_t expr_len, uint8_t reparse);
+struct lyxp_expr *lyxp_expr_parse(const struct ly_ctx *ctx, const char *expr, size_t expr_len, ly_bool reparse);
/**
* @brief Duplicate parsed XPath expression.