1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
13 #define ARGV0 "ossec-regex"
16 static void helpmsg(void) __attribute__((noreturn));
21 printf("\nOSSEC HIDS %s: ossec-regex pattern\n", ARGV0);
25 int main(int argc, char **argv)
29 char msg[OS_MAXSTR + 1];
30 memset(msg, '\0', OS_MAXSTR + 1);
43 if (strcmp(argv[1], "-h") == 0) {
50 if (!OSRegex_Compile(pattern, ®ex, 0)) {
51 printf("pattern does not compile with OSRegex_Compile\n");
54 if (!OSMatch_Compile(pattern, &matcher, 0)) {
55 printf("pattern does not compile with OSMatch_Compile\n");
59 while ((fgets(msg, OS_MAXSTR, stdin)) != NULL) {
61 if (msg[strlen(msg) - 1] == '\n') {
62 msg[strlen(msg) - 1] = '\0';
65 /* Make sure we ignore blank lines */
66 if (strlen(msg) < 2) {
70 if (OSRegex_Execute(msg, ®ex)) {
71 printf("+OSRegex_Execute: %s\n", msg);
75 printf("-OSRegex_Execute: \n");
78 if (OS_Regex(pattern, msg)) {
79 printf("+OS_Regex : %s\n", msg);
83 printf("-OS_Regex: \n");
86 if (OSMatch_Execute(msg, strlen(msg), &matcher)) {
87 printf("+OSMatch_Compile: %s\n", msg);
90 if (OS_Match2(pattern, msg)) {
91 printf("+OS_Match2 : %s\n", msg);