Debian Codegraph @

vendor/onigmo-source/onigmoposix.h

raw symbols SCIP
1 #ifndef ONIGMOPOSIX_H
2 #define ONIGMOPOSIX_H
3 /**********************************************************************
4 onigmoposix.h - Onigmo (Oniguruma-mod) (regular expression library)
5 **********************************************************************/
6 /*-
7 * Copyright (c) 2002-2005 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8 * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32 #include <stdlib.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /* options */
39 #define REG_ICASE (1<<0)
40 #define REG_NEWLINE (1<<1)
41 #define REG_NOTBOL (1<<2)
42 #define REG_NOTEOL (1<<3)
43 #define REG_EXTENDED (1<<4) /* if not set, Basic Onigular Expression */
44 #define REG_NOSUB (1<<5)
45
46 /* POSIX error codes */
47 #define REG_NOMATCH 1
48 #define REG_BADPAT 2
49 #define REG_ECOLLATE 3
50 #define REG_ECTYPE 4
51 #define REG_EESCAPE 5
52 #define REG_ESUBREG 6
53 #define REG_EBRACK 7
54 #define REG_EPAREN 8
55 #define REG_EBRACE 9
56 #define REG_BADBR 10
57 #define REG_ERANGE 11
58 #define REG_ESPACE 12
59 #define REG_BADRPT 13
60
61 /* extended error codes */
62 #define REG_EONIG_INTERNAL 14
63 #define REG_EONIG_BADWC 15
64 #define REG_EONIG_BADARG 16
65 /* #define REG_EONIG_THREAD 17 */
66
67 /* character encodings (for reg_set_encoding()) */
68 #define REG_POSIX_ENCODING_ASCII 0
69 #define REG_POSIX_ENCODING_EUC_JP 1
70 #define REG_POSIX_ENCODING_SJIS 2
71 #define REG_POSIX_ENCODING_UTF8 3
72 #define REG_POSIX_ENCODING_UTF16_BE 4
73 #define REG_POSIX_ENCODING_UTF16_LE 5
74
75
76 typedef int regoff_t;
77
78 typedef struct {
79 regoff_t rm_so;
80 regoff_t rm_eo;
81 } regmatch_t;
82
83 /* POSIX regex_t */
84 typedef struct {
85 void* onig; /* Oniguruma regex_t* */
86 size_t re_nsub;
87 int comp_options;
88 } regex_t;
89
90
91 #ifndef ONIG_EXTERN
92 # if defined(_WIN32) && !defined(__GNUC__)
93 # if defined(EXPORT)
94 # define ONIG_EXTERN extern __declspec(dllexport)
95 # else
96 # define ONIG_EXTERN extern __declspec(dllimport)
97 # endif
98 # endif
99 #endif
100
101 #ifndef ONIG_EXTERN
102 # define ONIG_EXTERN extern
103 #endif
104
105 #ifndef ONIGMO_H
106 typedef unsigned int OnigOptionType;
107
108 /* syntax */
109 typedef struct {
110 unsigned int op;
111 unsigned int op2;
112 unsigned int behavior;
113 OnigOptionType options; /* default option */
114 } OnigSyntaxType;
115
116 ONIG_EXTERN const OnigSyntaxType OnigSyntaxPosixBasic;
117 ONIG_EXTERN const OnigSyntaxType OnigSyntaxPosixExtended;
118 ONIG_EXTERN const OnigSyntaxType OnigSyntaxEmacs;
119 ONIG_EXTERN const OnigSyntaxType OnigSyntaxGrep;
120 ONIG_EXTERN const OnigSyntaxType OnigSyntaxGnuRegex;
121 ONIG_EXTERN const OnigSyntaxType OnigSyntaxJava;
122 ONIG_EXTERN const OnigSyntaxType OnigSyntaxPerl;
123 ONIG_EXTERN const OnigSyntaxType OnigSyntaxRuby;
124
125 /* predefined syntaxes (see regsyntax.c) */
126 #define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)
127 #define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)
128 #define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)
129 #define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)
130 #define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)
131 #define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)
132 #define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)
133 #define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)
134 /* default syntax */
135 #define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax
136
137 ONIG_EXTERN const OnigSyntaxType* OnigDefaultSyntax;
138
139 ONIG_EXTERN int onig_set_default_syntax(const OnigSyntaxType* syntax);
140 ONIG_EXTERN void onig_copy_syntax(OnigSyntaxType* to, const OnigSyntaxType* from);
141 ONIG_EXTERN const char* onig_version(void);
142 ONIG_EXTERN const char* onig_copyright(void);
143
144 #endif /* ONIGMO_H */
145
146
147 ONIG_EXTERN int regcomp(regex_t* reg, const char* pat, int options);
148 ONIG_EXTERN int regexec(regex_t* reg, const char* str, size_t nmatch, regmatch_t* matches, int options);
149 ONIG_EXTERN void regfree(regex_t* reg);
150 ONIG_EXTERN size_t regerror(int code, const regex_t* reg, char* buf, size_t size);
151
152 /* extended API */
153 ONIG_EXTERN void reg_set_encoding(int enc);
154 ONIG_EXTERN int reg_name_to_group_numbers(regex_t* reg, const unsigned char* name, const unsigned char* name_end, int** nums);
155 ONIG_EXTERN int reg_foreach_name(regex_t* reg, int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*), void* arg);
156 ONIG_EXTERN int reg_number_of_names(regex_t* reg);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* ONIGMOPOSIX_H */