summaryrefslogtreecommitdiff
path: root/src/analysis/scan/match.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/match.c')
-rw-r--r--src/analysis/scan/match.c177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/analysis/scan/match.c b/src/analysis/scan/match.c
new file mode 100644
index 0000000..c7e2a78
--- /dev/null
+++ b/src/analysis/scan/match.c
@@ -0,0 +1,177 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * match.c - sauvegarde d'une correspondance identifiée de motif
+ *
+ * Copyright (C) 2022 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "match.h"
+
+
+#include "match-int.h"
+
+
+
+/* Initialise la classe des correspondances de motifs. */
+static void g_scan_match_class_init(GScanMatchClass *);
+
+/* Initialise une instance de correspondance de motif trouvée. */
+static void g_scan_match_init(GScanMatch *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_match_dispose(GScanMatch *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_match_finalize(GScanMatch *);
+
+
+
+/* Indique le type défini pour un correspondance de motif identifiée. */
+G_DEFINE_TYPE(GScanMatch, g_scan_match, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des correspondances de motifs. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_match_class_init(GScanMatchClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_match_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_match_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : match = instance à initialiser. *
+* *
+* Description : Initialise une instance de correspondance de motif trouvée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_match_init(GScanMatch *match)
+{
+ match->source = NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : match = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_match_dispose(GScanMatch *match)
+{
+ g_clear_object(&match->source);
+
+ G_OBJECT_CLASS(g_scan_match_parent_class)->dispose(G_OBJECT(match));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : match = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_match_finalize(GScanMatch *match)
+{
+ G_OBJECT_CLASS(g_scan_match_parent_class)->finalize(G_OBJECT(match));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : match = définition de correspondance à consulter. *
+* *
+* Description : Indique la source du motif d'origine recherché. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GSearchPattern *g_scan_match_get_source(const GScanMatch *match)
+{
+ GSearchPattern *result; /* Source à retourner */
+
+ result = match->source;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : match = définition de correspondance à manipuler. *
+* *
+* Description : Affiche une correspondance sur la sortie standard. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_scan_match_display(const GScanMatch *match)
+{
+ GScanMatchClass *class; /* Classe à activer */
+
+ class = G_SCAN_MATCH_GET_CLASS(match);
+
+ class->display(match);
+
+}