2006-09-12 19:38:39 +00:00
|
|
|
|
/*
|
|
|
|
|
|
* Match a string against a list of patterns/regexes.
|
|
|
|
|
|
*
|
2007-03-11 11:14:35 +00:00
|
|
|
|
* Copyright (C) 2006 T<EFBFBD>r<EFBFBD>k Edvin <edwin@clamav.net>
|
2006-09-12 19:38:39 +00:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-06-30 11:50:56 +00:00
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
|
* published by the Free Software Foundation.
|
2006-09-12 19:38:39 +00:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
|
|
|
|
|
|
2006-10-10 23:51:49 +00:00
|
|
|
|
#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
|
|
|
|
|
|
|
2007-09-27 21:27:37 +00:00
|
|
|
|
#include "phishcheck.h"
|
2007-12-18 19:23:56 +00:00
|
|
|
|
#include <zlib.h> /* for gzFile */
|
2006-09-12 19:38:39 +00:00
|
|
|
|
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;
|
2007-03-18 23:27:15 +00:00
|
|
|
|
struct tree_node* root_regex_hostonly;
|
2007-12-28 12:30:23 +00:00
|
|
|
|
struct node_stack node_stack;
|
|
|
|
|
|
struct node_stack node_stack_alt;
|
2006-10-15 19:16:33 +00:00
|
|
|
|
size_t root_hosts_cnt;
|
2006-09-12 19:38:39 +00:00
|
|
|
|
int list_inited;
|
|
|
|
|
|
int list_loaded;
|
|
|
|
|
|
int list_built;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2007-10-03 12:53:09 +00:00
|
|
|
|
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);
|
2006-09-12 19:38:39 +00:00
|
|
|
|
int init_regex_list(struct regex_matcher* matcher);
|
2007-12-18 19:23:56 +00:00
|
|
|
|
int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,gzFile *gzs,unsigned int gzrsize);
|
2006-09-12 19:38:39 +00:00
|
|
|
|
void regex_list_cleanup(struct regex_matcher* matcher);
|
|
|
|
|
|
void regex_list_done(struct regex_matcher* matcher);
|
|
|
|
|
|
int is_regex_ok(struct regex_matcher* matcher);
|
2006-10-07 11:00:46 +00:00
|
|
|
|
|
2006-09-12 19:38:39 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|