From f65fdbad3ae0b2accfe324f996eef0c193ad9dfc Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 24 Feb 2024 23:52:58 +0100 Subject: Provide the match count for bytes using the generic API. --- src/analysis/scan/context.c | 2 +- src/analysis/scan/matches.c | 2 +- src/analysis/scan/matches/bytes.c | 51 +++++++++++++++++++++------------------ src/analysis/scan/matches/bytes.h | 3 --- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/analysis/scan/context.c b/src/analysis/scan/context.c index fc4194b..9a0e9ac 100644 --- a/src/analysis/scan/context.c +++ b/src/analysis/scan/context.c @@ -483,7 +483,7 @@ size_t g_scan_context_count_full_matches(const GScanContext *context, const GSea matches = g_hash_table_lookup(context->full_trackers, pattern); if (matches != NULL) - result = g_scan_bytes_matches_count(matches); + result = g_scan_matches_count(matches); else result = 0; diff --git a/src/analysis/scan/matches.c b/src/analysis/scan/matches.c index d83114c..1290c90 100644 --- a/src/analysis/scan/matches.c +++ b/src/analysis/scan/matches.c @@ -207,7 +207,7 @@ GSearchPattern *g_scan_matches_get_source(const GScanMatches *matches) /****************************************************************************** * * -* Paramètres : matches = définition de correspondance à consulter. * +* Paramètres : matches = définition de correspondances à consulter. * * * * Description : Dénombre les correspondances enregistrées pour un motif. * * * diff --git a/src/analysis/scan/matches/bytes.c b/src/analysis/scan/matches/bytes.c index 218121d..a23188b 100644 --- a/src/analysis/scan/matches/bytes.c +++ b/src/analysis/scan/matches/bytes.c @@ -56,6 +56,9 @@ static void g_scan_bytes_matches_finalize(GScanBytesMatches *); /* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ +/* Dénombre les correspondances enregistrées pour un motif. */ +static size_t g_scan_bytes_matches_count(const GScanBytesMatches *); + /* Affiche une correspondance au format texte. */ static void g_scan_bytes_matches_output_to_text(const GScanBytesMatches *, int); @@ -97,6 +100,8 @@ static void g_scan_bytes_matches_class_init(GScanBytesMatchesClass *klass) matches = G_SCAN_MATCHES_CLASS(klass); + matches->count = (count_scan_matches_fc)g_scan_bytes_matches_count; + matches->to_text = (output_scan_matches_to_text_fc)g_scan_bytes_matches_output_to_text; matches->to_json = (output_scan_matches_to_json_fc)g_scan_bytes_matches_output_to_json; @@ -210,29 +215,6 @@ void g_scan_bytes_matches_set_list(GScanBytesMatches *matches, match_area_t *lis /****************************************************************************** * * * Paramètres : matches = suivi de correspondances à consulter. * -* * -* Description : Indique le nombre de correspondances pour une définition. * -* * -* Retour : Quantité de correspondances établies pour un motif entier. * -* * -* Remarques : - * -* * -******************************************************************************/ - -size_t g_scan_bytes_matches_count(const GScanBytesMatches *matches) -{ - size_t result; /* Quantité à retourner */ - - result = matches->count; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : matches = suivi de correspondances à consulter. * * index = indice de la correspondance recherchée. * * * * Description : Fournit les informations relatives à une correspondance. * @@ -337,6 +319,29 @@ char *g_scan_bytes_matches_get_modifier_path(const GScanBytesMatches *matches) /****************************************************************************** * * +* Paramètres : matches = suivi de correspondances à consulter. * +* * +* Description : Dénombre les correspondances enregistrées pour un motif. * +* * +* Retour : Quantité de correspondances établies. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static size_t g_scan_bytes_matches_count(const GScanBytesMatches *matches) +{ + size_t result; /* Quantité à retourner */ + + result = matches->count; + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : matches = définition de correspondance à manipuler. * * fd = canal d'écriture. * * * diff --git a/src/analysis/scan/matches/bytes.h b/src/analysis/scan/matches/bytes.h index 50f60a4..90d6062 100644 --- a/src/analysis/scan/matches/bytes.h +++ b/src/analysis/scan/matches/bytes.h @@ -61,9 +61,6 @@ GScanMatches *g_scan_bytes_matches_new(void); /* Intègre une liste de correspondances vérifiées. */ void g_scan_bytes_matches_set_list(GScanBytesMatches *, match_area_t *, size_t); -/* Indique le nombre de correspondances pour une définition. */ -size_t g_scan_bytes_matches_count(const GScanBytesMatches *); - /* Fournit les informations relatives à une correspondance. */ const match_area_t *g_scan_bytes_matches_get(const GScanBytesMatches *, size_t); -- cgit v0.11.2-87-g4458