1 #ifndef ONIGPOSIX_H
2 #define ONIGPOSIX_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include <stdlib.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37
38 #define REG_ICASE (1<<0)
39 #define REG_NEWLINE (1<<1)
40 #define REG_NOTBOL (1<<2)
41 #define REG_NOTEOL (1<<3)
42 #define REG_EXTENDED (1<<4)
43 #define REG_NOSUB (1<<5)
44
45
46 #define REG_NOMATCH 1
47 #define REG_BADPAT 2
48 #define REG_ECOLLATE 3
49 #define REG_ECTYPE 4
50 #define REG_EESCAPE 5
51 #define REG_ESUBREG 6
52 #define REG_EBRACK 7
53 #define REG_EPAREN 8
54 #define REG_EBRACE 9
55 #define REG_BADBR 10
56 #define REG_ERANGE 11
57 #define REG_ESPACE 12
58 #define REG_BADRPT 13
59
60
61 #define REG_EONIG_INTERNAL 14
62 #define REG_EONIG_BADWC 15
63 #define REG_EONIG_BADARG 16
64 #define REG_EONIG_THREAD 17
65
66
67 #define REG_POSIX_ENCODING_ASCII 0
68 #define REG_POSIX_ENCODING_EUC_JP 1
69 #define REG_POSIX_ENCODING_SJIS 2
70 #define REG_POSIX_ENCODING_UTF8 3
71 #define REG_POSIX_ENCODING_UTF16_BE 4
72 #define REG_POSIX_ENCODING_UTF16_LE 5
73
74
75 typedef int regoff_t;
76
77 typedef struct {
78 regoff_t rm_so;
79 regoff_t rm_eo;
80 } regmatch_t;
81
82
83 typedef struct {
84 void* onig;
85 size_t re_nsub;
86 int comp_options;
87 } regex_t;
88
89
90 #ifndef P_
91 #if defined(__STDC__) || defined(_WIN32)
92 # define P_(args) args
93 #else
94 # define P_(args) ()
95 #endif
96 #endif
97
98 #ifndef ONIG_EXTERN
99 #if defined(_WIN32) && !defined(__GNUC__)
100 #if defined(EXPORT)
101 #define ONIG_EXTERN extern __declspec(dllexport)
102 #else
103 #define ONIG_EXTERN extern __declspec(dllimport)
104 #endif
105 #endif
106 #endif
107
108 #ifndef ONIG_EXTERN
109 #define ONIG_EXTERN extern
110 #endif
111
112 #ifndef ONIGURUMA_H
113 typedef unsigned int OnigOptionType;
114
115
116 typedef struct {
117 unsigned int op;
118 unsigned int op2;
119 unsigned int behavior;
120 OnigOptionType options;
121 } OnigSyntaxType;
122
123 ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
124 ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
125 ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
126 ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
127 ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
128 ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
129 ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
130 ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
131
132
133 #define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)
134 #define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)
135 #define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)
136 #define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)
137 #define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)
138 #define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)
139 #define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)
140 #define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)
141
142 #define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax
143
144 ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;
145
146 ONIG_EXTERN int onig_set_default_syntax P_((OnigSyntaxType* syntax));
147 ONIG_EXTERN void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
148 ONIG_EXTERN const char* onig_version P_((void));
149 ONIG_EXTERN const char* onig_copyright P_((void));
150
151 #endif
152
153
154 ONIG_EXTERN int regcomp P_((regex_t* reg, const char* pat, int options));
155 ONIG_EXTERN int regexec P_((regex_t* reg, const char* str, size_t nmatch, regmatch_t* matches, int options));
156 ONIG_EXTERN void regfree P_((regex_t* reg));
157 ONIG_EXTERN size_t regerror P_((int code, const regex_t* reg, char* buf, size_t size));
158
159
160 ONIG_EXTERN void reg_set_encoding P_((int enc));
161 ONIG_EXTERN int reg_name_to_group_numbers P_((regex_t* reg, const unsigned char* name, const unsigned char* name_end, int** nums));
162 ONIG_EXTERN int reg_foreach_name P_((regex_t* reg, int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*), void* arg));
163 ONIG_EXTERN int reg_number_of_names P_((regex_t* reg));
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif