Skip to content

Commit 8d3d805

Browse files
committed
plugins types REFACTOR rebase fixes
1 parent e9ca6ed commit 8d3d805

File tree

15 files changed

+30
-86
lines changed

15 files changed

+30
-86
lines changed

src/plugins_types/binary.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
*/
4444
static const char b64_etable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4545

46-
4746
static void lyplg_type_free_binary(const struct ly_ctx *ctx, struct lyd_value *value);
4847
static LY_ERR lyplg_type_validate_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
49-
const struct lyd_node *ctx_node, const struct lyd_node *tree, struct lyd_value *storage, struct ly_err_item **err);
48+
const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lysc_ext_instance *top_ext,
49+
struct lyd_value *storage, struct ly_err_item **err);
5050

5151
/**
5252
* @brief Encode binary value into a base64 string value.
@@ -332,7 +332,7 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
332332

333333
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
334334
/* validate value */
335-
ret = lyplg_type_validate_binary(ctx, type, NULL, NULL, storage, err);
335+
ret = lyplg_type_validate_binary(ctx, type, NULL, NULL, NULL, storage, err);
336336
LY_CHECK_GOTO(ret, cleanup);
337337
}
338338

@@ -347,13 +347,13 @@ lyplg_type_store_binary(const struct ly_ctx *ctx, const struct lysc_type *type,
347347
return ret;
348348
}
349349

350-
static LY_ERR
351350
/**
352351
* @brief Implementation of ::lyplg_type_validate_clb for the binary type.
353352
*/
354353
static LY_ERR
355354
lyplg_type_validate_binary(const struct ly_ctx *ctx, const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node),
356-
const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err)
355+
const struct lyd_node *UNUSED(tree), const struct lysc_ext_instance *UNUSED(top_ext), struct lyd_value *storage,
356+
struct ly_err_item **err)
357357
{
358358
struct lysc_type_bin *type_bin = (struct lysc_type_bin *)type;
359359
struct lyd_value_binary *val;

src/plugins_types/date_and_time.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type
5353
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
5454
{
5555
LY_ERR ret = LY_SUCCESS;
56-
struct lysc_type_str *type_dat = (struct lysc_type_str *)type;
5756
struct lyd_value_date_and_time *val;
5857
uint32_t i, value_size;
5958
char c;
@@ -108,16 +107,6 @@ lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type
108107
ret = lyplg_type_check_hints(hints, value, value_size, type->basetype, NULL, err);
109108
LY_CHECK_GOTO(ret, cleanup);
110109

111-
/* length restriction, there can be only ASCII chars */
112-
if (type_dat->length) {
113-
ret = lyplg_type_validate_range(LY_TYPE_STRING, type_dat->length, value_len, value, value_len, err);
114-
LY_CHECK_GOTO(ret, cleanup);
115-
}
116-
117-
/* date-and-time pattern */
118-
ret = lyplg_type_validate_patterns(type_dat->patterns, value, value_len, err);
119-
LY_CHECK_GOTO(ret, cleanup);
120-
121110
/* convert to UNIX time and fractions of second */
122111
ret = ly_time_str2time(value, &val->time, &val->fractions_s);
123112
if (ret) {

src/plugins_types/decimal64.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* | 64 | yes | `int64_t *` | little-endian value represented without floating point |
3535
*/
3636

37-
static LY_ERR lyplg_type_validate_decimal64(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node), const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err);
37+
static LY_ERR lyplg_type_validate_decimal64(const struct ly_ctx *ctx, const struct lysc_type *type, const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lysc_ext_instance *top_ext, struct lyd_value *storage, struct ly_err_item **err);
3838

3939
/**
4040
* @brief Convert decimal64 number to canonical string.
@@ -151,7 +151,7 @@ lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *typ
151151

152152
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
153153
/* validate value */
154-
ret = lyplg_type_validate_decimal64(ctx, type, NULL, NULL, storage, err);
154+
ret = lyplg_type_validate_decimal64(ctx, type, NULL, NULL, NULL, storage, err);
155155
LY_CHECK_GOTO(ret, cleanup);
156156
}
157157

@@ -166,13 +166,13 @@ lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *typ
166166
return ret;
167167
}
168168

