Oniguruma
🔠 The regular expression library that powered Ruby & PHP
Loading...
Searching...
No Matches
onigposix.h
Go to the documentation of this file.
1#ifndef ONIGPOSIX_H
2#define ONIGPOSIX_H
10#ifndef ONIG_NO_STANDARD_C_HEADERS
11#include <stddef.h>
12#endif
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/* options */
19#define REG_ICASE (1 << 0)
20#define REG_NEWLINE (1 << 1)
21#define REG_NOTBOL (1 << 2)
22#define REG_NOTEOL (1 << 3)
23#define REG_EXTENDED (1 << 4) /* if not set, Basic Onigular Expression */
24#define REG_NOSUB (1 << 5)
25
26/* POSIX error codes */
27#define REG_NOMATCH 1
28#define REG_BADPAT 2
29#define REG_ECOLLATE 3
30#define REG_ECTYPE 4
31#define REG_EESCAPE 5
32#define REG_ESUBREG 6
33#define REG_EBRACK 7
34#define REG_EPAREN 8
35#define REG_EBRACE 9
36#define REG_BADBR 10
37#define REG_ERANGE 11
38#define REG_ESPACE 12
39#define REG_BADRPT 13
40
41/* extended error codes */
42#define REG_EONIG_INTERNAL 14
43#define REG_EONIG_BADWC 15
44#define REG_EONIG_BADARG 16
45/* #define REG_EONIG_THREAD 17 */
46
47/* character encodings (for reg_set_encoding()) */
48#define REG_POSIX_ENCODING_ASCII 0
49#define REG_POSIX_ENCODING_EUC_JP 1
50#define REG_POSIX_ENCODING_SJIS 2
51#define REG_POSIX_ENCODING_UTF8 3
52#define REG_POSIX_ENCODING_UTF16_BE 4
53#define REG_POSIX_ENCODING_UTF16_LE 5
54
55typedef int onig_posix_regoff_t;
56
57typedef struct {
58 onig_posix_regoff_t rm_so;
59 onig_posix_regoff_t rm_eo;
61
62/* POSIX regex_t */
63typedef struct {
64 void *onig; /* Oniguruma regex_t* */
65 size_t re_nsub;
66 int comp_options;
68
69#ifndef P_
70#if defined(__STDC__) || defined(_WIN32)
71#define P_(args) args
72#else
73#define P_(args) ()
74#endif
75#endif
76
77#ifndef ONIG_STATIC
78#ifndef ONIG_EXTERN
79#if defined(_WIN32) && !defined(__GNUC__)
80#if defined(ONIGURUMA_EXPORT)
81#define ONIG_EXTERN extern __declspec(dllexport)
82#else
83#define ONIG_EXTERN extern __declspec(dllimport)
84#endif
85#endif
86#endif
87
88#ifndef ONIG_EXTERN
89#define ONIG_EXTERN extern
90#endif
91#else
92#define ONIG_EXTERN extern
93#endif
94
95#ifndef ONIGURUMA_H
96typedef unsigned int OnigOptionType;
97
98/* syntax */
99typedef struct {
100 unsigned int op;
101 unsigned int op2;
102 unsigned int behavior;
103 OnigOptionType options; /* default option */
105
106ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
107ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
108ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
109ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
110ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
111ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
112ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
113ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
114ONIG_EXTERN OnigSyntaxType OnigSyntaxOniguruma;
115
116/* predefined syntaxes (see regsyntax.c) */
117#define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)
118#define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)
119#define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)
120#define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)
121#define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)
122#define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)
123#define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)
124#define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)
125#define ONIG_SYNTAX_ONIGURUMA (&OnigSyntaxOniguruma)
126/* default syntax */
127#define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax
128
129ONIG_EXTERN OnigSyntaxType *OnigDefaultSyntax;
130
131ONIG_EXTERN int onig_set_default_syntax P_((OnigSyntaxType * syntax));
132ONIG_EXTERN void onig_copy_syntax P_((OnigSyntaxType * to,
133 OnigSyntaxType *from));
134ONIG_EXTERN const char *onig_version P_((void));
135ONIG_EXTERN const char *onig_copyright P_((void));
136ONIG_EXTERN int onig_end P_((void));
137
138#endif /* ONIGURUMA_H */
139
140ONIG_EXTERN int onig_posix_regcomp P_((onig_posix_regex_t * reg,
141 const char *pat, int options));
142ONIG_EXTERN int onig_posix_regexec P_((onig_posix_regex_t * reg,
143 const char *str, size_t nmatch,
144 onig_posix_regmatch_t *matches,
145 int options));
146ONIG_EXTERN void onig_posix_regfree P_((onig_posix_regex_t * reg));
147ONIG_EXTERN size_t onig_posix_regerror P_((int code,
148 const onig_posix_regex_t *reg,
149 char *buf, size_t size));
150
151/* extended API */
152ONIG_EXTERN void onig_posix_reg_set_encoding P_((int enc));
153ONIG_EXTERN int onig_posix_reg_name_to_group_numbers
154 P_((onig_posix_regex_t * reg, const unsigned char *name,
155 const unsigned char *name_end, int **nums));
156ONIG_EXTERN int onig_posix_reg_foreach_name
157 P_((onig_posix_regex_t * reg,
158 int (*func)(const unsigned char *, const unsigned char *, int, int *,
159 onig_posix_regex_t *, void *),
160 void *arg));
161ONIG_EXTERN int onig_posix_reg_number_of_names P_((onig_posix_regex_t * reg));
162
163/* aliases */
164#define regex_t onig_posix_regex_t
165#define regmatch_t onig_posix_regmatch_t
166#define regoff_t onig_posix_regoff_t
167
168#define regcomp onig_posix_regcomp
169#define regexec onig_posix_regexec
170#define regfree onig_posix_regfree
171#define regerror onig_posix_regerror
172#define reg_set_encoding onig_posix_reg_set_encoding
173#define reg_name_to_group_numbers onig_posix_reg_name_to_group_numbers
174#define reg_foreach_name onig_posix_reg_foreach_name
175#define reg_number_of_names onig_posix_reg_number_of_names
176
177#ifdef __cplusplus
178}
179#endif
180
181#endif /* ONIGPOSIX_H */
Definition onigposix.h:99
Definition onigposix.h:63
Definition onigposix.h:57