Annotation of embedaddon/php/ext/mbstring/oniguruma/oniguruma.h, revision 1.1.1.1

1.1       misho       1: #ifndef ONIGURUMA_H
                      2: #define ONIGURUMA_H
                      3: /**********************************************************************
                      4:   oniguruma.h - Oniguruma (regular expression library)
                      5: **********************************************************************/
                      6: /*-
                      7:  * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
                      8:  * All rights reserved.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  */
                     31: 
                     32: #include "../php_onig_compat.h"
                     33: 
                     34: #ifdef __cplusplus
                     35: extern "C" {
                     36: #endif
                     37: 
                     38: #define ONIGURUMA
                     39: #define ONIGURUMA_VERSION_MAJOR   4
                     40: #define ONIGURUMA_VERSION_MINOR   7
                     41: #define ONIGURUMA_VERSION_TEENY   1
                     42: 
                     43: #ifdef __cplusplus
                     44: # ifndef  HAVE_PROTOTYPES
                     45: #  define HAVE_PROTOTYPES 1
                     46: # endif
                     47: # ifndef  HAVE_STDARG_PROTOTYPES
                     48: #  define HAVE_STDARG_PROTOTYPES 1
                     49: # endif
                     50: #endif
                     51: 
                     52: /* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */
                     53: #if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4
                     54: # ifndef  HAVE_STDARG_PROTOTYPES
                     55: #  define HAVE_STDARG_PROTOTYPES 1
                     56: # endif
                     57: #endif
                     58: 
                     59: #ifndef P_
                     60: #if defined(__STDC__) || defined(_WIN32)
                     61: # define P_(args) args
                     62: #else
                     63: # define P_(args) ()
                     64: #endif
                     65: #endif
                     66: 
                     67: #ifndef PV_
                     68: #ifdef HAVE_STDARG_PROTOTYPES
                     69: # define PV_(args) args
                     70: #else
                     71: # define PV_(args) ()
                     72: #endif
                     73: #endif
                     74: 
                     75: #ifndef ONIG_EXTERN
                     76: #if defined(_WIN32) && !defined(__GNUC__)
                     77: #if defined(EXPORT) || defined(RUBY_EXPORT)
                     78: #define ONIG_EXTERN   extern __declspec(dllexport)
                     79: #else
                     80: #define ONIG_EXTERN   extern __declspec(dllimport)
                     81: #endif
                     82: #endif
                     83: #endif
                     84: 
                     85: #ifndef ONIG_EXTERN
                     86: #define ONIG_EXTERN   extern
                     87: #endif
                     88: 
                     89: /* PART: character encoding */
                     90: 
                     91: #ifndef ONIG_ESCAPE_UCHAR_COLLISION
                     92: #define UChar OnigUChar
                     93: #endif
                     94: 
                     95: typedef unsigned char  OnigUChar;
                     96: typedef unsigned long  OnigCodePoint;
                     97: typedef unsigned int   OnigDistance;
                     98: 
                     99: #define ONIG_INFINITE_DISTANCE  ~((OnigDistance )0)
                    100: 
                    101: /* ambiguous match flag */
                    102: typedef unsigned int OnigAmbigType;
                    103: 
                    104: ONIG_EXTERN OnigAmbigType OnigDefaultAmbigFlag;
                    105: 
                    106: #define ONIGENC_AMBIGUOUS_MATCH_NONE                   0
                    107: #define ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE            (1<<0)
                    108: #define ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE         (1<<1)
                    109: 
                    110: #define ONIGENC_AMBIGUOUS_MATCH_LIMIT                 (1<<1)
                    111: 
                    112: #define ONIGENC_AMBIGUOUS_MATCH_FULL \
                    113:  ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE )
                    114: #define ONIGENC_AMBIGUOUS_MATCH_DEFAULT  OnigDefaultAmbigFlag
                    115: 
                    116: 
                    117: #define ONIGENC_MAX_COMP_AMBIG_CODE_LEN       3
                    118: #define ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM  4
                    119: 
                    120: /* code range */
                    121: #define ONIGENC_CODE_RANGE_NUM(range)     ((int )range[0])
                    122: #define ONIGENC_CODE_RANGE_FROM(range,i)  range[((i)*2) + 1]
                    123: #define ONIGENC_CODE_RANGE_TO(range,i)    range[((i)*2) + 2]
                    124: 
                    125: typedef struct {
                    126:   int len;
                    127:   OnigCodePoint code[ONIGENC_MAX_COMP_AMBIG_CODE_LEN];
                    128: } OnigCompAmbigCodeItem;
                    129: 
                    130: typedef struct {
                    131:   int n;
                    132:   OnigCodePoint code;
                    133:   OnigCompAmbigCodeItem items[ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM];
                    134: } OnigCompAmbigCodes;
                    135: 
                    136: typedef struct {
                    137:   OnigCodePoint from;
                    138:   OnigCodePoint to;
                    139: } OnigPairAmbigCodes;
                    140: 
                    141: typedef struct {
                    142:   OnigCodePoint esc;
                    143:   OnigCodePoint anychar;
                    144:   OnigCodePoint anytime;
                    145:   OnigCodePoint zero_or_one_time;
                    146:   OnigCodePoint one_or_more_time;
                    147:   OnigCodePoint anychar_anytime;
                    148: } OnigMetaCharTableType;
                    149: 
                    150: 
                    151: #if defined(RUBY_PLATFORM) && defined(M17N_H)
                    152: 
                    153: #define ONIG_RUBY_M17N
                    154: typedef m17n_encoding*        OnigEncoding;
                    155: 
                    156: #else
                    157: 
                    158: typedef struct {
                    159:   int    (*mbc_enc_len)(const OnigUChar* p);
                    160:   const char*   name;
                    161:   int           max_enc_len;
                    162:   int           min_enc_len;
                    163:   OnigAmbigType support_ambig_flag;
                    164:   OnigMetaCharTableType meta_char_table;
                    165:   int    (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end);
                    166:   OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end);
                    167:   int    (*code_to_mbclen)(OnigCodePoint code);
                    168:   int    (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf);
                    169:   int    (*mbc_to_normalize)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to);
                    170:   int    (*is_mbc_ambiguous)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end);
                    171:   int    (*get_all_pair_ambig_codes)(OnigAmbigType flag, const OnigPairAmbigCodes** acs);
                    172:   int    (*get_all_comp_ambig_codes)(OnigAmbigType flag, const OnigCompAmbigCodes** acs);
                    173:   int    (*is_code_ctype)(OnigCodePoint code, unsigned int ctype);
                    174:   int    (*get_ctype_code_range)(int ctype, const OnigCodePoint* sb_range[], const OnigCodePoint* mb_range[]);
                    175:   OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p);
                    176:   int    (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end);
                    177: } OnigEncodingType;
                    178: 
                    179: typedef OnigEncodingType* OnigEncoding;
                    180: 
                    181: ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
                    182: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_1;
                    183: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_2;
                    184: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_3;
                    185: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_4;
                    186: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_5;
                    187: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_6;
                    188: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_7;
                    189: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_8;
                    190: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_9;
                    191: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_10;
                    192: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_11;
                    193: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_13;
                    194: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_14;
                    195: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_15;
                    196: ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_16;
                    197: ONIG_EXTERN OnigEncodingType OnigEncodingUTF8;
                    198: ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_BE;
                    199: ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_LE;
                    200: ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_BE;
                    201: ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_LE;
                    202: ONIG_EXTERN OnigEncodingType OnigEncodingEUC_JP;
                    203: ONIG_EXTERN OnigEncodingType OnigEncodingEUC_TW;
                    204: ONIG_EXTERN OnigEncodingType OnigEncodingEUC_KR;
                    205: ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN;
                    206: ONIG_EXTERN OnigEncodingType OnigEncodingSJIS;
                    207: ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;
                    208: ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;
                    209: ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;
                    210: ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
                    211: 
                    212: #define ONIG_ENCODING_ASCII        (&OnigEncodingASCII)
                    213: #define ONIG_ENCODING_ISO_8859_1   (&OnigEncodingISO_8859_1)
                    214: #define ONIG_ENCODING_ISO_8859_2   (&OnigEncodingISO_8859_2)
                    215: #define ONIG_ENCODING_ISO_8859_3   (&OnigEncodingISO_8859_3)
                    216: #define ONIG_ENCODING_ISO_8859_4   (&OnigEncodingISO_8859_4)
                    217: #define ONIG_ENCODING_ISO_8859_5   (&OnigEncodingISO_8859_5)
                    218: #define ONIG_ENCODING_ISO_8859_6   (&OnigEncodingISO_8859_6)
                    219: #define ONIG_ENCODING_ISO_8859_7   (&OnigEncodingISO_8859_7)
                    220: #define ONIG_ENCODING_ISO_8859_8   (&OnigEncodingISO_8859_8)
                    221: #define ONIG_ENCODING_ISO_8859_9   (&OnigEncodingISO_8859_9)
                    222: #define ONIG_ENCODING_ISO_8859_10  (&OnigEncodingISO_8859_10)
                    223: #define ONIG_ENCODING_ISO_8859_11  (&OnigEncodingISO_8859_11)
                    224: #define ONIG_ENCODING_ISO_8859_13  (&OnigEncodingISO_8859_13)
                    225: #define ONIG_ENCODING_ISO_8859_14  (&OnigEncodingISO_8859_14)
                    226: #define ONIG_ENCODING_ISO_8859_15  (&OnigEncodingISO_8859_15)
                    227: #define ONIG_ENCODING_ISO_8859_16  (&OnigEncodingISO_8859_16)
                    228: #define ONIG_ENCODING_UTF8         (&OnigEncodingUTF8)
                    229: #define ONIG_ENCODING_UTF16_BE     (&OnigEncodingUTF16_BE)
                    230: #define ONIG_ENCODING_UTF16_LE     (&OnigEncodingUTF16_LE)
                    231: #define ONIG_ENCODING_UTF32_BE     (&OnigEncodingUTF32_BE)
                    232: #define ONIG_ENCODING_UTF32_LE     (&OnigEncodingUTF32_LE)
                    233: #define ONIG_ENCODING_EUC_JP       (&OnigEncodingEUC_JP)
                    234: #define ONIG_ENCODING_EUC_TW       (&OnigEncodingEUC_TW)
                    235: #define ONIG_ENCODING_EUC_KR       (&OnigEncodingEUC_KR)
                    236: #define ONIG_ENCODING_EUC_CN       (&OnigEncodingEUC_CN)
                    237: #define ONIG_ENCODING_SJIS         (&OnigEncodingSJIS)
                    238: #define ONIG_ENCODING_KOI8         (&OnigEncodingKOI8)
                    239: #define ONIG_ENCODING_KOI8_R       (&OnigEncodingKOI8_R)
                    240: #define ONIG_ENCODING_BIG5         (&OnigEncodingBIG5)
                    241: #define ONIG_ENCODING_GB18030      (&OnigEncodingGB18030)
                    242: 
                    243: #endif /* else RUBY && M17N */
                    244: 
                    245: #define ONIG_ENCODING_UNDEF    ((OnigEncoding )0)
                    246: 
                    247: 
                    248: /* work size */
                    249: #define ONIGENC_CODE_TO_MBC_MAXLEN      7
                    250: #define ONIGENC_MBC_NORMALIZE_MAXLEN    ONIGENC_CODE_TO_MBC_MAXLEN
                    251: 
                    252: /* character types */
                    253: #define ONIGENC_CTYPE_NEWLINE  (1<< 0)
                    254: #define ONIGENC_CTYPE_ALPHA    (1<< 1)
                    255: #define ONIGENC_CTYPE_BLANK    (1<< 2)
                    256: #define ONIGENC_CTYPE_CNTRL    (1<< 3)
                    257: #define ONIGENC_CTYPE_DIGIT    (1<< 4)
                    258: #define ONIGENC_CTYPE_GRAPH    (1<< 5)
                    259: #define ONIGENC_CTYPE_LOWER    (1<< 6)
                    260: #define ONIGENC_CTYPE_PRINT    (1<< 7)
                    261: #define ONIGENC_CTYPE_PUNCT    (1<< 8)
                    262: #define ONIGENC_CTYPE_SPACE    (1<< 9)
                    263: #define ONIGENC_CTYPE_UPPER    (1<<10)
                    264: #define ONIGENC_CTYPE_XDIGIT   (1<<11)
                    265: #define ONIGENC_CTYPE_WORD     (1<<12)
                    266: #define ONIGENC_CTYPE_ASCII    (1<<13)
                    267: #define ONIGENC_CTYPE_ALNUM    (ONIGENC_CTYPE_ALPHA | ONIGENC_CTYPE_DIGIT)
                    268: 
                    269: #define enc_len(enc,p)                ONIGENC_MBC_ENC_LEN(enc, p)
                    270: 
                    271: #define ONIGENC_IS_UNDEF(enc)          ((enc) == ONIG_ENCODING_UNDEF)
                    272: #define ONIGENC_IS_SINGLEBYTE(enc)     (ONIGENC_MBC_MAXLEN(enc) == 1)
                    273: #define ONIGENC_IS_MBC_HEAD(enc,p)     (ONIGENC_MBC_ENC_LEN(enc,p) != 1)
                    274: #define ONIGENC_IS_MBC_ASCII(p)           (*(p)   < 128)
                    275: #define ONIGENC_IS_CODE_ASCII(code)       ((code) < 128)
                    276: #define ONIGENC_IS_CODE_SB_WORD(enc,code) \
                    277:   (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
                    278: #define ONIGENC_IS_MBC_WORD(enc,s,end) \
                    279:    ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end))
                    280: 
                    281: 
                    282: #ifdef ONIG_RUBY_M17N
                    283: 
                    284: #include <ctype.h> /* for isblank(), isgraph() */
                    285: 
                    286: #define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \
                    287:         onigenc_mbc_to_normalize(enc,flag,pp,end,buf)
                    288: #define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \
                    289:         onigenc_is_mbc_ambiguous(enc,flag,pp,end)
                    290: 
                    291: #define ONIGENC_SUPPORT_AMBIG_FLAG(enc)     ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE
                    292: #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
                    293:         onigenc_is_allowed_reverse_match(enc, s, end)
                    294: #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
                    295:         onigenc_get_left_adjust_char_head(enc, start, s)
                    296: #define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc, ambig_flag, acs)    0
                    297: #define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc, ambig_flag, acs)    0
                    298: #define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \
                    299:         ONIG_NO_SUPPORT_CONFIG
                    300: #define ONIGENC_MBC_ENC_LEN(enc,p)            m17n_mbclen(enc,(int )(*p))
                    301: #define ONIGENC_MBC_MAXLEN(enc)               m17n_mbmaxlen(enc)
                    302: #define ONIGENC_MBC_MAXLEN_DIST(enc) \
                    303:     (ONIGENC_MBC_MAXLEN(enc) > 0 ? ONIGENC_MBC_MAXLEN(enc) \
                    304:                                  : ONIG_INFINITE_DISTANCE)
                    305: #define ONIGENC_MBC_MINLEN(enc)            1
                    306: #define ONIGENC_MBC_TO_CODE(enc,p,e)       m17n_codepoint((enc),(p),(e))
                    307: #define ONIGENC_CODE_TO_MBCLEN(enc,code)   m17n_codelen((enc),(code))
                    308: #define ONIGENC_CODE_TO_MBC(enc,code,buf)  onigenc_code_to_mbc(enc, code, buf)
                    309: 
                    310: #if 0     /* !! not supported !! */
                    311: #define ONIGENC_IS_MBC_NEWLINE(enc,p,end)
                    312: #define ONIGENC_STEP_BACK(enc,start,s,n)
                    313: #endif
                    314: 
                    315: #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) \
                    316:         onigenc_is_code_ctype(enc,code,ctype)
                    317: 
                    318: #ifdef isblank
                    319: # define ONIGENC_IS_CODE_BLANK(enc,code) isblank((int )code)
                    320: #else
                    321: # define ONIGENC_IS_CODE_BLANK(enc,code) ((code) == ' ' || (code) == '\t')
                    322: #endif
                    323: #ifdef isgraph
                    324: # define ONIGENC_IS_CODE_GRAPH(enc,code) isgraph((int )code)
                    325: #else
                    326: # define ONIGENC_IS_CODE_GRAPH(enc,code) \
                    327:   (isprint((int )code) && !isspace((int )code))
                    328: #endif
                    329: 
                    330: #define ONIGENC_IS_CODE_PRINT(enc,code)     m17n_isprint(enc,code)
                    331: #define ONIGENC_IS_CODE_ALNUM(enc,code)     m17n_isalnum(enc,code)
                    332: #define ONIGENC_IS_CODE_ALPHA(enc,code)     m17n_isalpha(enc,code)
                    333: #define ONIGENC_IS_CODE_LOWER(enc,code)     m17n_islower(enc,code)
                    334: #define ONIGENC_IS_CODE_UPPER(enc,code)     m17n_isupper(enc,code)
                    335: #define ONIGENC_IS_CODE_CNTRL(enc,code)     m17n_iscntrl(enc,code)
                    336: #define ONIGENC_IS_CODE_PUNCT(enc,code)     m17n_ispunct(enc,code)
                    337: #define ONIGENC_IS_CODE_SPACE(enc,code)     m17n_isspace(enc,code)
                    338: #define ONIGENC_IS_CODE_DIGIT(enc,code)     m17n_isdigit(enc,code)
                    339: #define ONIGENC_IS_CODE_XDIGIT(enc,code)    m17n_isxdigit(enc,code)
                    340: #define ONIGENC_IS_CODE_WORD(enc,code)      m17n_iswchar(enc,code)
                    341: 
                    342: ONIG_EXTERN
                    343: int onigenc_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, int ctype));
                    344: ONIG_EXTERN
                    345: int onigenc_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, OnigUChar *buf));
                    346: ONIG_EXTERN
                    347: int onigenc_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* buf));
                    348: ONIG_EXTERN
                    349: int onigenc_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end));
                    350: ONIG_EXTERN
                    351: int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, const OnigUChar* end));
                    352: 
                    353: #else  /* ONIG_RUBY_M17N */
                    354: 
                    355: #define ONIGENC_NAME(enc)                      ((enc)->name)
                    356: 
                    357: #define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \
                    358:   (enc)->mbc_to_normalize(flag,(const OnigUChar** )pp,end,buf)
                    359: #define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \
                    360:   (enc)->is_mbc_ambiguous(flag,(const OnigUChar** )pp,end)
                    361: #define ONIGENC_SUPPORT_AMBIG_FLAG(enc)        ((enc)->support_ambig_flag)
                    362: #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
                    363:         (enc)->is_allowed_reverse_match(s,end)
                    364: #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
                    365:         (enc)->left_adjust_char_head(start, s)
                    366: #define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc,ambig_flag,acs) \
                    367:         (enc)->get_all_pair_ambig_codes(ambig_flag,acs)
                    368: #define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc,ambig_flag,acs) \
                    369:         (enc)->get_all_comp_ambig_codes(ambig_flag,acs)
                    370: #define ONIGENC_STEP_BACK(enc,start,s,n) \
                    371:         onigenc_step_back((enc),(start),(s),(n))
                    372: 
                    373: #define ONIGENC_MBC_ENC_LEN(enc,p)             (enc)->mbc_enc_len(p)
                    374: #define ONIGENC_MBC_MAXLEN(enc)               ((enc)->max_enc_len)
                    375: #define ONIGENC_MBC_MAXLEN_DIST(enc)           ONIGENC_MBC_MAXLEN(enc)
                    376: #define ONIGENC_MBC_MINLEN(enc)               ((enc)->min_enc_len)
                    377: #define ONIGENC_IS_MBC_NEWLINE(enc,p,end)      (enc)->is_mbc_newline((p),(end))
                    378: #define ONIGENC_MBC_TO_CODE(enc,p,end)         (enc)->mbc_to_code((p),(end))
                    379: #define ONIGENC_CODE_TO_MBCLEN(enc,code)       (enc)->code_to_mbclen(code)
                    380: #define ONIGENC_CODE_TO_MBC(enc,code,buf)      (enc)->code_to_mbc(code,buf)
                    381: 
                    382: #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype)  (enc)->is_code_ctype(code,ctype)
                    383: 
                    384: #define ONIGENC_IS_CODE_NEWLINE(enc,code) \
                    385:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_NEWLINE)
                    386: #define ONIGENC_IS_CODE_GRAPH(enc,code) \
                    387:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_GRAPH)
                    388: #define ONIGENC_IS_CODE_PRINT(enc,code) \
                    389:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PRINT)
                    390: #define ONIGENC_IS_CODE_ALNUM(enc,code) \
                    391:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALNUM)
                    392: #define ONIGENC_IS_CODE_ALPHA(enc,code) \
                    393:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALPHA)
                    394: #define ONIGENC_IS_CODE_LOWER(enc,code) \
                    395:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_LOWER)
                    396: #define ONIGENC_IS_CODE_UPPER(enc,code) \
                    397:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_UPPER)
                    398: #define ONIGENC_IS_CODE_CNTRL(enc,code) \
                    399:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_CNTRL)
                    400: #define ONIGENC_IS_CODE_PUNCT(enc,code) \
                    401:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PUNCT)
                    402: #define ONIGENC_IS_CODE_SPACE(enc,code) \
                    403:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_SPACE)
                    404: #define ONIGENC_IS_CODE_BLANK(enc,code) \
                    405:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_BLANK)
                    406: #define ONIGENC_IS_CODE_DIGIT(enc,code) \
                    407:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT)
                    408: #define ONIGENC_IS_CODE_XDIGIT(enc,code) \
                    409:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_XDIGIT)
                    410: #define ONIGENC_IS_CODE_WORD(enc,code) \
                    411:         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD)
                    412: 
                    413: #define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \
                    414:         (enc)->get_ctype_code_range(ctype,sbr,mbr)
                    415: 
                    416: ONIG_EXTERN
                    417: OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));
                    418: 
                    419: #endif /* is not ONIG_RUBY_M17N */
                    420: 
                    421: 
                    422: /* encoding API */
                    423: ONIG_EXTERN
                    424: int onigenc_init P_((void));
                    425: ONIG_EXTERN
                    426: int onigenc_set_default_encoding P_((OnigEncoding enc));
                    427: ONIG_EXTERN
                    428: OnigEncoding onigenc_get_default_encoding P_((void));
                    429: ONIG_EXTERN
                    430: void  onigenc_set_default_caseconv_table P_((const OnigUChar* table));
                    431: ONIG_EXTERN
                    432: OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));
                    433: ONIG_EXTERN
                    434: OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
                    435: ONIG_EXTERN
                    436: OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
                    437: ONIG_EXTERN
                    438: OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
                    439: ONIG_EXTERN
                    440: int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
                    441: ONIG_EXTERN
                    442: int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));
                    443: ONIG_EXTERN
                    444: int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
                    445: 
                    446: 
                    447: 
                    448: /* PART: regular expression */
                    449: 
                    450: /* config parameters */
                    451: #define ONIG_NREGION                          10
                    452: #define ONIG_MAX_BACKREF_NUM                1000
                    453: #define ONIG_MAX_REPEAT_NUM               100000
                    454: #define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
                    455: /* constants */
                    456: #define ONIG_MAX_ERROR_MESSAGE_LEN            90
                    457: 
                    458: typedef unsigned int        OnigOptionType;
                    459: 
                    460: #define ONIG_OPTION_DEFAULT            ONIG_OPTION_NONE
                    461: 
                    462: /* options */
                    463: #define ONIG_OPTION_NONE                 0U
                    464: #define ONIG_OPTION_IGNORECASE           1U
                    465: #define ONIG_OPTION_EXTEND               (ONIG_OPTION_IGNORECASE         << 1)
                    466: #define ONIG_OPTION_MULTILINE            (ONIG_OPTION_EXTEND             << 1)
                    467: #define ONIG_OPTION_SINGLELINE           (ONIG_OPTION_MULTILINE          << 1)
                    468: #define ONIG_OPTION_FIND_LONGEST         (ONIG_OPTION_SINGLELINE         << 1)
                    469: #define ONIG_OPTION_FIND_NOT_EMPTY       (ONIG_OPTION_FIND_LONGEST       << 1)
                    470: #define ONIG_OPTION_NEGATE_SINGLELINE    (ONIG_OPTION_FIND_NOT_EMPTY     << 1)
                    471: #define ONIG_OPTION_DONT_CAPTURE_GROUP   (ONIG_OPTION_NEGATE_SINGLELINE  << 1)
                    472: #define ONIG_OPTION_CAPTURE_GROUP        (ONIG_OPTION_DONT_CAPTURE_GROUP << 1)
                    473: /* options (search time) */
                    474: #define ONIG_OPTION_NOTBOL               (ONIG_OPTION_CAPTURE_GROUP << 1)
                    475: #define ONIG_OPTION_NOTEOL               (ONIG_OPTION_NOTBOL << 1)
                    476: #define ONIG_OPTION_POSIX_REGION         (ONIG_OPTION_NOTEOL << 1)
                    477: #define ONIG_OPTION_MAXBIT               ONIG_OPTION_POSIX_REGION  /* limit */
                    478: 
                    479: #define ONIG_OPTION_ON(options,regopt)      ((options) |= (regopt))
                    480: #define ONIG_OPTION_OFF(options,regopt)     ((options) &= ~(regopt))
                    481: #define ONIG_IS_OPTION_ON(options,option)   ((options) & (option))
                    482: 
                    483: /* syntax */
                    484: typedef struct {
                    485:   unsigned int  op;
                    486:   unsigned int  op2;
                    487:   unsigned int  behavior;
                    488:   OnigOptionType options;    /* default option */
                    489: } OnigSyntaxType;
                    490: 
                    491: ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;
                    492: ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
                    493: ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
                    494: ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
                    495: ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
                    496: ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
                    497: ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
                    498: ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
                    499: ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl_NG;
                    500: ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
                    501: 
                    502: /* predefined syntaxes (see regsyntax.c) */
                    503: #define ONIG_SYNTAX_ASIS               (&OnigSyntaxASIS)
                    504: #define ONIG_SYNTAX_POSIX_BASIC        (&OnigSyntaxPosixBasic)
                    505: #define ONIG_SYNTAX_POSIX_EXTENDED     (&OnigSyntaxPosixExtended)
                    506: #define ONIG_SYNTAX_EMACS              (&OnigSyntaxEmacs)
                    507: #define ONIG_SYNTAX_GREP               (&OnigSyntaxGrep)
                    508: #define ONIG_SYNTAX_GNU_REGEX          (&OnigSyntaxGnuRegex)
                    509: #define ONIG_SYNTAX_JAVA               (&OnigSyntaxJava)
                    510: #define ONIG_SYNTAX_PERL               (&OnigSyntaxPerl)
                    511: #define ONIG_SYNTAX_PERL_NG            (&OnigSyntaxPerl_NG)
                    512: #define ONIG_SYNTAX_RUBY               (&OnigSyntaxRuby)
                    513: 
                    514: /* default syntax */
                    515: ONIG_EXTERN OnigSyntaxType*   OnigDefaultSyntax;
                    516: #define ONIG_SYNTAX_DEFAULT   OnigDefaultSyntax
                    517: 
                    518: /* syntax (operators) */
                    519: #define ONIG_SYN_OP_VARIABLE_META_CHARACTERS    (1U<<0)
                    520: #define ONIG_SYN_OP_DOT_ANYCHAR                 (1U<<1)   /* . */
                    521: #define ONIG_SYN_OP_ASTERISK_ZERO_INF           (1U<<2)   /* * */
                    522: #define ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF       (1U<<3)
                    523: #define ONIG_SYN_OP_PLUS_ONE_INF                (1U<<4)   /* + */
                    524: #define ONIG_SYN_OP_ESC_PLUS_ONE_INF            (1U<<5)
                    525: #define ONIG_SYN_OP_QMARK_ZERO_ONE              (1U<<6)   /* ? */
                    526: #define ONIG_SYN_OP_ESC_QMARK_ZERO_ONE          (1U<<7)
                    527: #define ONIG_SYN_OP_BRACE_INTERVAL              (1U<<8)   /* {lower,upper} */
                    528: #define ONIG_SYN_OP_ESC_BRACE_INTERVAL          (1U<<9)   /* \{lower,upper\} */
                    529: #define ONIG_SYN_OP_VBAR_ALT                    (1U<<10)   /* | */
                    530: #define ONIG_SYN_OP_ESC_VBAR_ALT                (1U<<11)  /* \| */
                    531: #define ONIG_SYN_OP_LPAREN_SUBEXP               (1U<<12)  /* (...)   */
                    532: #define ONIG_SYN_OP_ESC_LPAREN_SUBEXP           (1U<<13)  /* \(...\) */
                    533: #define ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR           (1U<<14)  /* \A, \Z, \z */
                    534: #define ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR  (1U<<15)  /* \G     */
                    535: #define ONIG_SYN_OP_DECIMAL_BACKREF             (1U<<16)  /* \num   */
                    536: #define ONIG_SYN_OP_BRACKET_CC                  (1U<<17)  /* [...]  */
                    537: #define ONIG_SYN_OP_ESC_W_WORD                  (1U<<18)  /* \w, \W */
                    538: #define ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END     (1U<<19)  /* \<. \> */
                    539: #define ONIG_SYN_OP_ESC_B_WORD_BOUND            (1U<<20)  /* \b, \B */
                    540: #define ONIG_SYN_OP_ESC_S_WHITE_SPACE           (1U<<21)  /* \s, \S */
                    541: #define ONIG_SYN_OP_ESC_D_DIGIT                 (1U<<22)  /* \d, \D */
                    542: #define ONIG_SYN_OP_LINE_ANCHOR                 (1U<<23)  /* ^, $   */
                    543: #define ONIG_SYN_OP_POSIX_BRACKET               (1U<<24)  /* [:xxxx:] */
                    544: #define ONIG_SYN_OP_QMARK_NON_GREEDY            (1U<<25)  /* ??,*?,+?,{n,m}? */
                    545: #define ONIG_SYN_OP_ESC_CONTROL_CHARS           (1U<<26)  /* \n,\r,\t,\a ... */
                    546: #define ONIG_SYN_OP_ESC_C_CONTROL               (1U<<27)  /* \cx  */
                    547: #define ONIG_SYN_OP_ESC_OCTAL3                  (1U<<28)  /* \OOO */
                    548: #define ONIG_SYN_OP_ESC_X_HEX2                  (1U<<29)  /* \xHH */
                    549: #define ONIG_SYN_OP_ESC_X_BRACE_HEX8            (1U<<30)  /* \x{7HHHHHHH} */
                    550: 
                    551: #define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE        (1U<<0)  /* \Q...\E */
                    552: #define ONIG_SYN_OP2_QMARK_GROUP_EFFECT         (1U<<1)  /* (?...) */
                    553: #define ONIG_SYN_OP2_OPTION_PERL                (1U<<2)  /* (?imsx),(?-imsx) */
                    554: #define ONIG_SYN_OP2_OPTION_RUBY                (1U<<3)  /* (?imx), (?-imx)  */
                    555: #define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT     (1U<<4)  /* ?+,*+,++ */
                    556: #define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL   (1U<<5)  /* {n,m}+   */
                    557: #define ONIG_SYN_OP2_CCLASS_SET_OP              (1U<<6)  /* [...&&..[..]..] */
                    558: #define ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP       (1U<<7)  /* (?<name>...) */
                    559: #define ONIG_SYN_OP2_ESC_K_NAMED_BACKREF        (1U<<8)  /* \k<name> */
                    560: #define ONIG_SYN_OP2_ESC_G_SUBEXP_CALL          (1U<<9)  /* \g<name>, \g<n> */
                    561: #define ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY     (1U<<10) /* (?@..),(?@<x>..) */
                    562: #define ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL  (1U<<11) /* \C-x */
                    563: #define ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META     (1U<<12) /* \M-x */
                    564: #define ONIG_SYN_OP2_ESC_V_VTAB                 (1U<<13) /* \v as VTAB */
                    565: #define ONIG_SYN_OP2_ESC_U_HEX4                 (1U<<14) /* \uHHHH */
                    566: #define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR         (1U<<15) /* \`, \' */
                    567: #define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  (1U<<16) /* \p{...}, \P{...} */
                    568: #define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */
                    569: #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS    (1U<<18) /* \p{IsXDigit} */
                    570: #define ONIG_SYN_OP2_ESC_H_XDIGIT               (1U<<19) /* \h, \H */
                    571: #define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE         (1U<<20) /* \ */
                    572: 
                    573: /* syntax (behavior) */
                    574: #define ONIG_SYN_CONTEXT_INDEP_ANCHORS           (1U<<31) /* not implemented */
                    575: #define ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS        (1U<<0)  /* ?, *, +, {n,m} */
                    576: #define ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS      (1U<<1)  /* error or ignore */
                    577: #define ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP    (1U<<2)  /* ...)... */
                    578: #define ONIG_SYN_ALLOW_INVALID_INTERVAL          (1U<<3)  /* {??? */
                    579: #define ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV       (1U<<4)  /* {,n} => {0,n} */
                    580: #define ONIG_SYN_STRICT_CHECK_BACKREF            (1U<<5)  /* /(\1)/,/\1()/ ..*/
                    581: #define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND   (1U<<6)  /* (?<=a|bc) */
                    582: #define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP        (1U<<7)  /* see doc/RE */
                    583: #define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME (1U<<8)  /* (?<x>)(?<x>) */
                    584: #define ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY   (1U<<9)  /* a{n}?=(?:a{n})? */
                    585: 
                    586: /* syntax (behavior) in char class [...] */
                    587: #define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC      (1U<<20) /* [^...] */
                    588: #define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC          (1U<<21) /* [..\w..] etc.. */
                    589: #define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC         (1U<<22)
                    590: #define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC     (1U<<23) /* [0-9-a]=[0-9\-a] */
                    591: /* syntax (behavior) warning */
                    592: #define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED          (1U<<24) /* [,-,] */
                    593: #define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT    (1U<<25) /* (?:a*)+ */
                    594: 
                    595: /* meta character specifiers (onig_set_meta_char()) */
                    596: #define ONIG_META_CHAR_ESCAPE               0
                    597: #define ONIG_META_CHAR_ANYCHAR              1
                    598: #define ONIG_META_CHAR_ANYTIME              2
                    599: #define ONIG_META_CHAR_ZERO_OR_ONE_TIME     3
                    600: #define ONIG_META_CHAR_ONE_OR_MORE_TIME     4
                    601: #define ONIG_META_CHAR_ANYCHAR_ANYTIME      5
                    602: 
                    603: #define ONIG_INEFFECTIVE_META_CHAR          0
                    604: 
                    605: /* error codes */
                    606: #define ONIG_IS_PATTERN_ERROR(ecode)   ((ecode) <= -100 && (ecode) > -1000)
                    607: /* normal return */
                    608: #define ONIG_NORMAL                                            0
                    609: #define ONIG_MISMATCH                                         -1
                    610: #define ONIG_NO_SUPPORT_CONFIG                                -2
                    611: 
                    612: /* internal error */
                    613: #define ONIGERR_MEMORY                                         -5
                    614: #define ONIGERR_TYPE_BUG                                       -6
                    615: #define ONIGERR_PARSER_BUG                                    -11
                    616: #define ONIGERR_STACK_BUG                                     -12
                    617: #define ONIGERR_UNDEFINED_BYTECODE                            -13
                    618: #define ONIGERR_UNEXPECTED_BYTECODE                           -14
                    619: #define ONIGERR_MATCH_STACK_LIMIT_OVER                        -15
                    620: #define ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED                -21
                    621: #define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR  -22
                    622: /* general error */
                    623: #define ONIGERR_INVALID_ARGUMENT                              -30 
                    624: /* syntax error */
                    625: #define ONIGERR_END_PATTERN_AT_LEFT_BRACE                    -100
                    626: #define ONIGERR_END_PATTERN_AT_LEFT_BRACKET                  -101
                    627: #define ONIGERR_EMPTY_CHAR_CLASS                             -102
                    628: #define ONIGERR_PREMATURE_END_OF_CHAR_CLASS                  -103
                    629: #define ONIGERR_END_PATTERN_AT_ESCAPE                        -104
                    630: #define ONIGERR_END_PATTERN_AT_META                          -105
                    631: #define ONIGERR_END_PATTERN_AT_CONTROL                       -106
                    632: #define ONIGERR_META_CODE_SYNTAX                             -108
                    633: #define ONIGERR_CONTROL_CODE_SYNTAX                          -109
                    634: #define ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE             -110
                    635: #define ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE           -111
                    636: #define ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS      -112
                    637: #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED      -113
                    638: #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID            -114
                    639: #define ONIGERR_NESTED_REPEAT_OPERATOR                       -115
                    640: #define ONIGERR_UNMATCHED_CLOSE_PARENTHESIS                  -116
                    641: #define ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS       -117
                    642: #define ONIGERR_END_PATTERN_IN_GROUP                         -118
                    643: #define ONIGERR_UNDEFINED_GROUP_OPTION                       -119
                    644: #define ONIGERR_INVALID_POSIX_BRACKET_TYPE                   -121
                    645: #define ONIGERR_INVALID_LOOK_BEHIND_PATTERN                  -122
                    646: #define ONIGERR_INVALID_REPEAT_RANGE_PATTERN                 -123
                    647: /* values error (syntax error) */
                    648: #define ONIGERR_TOO_BIG_NUMBER                               -200
                    649: #define ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE              -201
                    650: #define ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE     -202
                    651: #define ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS                    -203
                    652: #define ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE          -204
                    653: #define ONIGERR_TOO_MANY_MULTI_BYTE_RANGES                   -205
                    654: #define ONIGERR_TOO_SHORT_MULTI_BYTE_STRING                  -206
                    655: #define ONIGERR_TOO_BIG_BACKREF_NUMBER                       -207
                    656: #define ONIGERR_INVALID_BACKREF                              -208
                    657: #define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED         -209
                    658: #define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE                     -212
                    659: #define ONIGERR_EMPTY_GROUP_NAME                             -214
                    660: #define ONIGERR_INVALID_GROUP_NAME                           -215
                    661: #define ONIGERR_INVALID_CHAR_IN_GROUP_NAME                   -216
                    662: #define ONIGERR_UNDEFINED_NAME_REFERENCE                     -217
                    663: #define ONIGERR_UNDEFINED_GROUP_REFERENCE                    -218
                    664: #define ONIGERR_MULTIPLEX_DEFINED_NAME                       -219
                    665: #define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL               -220
                    666: #define ONIGERR_NEVER_ENDING_RECURSION                       -221
                    667: #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY        -222
                    668: #define ONIGERR_INVALID_CHAR_PROPERTY_NAME                   -223
                    669: #define ONIGERR_INVALID_WIDE_CHAR_VALUE                      -400
                    670: #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
                    671: #define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION           -402
                    672: #define ONIGERR_INVALID_COMBINATION_OF_OPTIONS               -403
                    673: 
                    674: /* errors related to thread */
                    675: #define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT                -1001
                    676: 
                    677: 
                    678: /* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */
                    679: #define ONIG_MAX_CAPTURE_HISTORY_GROUP   31
                    680: #define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \
                    681:   ((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])
                    682: 
                    683: typedef struct OnigCaptureTreeNodeStruct {
                    684:   int group;   /* group number */
                    685:   int beg;
                    686:   int end;
                    687:   int allocated;
                    688:   int num_childs;
                    689:   struct OnigCaptureTreeNodeStruct** childs;
                    690: } OnigCaptureTreeNode;
                    691: 
                    692: /* match result region type */
                    693: struct re_registers {
                    694:   int  allocated;
                    695:   int  num_regs;
                    696:   int* beg;
                    697:   int* end;
                    698:   /* extended */
                    699:   OnigCaptureTreeNode* history_root;  /* capture history tree root */
                    700: };
                    701: 
                    702: /* capture tree traverse */
                    703: #define ONIG_TRAVERSE_CALLBACK_AT_FIRST   1
                    704: #define ONIG_TRAVERSE_CALLBACK_AT_LAST    2
                    705: #define ONIG_TRAVERSE_CALLBACK_AT_BOTH \
                    706:   ( ONIG_TRAVERSE_CALLBACK_AT_FIRST | ONIG_TRAVERSE_CALLBACK_AT_LAST )
                    707: 
                    708: 
                    709: #define ONIG_REGION_NOTPOS            -1
                    710: 
                    711: typedef struct re_registers   OnigRegion;
                    712: 
                    713: typedef struct {
                    714:   OnigEncoding enc;
                    715:   OnigUChar* par;
                    716:   OnigUChar* par_end;
                    717: } OnigErrorInfo;
                    718: 
                    719: typedef struct {
                    720:   int lower;
                    721:   int upper;
                    722: } OnigRepeatRange;
                    723: 
                    724: typedef void (*OnigWarnFunc) P_((const char* s));
                    725: extern void onig_null_warn P_((const char* s));
                    726: #define ONIG_NULL_WARN       onig_null_warn
                    727: 
                    728: #define ONIG_CHAR_TABLE_SIZE   256
                    729: 
                    730: /* regex_t state */
                    731: #define ONIG_STATE_NORMAL              0
                    732: #define ONIG_STATE_SEARCHING           1
                    733: #define ONIG_STATE_COMPILING          -1
                    734: #define ONIG_STATE_MODIFY             -2
                    735: 
                    736: #define ONIG_STATE(reg) \
                    737:   ((reg)->state > 0 ? ONIG_STATE_SEARCHING : (reg)->state)
                    738: 
                    739: typedef struct re_pattern_buffer {
                    740:   /* common members of BBuf(bytes-buffer) */
                    741:   unsigned char* p;         /* compiled pattern */
                    742:   unsigned int used;        /* used space for p */
                    743:   unsigned int alloc;       /* allocated space for p */
                    744: 
                    745:   int state;                     /* normal, searching, compiling */
                    746:   int num_mem;                   /* used memory(...) num counted from 1 */
                    747:   int num_repeat;                /* OP_REPEAT/OP_REPEAT_NG id-counter */
                    748:   int num_null_check;            /* OP_NULL_CHECK_START/END id counter */
                    749:   int num_comb_exp_check;        /* combination explosion check */
                    750:   int num_call;                  /* number of subexp call */
                    751:   unsigned int capture_history;  /* (?@...) flag (1-31) */
                    752:   unsigned int bt_mem_start;     /* need backtrack flag */
                    753:   unsigned int bt_mem_end;       /* need backtrack flag */
                    754:   int stack_pop_level;
                    755:   int repeat_range_alloc;
                    756:   OnigRepeatRange* repeat_range;
                    757: 
                    758:   OnigEncoding  enc;
                    759:   OnigOptionType    options;
                    760:   OnigSyntaxType*   syntax;
                    761:   OnigAmbigType     ambig_flag;
                    762:   void*             name_table;
                    763: 
                    764:   /* optimization info (string search, char-map and anchors) */
                    765:   int            optimize;          /* optimize flag */
                    766:   int            threshold_len;     /* search str-length for apply optimize */
                    767:   int            anchor;            /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */
                    768:   OnigDistance   anchor_dmin;       /* (SEMI_)END_BUF anchor distance */
                    769:   OnigDistance   anchor_dmax;       /* (SEMI_)END_BUF anchor distance */
                    770:   int            sub_anchor;        /* start-anchor for exact or map */
                    771:   unsigned char *exact;
                    772:   unsigned char *exact_end;
                    773:   unsigned char  map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
                    774:   int           *int_map;                   /* BM skip for exact_len > 255 */
                    775:   int           *int_map_backward;          /* BM skip for backward search */
                    776:   OnigDistance   dmin;                      /* min-distance of exact or map */
                    777:   OnigDistance   dmax;                      /* max-distance of exact or map */
                    778: 
                    779:   /* regex_t link chain */
                    780:   struct re_pattern_buffer* chain;  /* escape compile-conflict */
                    781: } OnigRegexType;
                    782: 
                    783: typedef OnigRegexType*  OnigRegex;
                    784: 
                    785: #ifndef ONIG_ESCAPE_REGEX_T_COLLISION
                    786:   typedef OnigRegexType  regex_t;
                    787: #endif
                    788: 
                    789: 
                    790: typedef struct {
                    791:   int             num_of_elements;
                    792:   OnigEncoding    pattern_enc;
                    793:   OnigEncoding    target_enc;
                    794:   OnigSyntaxType* syntax;
                    795:   OnigOptionType  option;
                    796:   OnigAmbigType   ambig_flag;
                    797: } OnigCompileInfo;
                    798: 
                    799: /* Oniguruma Native API */
                    800: ONIG_EXTERN
                    801: int onig_init P_((void));
                    802: ONIG_EXTERN
                    803: int onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...));
                    804: ONIG_EXTERN
                    805: void onig_set_warn_func P_((OnigWarnFunc f));
                    806: ONIG_EXTERN
                    807: void onig_set_verb_warn_func P_((OnigWarnFunc f));
                    808: ONIG_EXTERN
                    809: int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
                    810: ONIG_EXTERN
                    811: int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
                    812: ONIG_EXTERN
                    813: void onig_free P_((OnigRegex));
                    814: ONIG_EXTERN
                    815: int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
                    816: ONIG_EXTERN
                    817: int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
                    818: ONIG_EXTERN
                    819: int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
                    820: ONIG_EXTERN
                    821: int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));
                    822: ONIG_EXTERN
                    823: OnigRegion* onig_region_new P_((void));
                    824: ONIG_EXTERN
                    825: void onig_region_init P_((OnigRegion* region));
                    826: ONIG_EXTERN
                    827: void onig_region_free P_((OnigRegion* region, int free_self));
                    828: ONIG_EXTERN
                    829: void onig_region_copy P_((OnigRegion* to, OnigRegion* from));
                    830: ONIG_EXTERN
                    831: void onig_region_clear P_((OnigRegion* region));
                    832: ONIG_EXTERN
                    833: int onig_region_resize P_((OnigRegion* region, int n));
                    834: ONIG_EXTERN
                    835: int onig_region_set P_((OnigRegion* region, int at, int beg, int end));
                    836: ONIG_EXTERN
                    837: int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));
                    838: ONIG_EXTERN
                    839: int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));
                    840: ONIG_EXTERN
                    841: int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));
                    842: ONIG_EXTERN
                    843: int onig_number_of_names P_((OnigRegex reg));
                    844: ONIG_EXTERN
                    845: int onig_number_of_captures P_((OnigRegex reg));
                    846: ONIG_EXTERN
                    847: int onig_number_of_capture_histories P_((OnigRegex reg));
                    848: ONIG_EXTERN
                    849: OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));
                    850: ONIG_EXTERN
                    851: int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,int,int,int,int,void*), void* arg));
                    852: ONIG_EXTERN
                    853: int onig_noname_group_capture_is_active P_((OnigRegex reg));
                    854: ONIG_EXTERN
                    855: OnigEncoding onig_get_encoding P_((OnigRegex reg));
                    856: ONIG_EXTERN
                    857: OnigOptionType onig_get_options P_((OnigRegex reg));
                    858: ONIG_EXTERN
                    859: OnigAmbigType onig_get_ambig_flag P_((OnigRegex reg));
                    860: ONIG_EXTERN
                    861: OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));
                    862: ONIG_EXTERN
                    863: int onig_set_default_syntax P_((OnigSyntaxType* syntax));
                    864: ONIG_EXTERN
                    865: void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
                    866: ONIG_EXTERN
                    867: unsigned int onig_get_syntax_op P_((OnigSyntaxType* syntax));
                    868: ONIG_EXTERN
                    869: unsigned int onig_get_syntax_op2 P_((OnigSyntaxType* syntax));
                    870: ONIG_EXTERN
                    871: unsigned int onig_get_syntax_behavior P_((OnigSyntaxType* syntax));
                    872: ONIG_EXTERN
                    873: OnigOptionType onig_get_syntax_options P_((OnigSyntaxType* syntax));
                    874: ONIG_EXTERN
                    875: void onig_set_syntax_op P_((OnigSyntaxType* syntax, unsigned int op));
                    876: ONIG_EXTERN
                    877: void onig_set_syntax_op2 P_((OnigSyntaxType* syntax, unsigned int op2));
                    878: ONIG_EXTERN
                    879: void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior));
                    880: ONIG_EXTERN
                    881: void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options));
                    882: ONIG_EXTERN
                    883: int onig_set_meta_char P_((OnigEncoding enc, unsigned int what, OnigCodePoint code));
                    884: ONIG_EXTERN
                    885: void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));
                    886: ONIG_EXTERN
                    887: OnigAmbigType onig_get_default_ambig_flag P_((void));
                    888: ONIG_EXTERN
                    889: int onig_set_default_ambig_flag P_((OnigAmbigType ambig_flag));
                    890: ONIG_EXTERN
                    891: unsigned int onig_get_match_stack_limit_size P_((void));
                    892: ONIG_EXTERN
                    893: int onig_set_match_stack_limit_size P_((unsigned int size));
                    894: ONIG_EXTERN
                    895: int onig_end P_((void));
                    896: ONIG_EXTERN
                    897: const char* onig_version P_((void));
                    898: ONIG_EXTERN
                    899: const char* onig_copyright P_((void));
                    900: 
                    901: #ifdef __cplusplus
                    902: }
                    903: #endif
                    904: 
                    905: #endif /* ONIGURUMA_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>