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

acsmx2.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "acsmx2.h"

Go to the source code of this file.

Classes

struct  _queue

Defines

#define MEMASSERT(p, s)   if(!p){printf("ACSM-No Memory: %s!\n",s);exit(0);}

Typedefs

typedef acsm_summary_s acsm_summary_t
typedef _queue QUEUE

Functions

static void init_xlatcase ()
static void ConvertCaseEx (unsigned char *d, unsigned char *s, int m)
void acsmSetVerbose2 (int n)
static void queue_init (QUEUE *s)
static int queue_find (QUEUE *s, int state)
static void queue_add (QUEUE *s, int state)
static int queue_remove (QUEUE *s)
static int queue_count (QUEUE *s)
static void queue_free (QUEUE *s)
static int List_GetNextState (ACSM_STRUCT2 *acsm, int state, int input)
static int List_GetNextState2 (ACSM_STRUCT2 *acsm, int state, int input)
static int List_PutNextState (ACSM_STRUCT2 *acsm, int state, int input, int next_state)
static int List_FreeTransTable (ACSM_STRUCT2 *acsm)
static int List_PrintTransTable (ACSM_STRUCT2 *acsm)
static int List_ConvToFull (ACSM_STRUCT2 *acsm, acstate_t state, acstate_t *full)
static ACSM_PATTERN2CopyMatchListEntry (ACSM_PATTERN2 *px)
static void AddMatchListEntry (ACSM_STRUCT2 *acsm, int state, ACSM_PATTERN2 *px)
static void AddPatternStates (ACSM_STRUCT2 *acsm, ACSM_PATTERN2 *p)
static void Build_NFA (ACSM_STRUCT2 *acsm)
static void Convert_NFA_To_DFA (ACSM_STRUCT2 *acsm)
static int Conv_List_To_Full (ACSM_STRUCT2 *acsm)
static int Conv_Full_DFA_To_Sparse (ACSM_STRUCT2 *acsm)
static int Conv_Full_DFA_To_Banded (ACSM_STRUCT2 *acsm)
static int calcSparseBands (acstate_t *next, int *begin, int *end, int asize, int zmax)
static int Conv_Full_DFA_To_SparseBands (ACSM_STRUCT2 *acsm)
void Print_DFA_MatchList (ACSM_STRUCT2 *acsm, int state)
static void Print_DFA (ACSM_STRUCT2 *acsm)
int acsmSelectFormat2 (ACSM_STRUCT2 *acsm, int m)
void acsmSetMaxSparseBandZeros2 (ACSM_STRUCT2 *acsm, int n)
void acsmSetMaxSparseElements2 (ACSM_STRUCT2 *acsm, int n)
int acsmSelectFSA2 (ACSM_STRUCT2 *acsm, int m)
int acsmSetAlphabetSize2 (ACSM_STRUCT2 *acsm, int n)
ACSM_STRUCT2acsmNew2 ()
int acsmAddPattern2 (ACSM_STRUCT2 *p, unsigned char *pat, int n, int nocase, int offset, int depth, void *id, int iid)
int acsmAddKey2 (ACSM_STRUCT2 *p, unsigned char *key, int klen, int nocase, void *data)
static void acsmUpdateMatchStates (ACSM_STRUCT2 *acsm)
int acsmCompile2 (ACSM_STRUCT2 *acsm)
acstate_t SparseGetNextStateNFA (acstate_t *ps, acstate_t state, unsigned input)
acstate_t SparseGetNextStateDFA (acstate_t *ps, acstate_t state, unsigned input)
static int acsmSearchSparseDFA (ACSM_STRUCT2 *acsm, unsigned char *Tx, int n, int(*Match)(void *id, int index, void *data), void *data)
static int acsmSearchSparseDFA_Full (ACSM_STRUCT2 *acsm, unsigned char *Tx, int n, int(*Match)(void *id, int index, void *data), void *data)
static int acsmSearchSparseDFA_Banded (ACSM_STRUCT2 *acsm, unsigned char *Tx, int n, int(*Match)(void *id, int index, void *data), void *data)
static int acsmSearchSparseNFA (ACSM_STRUCT2 *acsm, unsigned char *Tx, int n, int(*Match)(void *id, int index, void *data), void *data)
int acsmSearch2 (ACSM_STRUCT2 *acsm, unsigned char *Tx, int n, int(*Match)(void *id, int index, void *data), void *data)
void acsmFree2 (ACSM_STRUCT2 *acsm)
void acsmPrintInfo2 (ACSM_STRUCT2 *p)
int acsmPrintDetailInfo2 (ACSM_STRUCT2 *p)
int acsmPrintSummaryInfo2 ()

