data tree CHANGE prepare updated validation flags
Except LYD_OPT_VAL_DATA_ONLY, none are implemented, only defined.
Operations (RPC/action/rpc-reply/notification) cannot be parsed
nor validated as they will have a separate function implemented.
Also, mandatory validation implemented.
diff --git a/tools/lint/commands.c b/tools/lint/commands.c
index 90a1480..67c0e53 100644
--- a/tools/lint/commands.c
+++ b/tools/lint/commands.c
@@ -637,7 +637,6 @@
}
lyxml_free(ctx, xml);
} else {
-#endif
if (opts & LYD_OPT_RPCREPLY) {
if (!rpc_act_file) {
fprintf(stderr, "RPC/action reply data require additional argument (file with the RPC/action).\n");
@@ -664,22 +663,17 @@
data = lyd_parse_path(ctx, filepath, informat, opts, trees);
} else if (opts & (LYD_OPT_RPC | LYD_OPT_NOTIF)) {
data = lyd_parse_path(ctx, filepath, informat, opts, trees);
-#if 0
} else if (opts & LYD_OPT_DATA_TEMPLATE) {
if (!rpc_act_file) {
fprintf(stderr, "YANG-DATA require additional argument (name instance of yang-data extension).\n");
return EXIT_FAILURE;
}
data = lyd_parse_path(ctx, filepath, informat, opts, rpc_act_file);
-#endif
} else {
- if (!(opts & LYD_OPT_TYPEMASK)) {
- /* automatically add yang-library data */
- opts |= LYD_OPT_DATA_ADD_YANGLIB;
- }
- data = lyd_parse_path(ctx, filepath, informat, opts, NULL);
- }
+#endif
+ data = lyd_parse_path(ctx, filepath, informat, opts);
#if 0
+ }
}
#endif
lyd_free_all(rpc_act);
@@ -780,6 +774,7 @@
}
out_path = optarg;
break;
+#if 0
case 'r':
if (optarg[0] == '!') {
/* ignore extenral dependencies to the running datastore */
@@ -802,27 +797,20 @@
options |= LYD_OPT_STRICT;
options |= LYD_OPT_OBSOLETE;
break;
+#endif
case 't':
if (!strcmp(optarg, "auto")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_TYPEMASK;
+ /* no flags */
} else if (!strcmp(optarg, "data")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_DATA;
+ /* no flags */
} else if (!strcmp(optarg, "config")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_CONFIG;
+ options |= LYD_OPT_CONFIG;
} else if (!strcmp(optarg, "get")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_GET;
+ options |= LYD_OPT_GET;
} else if (!strcmp(optarg, "getconfig")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_GETCONFIG;
+ options |= LYD_OPT_GETCONFIG;
} else if (!strcmp(optarg, "edit")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_EDIT;
- } else if (!strcmp(optarg, "rpc")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_RPC;
- } else if (!strcmp(optarg, "rpcreply")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_RPCREPLY;
- } else if (!strcmp(optarg, "notif")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_NOTIF;
- } else if (!strcmp(optarg, "yangdata")) {
- options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_DATA_TEMPLATE;
+ options |= LYD_OPT_EDIT;
} else {
fprintf(stderr, "Invalid parser option \"%s\".\n", optarg);
cmd_data_help();
@@ -854,11 +842,7 @@
}
if (outformat != LYD_UNKNOWN) {
- if (options & LYD_OPT_RPCREPLY) {
- lyd_print_file(output, lyd_node_children(data), outformat, LYDP_WITHSIBLINGS | LYDP_FORMAT | printopt);
- } else {
- lyd_print_file(output, data, outformat, LYDP_WITHSIBLINGS | LYDP_FORMAT | printopt);
- }
+ lyd_print_file(output, data, outformat, LYDP_WITHSIBLINGS | LYDP_FORMAT | printopt);
}
ret = 0;
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 86ea97d..60ecfe1 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -326,7 +326,7 @@
struct lyd_node *tree;
struct dataitem *next;
LYD_FORMAT format;
- int type;
+ int flags;
} *data = NULL, *data_item, *data_prev = NULL;
struct ly_set *mods = NULL;
void *p;
@@ -513,24 +513,17 @@
break;
case 't':
if (!strcmp(optarg, "auto")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK);
autodetection = 1;
} else if (!strcmp(optarg, "config")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_CONFIG;
+ options_parser |= LYD_OPT_CONFIG;
} else if (!strcmp(optarg, "get")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_GET;
+ options_parser |= LYD_OPT_GET;
} else if (!strcmp(optarg, "getconfig")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_GETCONFIG;
+ options_parser |= LYD_OPT_GETCONFIG;
} else if (!strcmp(optarg, "edit")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_EDIT;
+ options_parser |= LYD_OPT_EDIT;
} else if (!strcmp(optarg, "data")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_DATA_NO_YANGLIB;
- } else if (!strcmp(optarg, "rpc")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_RPC;
- } else if (!strcmp(optarg, "rpcreply")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_RPCREPLY;
- } else if (!strcmp(optarg, "notif")) {
- options_parser = (options_parser & ~LYD_OPT_TYPEMASK) | LYD_OPT_NOTIF;
+ /* no options */
} else {
fprintf(stderr, "yanglint error: unknown data tree type %s\n", optarg);
help(1);
@@ -659,11 +652,11 @@
/* ignore operational datastore file */
oper_file = NULL;
}
-#endif
if ((options_parser & LYD_OPT_TYPEMASK) == LYD_OPT_DATA) {
/* add option to ignore ietf-yang-library data for implicit data type */
options_parser |= LYD_OPT_DATA_NO_YANGLIB;
}
+#endif
/* set callback for printing libyang messages */
ly_set_log_clb(libyang_verbclb, 1);
@@ -733,7 +726,7 @@
}
data_item->filename = argv[optind + i];
data_item->format = informat_d;
- data_item->type = options_parser & LYD_OPT_TYPEMASK;
+ data_item->flags = options_parser;
data_item->tree = NULL;
data_item->next = NULL;
}
@@ -804,7 +797,7 @@
fprintf(stderr, "yanglint error: The operational data are expected in XML or JSON format.\n");
goto cleanup;
}
- oper = lyd_parse_path(ctx, oper_file, informat_d, LYD_OPT_DATA_NO_YANGLIB | LYD_OPT_TRUSTED, NULL);
+ oper = lyd_parse_path(ctx, oper_file, informat_d, LYD_OPT_PARSE_ONLY);
if (!oper) {
fprintf(stderr, "yanglint error: Failed to parse the operational datastore file for RPC/Notification validation.\n");
goto cleanup;
@@ -975,7 +968,7 @@
#else
{
#endif
- data_item->tree = lyd_parse_path(ctx, data_item->filename, data_item->format, options_parser, trees);
+ data_item->tree = lyd_parse_path(ctx, data_item->filename, data_item->format, options_parser);
}
if (ly_err_first(ctx)) {
goto cleanup;
@@ -1069,8 +1062,7 @@
}
}
#endif
- lyd_print_file(out, (data_item->type == LYD_OPT_RPCREPLY) ? lyd_node_children(data_item->tree) : data_item->tree,
- outformat_d, LYDP_WITHSIBLINGS | LYDP_FORMAT /* TODO defaults | options_dflt */);
+ lyd_print_file(out, data_item->tree, outformat_d, LYDP_WITHSIBLINGS | LYDP_FORMAT /* TODO defaults | options_dflt */);
#if 0
if (envelope_s) {
if (data_item->type == LYD_OPT_RPC && data_item->tree->schema->nodetype != LYS_RPC) {