diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-10-22 12:21:44 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-10-22 12:21:44 (GMT) |
commit | 98dab5148243637a4f2d19a7c44b0e643a0e0f8c (patch) | |
tree | aa5f22f47e01f5ff7f2e0239cae9949ab6354ac9 /src/analysis/scan | |
parent | c370bb014b20654a2b7351b2a9d7e1e5a3ce92cc (diff) |
Provide the size of a rule without recomputing it.
Diffstat (limited to 'src/analysis/scan')
-rw-r--r-- | src/analysis/scan/scanner-int.h | 2 | ||||
-rw-r--r-- | src/analysis/scan/scanner.c | 13 | ||||
-rw-r--r-- | src/analysis/scan/scanner.h | 2 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/analysis/scan/scanner-int.h b/src/analysis/scan/scanner-int.h index 4fcda87..02fd6b3 100644 --- a/src/analysis/scan/scanner-int.h +++ b/src/analysis/scan/scanner-int.h @@ -55,7 +55,7 @@ struct _GContentScannerClass /* Met en place un scanner de contenus binaires. */ -bool g_content_scanner_create_from_text(GContentScanner *, const char *); +bool g_content_scanner_create_from_text(GContentScanner *, const char *, size_t); /* Met en place un scanner de contenus binaires. */ bool g_content_scanner_create_from_file(GContentScanner *, const char *); diff --git a/src/analysis/scan/scanner.c b/src/analysis/scan/scanner.c index 57fe0d9..1f90393 100644 --- a/src/analysis/scan/scanner.c +++ b/src/analysis/scan/scanner.c @@ -163,7 +163,8 @@ static void g_content_scanner_finalize(GContentScanner *scanner) /****************************************************************************** * * -* Paramètres : text = définitions textuelles de règles de recherche. * +* Paramètres : text = définitions textuelles de règles de recherche. * +* length = taille de la définition. * * * * Description : Prépare une recherche de motifs dans du contenu binaire. * * * @@ -173,13 +174,13 @@ static void g_content_scanner_finalize(GContentScanner *scanner) * * ******************************************************************************/ -GContentScanner *g_content_scanner_new_from_text(const char *text) +GContentScanner *g_content_scanner_new_from_text(const char *text, size_t length) { GContentScanner *result; /* Structure à retourner */ result = g_object_new(G_TYPE_CONTENT_SCANNER, NULL); - if (!g_content_scanner_create_from_text(result, text)) + if (!g_content_scanner_create_from_text(result, text, length)) g_clear_object(&result); return result; @@ -191,6 +192,7 @@ GContentScanner *g_content_scanner_new_from_text(const char *text) * * * Paramètres : scanner = scanner de contenus à initialiser pleinement. * * text = définitions textuelles de règles de recherche. * +* length = taille de la définition. * * * * Description : Met en place un scanner de contenus binaires. * * * @@ -200,12 +202,9 @@ GContentScanner *g_content_scanner_new_from_text(const char *text) * * ******************************************************************************/ -bool g_content_scanner_create_from_text(GContentScanner *scanner, const char *text) +bool g_content_scanner_create_from_text(GContentScanner *scanner, const char *text, size_t length) { bool result; /* Bilan à retourner */ - size_t length; /* Taille de la définition */ - - length = strlen(text); result = process_rules_definitions(scanner, text, length); diff --git a/src/analysis/scan/scanner.h b/src/analysis/scan/scanner.h index e03ecda..7926ba1 100644 --- a/src/analysis/scan/scanner.h +++ b/src/analysis/scan/scanner.h @@ -55,7 +55,7 @@ typedef struct _GContentScannerClass GContentScannerClass; GType g_content_scanner_get_type(void); /* Prépare une recherche de motifs dans du contenu binaire. */ -GContentScanner *g_content_scanner_new_from_text(const char *); +GContentScanner *g_content_scanner_new_from_text(const char *, size_t); /* Prépare une recherche de motifs dans du contenu binaire. */ GContentScanner *g_content_scanner_new_from_file(const char *); |