Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

pattern.c File Reference


Detailed Description

Pattern matching.

Author:
Raphael Manfredi
Date:
2001-2004

#include "common.h"
#include "misc.h"
#include "pattern.h"
#include "zalloc.h"
#include "override.h"

Functions

 RCSID ("$Id:pattern.c, v 1.7 2005/09/10 10:10:36 daichik Exp $")
void pattern_init (void)
 Initialize pattern data structures.

void pattern_close (void)
 Cleanup data structures.

cpattern_tpattern_compile (const gchar *pattern)
 Compile given string pattern by computing the delta shift table.

cpattern_tpattern_compile_fast (const gchar *pattern, size_t plen)
 Same as pattern_compile(), but the pattern string is NOT duplicated, and its length is known upon entry.

void pattern_free (cpattern_t *cpat)
 Dispose of compiled pattern.

const gchar * pattern_qsearch (cpattern_t *cpat, const gchar *text, size_t tlen, size_t toffset, qsearch_mode_t word)
 Quick substring search algorithm.


Variables

zone_tpat_zone = NULL
 Compiled patterns.


Function Documentation

void pattern_close void   ) 
 

Cleanup data structures.

cpattern_t* pattern_compile const gchar *  pattern  ) 
 

Compile given string pattern by computing the delta shift table.

The pattern string given is duplicated.

Returns:
a compiled pattern structure.

cpattern_t* pattern_compile_fast const gchar *  pattern,
size_t  plen
 

Same as pattern_compile(), but the pattern string is NOT duplicated, and its length is known upon entry.

Attention:
NB: There is no pattern_free_fast(), just call zfree() on the result.

void pattern_free cpattern_t cpat  ) 
 

Dispose of compiled pattern.

void pattern_init void   ) 
 

Initialize pattern data structures.

const gchar* pattern_qsearch cpattern_t cpat,
const gchar *  text,
size_t  tlen,
size_t  toffset,
qsearch_mode_t  word
 

Quick substring search algorithm.

It looks for the compiled pattern with `text', from left to right. The `tlen' argument is the length of the text, and can left to 0, in which case it will be computed.

Returns:
pointer to beginning of matching substring, NULL if not found.
Parameters:
cpat  Compiled pattern
text  Text we're scanning
tlen  Text length, 0 = compute strlen(text)
toffset  Offset within text for search start
word  Beginning/whole word matching?

RCSID "$Id:pattern.  c,
v 1.7 2005/09/10 10:10:36 daichik Exp $" 
 


Variable Documentation

zone_t* pat_zone = NULL [static]
 

Compiled patterns.


Generated on Sun Feb 12 10:50:05 2006 for Gtk-Gnutella by doxygen 1.3.6