1 /* $OSSEC, os_match_execute.c, v0.1, 2006/04/18, Daniel B. Cid$ */
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 3) as published by the FSF - Free Software
18 #include "os_regex_internal.h"
21 /** Internal matching **/
22 int _OS_Match(char *pattern, char *str, int str_len, int size)
27 size = str_len - size;
29 /* Look to match the first pattern */
33 if(charmap[(uchar)str[i]] == *pt)
43 else if(*pt != charmap[(uchar)str[j]])
60 /** Internal matching **/
61 int _os_strncmp(char *pattern, char *str, int str_len, int size)
63 if(strncasecmp(pattern, str, size) == 0)
69 /** Internal matching **/
70 int _os_strcmp(char *pattern, char *str, int str_len, int size)
72 if(strcasecmp(pattern, str) == 0)
78 int _os_strmatch(char *pattern, char *str, int str_len, int size)
84 /** Internal matching **/
85 int _os_strcmp_last(char *pattern, char *str, int str_len, int size)
87 /* Size of the string must be bigger */
88 if((str_len - size) < 0)
91 if(strcasecmp(pattern, str + (str_len - size)) == 0)
98 /** int OSMatch_Execute(char *str, int str_len, OSMatch *reg) v0.1
99 * Compare an already compiled pattern with
101 * Returns 1 on success or 0 on error.
102 * The error code is set on reg->error.
104 int OSMatch_Execute(char *str, int str_len, OSMatch *reg)
108 /* The string can't be NULL */
111 reg->error = OS_REGEX_STR_NULL;
116 /* Looping on all sub patterns */
117 while(reg->patterns[i])
119 if(reg->match_fp[i](reg->patterns[i],
122 reg->size[i]) == TRUE)