yanglint REFACTOR new yl_opt and cmd callbacks

The yanglint options were stored in non-interactive mode in the
structure named 'context'. This structure was renamed to yl_opt
and is now also used in the interactive mode, which has also been
expanded with new callbacks. These callbacks are the basis for
further refactoring commits, which aim to reduce duplicate code
between interactive and non-interactive modes to a minimum.
diff --git a/tools/lint/common.c b/tools/lint/common.c
index 96fdb76..205c32a 100644
--- a/tools/lint/common.c
+++ b/tools/lint/common.c
@@ -1,9 +1,10 @@
 /**
  * @file common.c
  * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Adam Piecek <piecek@cesnet.cz>
  * @brief libyang's yanglint tool - common functions for both interactive and non-interactive mode.
  *
- * Copyright (c) 2020 CESNET, z.s.p.o.
+ * Copyright (c) 2023 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@
 #include "compat.h"
 #include "libyang.h"
 #include "plugins_exts.h"
+#include "yl_opt.h"
 
 int
 parse_schema_path(const char *path, char **dir, char **module)
@@ -104,7 +106,7 @@
 }
 
 void
-get_features(struct ly_set *fset, const char *module, const char ***features)
+get_features(const struct ly_set *fset, const char *module, const char ***features)
 {
     /* get features list for this module */
     for (uint32_t u = 0; u < fset->count; ++u) {
@@ -185,29 +187,6 @@
     return 0;
 }
 
-struct cmdline_file *
-fill_cmdline_file(struct ly_set *set, struct ly_in *in, const char *path, LYD_FORMAT format)
-{
-    struct cmdline_file *rec;
-
-    rec = malloc(sizeof *rec);
-    if (!rec) {
-        YLMSG_E("Allocating memory for data file information failed.\n");
-        return NULL;
-    }
-    rec->in = in;
-    rec->path = path;
-    rec->format = format;
-
-    if (set && ly_set_add(set, rec, 1, NULL)) {
-        free(rec);
-        YLMSG_E("Storing data file information failed.\n");
-        return NULL;
-    }
-
-    return rec;
-}
-
 int
 collect_features(const struct lys_module *mod, struct ly_set *set)
 {
@@ -348,104 +327,6 @@
     return ret;
 }
 
-void
-free_cmdline_file(void *cmdline_file)
-{
-    struct cmdline_file *rec = (struct cmdline_file *)cmdline_file;
-
-    if (rec) {
-        ly_in_free(rec->in, 1);
-        free(rec);
-    }
-}
-
-void
-free_cmdline(char *argv[])
-{
-    if (argv) {
-        free(argv[0]);
-        free(argv);
-    }
-}
-
-int
-parse_cmdline(const char *cmdline, int *argc_p, char **argv_p[])
-{
-    int count;
-    char **vector;
-    char *ptr;
-    char qmark = 0;
-
-    assert(cmdline);
-    assert(argc_p);
-    assert(argv_p);
-
-    /* init */
-    optind = 0; /* reinitialize getopt() */
-    count = 1;
-    vector = malloc((count + 1) * sizeof *vector);
-    vector[0] = strdup(cmdline);
-
-    /* command name */
-    strtok(vector[0], " ");
-
-    /* arguments */
-    while ((ptr = strtok(NULL, " "))) {
-        size_t len;
-        void *r;
-
-        len = strlen(ptr);
-
-        if (qmark) {
-            /* still in quotated text */
-            /* remove NULL termination of the previous token since it is not a token,
-             * but a part of the quotation string */
-            ptr[-1] = ' ';
-
-            if ((ptr[len - 1] == qmark) && (ptr[len - 2] != '\\')) {
-                /* end of quotation */
-                qmark = 0;
-                /* shorten the argument by the terminating quotation mark */
-                ptr[len - 1] = '\0';
-            }
-            continue;
-        }
-
-        /* another token in cmdline */
-        ++count;
-        r = realloc(vector, (count + 1) * sizeof *vector);
-        if (!r) {
-            YLMSG_E("Memory allocation failed (%s:%d, %s).\n", __FILE__, __LINE__, strerror(errno));
-            free(vector);
-            return -1;
-        }
-        vector = r;
-        vector[count - 1] = ptr;
-
-        if ((ptr[0] == '"') || (ptr[0] == '\'')) {
-            /* remember the quotation mark to identify end of quotation */
-            qmark = ptr[0];
-
-            /* move the remembered argument after the quotation mark */
-            ++vector[count - 1];
-
-            /* check if the quotation is terminated within this token */
-            if ((ptr[len - 1] == qmark) && (ptr[len - 2] != '\\')) {
-                /* end of quotation */
-                qmark = 0;
-                /* shorten the argument by the terminating quotation mark */
-                ptr[len - 1] = '\0';
-            }
-        }
-    }
-    vector[count] = NULL;
-
-    *argc_p = count;
-    *argv_p = vector;
-
-    return 0;
-}
-
 LYS_INFORMAT
 get_schema_format(const char *filename)
 {