Skip to content

Commit 80f46b0

Browse files
committed
lyb UPDATE improve LYB format
Store context hash instead of all the modules. Causes that it is now necessary for printing/ parsing contexts to be the same, hash must match.
1 parent a0e8c2f commit 80f46b0

File tree

6 files changed

+80
-293
lines changed

6 files changed

+80
-293
lines changed

src/lyb.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,3 @@ lyb_cache_module_hash(const struct lys_module *mod)
109109
/* UNLOCK */
110110
pthread_mutex_unlock(&mod->ctx->lyb_hash_lock);
111111
}
112-
113-
ly_bool
114-
lyb_has_schema_model(const struct lysc_node *node, const struct lys_module **models)
115-
{
116-
LY_ARRAY_COUNT_TYPE u;
117-
118-
LY_ARRAY_FOR(models, u) {
119-
if (node->module == models[u]) {
120-
return 1;
121-
}
122-
}
123-
124-
return 0;
125-
}

src/lyb.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ struct lylyb_ctx {
8383
uint64_t line; /* current line */
8484
struct ly_in *in; /* input structure */
8585

86-
const struct lys_module **models;
87-
8886
struct lyd_lyb_sibling {
8987
size_t written;
9088
size_t position;
@@ -97,6 +95,7 @@ struct lylyb_ctx {
9795
struct lysc_node *first_sibling;
9896
struct ly_ht *ht;
9997
} *sib_hts;
98+
ly_bool empty_hash;
10099
};
101100

102101
/**
@@ -111,7 +110,7 @@ void lyd_lyb_ctx_free(struct lyd_ctx *lydctx);
111110
#define LYB_SIBLING_STEP 4
112111

113112
/* current LYB format version */
114-
#define LYB_HEADER_VERSION_NUM 0x06
113+
#define LYB_HEADER_VERSION_NUM 0x07
115114

116115
/* LYB format version mask of the header byte */
117116
#define LYB_HEADER_VERSION_MASK 0x0F
@@ -197,13 +196,4 @@ LYB_HASH lyb_get_hash(const struct lysc_node *node, uint8_t collision_id);
197196
*/
198197
void lyb_cache_module_hash(const struct lys_module *mod);
199198

200-
/**
201-
* @brief Check whether a node's module is in a module array.
202-
*
203-
* @param[in] node Node to check.
204-
* @param[in] models Modules in a sized array.
205-
* @return Boolean value whether @p node's module was found in the given @p models array.
206-
*/
207-
ly_bool lyb_has_schema_model(const struct lysc_node *node, const struct lys_module **models);
208-
209199
#endif /* LY_LYB_H_ */

src/parser_data.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,11 @@ struct ly_in;
145145
resolved, and default values are not added (only the ones parsed are
146146
present). */
147147
#define LYD_PARSE_STRICT 0x020000 /**< Instead of silently ignoring data without schema definition raise an error.
148-
Do not combine with ::LYD_PARSE_OPAQ (except for ::LYD_LYB). */
148+
Do not combine with ::LYD_PARSE_OPAQ. Always set for ::LYD_LYB. */
149149
#define LYD_PARSE_OPAQ 0x040000 /**< Instead of silently ignoring data without definition, parse them into
150150
an opaq node. Do not combine with ::LYD_PARSE_STRICT (except for ::LYD_LYB). */
151151
#define LYD_PARSE_NO_STATE 0x080000 /**< Forbid state data in the parsed data. Usually used with ::LYD_VALIDATE_NO_STATE. */
152-
#define LYD_PARSE_LYB_MOD_UPDATE 0x100000 /**< Only for LYB format, allow parsing data printed using a specific module
153-
revision to be loaded even with a module with the same name but newer
154-
revision. */
152+
#define LYD_PARSE_LYB_MOD_UPDATE 0x100000 /**< Deprecated, ignored. */
155153
#define LYD_PARSE_ORDERED 0x200000 /**< Do not search for the correct place of each node but instead expect
156154
that the nodes are being parsed in the correct schema-based order,
157155
which is always true if the data were printed by libyang and not

0 commit comments

Comments
 (0)