Back to index

php5  5.3.10
regenc.h
Go to the documentation of this file.
00001 #ifndef REGENC_H
00002 #define REGENC_H
00003 /**********************************************************************
00004   regenc.h -  Oniguruma (regular expression library)
00005 **********************************************************************/
00006 /*-
00007  * Copyright (c) 2002-2006  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 #ifndef RUBY_PLATFORM
00033 #include "config.h"
00034 #endif
00035 #include "oniguruma.h"
00036 
00037 #ifndef NULL
00038 #define NULL   ((void* )0)
00039 #endif
00040 
00041 #ifndef TRUE
00042 #define TRUE    1
00043 #endif
00044 
00045 #ifndef FALSE
00046 #define FALSE   0
00047 #endif
00048 
00049 /* error codes */
00050 #define ONIGENCERR_MEMORY                                         -5
00051 #define ONIGENCERR_TYPE_BUG                                       -6
00052 #define ONIGENCERR_INVALID_WIDE_CHAR_VALUE                      -400
00053 #define ONIGENCERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
00054 
00055 #define ONIG_IS_NULL(p)                    (((void*)(p)) == (void*)0)
00056 #define ONIG_IS_NOT_NULL(p)                (((void*)(p)) != (void*)0)
00057 #define ONIG_CHECK_NULL_RETURN(p)          if (ONIG_IS_NULL(p)) return NULL
00058 #define ONIG_CHECK_NULL_RETURN_VAL(p,val)  if (ONIG_IS_NULL(p)) return (val)
00059 
00060 
00061 #ifdef ONIG_RUBY_M17N
00062 
00063 #define ONIG_ENCODING_INIT_DEFAULT            ONIG_ENCODING_UNDEF
00064 
00065 #else  /* ONIG_RUBY_M17N */
00066 
00067 #define USE_UNICODE_FULL_RANGE_CTYPE
00068 /* following must not use with USE_CRNL_AS_LINE_TERMINATOR */
00069 /* #define USE_UNICODE_ALL_LINE_TERMINATORS */  /* see Unicode.org UTF#18 */
00070 
00071 #define ONIG_ENCODING_INIT_DEFAULT           ONIG_ENCODING_ASCII
00072 
00073 /* for encoding system implementation (internal) */
00074 ONIG_EXTERN int onigenc_ascii_get_all_pair_ambig_codes P_((OnigAmbigType flag, const OnigPairAmbigCodes** acs));
00075 ONIG_EXTERN int onigenc_nothing_get_all_comp_ambig_codes P_((OnigAmbigType flag, const OnigCompAmbigCodes** acs));
00076 ONIG_EXTERN int onigenc_iso_8859_1_get_all_pair_ambig_codes P_((OnigAmbigType flag, const OnigPairAmbigCodes** acs));
00077 ONIG_EXTERN int onigenc_ess_tsett_get_all_comp_ambig_codes P_((OnigAmbigType flag, const OnigCompAmbigCodes** acs));
00078 ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((int ctype, const OnigCodePoint* sbr[], const OnigCodePoint* mbr[]));
00079 ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end));
00080 
00081 /* methods for single byte encoding */
00082 ONIG_EXTERN int onigenc_ascii_mbc_to_normalize P_((OnigAmbigType flag, const UChar** p, const UChar* end, UChar* lower));
00083 ONIG_EXTERN int onigenc_ascii_is_mbc_ambiguous P_((OnigAmbigType flag, const UChar** p, const UChar* end));
00084 ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p));
00085 ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end));
00086 ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code));
00087 ONIG_EXTERN int onigenc_single_byte_code_to_mbc_first P_((OnigCodePoint code));
00088 ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf));
00089 ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s));
00090 ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end));
00091 ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end));
00092 
00093 /* methods for multi byte encoding */
00094 ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
00095 ONIG_EXTERN int onigenc_mbn_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const UChar** p, const UChar* end, UChar* lower));
00096 ONIG_EXTERN int onigenc_mbn_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const UChar** p, const UChar* end));
00097 ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code));
00098 ONIG_EXTERN int onigenc_mb2_code_to_mbc_first P_((OnigCodePoint code));
00099 ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
00100 ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
00101 ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code));
00102 ONIG_EXTERN int onigenc_mb4_code_to_mbc_first P_((OnigCodePoint code));
00103 ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
00104 ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
00105 
00106 ONIG_EXTERN int onigenc_get_all_fold_match_code_ss_0xdf P_((OnigCodePoint** codes));
00107 
00108 /* in enc/unicode.c */
00109 ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));
00110 ONIG_EXTERN int onigenc_unicode_get_ctype_code_range P_((int ctype, const OnigCodePoint* sbr[], const OnigCodePoint* mbr[]));
00111 
00112 
00113 #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
00114   OnigEncISO_8859_1_ToLowerCaseTable[c]
00115 #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
00116   OnigEncISO_8859_1_ToUpperCaseTable[c]
00117 #define ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code,ctype) \
00118   ((OnigEnc_Unicode_ISO_8859_1_CtypeTable[code] & ctype) != 0)
00119 
00120 ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
00121 ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
00122 ONIG_EXTERN const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[];
00123 ONIG_EXTERN const OnigPairAmbigCodes OnigAsciiPairAmbigCodes[];
00124 
00125 #endif /* is not ONIG_RUBY_M17N */
00126 
00127 ONIG_EXTERN int
00128 onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
00129 ONIG_EXTERN UChar*
00130 onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
00131 
00132 /* defined in regexec.c, but used in enc/xxx.c */
00133 extern int  onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
00134 
00135 ONIG_EXTERN OnigEncoding  OnigEncDefaultCharEncoding;
00136 ONIG_EXTERN const UChar* OnigEncAsciiToLowerCaseTable;
00137 ONIG_EXTERN const UChar  OnigEncAsciiToUpperCaseTable[];
00138 ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
00139 
00140 #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
00141 #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
00142 #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
00143   ((OnigEncAsciiCtypeTable[code] & ctype) != 0)
00144 #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
00145     ONIGENC_IS_ASCII_CODE_CTYPE(code, (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER))
00146 
00147 #endif /* REGENC_H */