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

acsmx.h

Go to the documentation of this file.
00001 /* $Id$ */
00002 /*
00003 ** Copyright (C) 2002 Martin Roesch <roesch@sourcefire.com>
00004 **
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 **
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 **
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 
00021 /*
00022 **   ACSMX.H 
00023 **
00024 **
00025 */
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 
00031 #ifndef ACSMX_H
00032 #define ACSMX_H
00033 
00034 
00035 #ifdef HAVE_CONFIG_H
00036 #include "config.h"
00037 #endif
00038 
00039 /*
00040 *   Prototypes
00041 */
00042 
00043 
00044 #define ALPHABET_SIZE    256     
00045 
00046 #define ACSM_FAIL_STATE   -1     
00047 
00048 
00049 typedef struct _acsm_pattern {      
00050 
00051     struct  _acsm_pattern *next;
00052     unsigned char         *patrn;
00053     unsigned char         *casepatrn;
00054     int      n;
00055     int      nocase;
00056     int      offset;
00057     int      depth;
00058     void   * id;
00059     int      iid;
00060 
00061 } ACSM_PATTERN;
00062 
00063 
00064 typedef struct  {    
00065 
00066     /* Next state - based on input character */
00067     int      NextState[ ALPHABET_SIZE ];  
00068 
00069     /* Failure state - used while building NFA & DFA  */
00070     int      FailState;   
00071 
00072     /* List of patterns that end here, if any */
00073     ACSM_PATTERN *MatchList;   
00074 
00075 }ACSM_STATETABLE; 
00076 
00077 
00078 /*
00079 * State machine Struct
00080 */
00081 typedef struct {
00082   
00083         int acsmMaxStates;  
00084         int acsmNumStates;  
00085 
00086         ACSM_PATTERN    * acsmPatterns;
00087         ACSM_STATETABLE * acsmStateTable;
00088 
00089         int   bcSize;
00090         short bcShift[256];
00091 
00092 }ACSM_STRUCT;
00093 
00094 /*
00095 *   Prototypes
00096 */
00097 ACSM_STRUCT * acsmNew ();
00098 
00099 int acsmAddPattern( ACSM_STRUCT * p, unsigned char * pat, int n,
00100           int nocase, int offset, int depth, void *  id, int iid );
00101 
00102 int acsmCompile ( ACSM_STRUCT * acsm );
00103 
00104 int acsmSearch ( ACSM_STRUCT * acsm,unsigned char * T, int n, 
00105                   int (*Match)( void * id, int index, void * data ),
00106                   void * data );
00107 
00108 void acsmFree ( ACSM_STRUCT * acsm );
00109 
00110 int acsmPrintDetailInfo(ACSM_STRUCT *);
00111 
00112 int acsmPrintSummaryInfo();
00113 
00114 #endif

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