169-
static LY_ERR
170169
/**
171170
* @brief Implementation of ::lyplg_type_validate_clb for the built-in decimal64 type.
172171
*/
173172
static LY_ERR
174-
lyplg_type_validate_decimal64(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node),
175-
const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err)
173+
lyplg_type_validate_decimal64(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type,
174+
const struct lyd_node *UNUSED(ctx_node), const struct lyd_node *UNUSED(tree),
175+
const struct lysc_ext_instance *UNUSED(top_ext), struct lyd_value *storage, struct ly_err_item **err)
176176
{
177177
LY_ERR ret;
178178
struct lysc_type_dec *type_dec = (struct lysc_type_dec *)type;

src/plugins_types/hex_string.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ lyplg_type_store_hex_string(const struct ly_ctx *ctx, const struct lysc_type *ty
6060
ret = lyplg_type_check_hints(hints, value, value_size, type->basetype, NULL, err);
6161
LY_CHECK_GOTO(ret, cleanup);
6262

63-
/* length restriction of the string */
64-
if (type_str->length) {
65-
/* value_len is in bytes, but we need number of characters here */
66-
ret = lyplg_type_validate_range(LY_TYPE_STRING, type_str->length, ly_utf8len(value, value_len), value, value_len, err);
67-
LY_CHECK_GOTO(ret, cleanup);
68-
}
69-
70-
/* pattern restrictions */
71-
ret = lyplg_type_validate_patterns(type_str->patterns, value, value_len, err);
72-
LY_CHECK_GOTO(ret, cleanup);
73-
7463
/* make a copy, it is needed for canonization */
7564
if ((format != LY_VALUE_CANON) && !(options & LYPLG_TYPE_STORE_DYNAMIC)) {
7665
value = strndup(value, value_size);

src/plugins_types/integer.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
*/
4141

4242
static LY_ERR lyplg_type_validate_int(const struct ly_ctx *ctx, const struct lysc_type *type,
43-
const struct lyd_node *ctx_node, const struct lyd_node *tree, struct lyd_value *storage, struct ly_err_item **err);
43+
const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lysc_ext_instance *top_ext,
44+
struct lyd_value *storage, struct ly_err_item **err);
4445
static LY_ERR lyplg_type_validate_uint(const struct ly_ctx *ctx, const struct lysc_type *type,
45-
const struct lyd_node *ctx_node, const struct lyd_node *tree, struct lyd_value *storage, struct ly_err_item **err);
46+
const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lysc_ext_instance *top_ext,
47+
struct lyd_value *storage, struct ly_err_item **err);
4648

4749
static LY_ERR
4850
lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, uint32_t value_size_bits,
@@ -51,7 +53,6 @@ lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, con
5153
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
5254
{
5355
LY_ERR ret = LY_SUCCESS;
54-
struct lysc_type_num *type_num = (struct lysc_type_num *)type;
5556
uint32_t value_size;
5657
int64_t num = 0;
5758
int base = 1;
@@ -155,7 +156,7 @@ lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, con
155156

156157
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
157158
/* validate value */
158-
ret = lyplg_type_validate_int(ctx, type, NULL, NULL, storage, err);
159+
ret = lyplg_type_validate_int(ctx, type, NULL, NULL, NULL, storage, err);
159160
LY_CHECK_GOTO(ret, cleanup);
160161
}
161162

@@ -175,7 +176,8 @@ lyplg_type_store_int(const struct ly_ctx *ctx, const struct lysc_type *type, con
175176
*/
176177
static LY_ERR
177178
lyplg_type_validate_int(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node),
178-
const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err)
179+
const struct lyd_node *UNUSED(tree), const struct lysc_ext_instance *UNUSED(top_ext), struct lyd_value *storage,
180+
struct ly_err_item **err)
179181
{
180182
LY_ERR ret;
181183
struct lysc_type_num *type_num = (struct lysc_type_num *)type;
@@ -357,7 +359,6 @@ lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, co
357359
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
358360
{
359361
LY_ERR ret = LY_SUCCESS;
360-
struct lysc_type_num *type_num = (struct lysc_type_num *)type;
361362
uint32_t value_size;
362363
uint64_t num = 0;
363364
int base = 0;
@@ -441,7 +442,7 @@ lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, co
441442

442443
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
443444
/* validate value */
444-
ret = lyplg_type_validate_uint(ctx, type, NULL, NULL, storage, err);
445+
ret = lyplg_type_validate_uint(ctx, type, NULL, NULL, NULL, storage, err);
445446
LY_CHECK_GOTO(ret, cleanup);
446447
}
447448

@@ -461,7 +462,8 @@ lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, co
461462
*/
462463
static LY_ERR
463464
lyplg_type_validate_uint(const struct ly_ctx *UNUSED(ctx), const struct lysc_type *type, const struct lyd_node *UNUSED(ctx_node),
464-
const struct lyd_node *UNUSED(tree), struct lyd_value *storage, struct ly_err_item **err)
465+
const struct lyd_node *UNUSED(tree), const struct lysc_ext_instance *UNUSED(top_ext), struct lyd_value *storage,
466+
struct ly_err_item **err)
465467
{
466468
LY_ERR ret;
467469
struct lysc_type_num *type_num = (struct lysc_type_num *)type;

src/plugins_types/ipv4_address.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ lyplg_type_store_ipv4_address(const struct ly_ctx *ctx, const struct lysc_type *
126126
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
127127
{
128128
LY_ERR ret = LY_SUCCESS;
129-
struct lysc_type_str *type_str = (struct lysc_type_str *)type;
130129
struct lyd_value_ipv4_address *val;
131130
const char *value_str = value;
132131
uint32_t value_size, i;

src/plugins_types/ipv4_address_no_zone.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ lyplg_type_store_ipv4_address_no_zone(const struct ly_ctx *ctx, const struct lys
6565
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
6666
{
6767
LY_ERR ret = LY_SUCCESS;
68-
struct lysc_type_str *type_str = (struct lysc_type_str *)type;
6968
struct lyd_value_ipv4_address_no_zone *val;
7069
uint32_t value_size;
7170

@@ -92,17 +91,6 @@ lyplg_type_store_ipv4_address_no_zone(const struct ly_ctx *ctx, const struct lys
9291
ret = lyplg_type_check_hints(hints, value, value_size, type->basetype, NULL, err);
9392
LY_CHECK_GOTO(ret, cleanup);
9493

95-
/* length restriction of the string */
96-
if (type_str->length) {
97-
/* value_len is in bytes, but we need number of characters here */
98-
ret = lyplg_type_validate_range(LY_TYPE_STRING, type_str->length, ly_utf8len(value, value_len), value, value_len, err);
99-
LY_CHECK_GOTO(ret, cleanup);
100-
}
101-
102-
/* pattern restrictions */
103-
ret = lyplg_type_validate_patterns(type_str->patterns, value, value_len, err);
104-
LY_CHECK_GOTO(ret, cleanup);
105-
10694
/* we always need a dynamic value */
10795
if (!(options & LYPLG_TYPE_STORE_DYNAMIC)) {
10896
value = strndup(value, value_size);

src/plugins_types/ipv4_prefix.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ lyplg_type_store_ipv4_prefix(const struct ly_ctx *ctx, const struct lysc_type *t
128128
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
129129
{
130130
LY_ERR ret = LY_SUCCESS;
131-
struct lysc_type_str *type_str = (struct lysc_type_str *)type;
132131
struct lyd_value_ipv4_prefix *val;
133132
uint32_t value_size;
134133

@@ -165,14 +164,6 @@ lyplg_type_store_ipv4_prefix(const struct ly_ctx *ctx, const struct lysc_type *t
165164
ret = lyplg_type_check_hints(hints, value, value_size, type->basetype, NULL, err);
166165
LY_CHECK_GOTO(ret, cleanup);
167166

168-
/* pattern restrictions */
169-
ret = lyplg_type_validate_patterns(type_str->patterns, value, value_len, err);
170-
LY_CHECK_GOTO(ret, cleanup);
171-
172-
/* pattern restrictions */
173-
ret = lyplg_type_validate_patterns(type_str->patterns, value, value_len, err);
174-
LY_CHECK_GOTO(ret, cleanup);
175-
176167
/* get the mask in network-byte order */
177168
ret = ipv4prefix_str2ip(value, value_size, &val->addr, &val->prefix, err);
178169
LY_CHECK_GOTO(ret, cleanup);

src/plugins_types/ipv6_address.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ lyplg_type_store_ipv6_address(const struct ly_ctx *ctx, const struct lysc_type *
127127
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
128128
{
129129
LY_ERR ret = LY_SUCCESS;
130-
struct lysc_type_str *type_str = (struct lysc_type_str *)type;
131130
struct lyd_value_ipv6_address *val;
132131
const char *value_str = value;
133132
uint32_t value_size, i;

src/plugins_types/ipv6_address_no_zone.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ lyplg_type_store_ipv6_address_no_zone(const struct ly_ctx *ctx, const struct lys
104104
struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
105105
{
106106
LY_ERR ret = LY_SUCCESS;
107-
struct lysc_type_str *type_str = (struct lysc_type_str *)type;
108107
struct lyd_value_ipv6_address_no_zone *val;
109108
uint32_t value_size;
110109

0 commit comments

Comments
 (0)