libclamav/regex_list.h
bd912dd8
 /*
  *  Match a string against a list of patterns/regexes.
  *
c726f2da
  *  Copyright (C) 2007-2008 Sourcefire, Inc.
  *
  *  Authors: Török Edvin
bd912dd8
  *
  *  This program is free software; you can redistribute it and/or modify
c726f2da
  *  it under the terms of the GNU General Public License version 2 as
38a00199
  *  published by the Free Software Foundation.
bd912dd8
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  *  MA 02110-1301, USA.
  */
 
 
 #ifndef _REGEX_LIST_H
 #define _REGEX_LIST_H
 
ec481027
 #ifdef NDEBUG
 #define massert(x) (void)(0)
 #else
 /*debug version, massert enabled*/
 
 #define __massert_fail(expr,file,line) (void)cli_errmsg("Assertion failed at %s:%d\n %s\n",file,line,expr)
 
 #define massert(expr) ((void) ((expr) ? (void)0 : (__massert_fail (#expr,__FILE__,__LINE__))))
 #endif
 
b5341ac0
 #include "phishcheck.h"
e2c26a8a
 #include "readdb.h"
 #include "matcher.h"
056d95dc
 #include <zlib.h> /* for gzFile */
bd912dd8
 struct node_stack {
 	struct tree_node** data;
 	size_t capacity;
 	size_t cnt;
 };
 
 struct regex_matcher {
 	struct cli_matcher* root_hosts;
 	struct tree_node* root_regex;
6e3332cf
 	struct tree_node* root_regex_hostonly; 
5a9a9989
 	struct node_stack node_stack;
 	struct node_stack node_stack_alt;
e3b67c5e
 	size_t root_hosts_cnt;
bd912dd8
 	int list_inited;
 	int list_loaded;
 	int list_built;
 };
 
7191e94b
 int regex_list_match(struct regex_matcher* matcher, char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup, int hostOnly,const char** info,int is_whitelist);
bd912dd8
 int init_regex_list(struct regex_matcher* matcher);
e2c26a8a
 int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,struct cli_dbio *dbio);
bd912dd8
 void regex_list_cleanup(struct regex_matcher* matcher);
 void regex_list_done(struct regex_matcher* matcher);
 int is_regex_ok(struct regex_matcher* matcher);
3da4dd4c
 
bd912dd8
 #endif