|
|
@ -11,7 +11,7 @@ |
|
|
|
#include "filter.h" |
|
|
|
#include "filter.h" |
|
|
|
|
|
|
|
|
|
|
|
void usage() { |
|
|
|
void usage() { |
|
|
|
fprintf(stderr, "Usage: filter-test <library.so> <regexps-file.txt>\n"); |
|
|
|
fprintf(stderr, "Usage: filter-test <library.so> <regexps-file.txt> [<file.log>]\n"); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +23,7 @@ int main(int argc, char *argv[]) { |
|
|
|
char line[LOGLINE_MAX] = ""; |
|
|
|
char line[LOGLINE_MAX] = ""; |
|
|
|
size_t read = 0, matched = 0; |
|
|
|
size_t read = 0, matched = 0; |
|
|
|
const char *error; |
|
|
|
const char *error; |
|
|
|
|
|
|
|
FILE *file = NULL; |
|
|
|
|
|
|
|
|
|
|
|
if (argc < 3) |
|
|
|
if (argc < 3) |
|
|
|
usage(); |
|
|
|
usage(); |
|
|
@ -33,7 +34,14 @@ int main(int argc, char *argv[]) { |
|
|
|
if ((filter = f2b_filter_create(&config, argv[2])) == false) |
|
|
|
if ((filter = f2b_filter_create(&config, argv[2])) == false) |
|
|
|
usage(); |
|
|
|
usage(); |
|
|
|
|
|
|
|
|
|
|
|
while (fgets(line, sizeof(line), stdin) != NULL) { |
|
|
|
if (argc > 3) { |
|
|
|
|
|
|
|
if ((file = fopen(argv[3], "r")) == NULL) |
|
|
|
|
|
|
|
usage(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
file = stdin; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (fgets(line, sizeof(line), file) != NULL) { |
|
|
|
read++; |
|
|
|
read++; |
|
|
|
if (f2b_filter_match(filter, line, match, sizeof(match))) { |
|
|
|
if (f2b_filter_match(filter, line, match, sizeof(match))) { |
|
|
|
matched++; |
|
|
|
matched++; |
|
|
|