pcre.c File Reference

#include "pcre_internal.h"
#include "chartables.c"

Include dependency graph for pcre.c:

Go to the source code of this file.

Data Structures

struct  eptrblock

Defines

#define DPRINTF(p)
#define BRASTACK_SIZE   200
#define REC_STACK_SAVE_MAX   30
#define MAXLIT   250
#define REQ_BYTE_MAX   1000
#define match_condassert   0x01
#define match_isgroup   0x02
#define MATCH_MATCH   1
#define MATCH_NOMATCH   0
#define GETCHAR(c, eptr)   c = *eptr;
#define GETCHARINC(c, eptr)   c = *eptr++;
#define GETCHARINCTEST(c, eptr)   c = *eptr++;
#define GETCHARLEN(c, eptr, len)   c = *eptr;
#define BACKCHAR(eptr)
#define STRING(a)   # a
#define XSTRING(s)   STRING(s)

Functions

static BOOL compile_regex (int, int, int *, uschar **, const uschar **, const char **, BOOL, int, int *, int *, branch_chain *, compile_data *)
const char * pcre_version (void)
int pcre_info (const pcre *external_re, int *optptr, int *first_byte)
int pcre_fullinfo (const pcre *external_re, const pcre_extra *extra_data, int what, void *where)
int pcre_config (int what, void *where)
static int check_escape (const uschar **ptrptr, const char **errorptr, int bracount, int options, BOOL isclass, compile_data *cd)
static BOOL is_counted_repeat (const uschar *p, compile_data *cd)
static const uscharread_repeat_counts (const uschar *p, int *minp, int *maxp, const char **errorptr, compile_data *cd)
static const uscharfirst_significant_code (const uschar *code, int *options, int optbit)
static int find_fixedlength (uschar *code, int options)
static const uscharfind_bracket (const uschar *code, BOOL utf8, int number)
static BOOL could_be_empty_branch (const uschar *code, const uschar *endcode, BOOL utf8)
static BOOL could_be_empty (const uschar *code, const uschar *endcode, branch_chain *bcptr, BOOL utf8)
static BOOL check_posix_syntax (const uschar *ptr, const uschar **endptr, compile_data *cd)
static int check_posix_name (const uschar *ptr, int len)
static BOOL compile_branch (int *optionsptr, int *brackets, uschar **codeptr, const uschar **ptrptr, const char **errorptr, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd)
static BOOL is_anchored (register const uschar *code, int *options, unsigned int bracket_map, unsigned int backref_map)
static BOOL is_startline (const uschar *code, unsigned int bracket_map, unsigned int backref_map)
static int find_firstassertedchar (const uschar *code, int *options, BOOL inassert)
pcrepcre_compile (const char *pattern, int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
static BOOL match_ref (int offset, register const uschar *eptr, int length, match_data *md, unsigned long int ims)
static int match (register const uschar *eptr, register const uschar *ecode, int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, int flags)
int pcre_exec (const pcre *external_re, const pcre_extra *extra_data, const char *subject, int length, int start_offset, int match_length, int options, int *offsets, int offsetcount, const unsigned char *tables)

Variables

static uschar OP_lengths [] = { OP_LENGTHS }
static const char rep_min [] = { 0, 0, 1, 1, 0, 0 }
static const char rep_max [] = { 0, 0, 0, 0, 1, 1 }
static const short int escapes []
static const char * posix_names []
static const uschar posix_name_lengths []
static const int posix_class_maps []
void *(* pcre_malloc )(size_t) = malloc
void(* pcre_free )(void *) = free
int(* pcre_callout )(pcre_callout_block *) = NULL


Define Documentation

#define BACKCHAR eptr   ) 
 

Definition at line 218 of file pcre.c.

#define BRASTACK_SIZE   200
 

Definition at line 73 of file pcre.c.

Referenced by pcre_compile().

#define DPRINTF  ) 
 

Definition at line 51 of file pcre.c.

Referenced by match(), pcre_compile(), and pcre_exec().

#define GETCHAR c,
eptr   )     c = *eptr;
 

