158 |
#define PCRE_CALL_CONVENTION |
#define PCRE_CALL_CONVENTION |
159 |
#endif |
#endif |
160 |
|
|
161 |
/* We need to have types that specify unsigned 16-bit and 32-bit integers. We |
/* We need to have types that specify unsigned 8, 16 and 32-bit integers. We |
162 |
cannot determine these outside the compilation (e.g. by running a program as |
cannot determine these outside the compilation (e.g. by running a program as |
163 |
part of "configure") because PCRE is often cross-compiled for use on other |
part of "configure") because PCRE is often cross-compiled for use on other |
164 |
systems. Instead we make use of the maximum sizes that are available at |
systems. Instead we make use of the maximum sizes that are available at |
165 |
preprocessor time in standard C environments. */ |
preprocessor time in standard C environments. */ |
166 |
|
|
167 |
|
typedef unsigned char pcre_uint8; |
168 |
|
|
169 |
#if USHRT_MAX == 65535 |
#if USHRT_MAX == 65535 |
170 |
typedef unsigned short pcre_uint16; |
typedef unsigned short pcre_uint16; |
171 |
typedef short pcre_int16; |
typedef short pcre_int16; |
209 |
/* All character handling must be done as unsigned characters. Otherwise there |
/* All character handling must be done as unsigned characters. Otherwise there |
210 |
are problems with top-bit-set characters and functions such as isspace(). |
are problems with top-bit-set characters and functions such as isspace(). |
211 |
However, we leave the interface to the outside world as char *, because that |
However, we leave the interface to the outside world as char *, because that |
212 |
should make things easier for callers. We define a short type for unsigned char |
should make things easier for callers. */ |
|
to save lots of typing. I tried "uchar", but it causes problems on Digital |
|
|
Unix, where it is defined in sys/types, so use "uschar" instead. */ |
|
213 |
|
|
214 |
typedef unsigned char uschar; |
typedef unsigned char pcre_uchar; |
215 |
|
|
216 |
/* This is an unsigned int value that no character can ever have. UTF-8 |
/* This is an unsigned int value that no character can ever have. UTF-8 |
217 |
characters only go up to 0x7fffffff (though Unicode doesn't go beyond |
characters only go up to 0x7fffffff (though Unicode doesn't go beyond |
267 |
must begin with PCRE_. */ |
must begin with PCRE_. */ |
268 |
|
|
269 |
#ifdef CUSTOM_SUBJECT_PTR |
#ifdef CUSTOM_SUBJECT_PTR |
270 |
#define PCRE_SPTR CUSTOM_SUBJECT_PTR |
#define PCRE_PUCHAR CUSTOM_SUBJECT_PTR |
|
#define USPTR CUSTOM_SUBJECT_PTR |
|
271 |
#else |
#else |
272 |
#define PCRE_SPTR const char * |
#define PCRE_PUCHAR const pcre_uchar * |
|
#define USPTR const unsigned char * |
|
273 |
#endif |
#endif |
274 |
|
|
275 |
|
|
1697 |
pcre_uint16 name_count; /* Number of name items */ |
pcre_uint16 name_count; /* Number of name items */ |
1698 |
pcre_uint16 ref_count; /* Reference count */ |
pcre_uint16 ref_count; /* Reference count */ |
1699 |
|
|
1700 |
const unsigned char *tables; /* Pointer to tables or NULL for std */ |
const pcre_uint8 *tables; /* Pointer to tables or NULL for std */ |
1701 |
const unsigned char *nullpad; /* NULL padding */ |
const pcre_uint8 *nullpad; /* NULL padding */ |
1702 |
} real_pcre; |
} real_pcre; |
1703 |
|
|
1704 |
/* The format of the block used to store data from pcre_study(). The same |
/* The format of the block used to store data from pcre_study(). The same |
1707 |
typedef struct pcre_study_data { |
typedef struct pcre_study_data { |
1708 |
pcre_uint32 size; /* Total that was malloced */ |
pcre_uint32 size; /* Total that was malloced */ |
1709 |
pcre_uint32 flags; /* Private flags */ |
pcre_uint32 flags; /* Private flags */ |
1710 |
uschar start_bits[32]; /* Starting char bits */ |
pcre_uint8 start_bits[32]; /* Starting char bits */ |
1711 |
pcre_uint32 minlength; /* Minimum subject length */ |
pcre_uint32 minlength; /* Minimum subject length */ |
1712 |
} pcre_study_data; |
} pcre_study_data; |
1713 |
|
|
1726 |
doing the compiling, so that they are thread-safe. */ |
doing the compiling, so that they are thread-safe. */ |
1727 |
|
|
1728 |
typedef struct compile_data { |
typedef struct compile_data { |
1729 |
const uschar *lcc; /* Points to lower casing table */ |
const pcre_uint8 *lcc; /* Points to lower casing table */ |
1730 |
const uschar *fcc; /* Points to case-flipping table */ |
const pcre_uint8 *fcc; /* Points to case-flipping table */ |
1731 |
const uschar *cbits; /* Points to character type table */ |
const pcre_uint8 *cbits; /* Points to character type table */ |
1732 |
const uschar *ctypes; /* Points to table of type maps */ |
const pcre_uint8 *ctypes; /* Points to table of type maps */ |
1733 |
const uschar *start_workspace;/* The start of working space */ |
const pcre_uchar *start_workspace;/* The start of working space */ |
1734 |
const uschar *start_code; /* The start of the compiled code */ |
const pcre_uchar *start_code; /* The start of the compiled code */ |
1735 |
const uschar *start_pattern; /* The start of the pattern */ |
const pcre_uchar *start_pattern; /* The start of the pattern */ |
1736 |
const uschar *end_pattern; /* The end of the pattern */ |
const pcre_uchar *end_pattern; /* The end of the pattern */ |
1737 |
open_capitem *open_caps; /* Chain of open capture items */ |
open_capitem *open_caps; /* Chain of open capture items */ |
1738 |
uschar *hwm; /* High watermark of workspace */ |
pcre_uchar *hwm; /* High watermark of workspace */ |
1739 |
uschar *name_table; /* The name/number table */ |
pcre_uchar *name_table; /* The name/number table */ |
1740 |
int names_found; /* Number of entries so far */ |
int names_found; /* Number of entries so far */ |
1741 |
int name_entry_size; /* Size of each entry */ |
int name_entry_size; /* Size of each entry */ |
1742 |
int bracount; /* Count of capturing parens as we compile */ |
int bracount; /* Count of capturing parens as we compile */ |
1743 |
int final_bracount; /* Saved value after first pass */ |
int final_bracount; /* Saved value after first pass */ |
1744 |
int top_backref; /* Maximum back reference */ |
int top_backref; /* Maximum back reference */ |
1745 |
unsigned int backref_map; /* Bitmap of low back refs */ |
unsigned int backref_map; /* Bitmap of low back refs */ |
1746 |
int assert_depth; /* Depth of nested assertions */ |
int assert_depth; /* Depth of nested assertions */ |
1747 |
int external_options; /* External (initial) options */ |
int external_options; /* External (initial) options */ |
1748 |
int external_flags; /* External flag bits to be set */ |
int external_flags; /* External flag bits to be set */ |
1749 |
int req_varyopt; /* "After variable item" flag for reqbyte */ |
int req_varyopt; /* "After variable item" flag for reqbyte */ |
1750 |
BOOL had_accept; /* (*ACCEPT) encountered */ |
BOOL had_accept; /* (*ACCEPT) encountered */ |
1751 |
BOOL check_lookbehind; /* Lookbehinds need later checking */ |
BOOL check_lookbehind; /* Lookbehinds need later checking */ |
1752 |
int nltype; /* Newline type */ |
int nltype; /* Newline type */ |
1753 |
int nllen; /* Newline string length */ |
int nllen; /* Newline string length */ |
1754 |
uschar nl[4]; /* Newline string when fixed length */ |
pcre_uchar nl[4]; /* Newline string when fixed length */ |
1755 |
} compile_data; |
} compile_data; |
1756 |
|
|
1757 |
/* Structure for maintaining a chain of pointers to the currently incomplete |
/* Structure for maintaining a chain of pointers to the currently incomplete |
1759 |
|
|
1760 |
typedef struct branch_chain { |
typedef struct branch_chain { |
1761 |
struct branch_chain *outer; |
struct branch_chain *outer; |
1762 |
uschar *current_branch; |
pcre_uchar *current_branch; |
1763 |
} branch_chain; |
} branch_chain; |
1764 |
|
|
1765 |
/* Structure for items in a linked list that represents an explicit recursive |
/* Structure for items in a linked list that represents an explicit recursive |
1770 |
int group_num; /* Number of group that was called */ |
int group_num; /* Number of group that was called */ |
1771 |
int *offset_save; /* Pointer to start of saved offsets */ |
int *offset_save; /* Pointer to start of saved offsets */ |
1772 |
int saved_max; /* Number of saved offsets */ |
int saved_max; /* Number of saved offsets */ |
1773 |
USPTR subject_position; /* Position at start of recursion */ |
PCRE_PUCHAR subject_position; /* Position at start of recursion */ |
1774 |
} recursion_info; |
} recursion_info; |
1775 |
|
|
1776 |
/* A similar structure for pcre_dfa_exec(). */ |
/* A similar structure for pcre_dfa_exec(). */ |
1778 |
typedef struct dfa_recursion_info { |
typedef struct dfa_recursion_info { |
1779 |
struct dfa_recursion_info *prevrec; |
struct dfa_recursion_info *prevrec; |
1780 |
int group_num; |
int group_num; |
1781 |
USPTR subject_position; |
PCRE_PUCHAR subject_position; |
1782 |
} dfa_recursion_info; |
} dfa_recursion_info; |
1783 |
|
|
1784 |
/* Structure for building a chain of data for holding the values of the subject |
/* Structure for building a chain of data for holding the values of the subject |
1788 |
|
|
1789 |
typedef struct eptrblock { |
typedef struct eptrblock { |
1790 |
struct eptrblock *epb_prev; |
struct eptrblock *epb_prev; |
1791 |
USPTR epb_saved_eptr; |
PCRE_PUCHAR epb_saved_eptr; |
1792 |
} eptrblock; |
} eptrblock; |
1793 |
|
|
1794 |
|
|
1799 |
unsigned long int match_call_count; /* As it says */ |
unsigned long int match_call_count; /* As it says */ |
1800 |
unsigned long int match_limit; /* As it says */ |
unsigned long int match_limit; /* As it says */ |
1801 |
unsigned long int match_limit_recursion; /* As it says */ |
unsigned long int match_limit_recursion; /* As it says */ |
1802 |
int *offset_vector; /* Offset vector */ |
int *offset_vector; /* Offset vector */ |
1803 |
int offset_end; /* One past the end */ |
int offset_end; /* One past the end */ |
1804 |
int offset_max; /* The maximum usable for return data */ |
int offset_max; /* The maximum usable for return data */ |
1805 |
int nltype; /* Newline type */ |
int nltype; /* Newline type */ |
1806 |
int nllen; /* Newline string length */ |
int nllen; /* Newline string length */ |
1807 |
int name_count; /* Number of names in name table */ |
int name_count; /* Number of names in name table */ |
1808 |
int name_entry_size; /* Size of entry in names table */ |
int name_entry_size; /* Size of entry in names table */ |
1809 |
uschar *name_table; /* Table of names */ |
pcre_uchar *name_table; /* Table of names */ |
1810 |
uschar nl[4]; /* Newline string when fixed */ |
pcre_uchar nl[4]; /* Newline string when fixed */ |
1811 |
const uschar *lcc; /* Points to lower casing table */ |
const pcre_uint8 *lcc; /* Points to lower casing table */ |
1812 |
const uschar *ctypes; /* Points to table of type maps */ |
const pcre_uint8 *ctypes; /* Points to table of type maps */ |
1813 |
BOOL offset_overflow; /* Set if too many extractions */ |
BOOL offset_overflow; /* Set if too many extractions */ |
1814 |
BOOL notbol; /* NOTBOL flag */ |
BOOL notbol; /* NOTBOL flag */ |
1815 |
BOOL noteol; /* NOTEOL flag */ |
BOOL noteol; /* NOTEOL flag */ |
1816 |
BOOL utf8; /* UTF8 flag */ |
BOOL utf8; /* UTF8 flag */ |
1817 |
BOOL jscript_compat; /* JAVASCRIPT_COMPAT flag */ |
BOOL jscript_compat; /* JAVASCRIPT_COMPAT flag */ |
1818 |
BOOL use_ucp; /* PCRE_UCP flag */ |
BOOL use_ucp; /* PCRE_UCP flag */ |
1819 |
BOOL endonly; /* Dollar not before final \n */ |
BOOL endonly; /* Dollar not before final \n */ |
1820 |
BOOL notempty; /* Empty string match not wanted */ |
BOOL notempty; /* Empty string match not wanted */ |
1821 |
BOOL notempty_atstart; /* Empty string match at start not wanted */ |
BOOL notempty_atstart; /* Empty string match at start not wanted */ |
1822 |
BOOL hitend; /* Hit the end of the subject at some point */ |
BOOL hitend; /* Hit the end of the subject at some point */ |
1823 |
BOOL bsr_anycrlf; /* \R is just any CRLF, not full Unicode */ |
BOOL bsr_anycrlf; /* \R is just any CRLF, not full Unicode */ |
1824 |
BOOL hasthen; /* Pattern contains (*THEN) */ |
BOOL hasthen; /* Pattern contains (*THEN) */ |
1825 |
const uschar *start_code; /* For use when recursing */ |
const pcre_uchar *start_code; /* For use when recursing */ |
1826 |
USPTR start_subject; /* Start of the subject string */ |
PCRE_PUCHAR start_subject; /* Start of the subject string */ |
1827 |
USPTR end_subject; /* End of the subject string */ |
PCRE_PUCHAR end_subject; /* End of the subject string */ |
1828 |
USPTR start_match_ptr; /* Start of matched string */ |
PCRE_PUCHAR start_match_ptr; /* Start of matched string */ |
1829 |
USPTR end_match_ptr; /* Subject position at end match */ |
PCRE_PUCHAR end_match_ptr; /* Subject position at end match */ |
1830 |
USPTR start_used_ptr; /* Earliest consulted character */ |
PCRE_PUCHAR start_used_ptr; /* Earliest consulted character */ |
1831 |
int partial; /* PARTIAL options */ |
int partial; /* PARTIAL options */ |
1832 |
int end_offset_top; /* Highwater mark at end of match */ |
int end_offset_top; /* Highwater mark at end of match */ |
1833 |
int capture_last; /* Most recent capture number */ |
int capture_last; /* Most recent capture number */ |
1834 |
int start_offset; /* The start offset value */ |
int start_offset; /* The start offset value */ |
1835 |
int match_function_type; /* Set for certain special calls of MATCH() */ |
int match_function_type; /* Set for certain special calls of MATCH() */ |
1836 |
eptrblock *eptrchain; /* Chain of eptrblocks for tail recursions */ |
eptrblock *eptrchain; /* Chain of eptrblocks for tail recursions */ |
1837 |
int eptrn; /* Next free eptrblock */ |
int eptrn; /* Next free eptrblock */ |
1838 |
recursion_info *recursive; /* Linked list of recursion data */ |
recursion_info *recursive; /* Linked list of recursion data */ |
1839 |
void *callout_data; /* To pass back to callouts */ |
void *callout_data; /* To pass back to callouts */ |
1840 |
const uschar *mark; /* Mark pointer to pass back */ |
const pcre_uchar *mark; /* Mark pointer to pass back */ |
1841 |
const uschar *once_target; /* Where to back up to for atomic groups */ |
const pcre_uchar *once_target; /* Where to back up to for atomic groups */ |
1842 |
} match_data; |
} match_data; |
1843 |
|
|
1844 |
/* A similar structure is used for the same purpose by the DFA matching |
/* A similar structure is used for the same purpose by the DFA matching |
1845 |
functions. */ |
functions. */ |
1846 |
|
|
1847 |
typedef struct dfa_match_data { |
typedef struct dfa_match_data { |
1848 |
const uschar *start_code; /* Start of the compiled pattern */ |
const pcre_uchar *start_code; /* Start of the compiled pattern */ |
1849 |
const uschar *start_subject; /* Start of the subject string */ |
const pcre_uchar *start_subject ; /* Start of the subject string */ |
1850 |
const uschar *end_subject; /* End of subject string */ |
const pcre_uchar *end_subject; /* End of subject string */ |
1851 |
const uschar *start_used_ptr; /* Earliest consulted character */ |
const pcre_uchar *start_used_ptr; /* Earliest consulted character */ |
1852 |
const uschar *tables; /* Character tables */ |
const pcre_uint8 *tables; /* Character tables */ |
1853 |
int start_offset; /* The start offset value */ |
int start_offset; /* The start offset value */ |
1854 |
int moptions; /* Match options */ |
int moptions; /* Match options */ |
1855 |
int poptions; /* Pattern options */ |
int poptions; /* Pattern options */ |
1856 |
int nltype; /* Newline type */ |
int nltype; /* Newline type */ |
1857 |
int nllen; /* Newline string length */ |
int nllen; /* Newline string length */ |
1858 |
uschar nl[4]; /* Newline string when fixed */ |
pcre_uchar nl[4]; /* Newline string when fixed */ |
1859 |
void *callout_data; /* To pass back to callouts */ |
void *callout_data; /* To pass back to callouts */ |
1860 |
dfa_recursion_info *recursive; /* Linked list of recursion data */ |
dfa_recursion_info *recursive; /* Linked list of recursion data */ |
1861 |
} dfa_match_data; |
} dfa_match_data; |
1862 |
|
|
1863 |
/* Bit definitions for entries in the pcre_ctypes table. */ |
/* Bit definitions for entries in the pcre_ctypes table. */ |
1910 |
but are not part of the PCRE public API. The data for these tables is in the |
but are not part of the PCRE public API. The data for these tables is in the |
1911 |
pcre_tables.c module. */ |
pcre_tables.c module. */ |
1912 |
|
|
1913 |
extern const int _pcre_utf8_table1[]; |
extern const int _pcre_utf8_table1[]; |
1914 |
extern const int _pcre_utf8_table2[]; |
extern const int _pcre_utf8_table2[]; |
1915 |
extern const int _pcre_utf8_table3[]; |
extern const int _pcre_utf8_table3[]; |
1916 |
extern const uschar _pcre_utf8_table4[]; |
extern const pcre_uint8 _pcre_utf8_table4[]; |
|
|
|
|
#ifdef SUPPORT_JIT |
|
|
extern const uschar _pcre_utf8_char_sizes[]; |
|
|
#endif |
|
1917 |
|
|
1918 |
extern const int _pcre_utf8_table1_size; |
extern const int _pcre_utf8_table1_size; |
1919 |
|
|
1920 |
extern const char _pcre_utt_names[]; |
extern const char _pcre_utt_names[]; |
1921 |
extern const ucp_type_table _pcre_utt[]; |
extern const ucp_type_table _pcre_utt[]; |
1922 |
extern const int _pcre_utt_size; |
extern const int _pcre_utt_size; |
1923 |
|
|
1924 |
extern const uschar _pcre_default_tables[]; |
extern const pcre_uint8 _pcre_default_tables[]; |
1925 |
|
|
1926 |
extern const uschar _pcre_OP_lengths[]; |
extern const pcre_uint8 _pcre_OP_lengths[]; |
1927 |
|
|
1928 |
|
|
1929 |
/* Internal shared functions. These are functions that are used by more than |
/* Internal shared functions. These are functions that are used by more than |
1930 |
one of the exported public functions. They have to be "external" in the C |
one of the exported public functions. They have to be "external" in the C |
1931 |
sense, but are not part of the PCRE public API. */ |
sense, but are not part of the PCRE public API. */ |
1932 |
|
|
1933 |
extern const uschar *_pcre_find_bracket(const uschar *, BOOL, int); |
extern const pcre_uchar *_pcre_find_bracket(const pcre_uchar *, BOOL, int); |
1934 |
extern BOOL _pcre_is_newline(USPTR, int, USPTR, int *, BOOL); |
extern BOOL _pcre_is_newline(PCRE_PUCHAR, int, PCRE_PUCHAR, |
1935 |
extern int _pcre_ord2utf8(int, uschar *); |
int *, BOOL); |
1936 |
extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *, |
extern int _pcre_ord2utf8(int, pcre_uint8 *); |
1937 |
const pcre_study_data *, pcre_study_data *); |
extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *, |
1938 |
extern int _pcre_valid_utf8(USPTR, int, int *); |
const pcre_study_data *, pcre_study_data *); |
1939 |
extern BOOL _pcre_was_newline(USPTR, int, USPTR, int *, BOOL); |
extern int _pcre_valid_utf8(PCRE_PUCHAR, int, int *); |
1940 |
extern BOOL _pcre_xclass(int, const uschar *); |
extern BOOL _pcre_was_newline(PCRE_PUCHAR, int, PCRE_PUCHAR, |
1941 |
|
int *, BOOL); |
1942 |
|
extern BOOL _pcre_xclass(int, const pcre_uchar *); |
1943 |
|
|
1944 |
#ifdef SUPPORT_JIT |
#ifdef SUPPORT_JIT |
1945 |
extern void _pcre_jit_compile(const real_pcre *, pcre_extra *); |
extern void _pcre_jit_compile(const real_pcre *, pcre_extra *); |
1946 |
extern int _pcre_jit_exec(const real_pcre *, void *, PCRE_SPTR, |
extern int _pcre_jit_exec(const real_pcre *, void *, PCRE_SPTR, |
1947 |
int, int, int, int, int *, int); |
int, int, int, int, int *, int); |
1948 |
extern void _pcre_jit_free(void *); |
extern void _pcre_jit_free(void *); |
1949 |
#endif |
#endif |
1950 |
|
|
1951 |
/* Unicode character database (UCD) */ |
/* Unicode character database (UCD) */ |
1952 |
|
|
1953 |
typedef struct { |
typedef struct { |
1954 |
uschar script; |
pcre_uint8 script; |
1955 |
uschar chartype; |
pcre_uint8 chartype; |
1956 |
pcre_int32 other_case; |
pcre_int32 other_case; |
1957 |
} ucd_record; |
} ucd_record; |
1958 |
|
|
1959 |
extern const ucd_record _pcre_ucd_records[]; |
extern const ucd_record _pcre_ucd_records[]; |
1960 |
extern const uschar _pcre_ucd_stage1[]; |
extern const pcre_uint8 _pcre_ucd_stage1[]; |
1961 |
extern const pcre_uint16 _pcre_ucd_stage2[]; |
extern const pcre_uint16 _pcre_ucd_stage2[]; |
1962 |
extern const int _pcre_ucp_gentype[]; |
extern const int _pcre_ucp_gentype[]; |
1963 |
#ifdef SUPPORT_JIT |
#ifdef SUPPORT_JIT |