Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

sfksearch.h

Go to the documentation of this file.
00001 /*
00002 *   ksearch.h
00003 *
00004 *   Trie based multi-pattern matcher
00005 *
00006 *
00007 *  Copyright (C) 2001 Marc Norton
00008 ** Copyright (C) 2003 Sourcefire, Inc
00009 **
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program; if not, write to the Free Software
00022 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef KTRIE_H
00026 #define KTRIE_H
00027 
00028 #define ALPHABET_SIZE 256
00029 
00030 #ifdef HAVE_CONFIG_H
00031 #include "config.h"
00032 #endif
00033 
00034 #ifdef WIN32
00035 #define inline __inline
00036 #endif
00037 
00038 /*
00039 *
00040 */
00041 typedef struct _ktriepattern {
00042 
00043   struct  _ktriepattern * next;  /* global list of all patterns */
00044   struct  _ktriepattern * mnext;  /* matching list of duplicate keywords */
00045   
00046   unsigned char * P;    /* no case */
00047   unsigned char * Pcase; /* case sensitive */
00048   int             n;
00049   int             nocase;
00050   void          * id;
00051 
00052 } KTRIEPATTERN;
00053 
00054 
00055 /*
00056 *
00057 */
00058 typedef struct _ktrienode {
00059 
00060   int     edge; /* character */
00061 
00062   struct  _ktrienode * sibling; 
00063   struct  _ktrienode * child; 
00064 
00065   KTRIEPATTERN *pkeyword; 
00066 
00067 } KTRIENODE;
00068 
00069 
00070 
00071 /*
00072 *
00073 */
00074 typedef struct {
00075 
00076   KTRIEPATTERN * patrn; /* List of patterns, built as they are added */
00077 
00078   
00079   KTRIENODE    * root[256];  /* KTrie nodes */
00080  
00081   int            memory;
00082   int            nchars;
00083   int            npats;
00084   int            duplicates;
00085 
00086   int            bcSize;
00087   unsigned short bcShift[256];  
00088  
00089 } KTRIE_STRUCT;
00090 
00091 
00092 
00093 KTRIE_STRUCT * KTrieNew();
00094 int            KTrieAddPattern( KTRIE_STRUCT *ts, unsigned char * P, int n, int nocase,void*  id );
00095 int            KTrieCompile(KTRIE_STRUCT * ts);
00096 int            KTrieSearch( KTRIE_STRUCT * ts, unsigned char * T, 
00097                int n, int (*match)(void* id, int index,void* data),void *data );
00098 
00099 #endif

Generated on Sun May 14 14:51:18 2006 by  doxygen 1.4.2