Variables

static int max_memory = 0
static int s_verbose = 0
static acsm_summary_t summary = {0,0}
static unsigned char xlatcase [256]


Define Documentation

#define MEMASSERT p,
 )     if(!p){printf("ACSM-No Memory: %s!\n",s);exit(0);}
 

Definition at line 111 of file acsmx2.c.


Typedef Documentation

typedef struct acsm_summary_s acsm_summary_t
 

typedef struct _queue QUEUE
 


Function Documentation

int acsmAddKey2 ACSM_STRUCT2 p,
unsigned char *  key,
int  klen,
int  nocase,
void *  data
 

Definition at line 1475 of file acsmx2.c.

References ACSM_STRUCT2::acsmPatterns, _acsm_pattern2::casepatrn, _acsm_pattern2::depth, _acsm_pattern2::id, _acsm_pattern2::iid, MEMASSERT, memcpy, _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, _acsm_pattern2::offset, and _acsm_pattern2::patrn.

int acsmAddPattern2 ACSM_STRUCT2 p,
unsigned char *  pat,
int  n,
int  nocase,
int  offset,
int  depth,
void *  id,
int  iid
 

Definition at line 1442 of file acsmx2.c.

References ACSM_STRUCT2::acsmPatterns, _acsm_pattern2::casepatrn, ConvertCaseEx(), _acsm_pattern2::depth, _acsm_pattern2::id, _acsm_pattern2::iid, MEMASSERT, memcpy, _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, _acsm_pattern2::offset, and _acsm_pattern2::patrn.

Referenced by mpseAddPattern().

int acsmCompile2 ACSM_STRUCT2 acsm  ) 
 

Definition at line 1528 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, ACF_SPARSE, ACF_SPARSEBANDS, acsm_summary_s::acsm, ACSM_STRUCT2::acsmFailState, ACSM_STRUCT2::acsmFormat, ACSM_STRUCT2::acsmFSA, ACSM_STRUCT2::acsmMatchList, ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmNextState, ACSM_STRUCT2::acsmNumStates, ACSM_STRUCT2::acsmNumTrans, ACSM_STRUCT2::acsmPatterns, ACSM_STRUCT2::acsmTransTable, acsmUpdateMatchStates(), AddPatternStates(), Build_NFA(), Conv_Full_DFA_To_Banded(), Conv_Full_DFA_To_Sparse(), Conv_Full_DFA_To_SparseBands(), Conv_List_To_Full(), Convert_NFA_To_DFA(), FSA_DFA, FSA_NFA, List_FreeTransTable(), List_PrintTransTable(), max_memory, MEMASSERT, memcpy, memset, _acsm_pattern2::n, _acsm_pattern2::next, NULL, acsm_summary_s::num_states, acsm_summary_s::num_transitions, Print_DFA(), and s_verbose.

Referenced by mpsePrepPatterns().

void acsmFree2 ACSM_STRUCT2 acsm  ) 
 

Definition at line 2259 of file acsmx2.c.

References ACSM_STRUCT2::acsmFailState, ACSM_STRUCT2::acsmMatchList, ACSM_STRUCT2::acsmNextState, and _acsm_pattern2::next.

Referenced by mpseFree().

ACSM_STRUCT2* acsmNew2  ) 
 

Definition at line 1414 of file acsmx2.c.

References ACF_FULL, FSA_DFA, init_xlatcase(), MEMASSERT, and memset.

Referenced by mpseNew().

int acsmPrintDetailInfo2 ACSM_STRUCT2 p  ) 
 

Definition at line 2320 of file acsmx2.c.

Referenced by mpsePrintDetail().

void acsmPrintInfo2 ACSM_STRUCT2 p  ) 
 

Definition at line 2282 of file acsmx2.c.

References ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmFormat, ACSM_STRUCT2::acsmFSA, ACSM_STRUCT2::acsmNumStates, ACSM_STRUCT2::acsmNumTrans, ACSM_STRUCT2::acsmSparseMaxRowNodes, ACSM_STRUCT2::acsmSparseMaxZcnt, and max_memory.