Definition at line 214 of file pcre.c.

#define GETCHARINC c,
eptr   )     c = *eptr++;
 

Definition at line 215 of file pcre.c.

#define GETCHARINCTEST c,
eptr   )     c = *eptr++;
 

Definition at line 216 of file pcre.c.

#define GETCHARLEN c,
eptr,
len   )     c = *eptr;
 

Definition at line 217 of file pcre.c.

Referenced by pcre_compile().

#define match_condassert   0x01
 

Definition at line 177 of file pcre.c.

#define match_isgroup   0x02
 

Definition at line 178 of file pcre.c.

Referenced by match(), and pcre_exec().

#define MATCH_MATCH   1
 

Definition at line 183 of file pcre.c.

Referenced by pcre_exec().

#define MATCH_NOMATCH   0
 

Definition at line 184 of file pcre.c.

Referenced by match(), and pcre_exec().

#define MAXLIT   250
 

Definition at line 88 of file pcre.c.

#define REC_STACK_SAVE_MAX   30
 

Definition at line 80 of file pcre.c.

#define REQ_BYTE_MAX   1000
 

Definition at line 94 of file pcre.c.

Referenced by pcre_exec().

#define STRING  )     # a
 

Definition at line 392 of file pcre.c.

#define XSTRING  )     STRING(s)
 

Definition at line 393 of file pcre.c.

Referenced by pcre_version().


Function Documentation

static int check_escape const uschar **  ptrptr,
const char **  errorptr,
int  bracount,
int  options,
BOOL  isclass,
compile_data cd
[static]
 

Definition at line 634 of file pcre.c.

References ctype_digit, ctype_xdigit, compile_data::ctypes, ERR1, ERR2, ERR3, ERR34, ERR37, ESC_REF, escapes, compile_data::fcc, compile_data::lcc, PCRE_EXTRA, PCRE_UTF8, and pt.

Referenced by pcre_compile().

static int check_posix_name const uschar ptr,
int  len
[static]
 

Definition at line 1420 of file pcre.c.

References posix_name_lengths, and posix_names.

static BOOL check_posix_syntax const uschar ptr,
const uschar **  endptr,
compile_data cd
[static]
 

Definition at line 1388 of file pcre.c.

References ctype_letter, compile_data::ctypes, FALSE, and TRUE.

Referenced by pcre_compile().

static BOOL compile_branch int *  optionsptr,
int *  brackets,
uschar **  codeptr,
const uschar **  ptrptr,
const char **  errorptr,
int *  firstbyteptr,
int *  reqbyteptr,
branch_chain bcptr,
compile_data cd
[static]
 

Definition at line 1459 of file pcre.c.

References ctype_space, compile_data::ctypes, FALSE, length, NEWLINE, NULL, PCRE_CASELESS, PCRE_EXTENDED, PCRE_UNGREEDY, PCRE_UTF8, REQ_CASELESS, REQ_UNSET, and skipbytes().

Here is the call graph for this function:

static BOOL compile_regex int  ,
int  ,
int *  ,
uschar **  ,
const uschar **  ,
const char **  ,
BOOL  ,
int  ,
int *  ,
int *  ,
branch_chain ,
compile_data
[static]
 

Definition at line 3295 of file pcre.c.

References branch_chain::current, NULL, OP_OPT, branch_chain::outer, PUT, and REQ_UNSET.

static BOOL could_be_empty const uschar code,
const uschar endcode,
branch_chain bcptr,
BOOL  utf8
[static]
 

Definition at line 1357 of file pcre.c.

References could_be_empty_branch(), branch_chain::current, FALSE, NULL, branch_chain::outer, and TRUE.

Here is the call graph for this function:

static BOOL could_be_empty_branch const uschar code,
const uschar endcode,
BOOL  utf8
[static]
 

