Initial commit of newLISP.
[newlisp.git] / pcre.h
blobee5bf16e788e828dbd2aa85703af5c50b94d2dc1
1 /*************************************************
2 * Perl-Compatible Regular Expressions *
3 *************************************************/
5 /* In its original form, this is the .in file that is transformed by
6 "configure" into pcre.h.
8 Copyright (c) 1997-2004 University of Cambridge
10 -----------------------------------------------------------------------------
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
21 * Neither the name of the University of Cambridge nor the names of its
22 contributors may be used to endorse or promote products derived from
23 this software without specific prior written permission.
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 POSSIBILITY OF SUCH DAMAGE.
36 -----------------------------------------------------------------------------
39 #ifndef _PCRE_H
40 #define _PCRE_H
42 /* The file pcre.h is build by "configure". Do not edit it; instead
43 make changes to pcre.in. */
45 #define PCRE_MAJOR 5
46 #define PCRE_MINOR 0
47 #define PCRE_DATE 13-Sep-2004
49 /* Win32 uses DLL by default */
51 #ifdef _WIN32
52 # ifdef PCRE_DEFINITION
53 # ifdef DLL_EXPORT
54 # define PCRE_DATA_SCOPE __declspec(dllexport)
55 # endif
56 # else
57 # ifndef PCRE_STATIC
58 # define PCRE_DATA_SCOPE extern __declspec(dllimport)
59 # endif
60 # endif
61 #endif
62 #ifndef PCRE_DATA_SCOPE
63 # define PCRE_DATA_SCOPE extern
64 #endif
66 /* Have to include stdlib.h in order to ensure that size_t is defined;
67 it is needed here for malloc. */
69 #include <stdlib.h>
71 /* Allow for C++ users */
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
77 /* Options */
79 #define PCRE_CASELESS 0x0001
80 #define PCRE_MULTILINE 0x0002
81 #define PCRE_DOTALL 0x0004
82 #define PCRE_EXTENDED 0x0008
83 #define PCRE_ANCHORED 0x0010
84 #define PCRE_DOLLAR_ENDONLY 0x0020
85 #define PCRE_EXTRA 0x0040
86 #define PCRE_NOTBOL 0x0080
87 #define PCRE_NOTEOL 0x0100
88 #define PCRE_UNGREEDY 0x0200
89 #define PCRE_NOTEMPTY 0x0400
90 #define PCRE_UTF8 0x0800
91 #define PCRE_NO_AUTO_CAPTURE 0x1000
92 #define PCRE_NO_UTF8_CHECK 0x2000
93 #define PCRE_AUTO_CALLOUT 0x4000
94 #define PCRE_PARTIAL 0x8000
96 /* Exec-time and get/set-time error codes */
98 #define PCRE_ERROR_NOMATCH (-1)
99 #define PCRE_ERROR_NULL (-2)
100 #define PCRE_ERROR_BADOPTION (-3)
101 #define PCRE_ERROR_BADMAGIC (-4)
102 #define PCRE_ERROR_UNKNOWN_NODE (-5)
103 #define PCRE_ERROR_NOMEMORY (-6)
104 #define PCRE_ERROR_NOSUBSTRING (-7)
105 #define PCRE_ERROR_MATCHLIMIT (-8)
106 #define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
107 #define PCRE_ERROR_BADUTF8 (-10)
108 #define PCRE_ERROR_BADUTF8_OFFSET (-11)
109 #define PCRE_ERROR_PARTIAL (-12)
110 #define PCRE_ERROR_BADPARTIAL (-13)
111 #define PCRE_ERROR_INTERNAL (-14)
112 #define PCRE_ERROR_BADCOUNT (-15)
114 /* Request types for pcre_fullinfo() */
116 #define PCRE_INFO_OPTIONS 0
117 #define PCRE_INFO_SIZE 1
118 #define PCRE_INFO_CAPTURECOUNT 2
119 #define PCRE_INFO_BACKREFMAX 3
120 #define PCRE_INFO_FIRSTBYTE 4
121 #define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
122 #define PCRE_INFO_FIRSTTABLE 5
123 #define PCRE_INFO_LASTLITERAL 6
124 #define PCRE_INFO_NAMEENTRYSIZE 7
125 #define PCRE_INFO_NAMECOUNT 8
126 #define PCRE_INFO_NAMETABLE 9
127 #define PCRE_INFO_STUDYSIZE 10
128 #define PCRE_INFO_DEFAULT_TABLES 11
130 /* Request types for pcre_config() */
132 #define PCRE_CONFIG_UTF8 0
133 #define PCRE_CONFIG_NEWLINE 1
134 #define PCRE_CONFIG_LINK_SIZE 2
135 #define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
136 #define PCRE_CONFIG_MATCH_LIMIT 4
137 #define PCRE_CONFIG_STACKRECURSE 5
138 #define PCRE_CONFIG_UNICODE_PROPERTIES 6
140 /* Bit flags for the pcre_extra structure */
142 #define PCRE_EXTRA_STUDY_DATA 0x0001
143 #define PCRE_EXTRA_MATCH_LIMIT 0x0002
144 #define PCRE_EXTRA_CALLOUT_DATA 0x0004
145 #define PCRE_EXTRA_TABLES 0x0008
147 /* Types */
149 struct real_pcre; /* declaration; the definition is private */
150 typedef struct real_pcre pcre;
152 /* The structure for passing additional data to pcre_exec(). This is defined in
153 such as way as to be extensible. Always add new fields at the end, in order to
154 remain compatible. */
156 typedef struct pcre_extra {
157 unsigned long int flags; /* Bits for which fields are set */
158 void *study_data; /* Opaque data from pcre_study() */
159 unsigned long int match_limit; /* Maximum number of calls to match() */
160 void *callout_data; /* Data passed back in callouts */
161 const unsigned char *tables; /* Pointer to character tables */
162 } pcre_extra;
164 /* The structure for passing out data via the pcre_callout_function. We use a
165 structure so that new fields can be added on the end in future versions,
166 without changing the API of the function, thereby allowing old clients to work
167 without modification. */
169 typedef struct pcre_callout_block {
170 int version; /* Identifies version of block */
171 /* ------------------------ Version 0 ------------------------------- */
172 int callout_number; /* Number compiled into pattern */
173 int *offset_vector; /* The offset vector */
174 const char *subject; /* The subject being matched */
175 int subject_length; /* The length of the subject */
176 int start_match; /* Offset to start of this match attempt */
177 int current_position; /* Where we currently are in the subject */
178 int capture_top; /* Max current capture */
179 int capture_last; /* Most recently closed capture */
180 void *callout_data; /* Data passed in with the call */
181 /* ------------------- Added for Version 1 -------------------------- */
182 int pattern_position; /* Offset to next item in the pattern */
183 int next_item_length; /* Length of next item in the pattern */
184 /* ------------------------------------------------------------------ */
185 } pcre_callout_block;
187 /* Indirection for store get and free functions. These can be set to
188 alternative malloc/free functions if required. Special ones are used in the
189 non-recursive case for "frames". There is also an optional callout function
190 that is triggered by the (?) regex item. Some magic is required for Win32 DLL;
191 it is null on other OS. For Virtual Pascal, these have to be different again.
194 #ifndef VPCOMPAT
195 PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
196 PCRE_DATA_SCOPE void (*pcre_free)(void *);
197 PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
198 PCRE_DATA_SCOPE void (*pcre_stack_free)(void *);
199 PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
200 #else /* VPCOMPAT */
201 extern void *pcre_malloc(size_t);
202 extern void pcre_free(void *);
203 extern void *pcre_stack_malloc(size_t);
204 extern void pcre_stack_free(void *);
205 extern int pcre_callout(pcre_callout_block *);
206 #endif /* VPCOMPAT */
208 /* Exported PCRE functions */
210 extern pcre *pcre_compile(const char *, int, const char **,
211 int *, const unsigned char *);
212 extern int pcre_config(int, void *);
213 extern int pcre_copy_named_substring(const pcre *, const char *,
214 int *, int, const char *, char *, int);
215 extern int pcre_copy_substring(const char *, int *, int, int,
216 char *, int);
217 extern int pcre_exec(const pcre *, const pcre_extra *,
218 const char *, int, int, int, int *, int);
219 extern void pcre_free_substring(const char *);
220 extern void pcre_free_substring_list(const char **);
221 extern int pcre_fullinfo(const pcre *, const pcre_extra *, int,
222 void *);
223 extern int pcre_get_named_substring(const pcre *, const char *,
224 int *, int, const char *, const char **);
225 extern int pcre_get_stringnumber(const pcre *, const char *);
226 extern int pcre_get_substring(const char *, int *, int, int,
227 const char **);
228 extern int pcre_get_substring_list(const char *, int *, int,
229 const char ***);
230 extern int pcre_info(const pcre *, int *, int *);
231 extern const unsigned char *pcre_maketables(void);
232 extern pcre_extra *pcre_study(const pcre *, int, const char **);
233 extern const char *pcre_version(void);
235 #ifdef __cplusplus
236 } /* extern "C" */
237 #endif
239 #endif /* End of pcre.h */