int acsmPrintSummaryInfo2  ) 
 

Definition at line 2332 of file acsmx2.c.

References acsm_summary_s::acsm, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmFormat, ACSM_STRUCT2::acsmFSA, max_memory, acsm_summary_s::num_states, and acsm_summary_s::num_transitions.

Referenced by mpsePrintSummary().

int acsmSearch2 ACSM_STRUCT2 acsm,
unsigned char *  Tx,
int  n,
int(*)(void *id, int index, void *data)  Match,
void *  data
 

Definition at line 2221 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, acsmSearchSparseDFA(), acsmSearchSparseDFA_Banded(), acsmSearchSparseDFA_Full(), acsmSearchSparseNFA(), FSA_DFA, FSA_NFA, and FSA_TRIE.

Referenced by mpseSearch().

static int acsmSearchSparseDFA ACSM_STRUCT2 acsm,
unsigned char *  Tx,
int  n,
int(*)(void *id, int index, void *data)  Match,
void *  data
[inline, static]
 

Definition at line 1911 of file acsmx2.c.

References _acsm_pattern2::casepatrn, _acsm_pattern2::id, memcmp(), _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, NULL, SparseGetNextStateDFA(), Tc, and xlatcase.

Referenced by acsmSearch2().

static int acsmSearchSparseDFA_Banded ACSM_STRUCT2 acsm,
unsigned char *  Tx,
int  n,
int(*)(void *id, int index, void *data)  Match,
void *  data
[inline, static]
 

Definition at line 2068 of file acsmx2.c.

References _acsm_pattern2::casepatrn, _acsm_pattern2::id, memcmp(), _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, NULL, and xlatcase.

Referenced by acsmSearch2().

static int acsmSearchSparseDFA_Full ACSM_STRUCT2 acsm,
unsigned char *  Tx,
int  n,
int(*)(void *id, int index, void *data)  Match,
void *  data
[inline, static]
 

Definition at line 1973 of file acsmx2.c.

References _acsm_pattern2::casepatrn, _acsm_pattern2::id, memcmp(), _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, NULL, and xlatcase.

Referenced by acsmSearch2().

static int acsmSearchSparseNFA ACSM_STRUCT2 acsm,
unsigned char *  Tx,
int  n,
int(*)(void *id, int index, void *data)  Match,
void *  data
[inline, static]
 

Definition at line 2161 of file acsmx2.c.

References ACSM_FAIL_STATE2, _acsm_pattern2::casepatrn, _acsm_pattern2::id, memcmp(), _acsm_pattern2::n, _acsm_pattern2::next, _acsm_pattern2::nocase, NULL, SparseGetNextStateNFA(), Tc, and xlatcase.

Referenced by acsmSearch2().

int acsmSelectFormat2 ACSM_STRUCT2 acsm,
int  m
 

Definition at line 1351 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, ACF_SPARSE, ACF_SPARSEBANDS, and ACSM_STRUCT2::acsmFormat.

Referenced by mpseNew().

int acsmSelectFSA2 ACSM_STRUCT2 acsm,
int  m
 

Definition at line 1384 of file acsmx2.c.

References ACSM_STRUCT2::acsmFSA, FSA_DFA, FSA_NFA, and FSA_TRIE.

int acsmSetAlphabetSize2 ACSM_STRUCT2 acsm,
int  n
 

Definition at line 1399 of file acsmx2.c.

References ACSM_STRUCT2::acsmAlphabetSize, and MAX_ALPHABET_SIZE.

void acsmSetMaxSparseBandZeros2 ACSM_STRUCT2 acsm,
int  n
 

Definition at line 1370 of file acsmx2.c.

References ACSM_STRUCT2::acsmSparseMaxZcnt.

void acsmSetMaxSparseElements2 ACSM_STRUCT2 acsm,
int  n
 

Definition at line 1377 of file acsmx2.c.

References ACSM_STRUCT2::acsmSparseMaxRowNodes.

void acsmSetVerbose2 int  n  ) 
 

Definition at line 197 of file acsmx2.c.

References s_verbose.

static void acsmUpdateMatchStates ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 1505 of file acsmx2.c.

References ACSM_STRUCT2::acsmMatchList, ACSM_STRUCT2::acsmNextState, and ACSM_STRUCT2::acsmNumStates.