Definition at line 1217 of file pcre.c.

References FALSE, first_significant_code(), GET, GET2, LINK_SIZE, NULL, OP_ALT, OP_ANY, OP_ANYBYTE, OP_BRA, OP_CHARS, OP_CLASS, OP_CRMINPLUS, OP_CRMINQUERY, OP_CRMINRANGE, OP_CRMINSTAR, OP_CRPLUS, OP_CRQUERY, OP_CRRANGE, OP_CRSTAR, OP_DIGIT, OP_EXACT, OP_KET, OP_KETRMAX, OP_KETRMIN, OP_lengths, OP_MINPLUS, OP_MINQUERY, OP_MINSTAR, OP_MINUPTO, OP_NCLASS, OP_NOT, OP_NOT_DIGIT, OP_NOT_WHITESPACE, OP_NOT_WORDCHAR, OP_NOTEXACT, OP_NOTMINPLUS, OP_NOTPLUS, OP_PLUS, OP_QUERY, OP_STAR, OP_TYPEEXACT, OP_TYPEMINPLUS, OP_TYPEPLUS, OP_UPTO, OP_WHITESPACE, OP_WORDCHAR, OP_XCLASS, and TRUE.

Referenced by could_be_empty().

Here is the call graph for this function:

static const uschar* find_bracket const uschar code,
BOOL  utf8,
int  number
[static]
 

Definition at line 1149 of file pcre.c.

References EXTRACT_BASIC_MAX, GET2, LINK_SIZE, NULL, OP_BRA, OP_CHARS, OP_END, and OP_lengths.

static int find_firstassertedchar const uschar code,
int *  options,
BOOL  inassert
[static]
 

Definition at line 3639 of file pcre.c.

References first_significant_code(), GET, OP_ALT, OP_ASSERT, OP_BRA, OP_CHARS, OP_COND, OP_EXACT, OP_MINPLUS, OP_ONCE, OP_PLUS, and REQ_CASELESS.

Here is the call graph for this function:

static int find_fixedlength uschar code,
int  options
[static]
 

Definition at line 966 of file pcre.c.

References GET, GET2, LINK_SIZE, OP_ALT, OP_ANY, OP_ANYBYTE, OP_ASSERT, OP_ASSERT_NOT, OP_ASSERTBACK, OP_ASSERTBACK_NOT, OP_BRA, OP_BRANUMBER, OP_CALLOUT, OP_CHARS, OP_CIRC, OP_CLASS, OP_COND, OP_CREF, OP_CRMINQUERY, OP_CRMINRANGE, OP_CRMINSTAR, OP_CRQUERY, OP_CRRANGE, OP_CRSTAR, OP_DIGIT, OP_DOLL, OP_END, OP_EOD, OP_EODN, OP_EXACT, OP_KET, OP_KETRMAX, OP_KETRMIN, OP_lengths, OP_NCLASS, OP_NOT_DIGIT, OP_NOT_WHITESPACE, OP_NOT_WORD_BOUNDARY, OP_NOT_WORDCHAR, OP_ONCE, OP_OPT, OP_REVERSE, OP_SOD, OP_SOM, OP_TYPEEXACT, OP_WHITESPACE, OP_WORD_BOUNDARY, OP_WORDCHAR, OP_XCLASS, and PCRE_UTF8.

static const uschar* first_significant_code const uschar code,
int *  options,
int  optbit
[static]
 

Definition at line 913 of file pcre.c.

References GET, OP_ALT, OP_ASSERT_NOT, OP_ASSERTBACK, OP_ASSERTBACK_NOT, OP_BRANUMBER, OP_CALLOUT, OP_CREF, OP_lengths, OP_NOT_WORD_BOUNDARY, OP_OPT, and OP_WORD_BOUNDARY.

Referenced by could_be_empty_branch(), find_firstassertedchar(), is_anchored(), and is_startline().

