[Forensics-changes] [yara] 185/415: Improve Aho-Corasick automaton printing function
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:43:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 5b6c86f35329d1d2bca97cb4ce657012ecda7b91
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Jun 27 08:36:25 2013 +0000
Improve Aho-Corasick automaton printing function
---
libyara/ahocorasick.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/libyara/ahocorasick.c b/libyara/ahocorasick.c
index fbc229a..4859b9f 100644
--- a/libyara/ahocorasick.c
+++ b/libyara/ahocorasick.c
@@ -1112,23 +1112,59 @@ int yr_ac_add_string(
void _yr_ac_print_automaton_state(
AC_STATE* state)
{
- int i;
char* identifier;
+ int i;
+ int child_count;
+
STRING* string;
+ AC_STATE_TRANSITION transition;
AC_MATCH* match;
AC_STATE* child_state;
- AC_STATE_TRANSITION transition;
for (i = 0; i < state->depth; i++)
printf(" ");
- printf("%p (%d) -> %p", state, state->depth, state->failure);
+ child_state = _yr_ac_first_transition(state, &transition);
+ child_count = 0;
+
+ while(child_state != NULL)
+ {
+ child_count++;
+ child_state = _yr_ac_next_transition(state, &transition);
+ }
+
+ printf("%p childs:%d depth:%d failure:%p",
+ state, child_count, state->depth, state->failure);
match = state->matches;
while (match != NULL)
{
- printf(" %s:%d", match->string->identifier, match->backtrack);
+ printf("\n");
+
+ for (i = 0; i < state->depth + 1; i++)
+ printf(" ");
+
+ printf("%s = ", match->string->identifier, match->backtrack);
+
+ if (STRING_IS_HEX(match->string))
+ {
+ printf("{ ");
+
+ for (i = 0; i < min(match->string->length, 10); i++)
+ printf("%02x ", match->string->string[i]);
+
+ printf("}");
+ }
+ else if (STRING_IS_REGEXP(match->string))
+ {
+ printf("/%s/", match->string->string);
+ }
+ else
+ {
+ printf("\"%s\"", match->string->string);
+ }
+
match = match->next;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list