Referenced by acsmCompile2().

static void AddMatchListEntry ACSM_STRUCT2 acsm,
int  state,
ACSM_PATTERN2 px
[static]
 

Definition at line 600 of file acsmx2.c.

References ACSM_STRUCT2::acsmMatchList, MEMASSERT, memcpy, and _acsm_pattern2::next.

static void AddPatternStates ACSM_STRUCT2 acsm,
ACSM_PATTERN2 p
[static]
 

Definition at line 617 of file acsmx2.c.

References ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmNumStates, AddMatchListEntry(), List_GetNextState(), List_PutNextState(), _acsm_pattern2::n, _acsm_pattern2::nocase, _acsm_pattern2::patrn, and s_verbose.

static void Build_NFA ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 666 of file acsmx2.c.

References ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmFailState, ACSM_STRUCT2::acsmMatchList, ACSM_STRUCT2::acsmNumStates, CopyMatchListEntry(), List_GetNextState(), List_GetNextState2(), _acsm_pattern2::next, queue_add(), queue_count(), queue_free(), queue_init(), queue_remove(), and s_verbose.

static int calcSparseBands acstate_t next,
int *  begin,
int *  end,
int  asize,
int  zmax
[static]
 

Definition at line 991 of file acsmx2.c.

References ACSM_FAIL_STATE2.

Referenced by Conv_Full_DFA_To_SparseBands().

static int Conv_Full_DFA_To_Banded ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 925 of file acsmx2.c.

References ACF_BANDED, ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmNextState, List_ConvToFull(), and MAX_ALPHABET_SIZE.

Referenced by acsmCompile2().

static int Conv_Full_DFA_To_Sparse ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 858 of file acsmx2.c.

References ACF_FULL, ACF_SPARSE, ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmNextState, ACSM_STRUCT2::acsmSparseMaxRowNodes, List_ConvToFull(), MAX_ALPHABET_SIZE, and memcpy.

Referenced by acsmCompile2().

static int Conv_Full_DFA_To_SparseBands ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 1047 of file acsmx2.c.

References ACF_SPARSEBANDS, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmNextState, ACSM_STRUCT2::acsmSparseMaxZcnt, calcSparseBands(), List_ConvToFull(), and MAX_ALPHABET_SIZE.

Referenced by acsmCompile2().

static int Conv_List_To_Full ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 807 of file acsmx2.c.

References ACF_FULL, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmNextState, and List_ConvToFull().

Referenced by acsmCompile2().

static void Convert_NFA_To_DFA ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 749 of file acsmx2.c.

References ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmFailState, ACSM_STRUCT2::acsmNumStates, List_GetNextState(), List_PutNextState(), queue_add(), queue_count(), queue_free(), queue_init(), queue_remove(), and s_verbose.

static void ConvertCaseEx unsigned char *  d,
unsigned char *  s,
int  m
[inline, static]
 

Definition at line 162 of file acsmx2.c.

References xlatcase.

static ACSM_PATTERN2* CopyMatchListEntry ACSM_PATTERN2 px  )  [static]
 

Definition at line 558 of file acsmx2.c.

References MEMASSERT, memcpy, and _acsm_pattern2::next.

static void init_xlatcase  )  [static]
 

Definition at line 148 of file acsmx2.c.

References xlatcase.

static int List_ConvToFull ACSM_STRUCT2 acsm,
acstate_t  state,
acstate_t full
[static]
 

Definition at line 536 of file acsmx2.c.

References ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmTransTable, trans_node_s::key, memset, trans_node_s::next, and trans_node_s::next_state.

Referenced by Conv_Full_DFA_To_Banded(), Conv_Full_DFA_To_Sparse(), Conv_Full_DFA_To_SparseBands(), and Conv_List_To_Full().

static int List_FreeTransTable ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 434 of file acsmx2.c.

References ACSM_STRUCT2::acsmMaxStates, ACSM_STRUCT2::acsmTransTable, max_memory, and trans_node_s::next.

Referenced by acsmCompile2().

static int List_GetNextState ACSM_STRUCT2 acsm,
int  state,
int  input
[static]
 

Definition at line 354 of file acsmx2.c.

References ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmTransTable, trans_node_s::key, trans_node_s::next, and trans_node_s::next_state.

Referenced by AddPatternStates(), Build_NFA(), and Convert_NFA_To_DFA().

