libclamav/matcher-ac.h
8000d078
 /*
bedc58de
  *  Copyright (C) 2002 - 2007 Tomasz Kojm <tkojm@clamav.net>
8000d078
  *
  *  This program is free software; you can redistribute it and/or modify
bb34cb31
  *  it under the terms of the GNU General Public License version 2 as
  *  published by the Free Software Foundation.
8000d078
  *
  *  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
48b7b4a7
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  *  MA 02110-1301, USA.
8000d078
  */
 
 #ifndef __MATCHER_AC_H
 #define __MATCHER_AC_H
 
ee99255a
 #include <sys/types.h>
 
a85bd2ac
 #include "filetypes.h"
227f8f7c
 #include "cltypes.h"
8000d078
 
fbcef1b0
 #define AC_DEFAULT_MIN_DEPTH 2
 #define AC_DEFAULT_MAX_DEPTH 3
4e9ab8ed
 #define AC_DEFAULT_TRACKLEN 8
3d53538b
 extern uint8_t cli_ac_mindepth, cli_ac_maxdepth;
4e9ab8ed
 
 struct cli_ac_data {
bedc58de
     uint32_t partsigs;
fbcef1b0
     int32_t ***offmatrix;
bedc58de
 };
 
1a648b37
 struct cli_ac_alt {
     uint8_t chmode;
20c2455d
     unsigned char *str;
1a648b37
     uint16_t len, num;
     struct cli_ac_alt *next;
 };
 
bedc58de
 struct cli_ac_patt {
     uint16_t *pattern, *prefix, length, prefix_length;
fbcef1b0
     uint8_t depth;
bedc58de
     uint32_t mindist, maxdist;
     char *virname, *offset;
     uint32_t sigid;
1a648b37
     uint16_t parts, partno, alt, alt_pattern;
     struct cli_ac_alt **alttable;
bedc58de
     uint8_t target;
     uint16_t type;
e38ab7c1
     struct cli_ac_patt *next, *next_same;
4e9ab8ed
 };
c6fb0b98
 
bedc58de
 struct cli_ac_node {
fbcef1b0
     uint8_t leaf, final;
bedc58de
     struct cli_ac_patt *list;
fbcef1b0
     struct cli_ac_node **trans, *fail;
bedc58de
 };
 
 #include "matcher.h"
 
5612732c
 int cli_ac_addpatt(struct cli_matcher *root, struct cli_ac_patt *pattern);
bedc58de
 int cli_ac_initdata(struct cli_ac_data *data, uint32_t partsigs, uint8_t tracklen);
4e9ab8ed
 void cli_ac_freedata(struct cli_ac_data *data);
bedc58de
 int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **virname, const struct cli_matcher *root, struct cli_ac_data *mdata, uint8_t otfrec, uint32_t offset, cli_file_t ftype, int fd, struct cli_matched_type **ftoffset);
5612732c
 int cli_ac_buildtrie(struct cli_matcher *root);
fbcef1b0
 int cli_ac_init(struct cli_matcher *root, uint8_t mindepth, uint8_t maxdepth);
5612732c
 void cli_ac_free(struct cli_matcher *root);
fbcef1b0
 int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hexsig, uint32_t sigid, uint16_t parts, uint16_t partno, uint16_t type, uint32_t mindist, uint32_t maxdist, const char *offset, uint8_t target);
 
8000d078
 
 #endif