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

pattern.h File Reference


Detailed Description

Sunday pattern search data structures.

Author:
Raphael Manfredi
Date:
2001-2003

Go to the source code of this file.

Data Structures

struct  cpattern_t

Defines

#define ALPHA_SIZE   256 /**< Alphabet size */
 Alphabet size.


Enumerations

enum  qsearch_mode_t { qs_any = 0, qs_begin, qs_whole }

Functions

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.


Define Documentation

#define ALPHA_SIZE   256 /**< Alphabet size */
 

Alphabet size.


Enumeration Type Documentation

enum qsearch_mode_t
 

Enumeration values:
qs_any  Match anywhere.
qs_begin  Match beginning of words.
qs_whole  Match whole words only.


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?


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