static BOOL is_anchored register const uschar code,
int *  options,
unsigned int  bracket_map,
unsigned int  backref_map
[static]
 

Definition at line 3506 of file pcre.c.

References EXTRACT_BASIC_MAX, FALSE, first_significant_code(), GET, GET2, OP_ALT, OP_ANY, OP_ASSERT, OP_BRA, OP_CIRC, OP_COND, OP_ONCE, OP_SOD, OP_SOM, OP_TYPEMINSTAR, OP_TYPESTAR, PCRE_DOTALL, and TRUE.

Here is the call graph for this function:

static BOOL is_counted_repeat const uschar p,
compile_data cd
[static]
 

Definition at line 821 of file pcre.c.

References ctype_digit, compile_data::ctypes, FALSE, and TRUE.

Referenced by pcre_compile().

static BOOL is_startline const uschar code,
unsigned int  bracket_map,
unsigned int  backref_map
[static]
 

Definition at line 3576 of file pcre.c.

References EXTRACT_BASIC_MAX, FALSE, first_significant_code(), GET, GET2, NULL, OP_ALT, OP_ANY, OP_ASSERT, OP_BRA, OP_CIRC, OP_COND, OP_ONCE, OP_TYPEMINSTAR, OP_TYPESTAR, and TRUE.

Here is the call graph for this function:

static int match register const uschar eptr,
register const uschar ecode,
int  offset_top,
match_data md,
unsigned long int  ims,
eptrblock eptrb,
int  flags
[static]
 

Definition at line 4944 of file pcre.c.

References match_data::capture_last, DPRINTF, EXTRACT_BASIC_MAX, FALSE, GET, GET2, match_data::match_call_count, match_isgroup, match_data::match_limit, MATCH_NOMATCH, max, min, offset, match_data::offset_end, match_data::offset_vector, OP_ALT, OP_BRA, PCRE_ERROR_MATCHLIMIT, eptrblock::prev, eptrblock::saved_eptr, match_data::start_subject, and TRUE.

Referenced by pcre_exec().

static BOOL match_ref int  offset,
register const uschar eptr,
int  length,
match_data md,
unsigned long int  ims
[static]
 

Definition at line 4815 of file pcre.c.

References match_data::end_subject, FALSE, match_data::lcc, match_data::offset_vector, match_data::start_subject, and TRUE.

pcre* pcre_compile const char *  pattern,
int  options,
const char **  errorptr,
int *  erroroffset,
const unsigned char *  tables
 

Definition at line 3710 of file pcre.c.

References compile_data::backref_map, BRASTACK_SIZE, compile_data::cbits, cbits_offset, check_escape(), check_posix_syntax(), ctype_word, compile_data::ctypes, ctypes_offset, DPRINTF, ERR12, ERR16, ERR17, ERR18, ERR24, ERR26, ERR28, ERR29, ERR32, ERR39, ERR41, ERR42, ERR6, ESC_b, ESC_Q, ESC_REF, extra, FALSE, compile_data::fcc, fcc_offset, GETCHARLEN, is_counted_repeat(), compile_data::lcc, lcc_offset, max, min, NEWLINE, NULL, pcre_default_tables, PCRE_DOTALL, PCRE_EXTRA, PCRE_ICHANGED, PCRE_UNGREEDY, PCRE_UTF8, PUBLIC_OPTIONS, read_repeat_counts(), compile_data::top_backref, and TRUE.

Here is the call graph for this function:

int pcre_config int  what,
void *  where
 

Definition at line 544 of file pcre.c.

References LINK_SIZE, MATCH_LIMIT, NEWLINE, PCRE_CONFIG_LINK_SIZE, PCRE_CONFIG_MATCH_LIMIT, PCRE_CONFIG_NEWLINE, PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, PCRE_CONFIG_UTF8, PCRE_ERROR_BADOPTION, and POSIX_MALLOC_THRESHOLD.

