00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef PCRE_INTERNAL_H
00046 #define PCRE_INTERNAL_H
00047
00048
00049
00050 #if 0
00051 #define DEBUG
00052 #endif
00053
00054
00055
00056
00057 #if defined EBCDIC && defined SUPPORT_UTF8
00058 #error The use of both EBCDIC and SUPPORT_UTF8 is not supported.
00059 #endif
00060
00061
00062
00063
00064 #if defined SUPPORT_UCP && !defined SUPPORT_UTF8
00065 #define SUPPORT_UTF8 1
00066 #endif
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #undef DPRINTF
00077 #ifdef DEBUG_PCRE
00078 #define DPRINTF(p) printf p
00079 #else
00080 #define DPRINTF(p)
00081 #endif
00082
00083
00084
00085
00086
00087 #include <ctype.h>
00088 #include <limits.h>
00089 #include <setjmp.h>
00090 #include <stdarg.h>
00091 #include <stddef.h>
00092 #include <stdio.h>
00093 #include <stdlib.h>
00094 #include <string.h>
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #ifndef PCRE_EXP_DECL
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 # ifdef __cplusplus
00136 # define PCRE_EXP_DECL extern "C"
00137 # else
00138 # define PCRE_EXP_DECL extern
00139 # endif
00140 # ifndef PCRE_EXP_DEFN
00141 # define PCRE_EXP_DEFN PCRE_EXP_DECL
00142 # endif
00143 # ifndef PCRE_EXP_DATA_DEFN
00144 # define PCRE_EXP_DATA_DEFN
00145 # endif
00146
00147 #endif
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 #ifndef PCRE_CALL_CONVENTION
00160 #define PCRE_CALL_CONVENTION
00161 #endif
00162
00163
00164
00165
00166
00167
00168
00169 #if USHRT_MAX == 65535
00170 typedef unsigned short pcre_uint16;
00171 typedef short pcre_int16;
00172 #elif UINT_MAX == 65535
00173 typedef unsigned int pcre_uint16;
00174 typedef int pcre_int16;
00175 #else
00176 #error Cannot determine a type for 16-bit unsigned integers
00177 #endif
00178
00179 #if UINT_MAX == 4294967295
00180 typedef unsigned int pcre_uint32;
00181 typedef int pcre_int32;
00182 #elif ULONG_MAX == 4294967295
00183 typedef unsigned long int pcre_uint32;
00184 typedef long int pcre_int32;
00185 #else
00186 #error Cannot determine a type for 32-bit unsigned integers
00187 #endif
00188
00189
00190
00191
00192
00193
00194
00195
00196 typedef unsigned char uschar;
00197
00198
00199
00200
00201
00202 #define NOTACHAR 0xffffffff
00203
00204
00205
00206
00207
00208
00209
00210 #define NLTYPE_FIXED 0
00211 #define NLTYPE_ANY 1
00212 #define NLTYPE_ANYCRLF 2
00213
00214
00215
00216 #define IS_NEWLINE(p) \
00217 ((NLBLOCK->nltype != NLTYPE_FIXED)? \
00218 ((p) < NLBLOCK->PSEND && \
00219 _pcre_is_newline((p), NLBLOCK->nltype, NLBLOCK->PSEND, &(NLBLOCK->nllen),\
00220 utf8)) \
00221 : \
00222 ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
00223 (p)[0] == NLBLOCK->nl[0] && \
00224 (NLBLOCK->nllen == 1 || (p)[1] == NLBLOCK->nl[1]) \
00225 ) \
00226 )
00227
00228
00229
00230 #define WAS_NEWLINE(p) \
00231 ((NLBLOCK->nltype != NLTYPE_FIXED)? \
00232 ((p) > NLBLOCK->PSSTART && \
00233 _pcre_was_newline((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
00234 &(NLBLOCK->nllen), utf8)) \
00235 : \
00236 ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
00237 (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
00238 (NLBLOCK->nllen == 1 || (p)[-NLBLOCK->nllen+1] == NLBLOCK->nl[1]) \
00239 ) \
00240 )
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 #ifdef CUSTOM_SUBJECT_PTR
00252 #define PCRE_SPTR CUSTOM_SUBJECT_PTR
00253 #define USPTR CUSTOM_SUBJECT_PTR
00254 #else
00255 #define PCRE_SPTR const char *
00256 #define USPTR const unsigned char *
00257 #endif
00258
00259
00260
00261
00262
00263
00264 #include "pcre.h"
00265 #include "ucp.h"
00266
00267
00268
00269
00270
00271 #ifdef VPCOMPAT
00272 #define strlen(s) _strlen(s)
00273 #define strncmp(s1,s2,m) _strncmp(s1,s2,m)
00274 #define memcmp(s,c,n) _memcmp(s,c,n)
00275 #define memcpy(d,s,n) _memcpy(d,s,n)
00276 #define memmove(d,s,n) _memmove(d,s,n)
00277 #define memset(s,c,n) _memset(s,c,n)
00278 #else
00279
00280
00281
00282
00283
00284
00285 #ifndef HAVE_MEMMOVE
00286 #undef memmove
00287 #ifdef HAVE_BCOPY
00288 #define memmove(a, b, c) bcopy(b, a, c)
00289 #else
00290 static void *
00291 pcre_memmove(void *d, const void *s, size_t n)
00292 {
00293 size_t i;
00294 unsigned char *dest = (unsigned char *)d;
00295 const unsigned char *src = (const unsigned char *)s;
00296 if (dest > src)
00297 {
00298 dest += n;
00299 src += n;
00300 for (i = 0; i < n; ++i) *(--dest) = *(--src);
00301 return (void *)dest;
00302 }
00303 else
00304 {
00305 for (i = 0; i < n; ++i) *dest++ = *src++;
00306 return (void *)(dest - n);
00307 }
00308 }
00309 #define memmove(a, b, c) pcre_memmove(a, b, c)
00310 #endif
00311 #endif
00312 #endif
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 #if LINK_SIZE == 2
00329
00330 #define PUT(a,n,d) \
00331 (a[n] = (d) >> 8), \
00332 (a[(n)+1] = (d) & 255)
00333
00334 #define GET(a,n) \
00335 (((a)[n] << 8) | (a)[(n)+1])
00336
00337 #define MAX_PATTERN_SIZE (1 << 16)
00338
00339
00340 #elif LINK_SIZE == 3
00341
00342 #define PUT(a,n,d) \
00343 (a[n] = (d) >> 16), \
00344 (a[(n)+1] = (d) >> 8), \
00345 (a[(n)+2] = (d) & 255)
00346
00347 #define GET(a,n) \
00348 (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
00349
00350 #define MAX_PATTERN_SIZE (1 << 24)
00351
00352
00353 #elif LINK_SIZE == 4
00354
00355 #define PUT(a,n,d) \
00356 (a[n] = (d) >> 24), \
00357 (a[(n)+1] = (d) >> 16), \
00358 (a[(n)+2] = (d) >> 8), \
00359 (a[(n)+3] = (d) & 255)
00360
00361 #define GET(a,n) \
00362 (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
00363
00364 #define MAX_PATTERN_SIZE (1 << 30)
00365
00366
00367 #else
00368 #error LINK_SIZE must be either 2, 3, or 4
00369 #endif
00370
00371
00372
00373
00374 #define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
00375
00376
00377
00378
00379
00380
00381 #define PUT2(a,n,d) \
00382 a[n] = (d) >> 8; \
00383 a[(n)+1] = (d) & 255
00384
00385 #define GET2(a,n) \
00386 (((a)[n] << 8) | (a)[(n)+1])
00387
00388 #define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
00389
00390
00391
00392
00393
00394
00395
00396
00397 #ifndef SUPPORT_UTF8
00398 #define GETCHAR(c, eptr) c = *eptr;
00399 #define GETCHARTEST(c, eptr) c = *eptr;
00400 #define GETCHARINC(c, eptr) c = *eptr++;
00401 #define GETCHARINCTEST(c, eptr) c = *eptr++;
00402 #define GETCHARLEN(c, eptr, len) c = *eptr;
00403
00404
00405 #else
00406
00407
00408
00409
00410 #define GETCHAR(c, eptr) \
00411 c = *eptr; \
00412 if (c >= 0xc0) \
00413 { \
00414 int gcii; \
00415 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00416 int gcss = 6*gcaa; \
00417 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00418 for (gcii = 1; gcii <= gcaa; gcii++) \
00419 { \
00420 gcss -= 6; \
00421 c |= (eptr[gcii] & 0x3f) << gcss; \
00422 } \
00423 }
00424
00425
00426
00427
00428 #define GETCHARTEST(c, eptr) \
00429 c = *eptr; \
00430 if (utf8 && c >= 0xc0) \
00431 { \
00432 int gcii; \
00433 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00434 int gcss = 6*gcaa; \
00435 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00436 for (gcii = 1; gcii <= gcaa; gcii++) \
00437 { \
00438 gcss -= 6; \
00439 c |= (eptr[gcii] & 0x3f) << gcss; \
00440 } \
00441 }
00442
00443
00444
00445
00446 #define GETCHARINC(c, eptr) \
00447 c = *eptr++; \
00448 if (c >= 0xc0) \
00449 { \
00450 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00451 int gcss = 6*gcaa; \
00452 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00453 while (gcaa-- > 0) \
00454 { \
00455 gcss -= 6; \
00456 c |= (*eptr++ & 0x3f) << gcss; \
00457 } \
00458 }
00459
00460
00461
00462 #define GETCHARINCTEST(c, eptr) \
00463 c = *eptr++; \
00464 if (utf8 && c >= 0xc0) \
00465 { \
00466 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00467 int gcss = 6*gcaa; \
00468 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00469 while (gcaa-- > 0) \
00470 { \
00471 gcss -= 6; \
00472 c |= (*eptr++ & 0x3f) << gcss; \
00473 } \
00474 }
00475
00476
00477
00478
00479 #define GETCHARLEN(c, eptr, len) \
00480 c = *eptr; \
00481 if (c >= 0xc0) \
00482 { \
00483 int gcii; \
00484 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00485 int gcss = 6*gcaa; \
00486 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00487 for (gcii = 1; gcii <= gcaa; gcii++) \
00488 { \
00489 gcss -= 6; \
00490 c |= (eptr[gcii] & 0x3f) << gcss; \
00491 } \
00492 len += gcaa; \
00493 }
00494
00495
00496
00497
00498
00499 #define GETCHARLENTEST(c, eptr, len) \
00500 c = *eptr; \
00501 if (utf8 && c >= 0xc0) \
00502 { \
00503 int gcii; \
00504 int gcaa = _pcre_utf8_table4[c & 0x3f]; \
00505 int gcss = 6*gcaa; \
00506 c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
00507 for (gcii = 1; gcii <= gcaa; gcii++) \
00508 { \
00509 gcss -= 6; \
00510 c |= (eptr[gcii] & 0x3f) << gcss; \
00511 } \
00512 len += gcaa; \
00513 }
00514
00515
00516
00517
00518
00519 #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
00520
00521 #endif
00522
00523
00524
00525
00526
00527 #ifndef offsetof
00528 #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
00529 #endif
00530
00531
00532
00533
00534 #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
00535
00536
00537
00538
00539
00540
00541
00542 #define PCRE_NOPARTIAL 0x0001
00543 #define PCRE_FIRSTSET 0x0002
00544 #define PCRE_REQCHSET 0x0004
00545 #define PCRE_STARTLINE 0x0008
00546 #define PCRE_JCHANGED 0x0010
00547 #define PCRE_HASCRORLF 0x0020
00548
00549
00550
00551 #define PCRE_STUDY_MAPPED 0x01
00552 #define PCRE_STUDY_MINLEN 0x02
00553
00554
00555
00556
00557 #define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
00558 PCRE_NEWLINE_ANYCRLF)
00559
00560 #define PUBLIC_COMPILE_OPTIONS \
00561 (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
00562 PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
00563 PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
00564 PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
00565 PCRE_JAVASCRIPT_COMPAT)
00566
00567 #define PUBLIC_EXEC_OPTIONS \
00568 (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
00569 PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_NEWLINE_BITS| \
00570 PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
00571
00572 #define PUBLIC_DFA_EXEC_OPTIONS \
00573 (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
00574 PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_DFA_SHORTEST| \
00575 PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
00576 PCRE_NO_START_OPTIMIZE)
00577
00578 #define PUBLIC_STUDY_OPTIONS 0
00579
00580
00581
00582
00583 #define MAGIC_NUMBER 0x50435245UL
00584
00585
00586
00587 #define REQ_UNSET (-2)
00588 #define REQ_NONE (-1)
00589
00590
00591
00592
00593 #define REQ_BYTE_MAX 1000
00594
00595
00596
00597
00598 #define REQ_CASELESS 0x0100
00599 #define REQ_VARY 0x0200
00600
00601
00602
00603
00604
00605 typedef int BOOL;
00606
00607 #ifndef FALSE
00608 #define FALSE 0
00609 #define TRUE 1
00610 #endif
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629 #ifndef SUPPORT_UTF8
00630
00631
00632
00633
00634 #define CHAR_HT '\t'
00635 #define CHAR_VT '\v'
00636 #define CHAR_FF '\f'
00637 #define CHAR_CR '\r'
00638 #define CHAR_NL '\n'
00639 #define CHAR_BS '\b'
00640 #define CHAR_BEL '\a'
00641 #ifdef EBCDIC
00642 #define CHAR_ESC '\047'
00643 #define CHAR_DEL '\007'
00644 #else
00645 #define CHAR_ESC '\033'
00646 #define CHAR_DEL '\177'
00647 #endif
00648
00649 #define CHAR_SPACE ' '
00650 #define CHAR_EXCLAMATION_MARK '!'
00651 #define CHAR_QUOTATION_MARK '"'
00652 #define CHAR_NUMBER_SIGN '#'
00653 #define CHAR_DOLLAR_SIGN '$'
00654 #define CHAR_PERCENT_SIGN '%'
00655 #define CHAR_AMPERSAND '&'
00656 #define CHAR_APOSTROPHE '\''
00657 #define CHAR_LEFT_PARENTHESIS '('
00658 #define CHAR_RIGHT_PARENTHESIS ')'
00659 #define CHAR_ASTERISK '*'
00660 #define CHAR_PLUS '+'
00661 #define CHAR_COMMA ','
00662 #define CHAR_MINUS '-'
00663 #define CHAR_DOT '.'
00664 #define CHAR_SLASH '/'
00665 #define CHAR_0 '0'
00666 #define CHAR_1 '1'
00667 #define CHAR_2 '2'
00668 #define CHAR_3 '3'
00669 #define CHAR_4 '4'
00670 #define CHAR_5 '5'
00671 #define CHAR_6 '6'
00672 #define CHAR_7 '7'
00673 #define CHAR_8 '8'
00674 #define CHAR_9 '9'
00675 #define CHAR_COLON ':'
00676 #define CHAR_SEMICOLON ';'
00677 #define CHAR_LESS_THAN_SIGN '<'
00678 #define CHAR_EQUALS_SIGN '='
00679 #define CHAR_GREATER_THAN_SIGN '>'
00680 #define CHAR_QUESTION_MARK '?'
00681 #define CHAR_COMMERCIAL_AT '@'
00682 #define CHAR_A 'A'
00683 #define CHAR_B 'B'
00684 #define CHAR_C 'C'
00685 #define CHAR_D 'D'
00686 #define CHAR_E 'E'
00687 #define CHAR_F 'F'
00688 #define CHAR_G 'G'
00689 #define CHAR_H 'H'
00690 #define CHAR_I 'I'
00691 #define CHAR_J 'J'
00692 #define CHAR_K 'K'
00693 #define CHAR_L 'L'
00694 #define CHAR_M 'M'
00695 #define CHAR_N 'N'
00696 #define CHAR_O 'O'
00697 #define CHAR_P 'P'
00698 #define CHAR_Q 'Q'
00699 #define CHAR_R 'R'
00700 #define CHAR_S 'S'
00701 #define CHAR_T 'T'
00702 #define CHAR_U 'U'
00703 #define CHAR_V 'V'
00704 #define CHAR_W 'W'
00705 #define CHAR_X 'X'
00706 #define CHAR_Y 'Y'
00707 #define CHAR_Z 'Z'
00708 #define CHAR_LEFT_SQUARE_BRACKET '['
00709 #define CHAR_BACKSLASH '\\'
00710 #define CHAR_RIGHT_SQUARE_BRACKET ']'
00711 #define CHAR_CIRCUMFLEX_ACCENT '^'
00712 #define CHAR_UNDERSCORE '_'
00713 #define CHAR_GRAVE_ACCENT '`'
00714 #define CHAR_a 'a'
00715 #define CHAR_b 'b'
00716 #define CHAR_c 'c'
00717 #define CHAR_d 'd'
00718 #define CHAR_e 'e'
00719 #define CHAR_f 'f'
00720 #define CHAR_g 'g'
00721 #define CHAR_h 'h'
00722 #define CHAR_i 'i'
00723 #define CHAR_j 'j'
00724 #define CHAR_k 'k'
00725 #define CHAR_l 'l'
00726 #define CHAR_m 'm'
00727 #define CHAR_n 'n'
00728 #define CHAR_o 'o'
00729 #define CHAR_p 'p'
00730 #define CHAR_q 'q'
00731 #define CHAR_r 'r'
00732 #define CHAR_s 's'
00733 #define CHAR_t 't'
00734 #define CHAR_u 'u'
00735 #define CHAR_v 'v'
00736 #define CHAR_w 'w'
00737 #define CHAR_x 'x'
00738 #define CHAR_y 'y'
00739 #define CHAR_z 'z'
00740 #define CHAR_LEFT_CURLY_BRACKET '{'
00741 #define CHAR_VERTICAL_LINE '|'
00742 #define CHAR_RIGHT_CURLY_BRACKET '}'
00743 #define CHAR_TILDE '~'
00744
00745 #define STR_HT "\t"
00746 #define STR_VT "\v"
00747 #define STR_FF "\f"
00748 #define STR_CR "\r"
00749 #define STR_NL "\n"
00750 #define STR_BS "\b"
00751 #define STR_BEL "\a"
00752 #ifdef EBCDIC
00753 #define STR_ESC "\047"
00754 #define STR_DEL "\007"
00755 #else
00756 #define STR_ESC "\033"
00757 #define STR_DEL "\177"
00758 #endif
00759
00760 #define STR_SPACE " "
00761 #define STR_EXCLAMATION_MARK "!"
00762 #define STR_QUOTATION_MARK "\""
00763 #define STR_NUMBER_SIGN "#"
00764 #define STR_DOLLAR_SIGN "$"
00765 #define STR_PERCENT_SIGN "%"
00766 #define STR_AMPERSAND "&"
00767 #define STR_APOSTROPHE "'"
00768 #define STR_LEFT_PARENTHESIS "("
00769 #define STR_RIGHT_PARENTHESIS ")"
00770 #define STR_ASTERISK "*"
00771 #define STR_PLUS "+"
00772 #define STR_COMMA ","
00773 #define STR_MINUS "-"
00774 #define STR_DOT "."
00775 #define STR_SLASH "/"
00776 #define STR_0 "0"
00777 #define STR_1 "1"
00778 #define STR_2 "2"
00779 #define STR_3 "3"
00780 #define STR_4 "4"
00781 #define STR_5 "5"
00782 #define STR_6 "6"
00783 #define STR_7 "7"
00784 #define STR_8 "8"
00785 #define STR_9 "9"
00786 #define STR_COLON ":"
00787 #define STR_SEMICOLON ";"
00788 #define STR_LESS_THAN_SIGN "<"
00789 #define STR_EQUALS_SIGN "="
00790 #define STR_GREATER_THAN_SIGN ">"
00791 #define STR_QUESTION_MARK "?"
00792 #define STR_COMMERCIAL_AT "@"
00793 #define STR_A "A"
00794 #define STR_B "B"
00795 #define STR_C "C"
00796 #define STR_D "D"
00797 #define STR_E "E"
00798 #define STR_F "F"
00799 #define STR_G "G"
00800 #define STR_H "H"
00801 #define STR_I "I"
00802 #define STR_J "J"
00803 #define STR_K "K"
00804 #define STR_L "L"
00805 #define STR_M "M"
00806 #define STR_N "N"
00807 #define STR_O "O"
00808 #define STR_P "P"
00809 #define STR_Q "Q"
00810 #define STR_R "R"
00811 #define STR_S "S"
00812 #define STR_T "T"
00813 #define STR_U "U"
00814 #define STR_V "V"
00815 #define STR_W "W"
00816 #define STR_X "X"
00817 #define STR_Y "Y"
00818 #define STR_Z "Z"
00819 #define STR_LEFT_SQUARE_BRACKET "["
00820 #define STR_BACKSLASH "\\"
00821 #define STR_RIGHT_SQUARE_BRACKET "]"
00822 #define STR_CIRCUMFLEX_ACCENT "^"
00823 #define STR_UNDERSCORE "_"
00824 #define STR_GRAVE_ACCENT "`"
00825 #define STR_a "a"
00826 #define STR_b "b"
00827 #define STR_c "c"
00828 #define STR_d "d"
00829 #define STR_e "e"
00830 #define STR_f "f"
00831 #define STR_g "g"
00832 #define STR_h "h"
00833 #define STR_i "i"
00834 #define STR_j "j"
00835 #define STR_k "k"
00836 #define STR_l "l"
00837 #define STR_m "m"
00838 #define STR_n "n"
00839 #define STR_o "o"
00840 #define STR_p "p"
00841 #define STR_q "q"
00842 #define STR_r "r"
00843 #define STR_s "s"
00844 #define STR_t "t"
00845 #define STR_u "u"
00846 #define STR_v "v"
00847 #define STR_w "w"
00848 #define STR_x "x"
00849 #define STR_y "y"
00850 #define STR_z "z"
00851 #define STR_LEFT_CURLY_BRACKET "{"
00852 #define STR_VERTICAL_LINE "|"
00853 #define STR_RIGHT_CURLY_BRACKET "}"
00854 #define STR_TILDE "~"
00855
00856 #define STRING_ACCEPT0 "ACCEPT\0"
00857 #define STRING_COMMIT0 "COMMIT\0"
00858 #define STRING_F0 "F\0"
00859 #define STRING_FAIL0 "FAIL\0"
00860 #define STRING_PRUNE0 "PRUNE\0"
00861 #define STRING_SKIP0 "SKIP\0"
00862 #define STRING_THEN "THEN"
00863
00864 #define STRING_alpha0 "alpha\0"
00865 #define STRING_lower0 "lower\0"
00866 #define STRING_upper0 "upper\0"
00867 #define STRING_alnum0 "alnum\0"
00868 #define STRING_ascii0 "ascii\0"
00869 #define STRING_blank0 "blank\0"
00870 #define STRING_cntrl0 "cntrl\0"
00871 #define STRING_digit0 "digit\0"
00872 #define STRING_graph0 "graph\0"
00873 #define STRING_print0 "print\0"
00874 #define STRING_punct0 "punct\0"
00875 #define STRING_space0 "space\0"
00876 #define STRING_word0 "word\0"
00877 #define STRING_xdigit "xdigit"
00878
00879 #define STRING_DEFINE "DEFINE"
00880
00881 #define STRING_CR_RIGHTPAR "CR)"
00882 #define STRING_LF_RIGHTPAR "LF)"
00883 #define STRING_CRLF_RIGHTPAR "CRLF)"
00884 #define STRING_ANY_RIGHTPAR "ANY)"
00885 #define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"
00886 #define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
00887 #define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
00888 #define STRING_UTF8_RIGHTPAR "UTF8)"
00889
00890 #else
00891
00892
00893
00894
00895
00896 #define CHAR_HT '\011'
00897 #define CHAR_VT '\013'
00898 #define CHAR_FF '\014'
00899 #define CHAR_CR '\015'
00900 #define CHAR_NL '\012'
00901 #define CHAR_BS '\010'
00902 #define CHAR_BEL '\007'
00903 #define CHAR_ESC '\033'
00904 #define CHAR_DEL '\177'
00905
00906 #define CHAR_SPACE '\040'
00907 #define CHAR_EXCLAMATION_MARK '\041'
00908 #define CHAR_QUOTATION_MARK '\042'
00909 #define CHAR_NUMBER_SIGN '\043'
00910 #define CHAR_DOLLAR_SIGN '\044'
00911 #define CHAR_PERCENT_SIGN '\045'
00912 #define CHAR_AMPERSAND '\046'
00913 #define CHAR_APOSTROPHE '\047'
00914 #define CHAR_LEFT_PARENTHESIS '\050'
00915 #define CHAR_RIGHT_PARENTHESIS '\051'
00916 #define CHAR_ASTERISK '\052'
00917 #define CHAR_PLUS '\053'
00918 #define CHAR_COMMA '\054'
00919 #define CHAR_MINUS '\055'
00920 #define CHAR_DOT '\056'
00921 #define CHAR_SLASH '\057'
00922 #define CHAR_0 '\060'
00923 #define CHAR_1 '\061'
00924 #define CHAR_2 '\062'
00925 #define CHAR_3 '\063'
00926 #define CHAR_4 '\064'
00927 #define CHAR_5 '\065'
00928 #define CHAR_6 '\066'
00929 #define CHAR_7 '\067'
00930 #define CHAR_8 '\070'
00931 #define CHAR_9 '\071'
00932 #define CHAR_COLON '\072'
00933 #define CHAR_SEMICOLON '\073'
00934 #define CHAR_LESS_THAN_SIGN '\074'
00935 #define CHAR_EQUALS_SIGN '\075'
00936 #define CHAR_GREATER_THAN_SIGN '\076'
00937 #define CHAR_QUESTION_MARK '\077'
00938 #define CHAR_COMMERCIAL_AT '\100'
00939 #define CHAR_A '\101'
00940 #define CHAR_B '\102'
00941 #define CHAR_C '\103'
00942 #define CHAR_D '\104'
00943 #define CHAR_E '\105'
00944 #define CHAR_F '\106'
00945 #define CHAR_G '\107'
00946 #define CHAR_H '\110'
00947 #define CHAR_I '\111'
00948 #define CHAR_J '\112'
00949 #define CHAR_K '\113'
00950 #define CHAR_L '\114'
00951 #define CHAR_M '\115'
00952 #define CHAR_N '\116'
00953 #define CHAR_O '\117'
00954 #define CHAR_P '\120'
00955 #define CHAR_Q '\121'
00956 #define CHAR_R '\122'
00957 #define CHAR_S '\123'
00958 #define CHAR_T '\124'
00959 #define CHAR_U '\125'
00960 #define CHAR_V '\126'
00961 #define CHAR_W '\127'
00962 #define CHAR_X '\130'
00963 #define CHAR_Y '\131'
00964 #define CHAR_Z '\132'
00965 #define CHAR_LEFT_SQUARE_BRACKET '\133'
00966 #define CHAR_BACKSLASH '\134'
00967 #define CHAR_RIGHT_SQUARE_BRACKET '\135'
00968 #define CHAR_CIRCUMFLEX_ACCENT '\136'
00969 #define CHAR_UNDERSCORE '\137'
00970 #define CHAR_GRAVE_ACCENT '\140'
00971 #define CHAR_a '\141'
00972 #define CHAR_b '\142'
00973 #define CHAR_c '\143'
00974 #define CHAR_d '\144'
00975 #define CHAR_e '\145'
00976 #define CHAR_f '\146'
00977 #define CHAR_g '\147'
00978 #define CHAR_h '\150'
00979 #define CHAR_i '\151'
00980 #define CHAR_j '\152'
00981 #define CHAR_k '\153'
00982 #define CHAR_l '\154'
00983 #define CHAR_m '\155'
00984 #define CHAR_n '\156'
00985 #define CHAR_o '\157'
00986 #define CHAR_p '\160'
00987 #define CHAR_q '\161'
00988 #define CHAR_r '\162'
00989 #define CHAR_s '\163'
00990 #define CHAR_t '\164'
00991 #define CHAR_u '\165'
00992 #define CHAR_v '\166'
00993 #define CHAR_w '\167'
00994 #define CHAR_x '\170'
00995 #define CHAR_y '\171'
00996 #define CHAR_z '\172'
00997 #define CHAR_LEFT_CURLY_BRACKET '\173'
00998 #define CHAR_VERTICAL_LINE '\174'
00999 #define CHAR_RIGHT_CURLY_BRACKET '\175'
01000 #define CHAR_TILDE '\176'
01001
01002 #define STR_HT "\011"
01003 #define STR_VT "\013"
01004 #define STR_FF "\014"
01005 #define STR_CR "\015"
01006 #define STR_NL "\012"
01007 #define STR_BS "\010"
01008 #define STR_BEL "\007"
01009 #define STR_ESC "\033"
01010 #define STR_DEL "\177"
01011
01012 #define STR_SPACE "\040"
01013 #define STR_EXCLAMATION_MARK "\041"
01014 #define STR_QUOTATION_MARK "\042"
01015 #define STR_NUMBER_SIGN "\043"
01016 #define STR_DOLLAR_SIGN "\044"
01017 #define STR_PERCENT_SIGN "\045"
01018 #define STR_AMPERSAND "\046"
01019 #define STR_APOSTROPHE "\047"
01020 #define STR_LEFT_PARENTHESIS "\050"
01021 #define STR_RIGHT_PARENTHESIS "\051"
01022 #define STR_ASTERISK "\052"
01023 #define STR_PLUS "\053"
01024 #define STR_COMMA "\054"
01025 #define STR_MINUS "\055"
01026 #define STR_DOT "\056"
01027 #define STR_SLASH "\057"
01028 #define STR_0 "\060"
01029 #define STR_1 "\061"
01030 #define STR_2 "\062"
01031 #define STR_3 "\063"
01032 #define STR_4 "\064"
01033 #define STR_5 "\065"
01034 #define STR_6 "\066"
01035 #define STR_7 "\067"
01036 #define STR_8 "\070"
01037 #define STR_9 "\071"
01038 #define STR_COLON "\072"
01039 #define STR_SEMICOLON "\073"
01040 #define STR_LESS_THAN_SIGN "\074"
01041 #define STR_EQUALS_SIGN "\075"
01042 #define STR_GREATER_THAN_SIGN "\076"
01043 #define STR_QUESTION_MARK "\077"
01044 #define STR_COMMERCIAL_AT "\100"
01045 #define STR_A "\101"
01046 #define STR_B "\102"
01047 #define STR_C "\103"
01048 #define STR_D "\104"
01049 #define STR_E "\105"
01050 #define STR_F "\106"
01051 #define STR_G "\107"
01052 #define STR_H "\110"
01053 #define STR_I "\111"
01054 #define STR_J "\112"
01055 #define STR_K "\113"
01056 #define STR_L "\114"
01057 #define STR_M "\115"
01058 #define STR_N "\116"
01059 #define STR_O "\117"
01060 #define STR_P "\120"
01061 #define STR_Q "\121"
01062 #define STR_R "\122"
01063 #define STR_S "\123"
01064 #define STR_T "\124"
01065 #define STR_U "\125"
01066 #define STR_V "\126"
01067 #define STR_W "\127"
01068 #define STR_X "\130"
01069 #define STR_Y "\131"
01070 #define STR_Z "\132"
01071 #define STR_LEFT_SQUARE_BRACKET "\133"
01072 #define STR_BACKSLASH "\134"
01073 #define STR_RIGHT_SQUARE_BRACKET "\135"
01074 #define STR_CIRCUMFLEX_ACCENT "\136"
01075 #define STR_UNDERSCORE "\137"
01076 #define STR_GRAVE_ACCENT "\140"
01077 #define STR_a "\141"
01078 #define STR_b "\142"
01079 #define STR_c "\143"
01080 #define STR_d "\144"
01081 #define STR_e "\145"
01082 #define STR_f "\146"
01083 #define STR_g "\147"
01084 #define STR_h "\150"
01085 #define STR_i "\151"
01086 #define STR_j "\152"
01087 #define STR_k "\153"
01088 #define STR_l "\154"
01089 #define STR_m "\155"
01090 #define STR_n "\156"
01091 #define STR_o "\157"
01092 #define STR_p "\160"
01093 #define STR_q "\161"
01094 #define STR_r "\162"
01095 #define STR_s "\163"
01096 #define STR_t "\164"
01097 #define STR_u "\165"
01098 #define STR_v "\166"
01099 #define STR_w "\167"
01100 #define STR_x "\170"
01101 #define STR_y "\171"
01102 #define STR_z "\172"
01103 #define STR_LEFT_CURLY_BRACKET "\173"
01104 #define STR_VERTICAL_LINE "\174"
01105 #define STR_RIGHT_CURLY_BRACKET "\175"
01106 #define STR_TILDE "\176"
01107
01108 #define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"
01109 #define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"
01110 #define STRING_F0 STR_F "\0"
01111 #define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"
01112 #define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"
01113 #define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"
01114 #define STRING_THEN STR_T STR_H STR_E STR_N
01115
01116 #define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"
01117 #define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"
01118 #define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"
01119 #define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"
01120 #define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"
01121 #define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"
01122 #define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"
01123 #define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"
01124 #define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"
01125 #define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"
01126 #define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"
01127 #define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"
01128 #define STRING_word0 STR_w STR_o STR_r STR_d "\0"
01129 #define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t
01130
01131 #define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E
01132
01133 #define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS
01134 #define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS
01135 #define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
01136 #define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
01137 #define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
01138 #define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
01139 #define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
01140 #define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
01141
01142 #endif
01143
01144
01145
01146 #ifndef ESC_e
01147 #define ESC_e CHAR_ESC
01148 #endif
01149
01150 #ifndef ESC_f
01151 #define ESC_f CHAR_FF
01152 #endif
01153
01154 #ifndef ESC_n
01155 #define ESC_n CHAR_NL
01156 #endif
01157
01158 #ifndef ESC_r
01159 #define ESC_r CHAR_CR
01160 #endif
01161
01162
01163
01164
01165 #ifndef ESC_tee
01166 #define ESC_tee CHAR_HT
01167 #endif
01168
01169
01170
01171 #define PT_ANY 0
01172 #define PT_LAMP 1
01173 #define PT_GC 2
01174 #define PT_PC 3
01175 #define PT_SC 4
01176
01177
01178
01179
01180 #define XCL_NOT 0x01
01181 #define XCL_MAP 0x02
01182
01183 #define XCL_END 0
01184 #define XCL_SINGLE 1
01185 #define XCL_RANGE 2
01186 #define XCL_PROP 3
01187 #define XCL_NOTPROP 4
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203 enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
01204 ESC_W, ESC_w, ESC_dum1, ESC_dum2, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
01205 ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_g, ESC_k,
01206 ESC_REF };
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216 enum {
01217 OP_END,
01218
01219
01220
01221 OP_SOD,
01222 OP_SOM,
01223 OP_SET_SOM,
01224 OP_NOT_WORD_BOUNDARY,
01225 OP_WORD_BOUNDARY,
01226 OP_NOT_DIGIT,
01227 OP_DIGIT,
01228 OP_NOT_WHITESPACE,
01229 OP_WHITESPACE,
01230 OP_NOT_WORDCHAR,
01231 OP_WORDCHAR,
01232 OP_ANY,
01233 OP_ALLANY,
01234 OP_ANYBYTE,
01235 OP_NOTPROP,
01236 OP_PROP,
01237 OP_ANYNL,
01238 OP_NOT_HSPACE,
01239 OP_HSPACE,
01240 OP_NOT_VSPACE,
01241 OP_VSPACE,
01242 OP_EXTUNI,
01243 OP_EODN,
01244 OP_EOD,
01245
01246 OP_OPT,
01247 OP_CIRC,
01248 OP_DOLL,
01249 OP_CHAR,
01250 OP_CHARNC,
01251 OP_NOT,
01252
01253 OP_STAR,
01254 OP_MINSTAR,
01255 OP_PLUS,
01256 OP_MINPLUS,
01257 OP_QUERY,
01258 OP_MINQUERY,
01259
01260 OP_UPTO,
01261 OP_MINUPTO,
01262 OP_EXACT,
01263
01264 OP_POSSTAR,
01265 OP_POSPLUS,
01266 OP_POSQUERY,
01267 OP_POSUPTO,
01268
01269 OP_NOTSTAR,
01270 OP_NOTMINSTAR,
01271 OP_NOTPLUS,
01272 OP_NOTMINPLUS,
01273 OP_NOTQUERY,
01274 OP_NOTMINQUERY,
01275
01276 OP_NOTUPTO,
01277 OP_NOTMINUPTO,
01278 OP_NOTEXACT,
01279
01280 OP_NOTPOSSTAR,
01281 OP_NOTPOSPLUS,
01282 OP_NOTPOSQUERY,
01283 OP_NOTPOSUPTO,
01284
01285 OP_TYPESTAR,
01286 OP_TYPEMINSTAR,
01287 OP_TYPEPLUS,
01288 OP_TYPEMINPLUS,
01289 OP_TYPEQUERY,
01290 OP_TYPEMINQUERY,
01291
01292 OP_TYPEUPTO,
01293 OP_TYPEMINUPTO,
01294 OP_TYPEEXACT,
01295
01296 OP_TYPEPOSSTAR,
01297 OP_TYPEPOSPLUS,
01298 OP_TYPEPOSQUERY,
01299 OP_TYPEPOSUPTO,
01300
01301 OP_CRSTAR,
01302 OP_CRMINSTAR,
01303 OP_CRPLUS,
01304 OP_CRMINPLUS,
01305 OP_CRQUERY,
01306 OP_CRMINQUERY,
01307 OP_CRRANGE,
01308 OP_CRMINRANGE,
01309
01310 OP_CLASS,
01311 OP_NCLASS,
01312
01313
01314
01315 OP_XCLASS,
01316
01317
01318 OP_REF,
01319 OP_RECURSE,
01320 OP_CALLOUT,
01321
01322 OP_ALT,
01323 OP_KET,
01324 OP_KETRMAX,
01325 OP_KETRMIN,
01326
01327
01328
01329 OP_ASSERT,
01330 OP_ASSERT_NOT,
01331 OP_ASSERTBACK,
01332 OP_ASSERTBACK_NOT,
01333 OP_REVERSE,
01334
01335
01336
01337
01338 OP_ONCE,
01339 OP_BRA,
01340 OP_CBRA,
01341 OP_COND,
01342
01343
01344
01345
01346 OP_SBRA,
01347 OP_SCBRA,
01348 OP_SCOND,
01349
01350
01351
01352 OP_CREF,
01353 OP_NCREF,
01354 OP_RREF,
01355 OP_NRREF,
01356 OP_DEF,
01357
01358 OP_BRAZERO,
01359 OP_BRAMINZERO,
01360
01361
01362
01363 OP_PRUNE,
01364 OP_SKIP,
01365 OP_THEN,
01366 OP_COMMIT,
01367
01368
01369
01370 OP_FAIL,
01371 OP_ACCEPT,
01372 OP_CLOSE,
01373
01374
01375
01376 OP_SKIPZERO
01377 };
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387 #define OP_NAME_LIST \
01388 "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \
01389 "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \
01390 "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \
01391 "extuni", "\\Z", "\\z", \
01392 "Opt", "^", "$", "char", "charnc", "not", \
01393 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
01394 "*+","++", "?+", "{", \
01395 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
01396 "*+","++", "?+", "{", \
01397 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
01398 "*+","++", "?+", "{", \
01399 "*", "*?", "+", "+?", "?", "??", "{", "{", \
01400 "class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
01401 "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
01402 "AssertB", "AssertB not", "Reverse", \
01403 "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond", \
01404 "Cond ref", "Cond nref", "Cond rec", "Cond nrec", "Cond def", \
01405 "Brazero", "Braminzero", \
01406 "*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT", \
01407 "Close", "Skip zero"
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419 #define OP_LENGTHS \
01420 1, \
01421 1, 1, 1, 1, 1, \
01422 1, 1, 1, 1, 1, 1, \
01423 1, 1, 1, \
01424 3, 3, 1, \
01425 1, 1, 1, 1, 1, \
01426 1, 1, 2, 1, 1, \
01427 2, \
01428 2, \
01429 2, \
01430 \
01431 2, 2, 2, 2, 2, 2, \
01432 4, 4, 4, \
01433 2, 2, 2, 4, \
01434 \
01435 2, 2, 2, 2, 2, 2, \
01436 4, 4, 4, \
01437 2, 2, 2, 4, \
01438 \
01439 2, 2, 2, 2, 2, 2, \
01440 4, 4, 4, \
01441 2, 2, 2, 4, \
01442 \
01443 1, 1, 1, 1, 1, 1, \
01444 5, 5, \
01445 33, \
01446 33, \
01447 0, \
01448 3, \
01449 1+LINK_SIZE, \
01450 2+2*LINK_SIZE, \
01451 1+LINK_SIZE, \
01452 1+LINK_SIZE, \
01453 1+LINK_SIZE, \
01454 1+LINK_SIZE, \
01455 1+LINK_SIZE, \
01456 1+LINK_SIZE, \
01457 1+LINK_SIZE, \
01458 1+LINK_SIZE, \
01459 1+LINK_SIZE, \
01460 1+LINK_SIZE, \
01461 1+LINK_SIZE, \
01462 3+LINK_SIZE, \
01463 1+LINK_SIZE, \
01464 1+LINK_SIZE, \
01465 3+LINK_SIZE, \
01466 1+LINK_SIZE, \
01467 3, 3, \
01468 3, 3, \
01469 1, \
01470 1, 1, \
01471 1, 1, 1, 1, \
01472 1, 1, 3, 1
01473
01474
01475
01476
01477
01478 #define RREF_ANY 0xffff
01479
01480
01481
01482
01483 enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
01484 ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,
01485 ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
01486 ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
01487 ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
01488 ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
01489 ERR60, ERR61, ERR62, ERR63, ERR64, ERR65 };
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508 typedef struct real_pcre {
01509 pcre_uint32 magic_number;
01510 pcre_uint32 size;
01511 pcre_uint32 options;
01512 pcre_uint16 flags;
01513 pcre_uint16 dummy1;
01514 pcre_uint16 top_bracket;
01515 pcre_uint16 top_backref;
01516 pcre_uint16 first_byte;
01517 pcre_uint16 req_byte;
01518 pcre_uint16 name_table_offset;
01519 pcre_uint16 name_entry_size;
01520 pcre_uint16 name_count;
01521 pcre_uint16 ref_count;
01522
01523 const unsigned char *tables;
01524 const unsigned char *nullpad;
01525 } real_pcre;
01526
01527
01528
01529
01530 typedef struct pcre_study_data {
01531 pcre_uint32 size;
01532 pcre_uint32 flags;
01533 uschar start_bits[32];
01534 pcre_uint32 minlength;
01535 } pcre_study_data;
01536
01537
01538
01539
01540
01541 typedef struct open_capitem {
01542 struct open_capitem *next;
01543 pcre_uint16 number;
01544 } open_capitem;
01545
01546
01547
01548
01549 typedef struct compile_data {
01550 const uschar *lcc;
01551 const uschar *fcc;
01552 const uschar *cbits;
01553 const uschar *ctypes;
01554 const uschar *start_workspace;
01555 const uschar *start_code;
01556 const uschar *start_pattern;
01557 const uschar *end_pattern;
01558 open_capitem *open_caps;
01559 uschar *hwm;
01560 uschar *name_table;
01561 int names_found;
01562 int name_entry_size;
01563 int bracount;
01564 int final_bracount;
01565 int top_backref;
01566 unsigned int backref_map;
01567 int external_options;
01568 int external_flags;
01569 int req_varyopt;
01570 BOOL had_accept;
01571 BOOL check_lookbehind;
01572 int nltype;
01573 int nllen;
01574 uschar nl[4];
01575 } compile_data;
01576
01577
01578
01579
01580 typedef struct branch_chain {
01581 struct branch_chain *outer;
01582 uschar *current;
01583 } branch_chain;
01584
01585
01586
01587
01588 typedef struct recursion_info {
01589 struct recursion_info *prevrec;
01590 int group_num;
01591 const uschar *after_call;
01592 USPTR save_start;
01593 int *offset_save;
01594 int saved_max;
01595 int save_offset_top;
01596 } recursion_info;
01597
01598
01599
01600
01601
01602 typedef struct eptrblock {
01603 struct eptrblock *epb_prev;
01604 USPTR epb_saved_eptr;
01605 } eptrblock;
01606
01607
01608
01609
01610
01611 typedef struct match_data {
01612 unsigned long int match_call_count;
01613 unsigned long int match_limit;
01614 unsigned long int match_limit_recursion;
01615 int *offset_vector;
01616 int offset_end;
01617 int offset_max;
01618 int nltype;
01619 int nllen;
01620 int name_count;
01621 int name_entry_size;
01622 uschar *name_table;
01623 uschar nl[4];
01624 const uschar *lcc;
01625 const uschar *ctypes;
01626 BOOL offset_overflow;
01627 BOOL notbol;
01628 BOOL noteol;
01629 BOOL utf8;
01630 BOOL jscript_compat;
01631 BOOL endonly;
01632 BOOL notempty;
01633 BOOL notempty_atstart;
01634 BOOL hitend;
01635 BOOL bsr_anycrlf;
01636 const uschar *start_code;
01637 USPTR start_subject;
01638 USPTR end_subject;
01639 USPTR start_match_ptr;
01640 USPTR end_match_ptr;
01641 USPTR start_used_ptr;
01642 int partial;
01643 int end_offset_top;
01644 int capture_last;
01645 int start_offset;
01646 eptrblock *eptrchain;
01647 int eptrn;
01648 recursion_info *recursive;
01649 void *callout_data;
01650 } match_data;
01651
01652
01653
01654
01655 typedef struct dfa_match_data {
01656 const uschar *start_code;
01657 const uschar *start_subject;
01658 const uschar *end_subject;
01659 const uschar *start_used_ptr;
01660 const uschar *tables;
01661 int start_offset;
01662 int moptions;
01663 int poptions;
01664 int nltype;
01665 int nllen;
01666 uschar nl[4];
01667 void *callout_data;
01668 } dfa_match_data;
01669
01670
01671
01672 #define ctype_space 0x01
01673 #define ctype_letter 0x02
01674 #define ctype_digit 0x04
01675 #define ctype_xdigit 0x08
01676 #define ctype_word 0x10
01677 #define ctype_meta 0x80
01678
01679
01680
01681
01682 #define cbit_space 0
01683 #define cbit_xdigit 32
01684 #define cbit_digit 64
01685 #define cbit_upper 96
01686 #define cbit_lower 128
01687 #define cbit_word 160
01688 #define cbit_graph 192
01689 #define cbit_print 224
01690 #define cbit_punct 256
01691 #define cbit_cntrl 288
01692 #define cbit_length 320
01693
01694
01695
01696
01697 #define lcc_offset 0
01698 #define fcc_offset 256
01699 #define cbits_offset 512
01700 #define ctypes_offset (cbits_offset + cbit_length)
01701 #define tables_length (ctypes_offset + 256)
01702
01703
01704
01705
01706
01707
01708 typedef struct {
01709 pcre_uint16 name_offset;
01710 pcre_uint16 type;
01711 pcre_uint16 value;
01712 } ucp_type_table;
01713
01714
01715
01716
01717
01718
01719
01720 extern const int _pcre_utf8_table1[];
01721 extern const int _pcre_utf8_table2[];
01722 extern const int _pcre_utf8_table3[];
01723 extern const uschar _pcre_utf8_table4[];
01724
01725 extern const int _pcre_utf8_table1_size;
01726
01727 extern const char _pcre_utt_names[];
01728 extern const ucp_type_table _pcre_utt[];
01729 extern const int _pcre_utt_size;
01730
01731 extern const uschar _pcre_default_tables[];
01732
01733 extern const uschar _pcre_OP_lengths[];
01734
01735
01736
01737
01738
01739
01740 extern const uschar *_pcre_find_bracket(const uschar *, BOOL, int);
01741 extern BOOL _pcre_is_newline(const uschar *, int, const uschar *,
01742 int *, BOOL);
01743 extern int _pcre_ord2utf8(int, uschar *);
01744 extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *,
01745 const pcre_study_data *, pcre_study_data *);
01746 extern int _pcre_valid_utf8(const uschar *, int);
01747 extern BOOL _pcre_was_newline(const uschar *, int, const uschar *,
01748 int *, BOOL);
01749 extern BOOL _pcre_xclass(int, const uschar *);
01750
01751
01752
01753
01754 typedef struct {
01755 uschar script;
01756 uschar chartype;
01757 pcre_int32 other_case;
01758 } ucd_record;
01759
01760 extern const ucd_record _pcre_ucd_records[];
01761 extern const uschar _pcre_ucd_stage1[];
01762 extern const pcre_uint16 _pcre_ucd_stage2[];
01763 extern const int _pcre_ucp_gentype[];
01764
01765
01766
01767
01768 #define UCD_BLOCK_SIZE 128
01769 #define GET_UCD(ch) (_pcre_ucd_records + \
01770 _pcre_ucd_stage2[_pcre_ucd_stage1[(ch) / UCD_BLOCK_SIZE] * \
01771 UCD_BLOCK_SIZE + ch % UCD_BLOCK_SIZE])
01772
01773 #define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
01774 #define UCD_SCRIPT(ch) GET_UCD(ch)->script
01775 #define UCD_CATEGORY(ch) _pcre_ucp_gentype[UCD_CHARTYPE(ch)]
01776 #define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)
01777
01778 #endif
01779
01780