summaryrefslogtreecommitdiff
path: root/src/analysis/scan/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/options.c')
-rw-r--r--src/analysis/scan/options.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/analysis/scan/options.c b/src/analysis/scan/options.c
index 637c821..0b50495 100644
--- a/src/analysis/scan/options.c
+++ b/src/analysis/scan/options.c
@@ -24,6 +24,10 @@
#include "options.h"
+#include <malloc.h>
+#include <string.h>
+
+
#include "options-int.h"
@@ -92,6 +96,9 @@ static void g_scan_options_init(GScanOptions *options)
options->print_strings = false;
options->print_stats = false;
+ options->selected_tags = NULL;
+ options->selected_count = 0;
+
}
@@ -128,6 +135,14 @@ static void g_scan_options_dispose(GScanOptions *options)
static void g_scan_options_finalize(GScanOptions *options)
{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < options->selected_count; i++)
+ free(options->selected_tags[i]);
+
+ if (options->selected_tags != NULL)
+ free(options->selected_tags);
+
G_OBJECT_CLASS(g_scan_options_parent_class)->finalize(G_OBJECT(options));
}
@@ -369,3 +384,64 @@ void g_scan_options_set_print_stats(GScanOptions *options, bool state)
options->print_stats = state;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : options = ensemble d'options d'analyses à compléter. *
+* tag = étiquette de règle à sélectionner. *
+* *
+* Description : Inscrit une étiquette comme sélection de règles à afficher. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_scan_options_select_tag(GScanOptions *options, const char *tag)
+{
+ options->selected_tags = realloc(options->selected_tags, ++options->selected_count * sizeof(char *));
+
+ options->selected_tags[options->selected_count - 1] = strdup(tag);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : options = ensemble d'options d'analyses à compléter. *
+* tag = étiquette de règle à auditionner. *
+* *
+* Description : Détermine si une étiquette donnée conduit à un affichage. *
+* *
+* Retour : true si une règle portant l'étiquette doit être affichée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_scan_options_has_tag_as_selected(const GScanOptions *options, const char *tag)
+{
+ bool result; /* Bilan à retourner */
+ size_t i; /* Boucle de parcours */
+
+ if (tag == NULL)
+ result = (options->selected_count == 0);
+
+ else
+ {
+ result = false;
+
+ for (i = 0; i < options->selected_count; i++)
+ if (strcmp(options->selected_tags[i], tag) == 0)
+ {
+ result = true;
+ break;
+ }
+
+ }
+
+ return result;
+
+}