Skip to content

Commit 44057af

Browse files
committed
plugins types UPDATE use plugins for previous revisions of modules
1 parent a83a931 commit 44057af

File tree

13 files changed

+76
-44
lines changed

13 files changed

+76
-44
lines changed

src/plugins_types/date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ lyplg_type_free_date(const struct ly_ctx *ctx, struct lyd_value *value)
398398
const struct lyplg_type_record plugins_date[] = {
399399
{
400400
.module = "ietf-yang-types",
401-
.revision = "2025-12-22",
401+
.revision = NULL,
402402
.name = "date",
403403

404404
.plugin.id = "ly2 date",
@@ -414,7 +414,7 @@ const struct lyplg_type_record plugins_date[] = {
414414
},
415415
{
416416
.module = "ietf-yang-types",
417-
.revision = "2025-12-22",
417+
.revision = NULL,
418418
.name = "date-no-zone",
419419

420420
.plugin.id = "ly2 date",

src/plugins_types/date_and_time.c

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static LY_ERR
5050
lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, uint64_t value_size_bits,
5151
uint32_t options, LY_VALUE_FORMAT format, void *UNUSED(prefix_data), uint32_t hints,
5252
const struct lysc_node *UNUSED(ctx_node), struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres),
53-
struct ly_err_item **err)
53+
ly_bool old_rev, struct ly_err_item **err)
5454
{
5555
LY_ERR ret = LY_SUCCESS;
5656
struct lyd_value_date_and_time *val;
@@ -120,7 +120,7 @@ lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type
120120
goto cleanup;
121121
}
122122

123-
if (!strncmp(((char *)value + value_size) - 6, "-00:00", 6) || (((char *)value)[value_size - 1] == 'Z')) {
123+
if (!strncmp(((char *)value + value_size) - 6, "-00:00", 6) || (!old_rev && (((char *)value)[value_size - 1] == 'Z'))) {
124124
/* unknown timezone, timezone format supported for backwards compatibility */
125125
val->unknown_tz = 1;
126126
}
@@ -148,6 +148,24 @@ lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type
148148
return ret;
149149
}
150150