int pcre_exec const pcre external_re,
const pcre_extra extra_data,
const char *  subject,
int  length,
int  start_offset,
int  match_length,
int  options,
int *  offsets,
int  offsetcount,
const unsigned char *  tables
 

Definition at line 7226 of file pcre.c.

References match_data::callout_data, pcre_extra::callout_data, match_data::capture_last, match_data::ctypes, ctypes_offset, DPRINTF, match_data::end_match_ptr, match_data::end_offset_top, match_data::end_subject, match_data::endonly, FALSE, fcc_offset, first_byte, real_pcre::first_byte, pcre_extra::flags, match_data::lcc, lcc_offset, real_pcre::magic_number, MAGIC_NUMBER, match(), match_data::match_call_count, match_isgroup, match_data::match_limit, MATCH_LIMIT, pcre_extra::match_limit, MATCH_MATCH, MATCH_NOMATCH, real_pcre::name_count, real_pcre::name_entry_size, NEWLINE, match_data::notbol, match_data::notempty, match_data::noteol, NULL, match_data::offset_end, match_data::offset_max, match_data::offset_overflow, match_data::offset_vector, real_pcre::options, pcre_study_data::options, PCRE_DOLLAR_ENDONLY, PCRE_ERROR_BADMAGIC, PCRE_ERROR_BADOPTION, PCRE_ERROR_NOMATCH, PCRE_ERROR_NOMEMORY, PCRE_ERROR_NULL, PCRE_EXTRA_CALLOUT_DATA, PCRE_EXTRA_MATCH_LIMIT, PCRE_EXTRA_STUDY_DATA, PCRE_FIRSTSET, pcre_malloc, PCRE_NOTBOL, PCRE_NOTEMPTY, PCRE_NOTEOL, PCRE_REQCHSET, PCRE_STARTLINE, PCRE_STUDY_MAPPED, PCRE_UTF8, PUBLIC_EXEC_OPTIONS, rc, match_data::recursive, real_pcre::req_byte, REQ_BYTE_MAX, REQ_CASELESS, pcre_study_data::start_bits, match_data::start_code, match_data::start_match, match_data::start_offset, match_data::start_subject, pcre_extra::study_data, real_pcre::top_backref, real_pcre::top_bracket, TRUE, and match_data::utf8.

Here is the call graph for this function:

int pcre_fullinfo const pcre external_re,
const pcre_extra extra_data,
int  what,
void *  where
 

Definition at line 458 of file pcre.c.

References real_pcre::first_byte, pcre_extra::flags, real_pcre::magic_number, MAGIC_NUMBER, real_pcre::name_count, real_pcre::name_entry_size, NULL, real_pcre::options, pcre_study_data::options, PCRE_ERROR_BADMAGIC, PCRE_ERROR_BADOPTION, PCRE_ERROR_NULL, PCRE_EXTRA_STUDY_DATA, PCRE_FIRSTSET, PCRE_INFO_BACKREFMAX, PCRE_INFO_CAPTURECOUNT, PCRE_INFO_FIRSTBYTE, PCRE_INFO_FIRSTTABLE, PCRE_INFO_LASTLITERAL, PCRE_INFO_NAMECOUNT, PCRE_INFO_NAMEENTRYSIZE, PCRE_INFO_NAMETABLE, PCRE_INFO_OPTIONS, PCRE_INFO_SIZE, PCRE_INFO_STUDYSIZE, PCRE_REQCHSET, PCRE_STARTLINE, PCRE_STUDY_MAPPED, PUBLIC_OPTIONS, real_pcre::req_byte, real_pcre::size, pcre_study_data::size, pcre_study_data::start_bits, pcre_extra::study_data, real_pcre::top_backref, and real_pcre::top_bracket.

Referenced by pcre_get_stringnumber().

int pcre_info const pcre external_re,
int *  optptr,
int *  first_byte
 

Definition at line 427 of file pcre.c.

