3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
13 /* This tool will clear the project statistics */
18 #define ARGV0 "ossec-regex"
24 printf("\nOSSEC HIDS %s: ossec-regex pattern\n", ARGV0);
30 int main(int argc, char **argv)
34 char msg[OS_MAXSTR +1];
35 memset(msg, '\0', OS_MAXSTR +1);
50 if(strcmp(argv[1], "-h") == 0)
56 os_strdup(argv[1], pattern);
57 if(!OSRegex_Compile(pattern, ®ex, 0))
59 printf("pattern does not compile with OSRegex_Compile\n");
62 if(!OSMatch_Compile(pattern, &matcher, 0))
64 printf("pattern does not compile with OSMatch_Compile\n");
69 while((fgets(msg, OS_MAXSTR, stdin)) != NULL)
71 /* Removing new line. */
72 if(msg[strlen(msg) -1] == '\n')
73 msg[strlen(msg) -1] = '\0';
75 /* Make sure we ignore blank lines. */
76 if(strlen(msg) < 2) { continue; }
78 if(OSRegex_Execute(msg, ®ex))
79 printf("+OSRegex_Execute: %s\n",msg);
82 printf("-OSRegex_Execute: \n");
85 if(OS_Regex(pattern, msg))
86 printf("+OS_Regex : %s\n", msg);
89 printf("-OS_Regex: \n");
92 if(OSMatch_Execute(msg, strlen(msg), &matcher))
93 printf("+OSMatch_Compile: %s\n", msg);
95 if(OS_Match2(pattern, msg))
96 printf("+OS_Match2 : %s\n", msg);