00001 #line 1106 "./lpsrc/tre.pak"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TRE_REGEX_H
00023 #define TRE_REGEX_H 1
00024
00025 #include "tre_config.hpp"
00026
00027 #ifdef HAVE_SYS_TYPES_H
00028 #include <sys/types.h>
00029 #endif
00030
00031 #ifdef HAVE_LIBUTF8_H
00032 #include <libutf8.h>
00033 #endif
00034
00035 #ifdef TRE_USE_SYSTEM_REGEX_H
00036
00037
00038 #include TRE_SYSTEM_REGEX_H_PATH
00039 #endif
00040
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044
00045 #ifdef TRE_USE_SYSTEM_REGEX_H
00046
00047 #ifndef REG_OK
00048 #define REG_OK 0
00049 #endif
00050
00051 #ifndef HAVE_REG_ERRCODE_T
00052 typedef int reg_errcode_t;
00053 #endif
00054
00055 #if !defined(REG_NOSPEC) && !defined(REG_LITERAL)
00056 #define REG_LITERAL 0x1000
00057 #endif
00058
00059
00060 #define REG_RIGHT_ASSOC (REG_LITERAL << 1)
00061
00062
00063 #define REG_APPROX_MATCHER 0x1000
00064 #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1)
00065
00066 #else
00067
00068
00069
00070
00071 typedef int regoff_t;
00072 typedef struct {
00073 size_t re_nsub;
00074 void *value;
00075 } regex_t;
00076
00077 typedef struct {
00078 regoff_t rm_so;
00079 regoff_t rm_eo;
00080 } regmatch_t;
00081
00082
00083 typedef enum {
00084 REG_OK = 0,
00085
00086
00087 REG_NOMATCH,
00088 REG_BADPAT,
00089 REG_ECOLLATE,
00090 REG_ECTYPE,
00091 REG_EESCAPE,
00092 REG_ESUBREG,
00093 REG_EBRACK,
00094 REG_EPAREN,
00095 REG_EBRACE,
00096 REG_BADBR,
00097 REG_ERANGE,
00098 REG_ESPACE,
00099 REG_BADRPT
00100 } reg_errcode_t;
00101
00102
00103 #define REG_EXTENDED 1
00104 #define REG_ICASE (REG_EXTENDED << 1)
00105 #define REG_NEWLINE (REG_ICASE << 1)
00106 #define REG_NOSUB (REG_NEWLINE << 1)
00107
00108
00109 #define REG_BASIC 0
00110 #define REG_LITERAL (REG_NOSUB << 1)
00111 #define REG_RIGHT_ASSOC (REG_LITERAL << 1)
00112
00113
00114 #define REG_NOTBOL 1
00115 #define REG_NOTEOL (REG_NOTBOL << 1)
00116
00117
00118 #define REG_APPROX_MATCHER (REG_NOTEOL << 1)
00119 #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1)
00120
00121 #endif
00122
00123
00124 #ifdef REG_LITERAL
00125 #define REG_NOSPEC REG_LITERAL
00126 #elif defined(REG_NOSPEC)
00127 #define REG_LITERAL REG_NOSPEC
00128 #endif
00129
00130
00131 #undef RE_DUP_MAX
00132 #define RE_DUP_MAX 255
00133
00134
00135 TRE_EXTERN int regcomp(regex_t *preg, const char *regex, int cflags);
00136 TRE_EXTERN int regexec(const regex_t *preg, const char *string, size_t nmatch,
00137 regmatch_t pmatch[], int eflags);
00138 TRE_EXTERN size_t regerror(int errcode, const regex_t *preg, char *errbuf,
00139 size_t errbuf_size);
00140 TRE_EXTERN void regfree(regex_t *preg);
00141
00142 #ifdef TRE_WCHAR
00143 #ifdef HAVE_WCHAR_H
00144 #include <wchar.h>
00145 #endif
00146
00147
00148 int regwcomp(regex_t *preg, const wchar_t *regex, int cflags);
00149 int regwexec(const regex_t *preg, const wchar_t *string, size_t nmatch,
00150 regmatch_t pmatch[], int eflags);
00151 #endif
00152
00153
00154
00155 TRE_EXTERN int regncomp(regex_t *preg, const char *regex, size_t len,
00156 int cflags);
00157 TRE_EXTERN int regnexec(const regex_t *preg, const char *string, size_t len,
00158 size_t nmatch, regmatch_t pmatch[], int eflags);
00159 #ifdef TRE_WCHAR
00160 TRE_EXTERN int regwncomp(regex_t *preg, const wchar_t *regex, size_t len,
00161 int cflags);
00162 TRE_EXTERN int regwnexec(const regex_t *preg, const wchar_t *string, size_t len,
00163 size_t nmatch, regmatch_t pmatch[], int eflags);
00164 #endif
00165
00166 #ifdef TRE_APPROX
00167
00168
00169 typedef struct {
00170 int cost_ins;
00171 int cost_del;
00172 int cost_subst;
00173 int max_cost;
00174
00175 int max_ins;
00176 int max_del;
00177 int max_subst;
00178 int max_err;
00179 } regaparams_t;
00180
00181
00182 typedef struct {
00183 size_t nmatch;
00184 regmatch_t *pmatch;
00185 int cost;
00186 int num_ins;
00187 int num_del;
00188 int num_subst;
00189 } regamatch_t;
00190
00191
00192
00193 int regaexec(const regex_t *preg, const char *string,
00194 regamatch_t *match, regaparams_t params, int eflags);
00195 int reganexec(const regex_t *preg, const char *string, size_t len,
00196 regamatch_t *match, regaparams_t params, int eflags);
00197 #ifdef TRE_WCHAR
00198
00199 int regawexec(const regex_t *preg, const wchar_t *string,
00200 regamatch_t *match, regaparams_t params, int eflags);
00201 int regawnexec(const regex_t *preg, const wchar_t *string, size_t len,
00202 regamatch_t *match, regaparams_t params, int eflags);
00203 #endif
00204
00205
00206 void regaparams_default(regaparams_t *params);
00207 #endif
00208
00209 #ifdef TRE_WCHAR
00210 typedef wchar_t tre_char_t;
00211 #else
00212 typedef unsigned char tre_char_t;
00213 #endif
00214
00215 typedef struct {
00216 int (*get_next_char)(tre_char_t *c, unsigned int *pos_add, void *context);
00217 void (*rewind)(size_t pos, void *context);
00218 int (*compare)(size_t pos1, size_t pos2, size_t len, void *context);
00219 void *context;
00220 } tre_str_source;
00221
00222 int reguexec(const regex_t *preg, const tre_str_source *string,
00223 size_t nmatch, regmatch_t pmatch[], int eflags);
00224
00225
00226 TRE_EXTERN char *tre_version(void);
00227
00228
00229
00230
00231 TRE_EXTERN int tre_config(int query, void *result);
00232
00233 enum {
00234 TRE_CONFIG_APPROX,
00235 TRE_CONFIG_WCHAR,
00236 TRE_CONFIG_MULTIBYTE,
00237 TRE_CONFIG_SYSTEM_ABI,
00238 TRE_CONFIG_VERSION
00239 };
00240
00241
00242 TRE_EXTERN int tre_have_backrefs(const regex_t *preg);
00243
00244
00245
00246 TRE_EXTERN int tre_have_approx(const regex_t *preg);
00247
00248 #ifdef __cplusplus
00249 }
00250 #endif
00251 #endif
00252
00253