Back to index

php5  5.3.10
oniguruma.h
Go to the documentation of this file.
00001 #ifndef ONIGURUMA_H
00002 #define ONIGURUMA_H
00003 /**********************************************************************
00004   oniguruma.h - Oniguruma (regular expression library)
00005 **********************************************************************/
00006 /*-
00007  * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00020  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00023  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00025  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00028  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  */
00031 
00032 #include "../php_onig_compat.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 #define ONIGURUMA
00039 #define ONIGURUMA_VERSION_MAJOR   4
00040 #define ONIGURUMA_VERSION_MINOR   7
00041 #define ONIGURUMA_VERSION_TEENY   1
00042 
00043 #ifdef __cplusplus
00044 # ifndef  HAVE_PROTOTYPES
00045 #  define HAVE_PROTOTYPES 1
00046 # endif
00047 # ifndef  HAVE_STDARG_PROTOTYPES
00048 #  define HAVE_STDARG_PROTOTYPES 1
00049 # endif
00050 #endif
00051 
00052 /* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */
00053 #if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4
00054 # ifndef  HAVE_STDARG_PROTOTYPES
00055 #  define HAVE_STDARG_PROTOTYPES 1
00056 # endif
00057 #endif
00058 
00059 #ifndef P_
00060 #if defined(__STDC__) || defined(_WIN32)
00061 # define P_(args) args
00062 #else
00063 # define P_(args) ()
00064 #endif
00065 #endif
00066 
00067 #ifndef PV_
00068 #ifdef HAVE_STDARG_PROTOTYPES
00069 # define PV_(args) args
00070 #else
00071 # define PV_(args) ()
00072 #endif
00073 #endif
00074 
00075 #ifndef ONIG_EXTERN
00076 #if defined(_WIN32) && !defined(__GNUC__)
00077 #if defined(EXPORT) || defined(RUBY_EXPORT)
00078 #define ONIG_EXTERN   extern __declspec(dllexport)
00079 #else
00080 #define ONIG_EXTERN   extern __declspec(dllimport)
00081 #endif
00082 #endif
00083 #endif
00084 
00085 #ifndef ONIG_EXTERN
00086 #define ONIG_EXTERN   extern
00087 #endif
00088 
00089 /* PART: character encoding */
00090 
00091 #ifndef ONIG_ESCAPE_UCHAR_COLLISION
00092 #define UChar OnigUChar
00093 #endif
00094 
00095 typedef unsigned char  OnigUChar;
00096 typedef unsigned long  OnigCodePoint;
00097 typedef unsigned int   OnigDistance;
00098 
00099 #define ONIG_INFINITE_DISTANCE  ~((OnigDistance )0)
00100 
00101 /* ambiguous match flag */
00102 typedef unsigned int OnigAmbigType;
00103 
00104 ONIG_EXTERN OnigAmbigType OnigDefaultAmbigFlag;
00105 
00106 #define ONIGENC_AMBIGUOUS_MATCH_NONE                   0
00107 #define ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE            (1<<0)
00108 #define ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE         (1<<1)
00109 
00110 #define ONIGENC_AMBIGUOUS_MATCH_LIMIT                 (1<<1)
00111 
00112 #define ONIGENC_AMBIGUOUS_MATCH_FULL \
00113  ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE )
00114 #define ONIGENC_AMBIGUOUS_MATCH_DEFAULT  OnigDefaultAmbigFlag
00115 
00116 
00117 #define ONIGENC_MAX_COMP_AMBIG_CODE_LEN       3
00118 #define ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM  4
00119 
00120 /* code range */
00121 #define ONIGENC_CODE_RANGE_NUM(range)     ((int )range[0])
00122 #define ONIGENC_CODE_RANGE_FROM(range,i)  range[((i)*2) + 1]
00123 #define ONIGENC_CODE_RANGE_TO(range,i)    range[((i)*2) + 2]
00124 
00125 typedef struct {
00126   int len;
00127   OnigCodePoint code[ONIGENC_MAX_COMP_AMBIG_CODE_LEN];
00128 } OnigCompAmbigCodeItem;
00129 
00130 typedef struct {
00131   int n;
00132   OnigCodePoint code;
00133   OnigCompAmbigCodeItem items[ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM];
00134 } OnigCompAmbigCodes;
00135 
00136 typedef struct {
00137   OnigCodePoint from;
00138   OnigCodePoint to;
00139 } OnigPairAmbigCodes;
00140 
00141 typedef struct {
00142   OnigCodePoint esc;
00143   OnigCodePoint anychar;
00144   OnigCodePoint anytime;
00145   OnigCodePoint zero_or_one_time;
00146   OnigCodePoint one_or_more_time;
00147   OnigCodePoint anychar_anytime;
00148 } OnigMetaCharTableType;
00149 
00150 
00151 #if defined(RUBY_PLATFORM) && defined(M17N_H)
00152 
00153 #define ONIG_RUBY_M17N
00154 typedef m17n_encoding*        OnigEncoding;
00155 
00156 #else
00157 
00158 typedef struct {
00159   int    (*mbc_enc_len)(const OnigUChar* p);
00160   const char*   name;
00161   int           max_enc_len;
00162   int           min_enc_len;
00163   OnigAmbigType support_ambig_flag;
00164   OnigMetaCharTableType meta_char_table;
00165   int    (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end);
00166   OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end);
00167   int    (*code_to_mbclen)(OnigCodePoint code);
00168   int    (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf);
00169   int    (*mbc_to_normalize)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to);
00170   int    (*is_mbc_ambiguous)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end);
00171   int    (*get_all_pair_ambig_codes)(OnigAmbigType flag, const OnigPairAmbigCodes** acs);
00172   int    (*get_all_comp_ambig_codes)(OnigAmbigType flag, const OnigCompAmbigCodes** acs);
00173   int    (*is_code_ctype)(OnigCodePoint code, unsigned int ctype);
00174   int    (*get_ctype_code_range)(int ctype, const OnigCodePoint* sb_range[], const OnigCodePoint* mb_range[]);
00175   OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p);
00176   int    (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end);
00177 } OnigEncodingType;
00178 
00179 typedef OnigEncodingType* OnigEncoding;
00180 
00181 ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
00182 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_1;
00183 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_2;
00184 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_3;
00185 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_4;
00186 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_5;
00187 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_6;
00188 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_7;
00189 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_8;
00190 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_9;
00191 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_10;
00192 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_11;
00193 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_13;
00194 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_14;
00195 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_15;
00196 ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_16;
00197 ONIG_EXTERN OnigEncodingType OnigEncodingUTF8;
00198 ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_BE;
00199 ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_LE;
00200 ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_BE;
00201 ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_LE;
00202 ONIG_EXTERN OnigEncodingType OnigEncodingEUC_JP;
00203 ONIG_EXTERN OnigEncodingType OnigEncodingEUC_TW;
00204 ONIG_EXTERN OnigEncodingType OnigEncodingEUC_KR;
00205 ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN;
00206 ONIG_EXTERN OnigEncodingType OnigEncodingSJIS;
00207 ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;
00208 ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;
00209 ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;
00210 ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
00211 
00212 #define ONIG_ENCODING_ASCII        (&OnigEncodingASCII)
00213 #define ONIG_ENCODING_ISO_8859_1   (&OnigEncodingISO_8859_1)
00214 #define ONIG_ENCODING_ISO_8859_2   (&OnigEncodingISO_8859_2)
00215 #define ONIG_ENCODING_ISO_8859_3   (&OnigEncodingISO_8859_3)
00216 #define ONIG_ENCODING_ISO_8859_4   (&OnigEncodingISO_8859_4)
00217 #define ONIG_ENCODING_ISO_8859_5   (&OnigEncodingISO_8859_5)
00218 #define ONIG_ENCODING_ISO_8859_6   (&OnigEncodingISO_8859_6)
00219 #define ONIG_ENCODING_ISO_8859_7   (&OnigEncodingISO_8859_7)
00220 #define ONIG_ENCODING_ISO_8859_8   (&OnigEncodingISO_8859_8)
00221 #define ONIG_ENCODING_ISO_8859_9   (&OnigEncodingISO_8859_9)
00222 #define ONIG_ENCODING_ISO_8859_10  (&OnigEncodingISO_8859_10)
00223 #define ONIG_ENCODING_ISO_8859_11  (&OnigEncodingISO_8859_11)
00224 #define ONIG_ENCODING_ISO_8859_13  (&OnigEncodingISO_8859_13)
00225 #define ONIG_ENCODING_ISO_8859_14  (&OnigEncodingISO_8859_14)
00226 #define ONIG_ENCODING_ISO_8859_15  (&OnigEncodingISO_8859_15)
00227 #define ONIG_ENCODING_ISO_8859_16  (&OnigEncodingISO_8859_16)
00228 #define ONIG_ENCODING_UTF8         (&OnigEncodingUTF8)
00229 #define ONIG_ENCODING_UTF16_BE     (&OnigEncodingUTF16_BE)
00230 #define ONIG_ENCODING_UTF16_LE     (&OnigEncodingUTF16_LE)
00231 #define ONIG_ENCODING_UTF32_BE     (&OnigEncodingUTF32_BE)
00232 #define ONIG_ENCODING_UTF32_LE     (&OnigEncodingUTF32_LE)
00233 #define ONIG_ENCODING_EUC_JP       (&OnigEncodingEUC_JP)
00234 #define ONIG_ENCODING_EUC_TW       (&OnigEncodingEUC_TW)
00235 #define ONIG_ENCODING_EUC_KR       (&OnigEncodingEUC_KR)
00236 #define ONIG_ENCODING_EUC_CN       (&OnigEncodingEUC_CN)
00237 #define ONIG_ENCODING_SJIS         (&OnigEncodingSJIS)
00238 #define ONIG_ENCODING_KOI8         (&OnigEncodingKOI8)
00239 #define ONIG_ENCODING_KOI8_R       (&OnigEncodingKOI8_R)
00240 #define ONIG_ENCODING_BIG5         (&OnigEncodingBIG5)
00241 #define ONIG_ENCODING_GB18030      (&OnigEncodingGB18030)
00242 
00243 #endif /* else RUBY && M17N */
00244 
00245 #define ONIG_ENCODING_UNDEF    ((OnigEncoding )0)
00246 
00247 
00248 /* work size */
00249 #define ONIGENC_CODE_TO_MBC_MAXLEN      7
00250 #define ONIGENC_MBC_NORMALIZE_MAXLEN    ONIGENC_CODE_TO_MBC_MAXLEN
00251 
00252 /* character types */
00253 #define ONIGENC_CTYPE_NEWLINE  (1<< 0)
00254 #define ONIGENC_CTYPE_ALPHA    (1<< 1)
00255 #define ONIGENC_CTYPE_BLANK    (1<< 2)
00256 #define ONIGENC_CTYPE_CNTRL    (1<< 3)
00257 #define ONIGENC_CTYPE_DIGIT    (1<< 4)
00258 #define ONIGENC_CTYPE_GRAPH    (1<< 5)
00259 #define ONIGENC_CTYPE_LOWER    (1<< 6)
00260 #define ONIGENC_CTYPE_PRINT    (1<< 7)
00261 #define ONIGENC_CTYPE_PUNCT    (1<< 8)
00262 #define ONIGENC_CTYPE_SPACE    (1<< 9)
00263 #define ONIGENC_CTYPE_UPPER    (1<<10)
00264 #define ONIGENC_CTYPE_XDIGIT   (1<<11)
00265 #define ONIGENC_CTYPE_WORD     (1<<12)
00266 #define ONIGENC_CTYPE_ASCII    (1<<13)
00267 #define ONIGENC_CTYPE_ALNUM    (ONIGENC_CTYPE_ALPHA | ONIGENC_CTYPE_DIGIT)
00268 
00269 #define enc_len(enc,p)                ONIGENC_MBC_ENC_LEN(enc, p)
00270 
00271 #define ONIGENC_IS_UNDEF(enc)          ((enc) == ONIG_ENCODING_UNDEF)
00272 #define ONIGENC_IS_SINGLEBYTE(enc)     (ONIGENC_MBC_MAXLEN(enc) == 1)
00273 #define ONIGENC_IS_MBC_HEAD(enc,p)     (ONIGENC_MBC_ENC_LEN(enc,p) != 1)
00274 #define ONIGENC_IS_MBC_ASCII(p)           (*(p)   < 128)
00275 #define ONIGENC_IS_CODE_ASCII(code)       ((code) < 128)
00276 #define ONIGENC_IS_CODE_SB_WORD(enc,code) \
00277   (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
00278 #define ONIGENC_IS_MBC_WORD(enc,s,end) \
00279    ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end))
00280 
00281 
00282 #ifdef ONIG_RUBY_M17N
00283 
00284 #include <ctype.h> /* for isblank(), isgraph() */
00285 
00286 #define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \
00287         onigenc_mbc_to_normalize(enc,flag,pp,end,buf)
00288 #define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \
00289         onigenc_is_mbc_ambiguous(enc,flag,pp,end)
00290 
00291 #define ONIGENC_SUPPORT_AMBIG_FLAG(enc)     ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE
00292 #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
00293         onigenc_is_allowed_reverse_match(enc, s, end)
00294 #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
00295         onigenc_get_left_adjust_char_head(enc, start, s)
00296 #define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc, ambig_flag, acs)    0
00297 #define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc, ambig_flag, acs)    0
00298 #define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \
00299         ONIG_NO_SUPPORT_CONFIG
00300 #define ONIGENC_MBC_ENC_LEN(enc,p)            m17n_mbclen(enc,(int )(*p))
00301 #define ONIGENC_MBC_MAXLEN(enc)               m17n_mbmaxlen(enc)
00302 #define ONIGENC_MBC_MAXLEN_DIST(enc) \
00303     (ONIGENC_MBC_MAXLEN(enc) > 0 ? ONIGENC_MBC_MAXLEN(enc) \
00304                                  : ONIG_INFINITE_DISTANCE)
00305 #define ONIGENC_MBC_MINLEN(enc)            1
00306 #define ONIGENC_MBC_TO_CODE(enc,p,e)       m17n_codepoint((enc),(p),(e))
00307 #define ONIGENC_CODE_TO_MBCLEN(enc,code)   m17n_codelen((enc),(code))
00308 #define ONIGENC_CODE_TO_MBC(enc,code,buf)  onigenc_code_to_mbc(enc, code, buf)
00309 
00310 #if 0     /* !! not supported !! */
00311 #define ONIGENC_IS_MBC_NEWLINE(enc,p,end)
00312 #define ONIGENC_STEP_BACK(enc,start,s,n)
00313 #endif
00314 
00315 #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) \
00316         onigenc_is_code_ctype(enc,code,ctype)
00317 
00318 #ifdef isblank
00319 # define ONIGENC_IS_CODE_BLANK(enc,code) isblank((int )code)
00320 #else
00321 # define ONIGENC_IS_CODE_BLANK(enc,code) ((code) == ' ' || (code) == '\t')
00322 #endif
00323 #ifdef isgraph
00324 # define ONIGENC_IS_CODE_GRAPH(enc,code) isgraph((int )code)
00325 #else
00326 # define ONIGENC_IS_CODE_GRAPH(enc,code) \
00327   (isprint((int )code) && !isspace((int )code))
00328 #endif
00329 
00330 #define ONIGENC_IS_CODE_PRINT(enc,code)     m17n_isprint(enc,code)
00331 #define ONIGENC_IS_CODE_ALNUM(enc,code)     m17n_isalnum(enc,code)
00332 #define ONIGENC_IS_CODE_ALPHA(enc,code)     m17n_isalpha(enc,code)
00333 #define ONIGENC_IS_CODE_LOWER(enc,code)     m17n_islower(enc,code)
00334 #define ONIGENC_IS_CODE_UPPER(enc,code)     m17n_isupper(enc,code)
00335 #define ONIGENC_IS_CODE_CNTRL(enc,code)     m17n_iscntrl(enc,code)
00336 #define ONIGENC_IS_CODE_PUNCT(enc,code)     m17n_ispunct(enc,code)
00337 #define ONIGENC_IS_CODE_SPACE(enc,code)     m17n_isspace(enc,code)
00338 #define ONIGENC_IS_CODE_DIGIT(enc,code)     m17n_isdigit(enc,code)
00339 #define ONIGENC_IS_CODE_XDIGIT(enc,code)    m17n_isxdigit(enc,code)
00340 #define ONIGENC_IS_CODE_WORD(enc,code)      m17n_iswchar(enc,code)
00341 
00342 ONIG_EXTERN
00343 int onigenc_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, int ctype));
00344 ONIG_EXTERN
00345 int onigenc_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, OnigUChar *buf));
00346 ONIG_EXTERN
00347 int onigenc_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* buf));
00348 ONIG_EXTERN
00349 int onigenc_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end));
00350 ONIG_EXTERN
00351 int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, const OnigUChar* end));
00352 
00353 #else  /* ONIG_RUBY_M17N */
00354 
00355 #define ONIGENC_NAME(enc)                      ((enc)->name)
00356 
00357 #define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \
00358   (enc)->mbc_to_normalize(flag,(const OnigUChar** )pp,end,buf)
00359 #define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \
00360   (enc)->is_mbc_ambiguous(flag,(const OnigUChar** )pp,end)
00361 #define ONIGENC_SUPPORT_AMBIG_FLAG(enc)        ((enc)->support_ambig_flag)
00362 #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
00363         (enc)->is_allowed_reverse_match(s,end)
00364 #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
00365         (enc)->left_adjust_char_head(start, s)
00366 #define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc,ambig_flag,acs) \
00367         (enc)->get_all_pair_ambig_codes(ambig_flag,acs)
00368 #define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc,ambig_flag,acs) \
00369         (enc)->get_all_comp_ambig_codes(ambig_flag,acs)
00370 #define ONIGENC_STEP_BACK(enc,start,s,n) \
00371         onigenc_step_back((enc),(start),(s),(n))
00372 
00373 #define ONIGENC_MBC_ENC_LEN(enc,p)             (enc)->mbc_enc_len(p)
00374 #define ONIGENC_MBC_MAXLEN(enc)               ((enc)->max_enc_len)
00375 #define ONIGENC_MBC_MAXLEN_DIST(enc)           ONIGENC_MBC_MAXLEN(enc)
00376 #define ONIGENC_MBC_MINLEN(enc)               ((enc)->min_enc_len)
00377 #define ONIGENC_IS_MBC_NEWLINE(enc,p,end)      (enc)->is_mbc_newline((p),(end))
00378 #define ONIGENC_MBC_TO_CODE(enc,p,end)         (enc)->mbc_to_code((p),(end))
00379 #define ONIGENC_CODE_TO_MBCLEN(enc,code)       (enc)->code_to_mbclen(code)
00380 #define ONIGENC_CODE_TO_MBC(enc,code,buf)      (enc)->code_to_mbc(code,buf)
00381 
00382 #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype)  (enc)->is_code_ctype(code,ctype)
00383 
00384 #define ONIGENC_IS_CODE_NEWLINE(enc,code) \
00385         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_NEWLINE)
00386 #define ONIGENC_IS_CODE_GRAPH(enc,code) \
00387         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_GRAPH)
00388 #define ONIGENC_IS_CODE_PRINT(enc,code) \
00389         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PRINT)
00390 #define ONIGENC_IS_CODE_ALNUM(enc,code) \
00391         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALNUM)
00392 #define ONIGENC_IS_CODE_ALPHA(enc,code) \
00393         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALPHA)
00394 #define ONIGENC_IS_CODE_LOWER(enc,code) \
00395         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_LOWER)
00396 #define ONIGENC_IS_CODE_UPPER(enc,code) \
00397         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_UPPER)
00398 #define ONIGENC_IS_CODE_CNTRL(enc,code) \
00399         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_CNTRL)
00400 #define ONIGENC_IS_CODE_PUNCT(enc,code) \
00401         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PUNCT)
00402 #define ONIGENC_IS_CODE_SPACE(enc,code) \
00403         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_SPACE)
00404 #define ONIGENC_IS_CODE_BLANK(enc,code) \
00405         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_BLANK)
00406 #define ONIGENC_IS_CODE_DIGIT(enc,code) \
00407         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT)
00408 #define ONIGENC_IS_CODE_XDIGIT(enc,code) \
00409         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_XDIGIT)
00410 #define ONIGENC_IS_CODE_WORD(enc,code) \
00411         ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD)
00412 
00413 #define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \
00414         (enc)->get_ctype_code_range(ctype,sbr,mbr)
00415 
00416 ONIG_EXTERN
00417 OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));
00418 
00419 #endif /* is not ONIG_RUBY_M17N */
00420 
00421 
00422 /* encoding API */
00423 ONIG_EXTERN
00424 int onigenc_init P_((void));
00425 ONIG_EXTERN
00426 int onigenc_set_default_encoding P_((OnigEncoding enc));
00427 ONIG_EXTERN
00428 OnigEncoding onigenc_get_default_encoding P_((void));
00429 ONIG_EXTERN
00430 void  onigenc_set_default_caseconv_table P_((const OnigUChar* table));
00431 ONIG_EXTERN
00432 OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));
00433 ONIG_EXTERN
00434 OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
00435 ONIG_EXTERN
00436 OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
00437 ONIG_EXTERN
00438 OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
00439 ONIG_EXTERN
00440 int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
00441 ONIG_EXTERN
00442 int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));
00443 ONIG_EXTERN
00444 int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
00445 
00446 
00447 
00448 /* PART: regular expression */
00449 
00450 /* config parameters */
00451 #define ONIG_NREGION                          10
00452 #define ONIG_MAX_BACKREF_NUM                1000
00453 #define ONIG_MAX_REPEAT_NUM               100000
00454 #define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
00455 /* constants */
00456 #define ONIG_MAX_ERROR_MESSAGE_LEN            90
00457 
00458 typedef unsigned int        OnigOptionType;
00459 
00460 #define ONIG_OPTION_DEFAULT            ONIG_OPTION_NONE
00461 
00462 /* options */
00463 #define ONIG_OPTION_NONE                 0U
00464 #define ONIG_OPTION_IGNORECASE           1U
00465 #define ONIG_OPTION_EXTEND               (ONIG_OPTION_IGNORECASE         << 1)
00466 #define ONIG_OPTION_MULTILINE            (ONIG_OPTION_EXTEND             << 1)
00467 #define ONIG_OPTION_SINGLELINE           (ONIG_OPTION_MULTILINE          << 1)
00468 #define ONIG_OPTION_FIND_LONGEST         (ONIG_OPTION_SINGLELINE         << 1)
00469 #define ONIG_OPTION_FIND_NOT_EMPTY       (ONIG_OPTION_FIND_LONGEST       << 1)
00470 #define ONIG_OPTION_NEGATE_SINGLELINE    (ONIG_OPTION_FIND_NOT_EMPTY     << 1)
00471 #define ONIG_OPTION_DONT_CAPTURE_GROUP   (ONIG_OPTION_NEGATE_SINGLELINE  << 1)
00472 #define ONIG_OPTION_CAPTURE_GROUP        (ONIG_OPTION_DONT_CAPTURE_GROUP << 1)
00473 /* options (search time) */
00474 #define ONIG_OPTION_NOTBOL               (ONIG_OPTION_CAPTURE_GROUP << 1)
00475 #define ONIG_OPTION_NOTEOL               (ONIG_OPTION_NOTBOL << 1)
00476 #define ONIG_OPTION_POSIX_REGION         (ONIG_OPTION_NOTEOL << 1)
00477 #define ONIG_OPTION_MAXBIT               ONIG_OPTION_POSIX_REGION  /* limit */
00478 
00479 #define ONIG_OPTION_ON(options,regopt)      ((options) |= (regopt))
00480 #define ONIG_OPTION_OFF(options,regopt)     ((options) &= ~(regopt))
00481 #define ONIG_IS_OPTION_ON(options,option)   ((options) & (option))
00482 
00483 /* syntax */
00484 typedef struct {
00485   unsigned int  op;
00486   unsigned int  op2;
00487   unsigned int  behavior;
00488   OnigOptionType options;    /* default option */
00489 } OnigSyntaxType;
00490 
00491 ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;
00492 ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
00493 ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
00494 ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
00495 ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
00496 ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
00497 ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
00498 ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
00499 ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl_NG;
00500 ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
00501 
00502 /* predefined syntaxes (see regsyntax.c) */
00503 #define ONIG_SYNTAX_ASIS               (&OnigSyntaxASIS)
00504 #define ONIG_SYNTAX_POSIX_BASIC        (&OnigSyntaxPosixBasic)
00505 #define ONIG_SYNTAX_POSIX_EXTENDED     (&OnigSyntaxPosixExtended)
00506 #define ONIG_SYNTAX_EMACS              (&OnigSyntaxEmacs)
00507 #define ONIG_SYNTAX_GREP               (&OnigSyntaxGrep)
00508 #define ONIG_SYNTAX_GNU_REGEX          (&OnigSyntaxGnuRegex)
00509 #define ONIG_SYNTAX_JAVA               (&OnigSyntaxJava)
00510 #define ONIG_SYNTAX_PERL               (&OnigSyntaxPerl)
00511 #define ONIG_SYNTAX_PERL_NG            (&OnigSyntaxPerl_NG)
00512 #define ONIG_SYNTAX_RUBY               (&OnigSyntaxRuby)
00513 
00514 /* default syntax */
00515 ONIG_EXTERN OnigSyntaxType*   OnigDefaultSyntax;
00516 #define ONIG_SYNTAX_DEFAULT   OnigDefaultSyntax
00517 
00518 /* syntax (operators) */
00519 #define ONIG_SYN_OP_VARIABLE_META_CHARACTERS    (1U<<0)
00520 #define ONIG_SYN_OP_DOT_ANYCHAR                 (1U<<1)   /* . */
00521 #define ONIG_SYN_OP_ASTERISK_ZERO_INF           (1U<<2)   /* * */
00522 #define ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF       (1U<<3)
00523 #define ONIG_SYN_OP_PLUS_ONE_INF                (1U<<4)   /* + */
00524 #define ONIG_SYN_OP_ESC_PLUS_ONE_INF            (1U<<5)
00525 #define ONIG_SYN_OP_QMARK_ZERO_ONE              (1U<<6)   /* ? */
00526 #define ONIG_SYN_OP_ESC_QMARK_ZERO_ONE          (1U<<7)
00527 #define ONIG_SYN_OP_BRACE_INTERVAL              (1U<<8)   /* {lower,upper} */
00528 #define ONIG_SYN_OP_ESC_BRACE_INTERVAL          (1U<<9)   /* \{lower,upper\} */
00529 #define ONIG_SYN_OP_VBAR_ALT                    (1U<<10)   /* | */
00530 #define ONIG_SYN_OP_ESC_VBAR_ALT                (1U<<11)  /* \| */
00531 #define ONIG_SYN_OP_LPAREN_SUBEXP               (1U<<12)  /* (...)   */
00532 #define ONIG_SYN_OP_ESC_LPAREN_SUBEXP           (1U<<13)  /* \(...\) */
00533 #define ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR           (1U<<14)  /* \A, \Z, \z */
00534 #define ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR  (1U<<15)  /* \G     */
00535 #define ONIG_SYN_OP_DECIMAL_BACKREF             (1U<<16)  /* \num   */
00536 #define ONIG_SYN_OP_BRACKET_CC                  (1U<<17)  /* [...]  */
00537 #define ONIG_SYN_OP_ESC_W_WORD                  (1U<<18)  /* \w, \W */
00538 #define ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END     (1U<<19)  /* <. > */
00539 #define ONIG_SYN_OP_ESC_B_WORD_BOUND            (1U<<20)  /* \b, \B */
00540 #define ONIG_SYN_OP_ESC_S_WHITE_SPACE           (1U<<21)  /* \s, \S */
00541 #define ONIG_SYN_OP_ESC_D_DIGIT                 (1U<<22)  /* \d, \D */
00542 #define ONIG_SYN_OP_LINE_ANCHOR                 (1U<<23)  /* ^, $   */
00543 #define ONIG_SYN_OP_POSIX_BRACKET               (1U<<24)  /* [:xxxx:] */
00544 #define ONIG_SYN_OP_QMARK_NON_GREEDY            (1U<<25)  /* ??,*?,+?,{n,m}? */
00545 #define ONIG_SYN_OP_ESC_CONTROL_CHARS           (1U<<26)  /* \n,\r,\t,\a ... */
00546 #define ONIG_SYN_OP_ESC_C_CONTROL               (1U<<27)  /* \cx  */
00547 #define ONIG_SYN_OP_ESC_OCTAL3                  (1U<<28)  /* \OOO */
00548 #define ONIG_SYN_OP_ESC_X_HEX2                  (1U<<29)  /* \xHH */
00549 #define ONIG_SYN_OP_ESC_X_BRACE_HEX8            (1U<<30)  /* \x{7HHHHHHH} */
00550 
00551 #define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE        (1U<<0)  /* \Q...\E */
00552 #define ONIG_SYN_OP2_QMARK_GROUP_EFFECT         (1U<<1)  /* (?...) */
00553 #define ONIG_SYN_OP2_OPTION_PERL                (1U<<2)  /* (?imsx),(?-imsx) */
00554 #define ONIG_SYN_OP2_OPTION_RUBY                (1U<<3)  /* (?imx), (?-imx)  */
00555 #define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT     (1U<<4)  /* ?+,*+,++ */
00556 #define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL   (1U<<5)  /* {n,m}+   */
00557 #define ONIG_SYN_OP2_CCLASS_SET_OP              (1U<<6)  /* [...&&..[..]..] */
00558 #define ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP       (1U<<7)  /* (?<name>...) */
00559 #define ONIG_SYN_OP2_ESC_K_NAMED_BACKREF        (1U<<8)  /* \k<name> */
00560 #define ONIG_SYN_OP2_ESC_G_SUBEXP_CALL          (1U<<9)  /* \g<name>, \g<n> */
00561 #define ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY     (1U<<10) /* (?@..),(?@<x>..) */
00562 #define ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL  (1U<<11) /* \C-x */
00563 #define ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META     (1U<<12) /* \M-x */
00564 #define ONIG_SYN_OP2_ESC_V_VTAB                 (1U<<13) /* \v as VTAB */
00565 #define ONIG_SYN_OP2_ESC_U_HEX4                 (1U<<14) /* \uHHHH */
00566 #define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR         (1U<<15) /* \`, \' */
00567 #define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  (1U<<16) /* \p{...}, \P{...} */
00568 #define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */
00569 #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS    (1U<<18) /* \p{IsXDigit} */
00570 #define ONIG_SYN_OP2_ESC_H_XDIGIT               (1U<<19) /* \h, \H */
00571 #define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE         (1U<<20) /* \ */
00572 
00573 /* syntax (behavior) */
00574 #define ONIG_SYN_CONTEXT_INDEP_ANCHORS           (1U<<31) /* not implemented */
00575 #define ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS        (1U<<0)  /* ?, *, +, {n,m} */
00576 #define ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS      (1U<<1)  /* error or ignore */
00577 #define ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP    (1U<<2)  /* ...)... */
00578 #define ONIG_SYN_ALLOW_INVALID_INTERVAL          (1U<<3)  /* {??? */
00579 #define ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV       (1U<<4)  /* {,n} => {0,n} */
00580 #define ONIG_SYN_STRICT_CHECK_BACKREF            (1U<<5)  /* /(\1)/,/\1()/ ..*/
00581 #define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND   (1U<<6)  /* (?<=a|bc) */
00582 #define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP        (1U<<7)  /* see doc/RE */
00583 #define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME (1U<<8)  /* (?<x>)(?<x>) */
00584 #define ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY   (1U<<9)  /* a{n}?=(?:a{n})? */
00585 
00586 /* syntax (behavior) in char class [...] */
00587 #define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC      (1U<<20) /* [^...] */
00588 #define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC          (1U<<21) /* [..\w..] etc.. */
00589 #define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC         (1U<<22)
00590 #define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC     (1U<<23) /* [0-9-a]=[0-9\-a] */
00591 /* syntax (behavior) warning */
00592 #define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED          (1U<<24) /* [,-,] */
00593 #define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT    (1U<<25) /* (?:a*)+ */
00594 
00595 /* meta character specifiers (onig_set_meta_char()) */
00596 #define ONIG_META_CHAR_ESCAPE               0
00597 #define ONIG_META_CHAR_ANYCHAR              1
00598 #define ONIG_META_CHAR_ANYTIME              2
00599 #define ONIG_META_CHAR_ZERO_OR_ONE_TIME     3
00600 #define ONIG_META_CHAR_ONE_OR_MORE_TIME     4
00601 #define ONIG_META_CHAR_ANYCHAR_ANYTIME      5
00602 
00603 #define ONIG_INEFFECTIVE_META_CHAR          0
00604 
00605 /* error codes */
00606 #define ONIG_IS_PATTERN_ERROR(ecode)   ((ecode) <= -100 && (ecode) > -1000)
00607 /* normal return */
00608 #define ONIG_NORMAL                                            0
00609 #define ONIG_MISMATCH                                         -1
00610 #define ONIG_NO_SUPPORT_CONFIG                                -2
00611 
00612 /* internal error */
00613 #define ONIGERR_MEMORY                                         -5
00614 #define ONIGERR_TYPE_BUG                                       -6
00615 #define ONIGERR_PARSER_BUG                                    -11
00616 #define ONIGERR_STACK_BUG                                     -12
00617 #define ONIGERR_UNDEFINED_BYTECODE                            -13
00618 #define ONIGERR_UNEXPECTED_BYTECODE                           -14
00619 #define ONIGERR_MATCH_STACK_LIMIT_OVER                        -15
00620 #define ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED                -21
00621 #define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR  -22
00622 /* general error */
00623 #define ONIGERR_INVALID_ARGUMENT                              -30 
00624 /* syntax error */
00625 #define ONIGERR_END_PATTERN_AT_LEFT_BRACE                    -100
00626 #define ONIGERR_END_PATTERN_AT_LEFT_BRACKET                  -101
00627 #define ONIGERR_EMPTY_CHAR_CLASS                             -102
00628 #define ONIGERR_PREMATURE_END_OF_CHAR_CLASS                  -103
00629 #define ONIGERR_END_PATTERN_AT_ESCAPE                        -104
00630 #define ONIGERR_END_PATTERN_AT_META                          -105
00631 #define ONIGERR_END_PATTERN_AT_CONTROL                       -106
00632 #define ONIGERR_META_CODE_SYNTAX                             -108
00633 #define ONIGERR_CONTROL_CODE_SYNTAX                          -109
00634 #define ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE             -110
00635 #define ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE           -111
00636 #define ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS      -112
00637 #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED      -113
00638 #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID            -114
00639 #define ONIGERR_NESTED_REPEAT_OPERATOR                       -115
00640 #define ONIGERR_UNMATCHED_CLOSE_PARENTHESIS                  -116
00641 #define ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS       -117
00642 #define ONIGERR_END_PATTERN_IN_GROUP                         -118
00643 #define ONIGERR_UNDEFINED_GROUP_OPTION                       -119
00644 #define ONIGERR_INVALID_POSIX_BRACKET_TYPE                   -121
00645 #define ONIGERR_INVALID_LOOK_BEHIND_PATTERN                  -122
00646 #define ONIGERR_INVALID_REPEAT_RANGE_PATTERN                 -123
00647 /* values error (syntax error) */
00648 #define ONIGERR_TOO_BIG_NUMBER                               -200
00649 #define ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE              -201
00650 #define ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE     -202
00651 #define ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS                    -203
00652 #define ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE          -204
00653 #define ONIGERR_TOO_MANY_MULTI_BYTE_RANGES                   -205
00654 #define ONIGERR_TOO_SHORT_MULTI_BYTE_STRING                  -206
00655 #define ONIGERR_TOO_BIG_BACKREF_NUMBER                       -207
00656 #define ONIGERR_INVALID_BACKREF                              -208
00657 #define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED         -209
00658 #define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE                     -212
00659 #define ONIGERR_EMPTY_GROUP_NAME                             -214
00660 #define ONIGERR_INVALID_GROUP_NAME                           -215
00661 #define ONIGERR_INVALID_CHAR_IN_GROUP_NAME                   -216
00662 #define ONIGERR_UNDEFINED_NAME_REFERENCE                     -217
00663 #define ONIGERR_UNDEFINED_GROUP_REFERENCE                    -218
00664 #define ONIGERR_MULTIPLEX_DEFINED_NAME                       -219
00665 #define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL               -220
00666 #define ONIGERR_NEVER_ENDING_RECURSION                       -221
00667 #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY        -222
00668 #define ONIGERR_INVALID_CHAR_PROPERTY_NAME                   -223
00669 #define ONIGERR_INVALID_WIDE_CHAR_VALUE                      -400
00670 #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
00671 #define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION           -402
00672 #define ONIGERR_INVALID_COMBINATION_OF_OPTIONS               -403
00673 
00674 /* errors related to thread */
00675 #define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT                -1001
00676 
00677 
00678 /* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */
00679 #define ONIG_MAX_CAPTURE_HISTORY_GROUP   31
00680 #define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \
00681   ((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])
00682 
00683 typedef struct OnigCaptureTreeNodeStruct {
00684   int group;   /* group number */
00685   int beg;
00686   int end;
00687   int allocated;
00688   int num_childs;
00689   struct OnigCaptureTreeNodeStruct** childs;
00690 } OnigCaptureTreeNode;
00691 
00692 /* match result region type */
00693 struct re_registers {
00694   int  allocated;
00695   int  num_regs;
00696   int* beg;
00697   int* end;
00698   /* extended */
00699   OnigCaptureTreeNode* history_root;  /* capture history tree root */
00700 };
00701 
00702 /* capture tree traverse */
00703 #define ONIG_TRAVERSE_CALLBACK_AT_FIRST   1
00704 #define ONIG_TRAVERSE_CALLBACK_AT_LAST    2
00705 #define ONIG_TRAVERSE_CALLBACK_AT_BOTH \
00706   ( ONIG_TRAVERSE_CALLBACK_AT_FIRST | ONIG_TRAVERSE_CALLBACK_AT_LAST )
00707 
00708 
00709 #define ONIG_REGION_NOTPOS            -1
00710 
00711 typedef struct re_registers   OnigRegion;
00712 
00713 typedef struct {
00714   OnigEncoding enc;
00715   OnigUChar* par;
00716   OnigUChar* par_end;
00717 } OnigErrorInfo;
00718 
00719 typedef struct {
00720   int lower;
00721   int upper;
00722 } OnigRepeatRange;
00723 
00724 typedef void (*OnigWarnFunc) P_((const char* s));
00725 extern void onig_null_warn P_((const char* s));
00726 #define ONIG_NULL_WARN       onig_null_warn
00727 
00728 #define ONIG_CHAR_TABLE_SIZE   256
00729 
00730 /* regex_t state */
00731 #define ONIG_STATE_NORMAL              0
00732 #define ONIG_STATE_SEARCHING           1
00733 #define ONIG_STATE_COMPILING          -1
00734 #define ONIG_STATE_MODIFY             -2
00735 
00736 #define ONIG_STATE(reg) \
00737   ((reg)->state > 0 ? ONIG_STATE_SEARCHING : (reg)->state)
00738 
00739 typedef struct re_pattern_buffer {
00740   /* common members of BBuf(bytes-buffer) */
00741   unsigned char* p;         /* compiled pattern */
00742   unsigned int used;        /* used space for p */
00743   unsigned int alloc;       /* allocated space for p */
00744 
00745   int state;                     /* normal, searching, compiling */
00746   int num_mem;                   /* used memory(...) num counted from 1 */
00747   int num_repeat;                /* OP_REPEAT/OP_REPEAT_NG id-counter */
00748   int num_null_check;            /* OP_NULL_CHECK_START/END id counter */
00749   int num_comb_exp_check;        /* combination explosion check */
00750   int num_call;                  /* number of subexp call */
00751   unsigned int capture_history;  /* (?@...) flag (1-31) */
00752   unsigned int bt_mem_start;     /* need backtrack flag */
00753   unsigned int bt_mem_end;       /* need backtrack flag */
00754   int stack_pop_level;
00755   int repeat_range_alloc;
00756   OnigRepeatRange* repeat_range;
00757 
00758   OnigEncoding  enc;
00759   OnigOptionType    options;
00760   OnigSyntaxType*   syntax;
00761   OnigAmbigType     ambig_flag;
00762   void*             name_table;
00763 
00764   /* optimization info (string search, char-map and anchors) */
00765   int            optimize;          /* optimize flag */
00766   int            threshold_len;     /* search str-length for apply optimize */
00767   int            anchor;            /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */
00768   OnigDistance   anchor_dmin;       /* (SEMI_)END_BUF anchor distance */
00769   OnigDistance   anchor_dmax;       /* (SEMI_)END_BUF anchor distance */
00770   int            sub_anchor;        /* start-anchor for exact or map */
00771   unsigned char *exact;
00772   unsigned char *exact_end;
00773   unsigned char  map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
00774   int           *int_map;                   /* BM skip for exact_len > 255 */
00775   int           *int_map_backward;          /* BM skip for backward search */
00776   OnigDistance   dmin;                      /* min-distance of exact or map */
00777   OnigDistance   dmax;                      /* max-distance of exact or map */
00778 
00779   /* regex_t link chain */
00780   struct re_pattern_buffer* chain;  /* escape compile-conflict */
00781 } OnigRegexType;
00782 
00783 typedef OnigRegexType*  OnigRegex;
00784 
00785 #ifndef ONIG_ESCAPE_REGEX_T_COLLISION
00786   typedef OnigRegexType  regex_t;
00787 #endif
00788 
00789 
00790 typedef struct {
00791   int             num_of_elements;
00792   OnigEncoding    pattern_enc;
00793   OnigEncoding    target_enc;
00794   OnigSyntaxType* syntax;
00795   OnigOptionType  option;
00796   OnigAmbigType   ambig_flag;
00797 } OnigCompileInfo;
00798 
00799 /* Oniguruma Native API */
00800 ONIG_EXTERN
00801 int onig_init P_((void));
00802 ONIG_EXTERN
00803 int onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...));
00804 ONIG_EXTERN
00805 void onig_set_warn_func P_((OnigWarnFunc f));
00806 ONIG_EXTERN
00807 void onig_set_verb_warn_func P_((OnigWarnFunc f));
00808 ONIG_EXTERN
00809 int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
00810 ONIG_EXTERN
00811 int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
00812 ONIG_EXTERN
00813 void onig_free P_((OnigRegex));
00814 ONIG_EXTERN
00815 int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
00816 ONIG_EXTERN
00817 int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
00818 ONIG_EXTERN
00819 int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
00820 ONIG_EXTERN
00821 int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));
00822 ONIG_EXTERN
00823 OnigRegion* onig_region_new P_((void));
00824 ONIG_EXTERN
00825 void onig_region_init P_((OnigRegion* region));
00826 ONIG_EXTERN
00827 void onig_region_free P_((OnigRegion* region, int free_self));
00828 ONIG_EXTERN
00829 void onig_region_copy P_((OnigRegion* to, OnigRegion* from));
00830 ONIG_EXTERN
00831 void onig_region_clear P_((OnigRegion* region));
00832 ONIG_EXTERN
00833 int onig_region_resize P_((OnigRegion* region, int n));
00834 ONIG_EXTERN
00835 int onig_region_set P_((OnigRegion* region, int at, int beg, int end));
00836 ONIG_EXTERN
00837 int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));
00838 ONIG_EXTERN
00839 int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));
00840 ONIG_EXTERN
00841 int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));
00842 ONIG_EXTERN
00843 int onig_number_of_names P_((OnigRegex reg));
00844 ONIG_EXTERN
00845 int onig_number_of_captures P_((OnigRegex reg));
00846 ONIG_EXTERN
00847 int onig_number_of_capture_histories P_((OnigRegex reg));
00848 ONIG_EXTERN
00849 OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));
00850 ONIG_EXTERN
00851 int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,int,int,int,int,void*), void* arg));
00852 ONIG_EXTERN
00853 int onig_noname_group_capture_is_active P_((OnigRegex reg));
00854 ONIG_EXTERN
00855 OnigEncoding onig_get_encoding P_((OnigRegex reg));
00856 ONIG_EXTERN
00857 OnigOptionType onig_get_options P_((OnigRegex reg));
00858 ONIG_EXTERN
00859 OnigAmbigType onig_get_ambig_flag P_((OnigRegex reg));
00860 ONIG_EXTERN
00861 OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));
00862 ONIG_EXTERN
00863 int onig_set_default_syntax P_((OnigSyntaxType* syntax));
00864 ONIG_EXTERN
00865 void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
00866 ONIG_EXTERN
00867 unsigned int onig_get_syntax_op P_((OnigSyntaxType* syntax));
00868 ONIG_EXTERN
00869 unsigned int onig_get_syntax_op2 P_((OnigSyntaxType* syntax));
00870 ONIG_EXTERN
00871 unsigned int onig_get_syntax_behavior P_((OnigSyntaxType* syntax));
00872 ONIG_EXTERN
00873 OnigOptionType onig_get_syntax_options P_((OnigSyntaxType* syntax));
00874 ONIG_EXTERN
00875 void onig_set_syntax_op P_((OnigSyntaxType* syntax, unsigned int op));
00876 ONIG_EXTERN
00877 void onig_set_syntax_op2 P_((OnigSyntaxType* syntax, unsigned int op2));
00878 ONIG_EXTERN
00879 void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior));
00880 ONIG_EXTERN
00881 void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options));
00882 ONIG_EXTERN
00883 int onig_set_meta_char P_((OnigEncoding enc, unsigned int what, OnigCodePoint code));
00884 ONIG_EXTERN
00885 void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));
00886 ONIG_EXTERN
00887 OnigAmbigType onig_get_default_ambig_flag P_((void));
00888 ONIG_EXTERN
00889 int onig_set_default_ambig_flag P_((OnigAmbigType ambig_flag));
00890 ONIG_EXTERN
00891 unsigned int onig_get_match_stack_limit_size P_((void));
00892 ONIG_EXTERN
00893 int onig_set_match_stack_limit_size P_((unsigned int size));
00894 ONIG_EXTERN
00895 int onig_end P_((void));
00896 ONIG_EXTERN
00897 const char* onig_version P_((void));
00898 ONIG_EXTERN
00899 const char* onig_copyright P_((void));
00900 
00901 #ifdef __cplusplus
00902 }
00903 #endif
00904 
00905 #endif /* ONIGURUMA_H */