static int List_GetNextState2 ACSM_STRUCT2 acsm,
int  state,
int  input
[static]
 

Definition at line 376 of file acsmx2.c.

References ACSM_STRUCT2::acsmTransTable, trans_node_s::key, trans_node_s::next, and trans_node_s::next_state.

Referenced by Build_NFA().

static int List_PrintTransTable ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 491 of file acsmx2.c.

References ACSM_STRUCT2::acsmMatchList, ACSM_STRUCT2::acsmNumStates, ACSM_STRUCT2::acsmTransTable, trans_node_s::key, _acsm_pattern2::n, _acsm_pattern2::next, trans_node_s::next, trans_node_s::next_state, and _acsm_pattern2::patrn.

Referenced by acsmCompile2().

static int List_PutNextState ACSM_STRUCT2 acsm,
int  state,
int  input,
int  next_state
[static]
 

Definition at line 395 of file acsmx2.c.

References ACSM_STRUCT2::acsmNumTrans, ACSM_STRUCT2::acsmTransTable, trans_node_s::key, trans_node_s::next, and trans_node_s::next_state.

Referenced by AddPatternStates(), and Convert_NFA_To_DFA().

static void Print_DFA ACSM_STRUCT2 acsm  )  [static]
 

Definition at line 1118 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, ACF_SPARSE, ACF_SPARSEBANDS, ACSM_FAIL_STATE2, ACSM_STRUCT2::acsmAlphabetSize, ACSM_STRUCT2::acsmNextState, ACSM_STRUCT2::acsmNumStates, index, and Print_DFA_MatchList().

Referenced by acsmCompile2().

void Print_DFA_MatchList ACSM_STRUCT2 acsm,
int  state
 

Definition at line 1103 of file acsmx2.c.

References ACSM_STRUCT2::acsmMatchList, _acsm_pattern2::n, _acsm_pattern2::next, and _acsm_pattern2::patrn.

Referenced by Print_DFA().

static void queue_add QUEUE s,
int  state
[static]
 

Definition at line 277 of file acsmx2.c.

References _queue::count, _queue::head, MEMASSERT, queue_find(), and _queue::tail.

static int queue_count QUEUE s  )  [static]
 

Definition at line 332 of file acsmx2.c.

References _queue::count.

static int queue_find QUEUE s,
int  state
[static]
 

Definition at line 261 of file acsmx2.c.

References _queue::head.

Referenced by queue_add().

static void queue_free QUEUE s  )  [static]
 

Definition at line 342 of file acsmx2.c.

References queue_count(), and queue_remove().

static void queue_init QUEUE s  )  [static]
 

Definition at line 251 of file acsmx2.c.

References _queue::count, _queue::head, and _queue::tail.

static int queue_remove QUEUE s  )  [static]
 

Definition at line 306 of file acsmx2.c.

References _queue::count, _queue::head, and _queue::tail.

acstate_t SparseGetNextStateDFA acstate_t ps,
acstate_t  state,
unsigned  input
[inline]
 

Definition at line 1827 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, ACF_SPARSE, ACF_SPARSEBANDS, and index.

Referenced by acsmSearchSparseDFA().

acstate_t SparseGetNextStateNFA acstate_t ps,
acstate_t  state,
unsigned  input
[inline]
 

Definition at line 1691 of file acsmx2.c.

References ACF_BANDED, ACF_FULL, ACF_SPARSE, ACF_SPARSEBANDS, ACSM_FAIL_STATE2, and index.

Referenced by acsmSearchSparseNFA().


Variable Documentation

int max_memory = 0 [static]
 

Definition at line 116 of file acsmx2.c.

Referenced by acsmCompile2(), acsmPrintInfo2(), acsmPrintSummaryInfo(), acsmPrintSummaryInfo2(), and List_FreeTransTable().

int s_verbose = 0 [static]
 

Definition at line 121 of file acsmx2.c.

Referenced by acsmCompile2(), acsmSetVerbose2(), AddPatternStates(), Build_NFA(), and Convert_NFA_To_DFA().

acsm_summary_t summary = {0,0} [static]
 

Definition at line 137 of file acsmx2.c.

Referenced by acsmPrintSummaryInfo().

unsigned char xlatcase[256] [static]
 

Definition at line 142 of file acsmx2.c.


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