References real_pcre::first_byte, real_pcre::magic_number, MAGIC_NUMBER, NULL, real_pcre::options, PCRE_ERROR_BADMAGIC, PCRE_ERROR_NULL, PCRE_FIRSTSET, PCRE_STARTLINE, PUBLIC_OPTIONS, and real_pcre::top_bracket.

const char* pcre_version void   ) 
 

Definition at line 396 of file pcre.c.

References PCRE_DATE, PCRE_MAJOR, PCRE_MINOR, and XSTRING.

static const uschar* read_repeat_counts const uschar p,
int *  minp,
int *  maxp,
const char **  errorptr,
compile_data cd
[static]
 

Definition at line 858 of file pcre.c.

References ctype_digit, compile_data::ctypes, ERR4, ERR5, max, and min.

Referenced by pcre_compile().


Variable Documentation

const short int escapes[] [static]
 

Initial value:

 {
    0,      0,      0,      0,      0,      0,      0,      0,   
    0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   
  '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E,      0, -ESC_G,   
    0,      0,      0,      0,      0,      0,      0,      0,   
    0, -ESC_Q,      0, -ESC_S,      0,      0,      0, -ESC_W,   
    0,      0, -ESC_Z,    '[',   '\\',    ']',    '^',    '_',   
  '`',      7, -ESC_b,      0, -ESC_d,  ESC_e,  ESC_f,      0,   
    0,      0,      0,      0,      0,      0,  ESC_n,      0,   
    0,      0,  ESC_r, -ESC_s,  ESC_t,      0,      0, -ESC_w,   
    0,      0, -ESC_z                                            
}

Definition at line 112 of file pcre.c.

Referenced by check_escape().

uschar OP_lengths[] = { OP_LENGTHS } [static]
 

Definition at line 100 of file pcre.c.

Referenced by could_be_empty_branch(), find_bracket(), find_fixedlength(), and first_significant_code().

int(* pcre_callout)(pcre_callout_block *) = NULL
 

Definition at line 201 of file pcre.c.

void(* pcre_free)(void *) = free
 

Definition at line 200 of file pcre.c.

Referenced by pcre_free_substring(), and pcre_free_substring_list().

void*(* pcre_malloc)(size_t) = malloc
 

Definition at line 199 of file pcre.c.

Referenced by pcre_exec(), pcre_get_substring(), pcre_get_substring_list(), pcre_maketables(), and pcre_study().

const int posix_class_maps[] [static]
 

Initial value:

 {
  cbit_lower, cbit_upper, -1,             
  cbit_lower, -1,         -1,             
  cbit_upper, -1,         -1,             
  cbit_digit, cbit_lower, cbit_upper,     
  cbit_print, cbit_cntrl, -1,             
  cbit_space, -1,         -1,             
  cbit_cntrl, -1,         -1,             
  cbit_digit, -1,         -1,             
  cbit_graph, -1,         -1,             
  cbit_print, -1,         -1,             
  cbit_punct, -1,         -1,             
  cbit_space, -1,         -1,             
  cbit_word,  -1,         -1,             
  cbit_xdigit,-1,         -1              
}

Definition at line 141 of file pcre.c.

const uschar posix_name_lengths[] [static]
 

Initial value:

 {
  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 }

Definition at line 134 of file pcre.c.

Referenced by check_posix_name().

const char* posix_names[] [static]
 

Initial value:

 {
  "alpha", "lower", "upper",
  "alnum", "ascii", "blank", "cntrl", "digit", "graph",
  "print", "punct", "space", "word",  "xdigit" }

Definition at line 129 of file pcre.c.

Referenced by check_posix_name().

const char rep_max[] = { 0, 0, 0, 0, 1, 1 } [static]
 

Definition at line 105 of file pcre.c.

const char rep_min[] = { 0, 0, 1, 1, 0, 0 } [static]
 

Definition at line 104 of file pcre.c.


Generated on Fri Jun 9 22:24:16 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6