151+
static LY_ERR
152+
lyplg_type_store_date_and_time_old(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value,
153+
uint64_t value_size_bits, uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
154+
const struct lysc_node *ctx_node, struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err)
155+
{
156+
return lyplg_type_store_date_and_time(ctx, type, value, value_size_bits, options, format, prefix_data, hints,
157+
ctx_node, storage, unres, 1, err);
158+
}
159+
160+
static LY_ERR
161+
lyplg_type_store_date_and_time_new(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value,
162+
uint64_t value_size_bits, uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
163+
const struct lysc_node *ctx_node, struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err)
164+
{
165+
return lyplg_type_store_date_and_time(ctx, type, value, value_size_bits, options, format, prefix_data, hints,
166+
ctx_node, storage, unres, 0, err);
167+
}
168+
151169
/**
152170
* @brief Implementation of ::lyplg_type_compare_clb for ietf-yang-types date-and-time type.
153171
*/
@@ -263,7 +281,7 @@ lyplg_type_sort_date_and_time(const struct ly_ctx *UNUSED(ctx), const struct lyd
263281
*/
264282
static const void *
265283
lyplg_type_print_date_and_time(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
266-
void *UNUSED(prefix_data), ly_bool *dynamic, uint64_t *value_size_bits)
284+
void *UNUSED(prefix_data), ly_bool old_rev, ly_bool *dynamic, uint64_t *value_size_bits)
267285
{
268286
struct lyd_value_date_and_time *val;
269287
struct tm tm;
@@ -303,9 +321,9 @@ lyplg_type_print_date_and_time(const struct ly_ctx *ctx, const struct lyd_value
303321
return NULL;
304322
}
305323

306-
if (asprintf(&ret, "%04d-%02d-%02dT%02d:%02d:%02d%s%sZ",
324+
if (asprintf(&ret, "%04d-%02d-%02dT%02d:%02d:%02d%s%s%s",
307325
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
308-
val->fractions_s ? "." : "", val->fractions_s ? val->fractions_s : "") == -1) {
326+
val->fractions_s ? "." : "", val->fractions_s ? val->fractions_s : "", old_rev ? "-00:00" : "Z") == -1) {
309327
return NULL;
310328
}
311329
} else {
@@ -331,6 +349,20 @@ lyplg_type_print_date_and_time(const struct ly_ctx *ctx, const struct lyd_value
331349
return value->_canonical;
332350
}
333351

352+
static const void *
353+
lyplg_type_print_date_and_time_old(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
354+
void *prefix_data, ly_bool *dynamic, uint64_t *value_size_bits)
355+
{
356+
return lyplg_type_print_date_and_time(ctx, value, format, prefix_data, 1, dynamic, value_size_bits);
357+
}
358+
359+
static const void *
360+
lyplg_type_print_date_and_time_new(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
361+
void *prefix_data, ly_bool *dynamic, uint64_t *value_size_bits)
362+
{
363+
return lyplg_type_print_date_and_time(ctx, value, format, prefix_data, 0, dynamic, value_size_bits);
364+
}
365+
334366
/**
335367
* @brief Implementation of ::lyplg_type_dup_clb for ietf-yang-types date-and-time type.
336368
*/
@@ -395,19 +427,35 @@ lyplg_type_free_date_and_time(const struct ly_ctx *ctx, struct lyd_value *value)
395427
* LYPLG_TYPES = {
396428
*/
397429
const struct lyplg_type_record plugins_date_and_time[] = {
430+
{
431+
.module = "ietf-yang-types",
432+
.revision = "2013-07-15",
433+
.name = "date-and-time",
434+
435+
.plugin.id = "ly2 date-and-time",
436+
.plugin.lyb_size = lyplg_type_lyb_size_variable_bytes,
437+
.plugin.store = lyplg_type_store_date_and_time_old,
438+
.plugin.validate_value = NULL,
439+
.plugin.validate_tree = NULL,
440+
.plugin.compare = lyplg_type_compare_date_and_time,
441+
.plugin.sort = lyplg_type_sort_date_and_time,
442+
.plugin.print = lyplg_type_print_date_and_time_old,
443+
.plugin.duplicate = lyplg_type_dup_date_and_time,
444+
.plugin.free = lyplg_type_free_date_and_time,
445+
},
398446
{
399447
.module = "ietf-yang-types",
400448
.revision = "2025-12-22",
401449
.name = "date-and-time",
402450

403451
.plugin.id = "ly2 date-and-time",
404452
.plugin.lyb_size = lyplg_type_lyb_size_variable_bytes,
405-
.plugin.store = lyplg_type_store_date_and_time,
453+
.plugin.store = lyplg_type_store_date_and_time_new,
406454
.plugin.validate_value = NULL,
407455
.plugin.validate_tree = NULL,
408456
.plugin.compare = lyplg_type_compare_date_and_time,
409457
.plugin.sort = lyplg_type_sort_date_and_time,
410-
.plugin.print = lyplg_type_print_date_and_time,
458+
.plugin.print = lyplg_type_print_date_and_time_new,
411459
.plugin.duplicate = lyplg_type_dup_date_and_time,
412460
.plugin.free = lyplg_type_free_date_and_time,
413461
},

src/plugins_types/hex_string.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ lyplg_type_store_hex_string(const struct ly_ctx *ctx, const struct lysc_type *ty
112112
const struct lyplg_type_record plugins_hex_string[] = {
113113
{
114114
.module = "ietf-yang-types",
115-
.revision = "2025-12-22",
115+
.revision = NULL,
116116
.name = "phys-address",
117117

118118
.plugin.id = "ly2 hex-string",
@@ -128,7 +128,7 @@ const struct lyplg_type_record plugins_hex_string[] = {
128128
},
129129
{
130130
.module = "ietf-yang-types",
131-
.revision = "2025-12-22",
131+
.revision = NULL,
132132
.name = "mac-address",
133133

134134
.plugin.id = "ly2 hex-string",
@@ -144,7 +144,7 @@ const struct lyplg_type_record plugins_hex_string[] = {
144144
},
145145
{
146146
.module = "ietf-yang-types",
147-
.revision = "2025-12-22",
147+
.revision = NULL,
148148
.name = "hex-string",
149149

150150
.plugin.id = "ly2 hex-string",
@@ -160,7 +160,7 @@ const struct lyplg_type_record plugins_hex_string[] = {
160160
},
161161
{
162162
.module = "ietf-yang-types",
163-
.revision = "2025-12-22",
163+
.revision = NULL,
164164
.name = "uuid",
165165

166166
.plugin.id = "ly2 hex-string",

src/plugins_types/ipv4_address.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ lyplg_type_free_ipv4_address(const struct ly_ctx *ctx, struct lyd_value *value)
377377
const struct lyplg_type_record plugins_ipv4_address[] = {
378378
{
379379
.module = "ietf-inet-types",
380-
.revision = "2025-12-22",
380+
.revision = NULL,
381381
.name = "ipv4-address",
382382

383383
.plugin.id = "ly2 ipv4-address",
@@ -393,7 +393,7 @@ const struct lyplg_type_record plugins_ipv4_address[] = {
393393
},
394394
{
395395
.module = "ietf-inet-types",
396-
.revision = "2025-12-22",
396+
.revision = NULL,
397397
.name = "ipv4-address-link-local",
398398

399399
.plugin.id = "ly2 ipv4-address",

src/plugins_types/ipv4_address_no_zone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ lyplg_type_print_ipv4_address_no_zone(const struct ly_ctx *ctx, const struct lyd
213213
const struct lyplg_type_record plugins_ipv4_address_no_zone[] = {
214214
{
215215
.module = "ietf-inet-types",
216-
.revision = "2025-12-22",
216+
.revision = NULL,
217217
.name = "ipv4-address-no-zone",
218218

219219
.plugin.id = "ly2 ipv4-address-no-zone",

src/plugins_types/ipv4_address_prefix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ lyplg_type_free_ipv4_address_prefix(const struct ly_ctx *ctx, struct lyd_value *
348348
const struct lyplg_type_record plugins_ipv4_address_prefix[] = {
349349
{
350350
.module = "ietf-inet-types",
351-
.revision = "2025-12-22",
351+
.revision = NULL,
352352
.name = "ipv4-prefix",
353353

354354
.plugin.id = "ly2 ipv4-address-prefix",
@@ -364,7 +364,7 @@ const struct lyplg_type_record plugins_ipv4_address_prefix[] = {
364364
},
365365
{
366366
.module = "ietf-inet-types",
367-
.revision = "2025-12-22",
367+
.revision = NULL,
368368
.name = "ipv4-address-and-prefix",
369369

370370
.plugin.id = "ly2 ipv4-address-prefix",

src/plugins_types/ipv6_address.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ lyplg_type_free_ipv6_address(const struct ly_ctx *ctx, struct lyd_value *value)
379379
const struct lyplg_type_record plugins_ipv6_address[] = {
380380
{
381381
.module = "ietf-inet-types",
382-
.revision = "2025-12-22",
382+
.revision = NULL,
383383
.name = "ipv6-address",
384384

385385
.plugin.id = "ly2 ipv6-address",
@@ -395,7 +395,7 @@ const struct lyplg_type_record plugins_ipv6_address[] = {
395395
},
396396
{
397397
.module = "ietf-inet-types",
398-
.revision = "2025-12-22",
398+
.revision = NULL,
399399
.name = "ipv6-address-link-local",
400400

401401
.plugin.id = "ly2 ipv6-address",

src/plugins_types/ipv6_address_no_zone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ lyplg_type_free_ipv6_address_no_zone(const struct ly_ctx *ctx, struct lyd_value
304304
const struct lyplg_type_record plugins_ipv6_address_no_zone[] = {
305305
{
306306
.module = "ietf-inet-types",
307-
.revision = "2025-12-22",
307+
.revision = NULL,
308308
.name = "ipv6-address-no-zone",
309309

310310
.plugin.id = "ly2 ipv6-address-no-zone",

src/plugins_types/ipv6_address_prefix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ lyplg_type_free_ipv6_address_prefix(const struct ly_ctx *ctx, struct lyd_value *
362362
const struct lyplg_type_record plugins_ipv6_address_prefix[] = {
363363
{
364364
.module = "ietf-inet-types",
365-
.revision = "2025-12-22",
365+
.revision = NULL,
366366
.name = "ipv6-prefix",
367367

368368
.plugin.id = "ly2 ipv6-address-prefix",
@@ -378,7 +378,7 @@ const struct lyplg_type_record plugins_ipv6_address_prefix[] = {
378378
},
379379
{
380380
.module = "ietf-inet-types",
381-
.revision = "2025-12-22",
381+
.revision = NULL,
382382
.name = "ipv6-address-and-prefix",
383383

384384
.plugin.id = "ly2 ipv6-address-prefix",

src/plugins_types/node_instanceid.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,7 @@ lyplg_type_dup_node_instanceid(const struct ly_ctx *ctx, const struct lyd_value
336336
const struct lyplg_type_record plugins_node_instanceid[] = {
337337
{
338338
.module = "ietf-netconf-acm",
339-
.revision = "2012-02-22",
340-
.name = "node-instance-identifier",
341-
342-
.plugin.id = "ly2 node-instance-identifier",
343-
.plugin.lyb_size = lyplg_type_lyb_size_variable_bytes,
344-
.plugin.store = lyplg_type_store_node_instanceid,
345-
.plugin.validate_value = NULL,
346-
.plugin.validate_tree = NULL,
347-
.plugin.compare = lyplg_type_compare_simple,
348-
.plugin.sort = lyplg_type_sort_simple,
349-
.plugin.print = lyplg_type_print_node_instanceid,
350-
.plugin.duplicate = lyplg_type_dup_node_instanceid,
351-
.plugin.free = lyplg_type_free_instanceid,
352-
},
353-
{
354-
.module = "ietf-netconf-acm",
355-
.revision = "2018-02-14",
339+
.revision = NULL,
356340
.name = "node-instance-identifier",
357341

358342
.plugin.id = "ly2 node-instance-identifier",

0 commit comments

Comments
 (0)