xref: /PHP-5.3/ext/pcre/pcrelib/pcre.h (revision 357ab3cb)
1 /*************************************************
2 *       Perl-Compatible Regular Expressions      *
3 *************************************************/
4 
5 /* This is the public header file for the PCRE library, to be #included by
6 applications that call the PCRE functions.
7 
8            Copyright (c) 1997-2012 University of Cambridge
9 
10 -----------------------------------------------------------------------------
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13 
14     * Redistributions of source code must retain the above copyright notice,
15       this list of conditions and the following disclaimer.
16 
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.
20 
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.
24 
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 -----------------------------------------------------------------------------
37 */
38 
39 #ifndef _PCRE_H
40 #define _PCRE_H
41 
42 /* The current PCRE version information. */
43 
44 #define PCRE_MAJOR          8
45 #define PCRE_MINOR          32
46 #define PCRE_PRERELEASE
47 #define PCRE_DATE           2012-11-30
48 
49 /* When an application links to a PCRE DLL in Windows, the symbols that are
50 imported have to be identified as such. When building PCRE, the appropriate
51 export setting is defined in pcre_internal.h, which includes this file. So we
52 don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
53 
54 #if defined(_WIN32) && !defined(PCRE_STATIC)
55 #  ifndef PCRE_EXP_DECL
56 #    define PCRE_EXP_DECL  extern __declspec(dllimport)
57 #  endif
58 #  ifdef __cplusplus
59 #    ifndef PCRECPP_EXP_DECL
60 #      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
61 #    endif
62 #    ifndef PCRECPP_EXP_DEFN
63 #      define PCRECPP_EXP_DEFN  __declspec(dllimport)
64 #    endif
65 #  endif
66 #endif
67 
68 /* By default, we use the standard "extern" declarations. */
69 
70 #ifndef PCRE_EXP_DECL
71 #  ifdef __cplusplus
72 #    define PCRE_EXP_DECL  extern "C"
73 #  else
74 #    define PCRE_EXP_DECL  extern
75 #  endif
76 #endif
77 
78 #ifdef __cplusplus
79 #  ifndef PCRECPP_EXP_DECL
80 #    define PCRECPP_EXP_DECL  extern
81 #  endif
82 #  ifndef PCRECPP_EXP_DEFN
83 #    define PCRECPP_EXP_DEFN
84 #  endif
85 #endif
86 
87 /* Have to include stdlib.h in order to ensure that size_t is defined;
88 it is needed here for malloc. */
89 
90 #include <stdlib.h>
91 
92 /* Allow for C++ users */
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
98 /* Public options. Some are compile-time only, some are run-time only, and some
99 are both, so we keep them all distinct. However, almost all the bits in the
100 options word are now used. In the long run, we may have to re-use some of the
101 compile-time only bits for runtime options, or vice versa. Any of the
102 compile-time options may be inspected during studying (and therefore JIT
103 compiling).
104 
105 Some options for pcre_compile() change its behaviour but do not affect the
106 behaviour of the execution functions. Other options are passed through to the
107 execution functions and affect their behaviour, with or without affecting the
108 behaviour of pcre_compile().
109 
110 Options that can be passed to pcre_compile() are tagged Cx below, with these
111 variants:
112 
113 C1   Affects compile only
114 C2   Does not affect compile; affects exec, dfa_exec
115 C3   Affects compile, exec, dfa_exec
116 C4   Affects compile, exec, dfa_exec, study
117 C5   Affects compile, exec, study
118 
119 Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged with
120 E and D, respectively. They take precedence over C3, C4, and C5 settings passed
121 from pcre_compile(). Those that are compatible with JIT execution are flagged
122 with J. */
123 
124 #define PCRE_CASELESS           0x00000001  /* C1       */
125 #define PCRE_MULTILINE          0x00000002  /* C1       */
126 #define PCRE_DOTALL             0x00000004  /* C1       */
127 #define PCRE_EXTENDED           0x00000008  /* C1       */
128 #define PCRE_ANCHORED           0x00000010  /* C4 E D   */
129 #define PCRE_DOLLAR_ENDONLY     0x00000020  /* C2       */
130 #define PCRE_EXTRA              0x00000040  /* C1       */
131 #define PCRE_NOTBOL             0x00000080  /*    E D J */
132 #define PCRE_NOTEOL             0x00000100  /*    E D J */
133 #define PCRE_UNGREEDY           0x00000200  /* C1       */
134 #define PCRE_NOTEMPTY           0x00000400  /*    E D J */
135 #define PCRE_UTF8               0x00000800  /* C4        )          */
136 #define PCRE_UTF16              0x00000800  /* C4        ) Synonyms */
137 #define PCRE_UTF32              0x00000800  /* C4        )          */
138 #define PCRE_NO_AUTO_CAPTURE    0x00001000  /* C1       */
139 #define PCRE_NO_UTF8_CHECK      0x00002000  /* C1 E D J  )          */
140 #define PCRE_NO_UTF16_CHECK     0x00002000  /* C1 E D J  ) Synonyms */
141 #define PCRE_NO_UTF32_CHECK     0x00002000  /* C1 E D J  )          */
142 #define PCRE_AUTO_CALLOUT       0x00004000  /* C1       */
143 #define PCRE_PARTIAL_SOFT       0x00008000  /*    E D J  ) Synonyms */
144 #define PCRE_PARTIAL            0x00008000  /*    E D J  )          */
145 #define PCRE_DFA_SHORTEST       0x00010000  /*      D   */
146 #define PCRE_DFA_RESTART        0x00020000  /*      D   */
147 #define PCRE_FIRSTLINE          0x00040000  /* C3       */
148 #define PCRE_DUPNAMES           0x00080000  /* C1       */
149 #define PCRE_NEWLINE_CR         0x00100000  /* C3 E D   */
150 #define PCRE_NEWLINE_LF         0x00200000  /* C3 E D   */
151 #define PCRE_NEWLINE_CRLF       0x00300000  /* C3 E D   */
152 #define PCRE_NEWLINE_ANY        0x00400000  /* C3 E D   */
153 #define PCRE_NEWLINE_ANYCRLF    0x00500000  /* C3 E D   */
154 #define PCRE_BSR_ANYCRLF        0x00800000  /* C3 E D   */
155 #define PCRE_BSR_UNICODE        0x01000000  /* C3 E D   */
156 #define PCRE_JAVASCRIPT_COMPAT  0x02000000  /* C5       */
157 #define PCRE_NO_START_OPTIMIZE  0x04000000  /* C2 E D    ) Synonyms */
158 #define PCRE_NO_START_OPTIMISE  0x04000000  /* C2 E D    )          */
159 #define PCRE_PARTIAL_HARD       0x08000000  /*    E D J */
160 #define PCRE_NOTEMPTY_ATSTART   0x10000000  /*    E D J */
161 #define PCRE_UCP                0x20000000  /* C3       */
162 
163 /* Exec-time and get/set-time error codes */
164 
165 #define PCRE_ERROR_NOMATCH          (-1)
166 #define PCRE_ERROR_NULL             (-2)
167 #define PCRE_ERROR_BADOPTION        (-3)
168 #define PCRE_ERROR_BADMAGIC         (-4)
169 #define PCRE_ERROR_UNKNOWN_OPCODE   (-5)
170 #define PCRE_ERROR_UNKNOWN_NODE     (-5)  /* For backward compatibility */
171 #define PCRE_ERROR_NOMEMORY         (-6)
172 #define PCRE_ERROR_NOSUBSTRING      (-7)
173 #define PCRE_ERROR_MATCHLIMIT       (-8)
174 #define PCRE_ERROR_CALLOUT          (-9)  /* Never used by PCRE itself */
175 #define PCRE_ERROR_BADUTF8         (-10)  /* Same for 8/16/32 */
176 #define PCRE_ERROR_BADUTF16        (-10)  /* Same for 8/16/32 */
177 #define PCRE_ERROR_BADUTF32        (-10)  /* Same for 8/16/32 */
178 #define PCRE_ERROR_BADUTF8_OFFSET  (-11)  /* Same for 8/16 */
179 #define PCRE_ERROR_BADUTF16_OFFSET (-11)  /* Same for 8/16 */
180 #define PCRE_ERROR_PARTIAL         (-12)
181 #define PCRE_ERROR_BADPARTIAL      (-13)
182 #define PCRE_ERROR_INTERNAL        (-14)
183 #define PCRE_ERROR_BADCOUNT        (-15)
184 #define PCRE_ERROR_DFA_UITEM       (-16)
185 #define PCRE_ERROR_DFA_UCOND       (-17)
186 #define PCRE_ERROR_DFA_UMLIMIT     (-18)
187 #define PCRE_ERROR_DFA_WSSIZE      (-19)
188 #define PCRE_ERROR_DFA_RECURSE     (-20)
189 #define PCRE_ERROR_RECURSIONLIMIT  (-21)
190 #define PCRE_ERROR_NULLWSLIMIT     (-22)  /* No longer actually used */
191 #define PCRE_ERROR_BADNEWLINE      (-23)
192 #define PCRE_ERROR_BADOFFSET       (-24)
193 #define PCRE_ERROR_SHORTUTF8       (-25)
194 #define PCRE_ERROR_SHORTUTF16      (-25)  /* Same for 8/16 */
195 #define PCRE_ERROR_RECURSELOOP     (-26)
196 #define PCRE_ERROR_JIT_STACKLIMIT  (-27)
197 #define PCRE_ERROR_BADMODE         (-28)
198 #define PCRE_ERROR_BADENDIANNESS   (-29)
199 #define PCRE_ERROR_DFA_BADRESTART  (-30)
200 #define PCRE_ERROR_JIT_BADOPTION   (-31)
201 #define PCRE_ERROR_BADLENGTH       (-32)
202 
203 /* Specific error codes for UTF-8 validity checks */
204 
205 #define PCRE_UTF8_ERR0               0
206 #define PCRE_UTF8_ERR1               1
207 #define PCRE_UTF8_ERR2               2
208 #define PCRE_UTF8_ERR3               3
209 #define PCRE_UTF8_ERR4               4
210 #define PCRE_UTF8_ERR5               5
211 #define PCRE_UTF8_ERR6               6
212 #define PCRE_UTF8_ERR7               7
213 #define PCRE_UTF8_ERR8               8
214 #define PCRE_UTF8_ERR9               9
215 #define PCRE_UTF8_ERR10             10
216 #define PCRE_UTF8_ERR11             11
217 #define PCRE_UTF8_ERR12             12
218 #define PCRE_UTF8_ERR13             13
219 #define PCRE_UTF8_ERR14             14
220 #define PCRE_UTF8_ERR15             15
221 #define PCRE_UTF8_ERR16             16
222 #define PCRE_UTF8_ERR17             17
223 #define PCRE_UTF8_ERR18             18
224 #define PCRE_UTF8_ERR19             19
225 #define PCRE_UTF8_ERR20             20
226 #define PCRE_UTF8_ERR21             21
227 #define PCRE_UTF8_ERR22             22
228 
229 /* Specific error codes for UTF-16 validity checks */
230 
231 #define PCRE_UTF16_ERR0              0
232 #define PCRE_UTF16_ERR1              1
233 #define PCRE_UTF16_ERR2              2
234 #define PCRE_UTF16_ERR3              3
235 #define PCRE_UTF16_ERR4              4
236 
237 /* Specific error codes for UTF-32 validity checks */
238 
239 #define PCRE_UTF32_ERR0              0
240 #define PCRE_UTF32_ERR1              1
241 #define PCRE_UTF32_ERR2              2
242 #define PCRE_UTF32_ERR3              3
243 
244 /* Request types for pcre_fullinfo() */
245 
246 #define PCRE_INFO_OPTIONS            0
247 #define PCRE_INFO_SIZE               1
248 #define PCRE_INFO_CAPTURECOUNT       2
249 #define PCRE_INFO_BACKREFMAX         3
250 #define PCRE_INFO_FIRSTBYTE          4
251 #define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
252 #define PCRE_INFO_FIRSTTABLE         5
253 #define PCRE_INFO_LASTLITERAL        6
254 #define PCRE_INFO_NAMEENTRYSIZE      7
255 #define PCRE_INFO_NAMECOUNT          8
256 #define PCRE_INFO_NAMETABLE          9
257 #define PCRE_INFO_STUDYSIZE         10
258 #define PCRE_INFO_DEFAULT_TABLES    11
259 #define PCRE_INFO_OKPARTIAL         12
260 #define PCRE_INFO_JCHANGED          13
261 #define PCRE_INFO_HASCRORLF         14
262 #define PCRE_INFO_MINLENGTH         15
263 #define PCRE_INFO_JIT               16
264 #define PCRE_INFO_JITSIZE           17
265 #define PCRE_INFO_MAXLOOKBEHIND     18
266 #define PCRE_INFO_FIRSTCHARACTER      19
267 #define PCRE_INFO_FIRSTCHARACTERFLAGS   20
268 #define PCRE_INFO_REQUIREDCHAR      21
269 #define PCRE_INFO_REQUIREDCHARFLAGS   22
270 
271 /* Request types for pcre_config(). Do not re-arrange, in order to remain
272 compatible. */
273 
274 #define PCRE_CONFIG_UTF8                    0
275 #define PCRE_CONFIG_NEWLINE                 1
276 #define PCRE_CONFIG_LINK_SIZE               2
277 #define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
278 #define PCRE_CONFIG_MATCH_LIMIT             4
279 #define PCRE_CONFIG_STACKRECURSE            5
280 #define PCRE_CONFIG_UNICODE_PROPERTIES      6
281 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
282 #define PCRE_CONFIG_BSR                     8
283 #define PCRE_CONFIG_JIT                     9
284 #define PCRE_CONFIG_UTF16                  10
285 #define PCRE_CONFIG_JITTARGET              11
286 #define PCRE_CONFIG_UTF32                  12
287 
288 /* Request types for pcre_study(). Do not re-arrange, in order to remain
289 compatible. */
290 
291 #define PCRE_STUDY_JIT_COMPILE                0x0001
292 #define PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE   0x0002
293 #define PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE   0x0004
294 #define PCRE_STUDY_EXTRA_NEEDED               0x0008
295 
296 /* Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine
297 these bits, just add new ones on the end, in order to remain compatible. */
298 
299 #define PCRE_EXTRA_STUDY_DATA             0x0001
300 #define PCRE_EXTRA_MATCH_LIMIT            0x0002
301 #define PCRE_EXTRA_CALLOUT_DATA           0x0004
302 #define PCRE_EXTRA_TABLES                 0x0008
303 #define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
304 #define PCRE_EXTRA_MARK                   0x0020
305 #define PCRE_EXTRA_EXECUTABLE_JIT         0x0040
306 
307 /* Types */
308 
309 struct real_pcre;                 /* declaration; the definition is private  */
310 typedef struct real_pcre pcre;
311 
312 struct real_pcre16;               /* declaration; the definition is private  */
313 typedef struct real_pcre16 pcre16;
314 
315 struct real_pcre32;               /* declaration; the definition is private  */
316 typedef struct real_pcre32 pcre32;
317 
318 struct real_pcre_jit_stack;       /* declaration; the definition is private  */
319 typedef struct real_pcre_jit_stack pcre_jit_stack;
320 
321 struct real_pcre16_jit_stack;     /* declaration; the definition is private  */
322 typedef struct real_pcre16_jit_stack pcre16_jit_stack;
323 
324 struct real_pcre32_jit_stack;     /* declaration; the definition is private  */
325 typedef struct real_pcre32_jit_stack pcre32_jit_stack;
326 
327 /* If PCRE is compiled with 16 bit character support, PCRE_UCHAR16 must contain
328 a 16 bit wide signed data type. Otherwise it can be a dummy data type since
329 pcre16 functions are not implemented. There is a check for this in pcre_internal.h. */
330 #ifndef PCRE_UCHAR16
331 #define PCRE_UCHAR16 unsigned short
332 #endif
333 
334 #ifndef PCRE_SPTR16
335 #define PCRE_SPTR16 const PCRE_UCHAR16 *
336 #endif
337 
338 /* If PCRE is compiled with 32 bit character support, PCRE_UCHAR32 must contain
339 a 32 bit wide signed data type. Otherwise it can be a dummy data type since
340 pcre32 functions are not implemented. There is a check for this in pcre_internal.h. */
341 #ifndef PCRE_UCHAR32
342 #define PCRE_UCHAR32 unsigned int
343 #endif
344 
345 #ifndef PCRE_SPTR32
346 #define PCRE_SPTR32 const PCRE_UCHAR32 *
347 #endif
348 
349 /* When PCRE is compiled as a C++ library, the subject pointer type can be
350 replaced with a custom type. For conventional use, the public interface is a
351 const char *. */
352 
353 #ifndef PCRE_SPTR
354 #define PCRE_SPTR const char *
355 #endif
356 
357 /* The structure for passing additional data to pcre_exec(). This is defined in
358 such as way as to be extensible. Always add new fields at the end, in order to
359 remain compatible. */
360 
361 typedef struct pcre_extra {
362   unsigned long int flags;        /* Bits for which fields are set */
363   void *study_data;               /* Opaque data from pcre_study() */
364   unsigned long int match_limit;  /* Maximum number of calls to match() */
365   void *callout_data;             /* Data passed back in callouts */
366   const unsigned char *tables;    /* Pointer to character tables */
367   unsigned long int match_limit_recursion; /* Max recursive calls to match() */
368   unsigned char **mark;           /* For passing back a mark pointer */
369   void *executable_jit;           /* Contains a pointer to a compiled jit code */
370 } pcre_extra;
371 
372 /* Same structure as above, but with 16 bit char pointers. */
373 
374 typedef struct pcre16_extra {
375   unsigned long int flags;        /* Bits for which fields are set */
376   void *study_data;               /* Opaque data from pcre_study() */
377   unsigned long int match_limit;  /* Maximum number of calls to match() */
378   void *callout_data;             /* Data passed back in callouts */
379   const unsigned char *tables;    /* Pointer to character tables */
380   unsigned long int match_limit_recursion; /* Max recursive calls to match() */
381   PCRE_UCHAR16 **mark;            /* For passing back a mark pointer */
382   void *executable_jit;           /* Contains a pointer to a compiled jit code */
383 } pcre16_extra;
384 
385 /* Same structure as above, but with 32 bit char pointers. */
386 
387 typedef struct pcre32_extra {
388   unsigned long int flags;        /* Bits for which fields are set */
389   void *study_data;               /* Opaque data from pcre_study() */
390   unsigned long int match_limit;  /* Maximum number of calls to match() */
391   void *callout_data;             /* Data passed back in callouts */
392   const unsigned char *tables;    /* Pointer to character tables */
393   unsigned long int match_limit_recursion; /* Max recursive calls to match() */
394   PCRE_UCHAR32 **mark;            /* For passing back a mark pointer */
395   void *executable_jit;           /* Contains a pointer to a compiled jit code */
396 } pcre32_extra;
397 
398 /* The structure for passing out data via the pcre_callout_function. We use a
399 structure so that new fields can be added on the end in future versions,
400 without changing the API of the function, thereby allowing old clients to work
401 without modification. */
402 
403 typedef struct pcre_callout_block {
404   int          version;           /* Identifies version of block */
405   /* ------------------------ Version 0 ------------------------------- */
406   int          callout_number;    /* Number compiled into pattern */
407   int         *offset_vector;     /* The offset vector */
408   PCRE_SPTR    subject;           /* The subject being matched */
409   int          subject_length;    /* The length of the subject */
410   int          start_match;       /* Offset to start of this match attempt */
411   int          current_position;  /* Where we currently are in the subject */
412   int          capture_top;       /* Max current capture */
413   int          capture_last;      /* Most recently closed capture */
414   void        *callout_data;      /* Data passed in with the call */
415   /* ------------------- Added for Version 1 -------------------------- */
416   int          pattern_position;  /* Offset to next item in the pattern */
417   int          next_item_length;  /* Length of next item in the pattern */
418   /* ------------------- Added for Version 2 -------------------------- */
419   const unsigned char *mark;      /* Pointer to current mark or NULL    */
420   /* ------------------------------------------------------------------ */
421 } pcre_callout_block;
422 
423 /* Same structure as above, but with 16 bit char pointers. */
424 
425 typedef struct pcre16_callout_block {
426   int          version;           /* Identifies version of block */
427   /* ------------------------ Version 0 ------------------------------- */
428   int          callout_number;    /* Number compiled into pattern */
429   int         *offset_vector;     /* The offset vector */
430   PCRE_SPTR16  subject;           /* The subject being matched */
431   int          subject_length;    /* The length of the subject */
432   int          start_match;       /* Offset to start of this match attempt */
433   int          current_position;  /* Where we currently are in the subject */
434   int          capture_top;       /* Max current capture */
435   int          capture_last;      /* Most recently closed capture */
436   void        *callout_data;      /* Data passed in with the call */
437   /* ------------------- Added for Version 1 -------------------------- */
438   int          pattern_position;  /* Offset to next item in the pattern */
439   int          next_item_length;  /* Length of next item in the pattern */
440   /* ------------------- Added for Version 2 -------------------------- */
441   const PCRE_UCHAR16 *mark;       /* Pointer to current mark or NULL    */
442   /* ------------------------------------------------------------------ */
443 } pcre16_callout_block;
444 
445 /* Same structure as above, but with 32 bit char pointers. */
446 
447 typedef struct pcre32_callout_block {
448   int          version;           /* Identifies version of block */
449   /* ------------------------ Version 0 ------------------------------- */
450   int          callout_number;    /* Number compiled into pattern */
451   int         *offset_vector;     /* The offset vector */
452   PCRE_SPTR32  subject;           /* The subject being matched */
453   int          subject_length;    /* The length of the subject */
454   int          start_match;       /* Offset to start of this match attempt */
455   int          current_position;  /* Where we currently are in the subject */
456   int          capture_top;       /* Max current capture */
457   int          capture_last;      /* Most recently closed capture */
458   void        *callout_data;      /* Data passed in with the call */
459   /* ------------------- Added for Version 1 -------------------------- */
460   int          pattern_position;  /* Offset to next item in the pattern */
461   int          next_item_length;  /* Length of next item in the pattern */
462   /* ------------------- Added for Version 2 -------------------------- */
463   const PCRE_UCHAR32 *mark;       /* Pointer to current mark or NULL    */
464   /* ------------------------------------------------------------------ */
465 } pcre32_callout_block;
466 
467 /* Indirection for store get and free functions. These can be set to
468 alternative malloc/free functions if required. Special ones are used in the
469 non-recursive case for "frames". There is also an optional callout function
470 that is triggered by the (?) regex item. For Virtual Pascal, these definitions
471 have to take another form. */
472 
473 #ifndef VPCOMPAT
474 PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
475 PCRE_EXP_DECL void  (*pcre_free)(void *);
476 PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
477 PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
478 PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
479 
480 PCRE_EXP_DECL void *(*pcre16_malloc)(size_t);
481 PCRE_EXP_DECL void  (*pcre16_free)(void *);
482 PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t);
483 PCRE_EXP_DECL void  (*pcre16_stack_free)(void *);
484 PCRE_EXP_DECL int   (*pcre16_callout)(pcre16_callout_block *);
485 
486 PCRE_EXP_DECL void *(*pcre32_malloc)(size_t);
487 PCRE_EXP_DECL void  (*pcre32_free)(void *);
488 PCRE_EXP_DECL void *(*pcre32_stack_malloc)(size_t);
489 PCRE_EXP_DECL void  (*pcre32_stack_free)(void *);
490 PCRE_EXP_DECL int   (*pcre32_callout)(pcre32_callout_block *);
491 #else   /* VPCOMPAT */
492 PCRE_EXP_DECL void *pcre_malloc(size_t);
493 PCRE_EXP_DECL void  pcre_free(void *);
494 PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
495 PCRE_EXP_DECL void  pcre_stack_free(void *);
496 PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
497 
498 PCRE_EXP_DECL void *pcre16_malloc(size_t);
499 PCRE_EXP_DECL void  pcre16_free(void *);
500 PCRE_EXP_DECL void *pcre16_stack_malloc(size_t);
501 PCRE_EXP_DECL void  pcre16_stack_free(void *);
502 PCRE_EXP_DECL int   pcre16_callout(pcre16_callout_block *);
503 
504 PCRE_EXP_DECL void *pcre32_malloc(size_t);
505 PCRE_EXP_DECL void  pcre32_free(void *);
506 PCRE_EXP_DECL void *pcre32_stack_malloc(size_t);
507 PCRE_EXP_DECL void  pcre32_stack_free(void *);
508 PCRE_EXP_DECL int   pcre32_callout(pcre32_callout_block *);
509 #endif  /* VPCOMPAT */
510 
511 /* User defined callback which provides a stack just before the match starts. */
512 
513 typedef pcre_jit_stack *(*pcre_jit_callback)(void *);
514 typedef pcre16_jit_stack *(*pcre16_jit_callback)(void *);
515 typedef pcre32_jit_stack *(*pcre32_jit_callback)(void *);
516 
517 /* Exported PCRE functions */
518 
519 PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
520                   const unsigned char *);
521 PCRE_EXP_DECL pcre16 *pcre16_compile(PCRE_SPTR16, int, const char **, int *,
522                   const unsigned char *);
523 PCRE_EXP_DECL pcre32 *pcre32_compile(PCRE_SPTR32, int, const char **, int *,
524                   const unsigned char *);
525 PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
526                   int *, const unsigned char *);
527 PCRE_EXP_DECL pcre16 *pcre16_compile2(PCRE_SPTR16, int, int *, const char **,
528                   int *, const unsigned char *);
529 PCRE_EXP_DECL pcre32 *pcre32_compile2(PCRE_SPTR32, int, int *, const char **,
530                   int *, const unsigned char *);
531 PCRE_EXP_DECL int  pcre_config(int, void *);
532 PCRE_EXP_DECL int  pcre16_config(int, void *);
533 PCRE_EXP_DECL int  pcre32_config(int, void *);
534 PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
535                   int *, int, const char *, char *, int);
536 PCRE_EXP_DECL int  pcre16_copy_named_substring(const pcre16 *, PCRE_SPTR16,
537                   int *, int, PCRE_SPTR16, PCRE_UCHAR16 *, int);
538 PCRE_EXP_DECL int  pcre32_copy_named_substring(const pcre32 *, PCRE_SPTR32,
539                   int *, int, PCRE_SPTR32, PCRE_UCHAR32 *, int);
540 PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int,
541                   char *, int);
542 PCRE_EXP_DECL int  pcre16_copy_substring(PCRE_SPTR16, int *, int, int,
543                   PCRE_UCHAR16 *, int);
544 PCRE_EXP_DECL int  pcre32_copy_substring(PCRE_SPTR32, int *, int, int,
545                   PCRE_UCHAR32 *, int);
546 PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
547                   const char *, int, int, int, int *, int , int *, int);
548 PCRE_EXP_DECL int  pcre16_dfa_exec(const pcre16 *, const pcre16_extra *,
549                   PCRE_SPTR16, int, int, int, int *, int , int *, int);
550 PCRE_EXP_DECL int  pcre32_dfa_exec(const pcre32 *, const pcre32_extra *,
551                   PCRE_SPTR32, int, int, int, int *, int , int *, int);
552 PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
553                    int, int, int, int *, int);
554 PCRE_EXP_DECL int  pcre16_exec(const pcre16 *, const pcre16_extra *,
555                    PCRE_SPTR16, int, int, int, int *, int);
556 PCRE_EXP_DECL int  pcre32_exec(const pcre32 *, const pcre32_extra *,
557                    PCRE_SPTR32, int, int, int, int *, int);
558 PCRE_EXP_DECL int  pcre_jit_exec(const pcre *, const pcre_extra *,
559                    PCRE_SPTR, int, int, int, int *, int,
560                    pcre_jit_stack *);
561 PCRE_EXP_DECL int  pcre16_jit_exec(const pcre16 *, const pcre16_extra *,
562                    PCRE_SPTR16, int, int, int, int *, int,
563                    pcre16_jit_stack *);
564 PCRE_EXP_DECL int  pcre32_jit_exec(const pcre32 *, const pcre32_extra *,
565                    PCRE_SPTR32, int, int, int, int *, int,
566                    pcre32_jit_stack *);
567 PCRE_EXP_DECL void pcre_free_substring(const char *);
568 PCRE_EXP_DECL void pcre16_free_substring(PCRE_SPTR16);
569 PCRE_EXP_DECL void pcre32_free_substring(PCRE_SPTR32);
570 PCRE_EXP_DECL void pcre_free_substring_list(const char **);
571 PCRE_EXP_DECL void pcre16_free_substring_list(PCRE_SPTR16 *);
572 PCRE_EXP_DECL void pcre32_free_substring_list(PCRE_SPTR32 *);
573 PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
574                   void *);
575 PCRE_EXP_DECL int  pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int,
576                   void *);
577 PCRE_EXP_DECL int  pcre32_fullinfo(const pcre32 *, const pcre32_extra *, int,
578                   void *);
579 PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
580                   int *, int, const char *, const char **);
581 PCRE_EXP_DECL int  pcre16_get_named_substring(const pcre16 *, PCRE_SPTR16,
582                   int *, int, PCRE_SPTR16, PCRE_SPTR16 *);
583 PCRE_EXP_DECL int  pcre32_get_named_substring(const pcre32 *, PCRE_SPTR32,
584                   int *, int, PCRE_SPTR32, PCRE_SPTR32 *);
585 PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
586 PCRE_EXP_DECL int  pcre16_get_stringnumber(const pcre16 *, PCRE_SPTR16);
587 PCRE_EXP_DECL int  pcre32_get_stringnumber(const pcre32 *, PCRE_SPTR32);
588 PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
589                   char **, char **);
590 PCRE_EXP_DECL int  pcre16_get_stringtable_entries(const pcre16 *, PCRE_SPTR16,
591                   PCRE_UCHAR16 **, PCRE_UCHAR16 **);
592 PCRE_EXP_DECL int  pcre32_get_stringtable_entries(const pcre32 *, PCRE_SPTR32,
593                   PCRE_UCHAR32 **, PCRE_UCHAR32 **);
594 PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
595                   const char **);
596 PCRE_EXP_DECL int  pcre16_get_substring(PCRE_SPTR16, int *, int, int,
597                   PCRE_SPTR16 *);
598 PCRE_EXP_DECL int  pcre32_get_substring(PCRE_SPTR32, int *, int, int,
599                   PCRE_SPTR32 *);
600 PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
601                   const char ***);
602 PCRE_EXP_DECL int  pcre16_get_substring_list(PCRE_SPTR16, int *, int,
603                   PCRE_SPTR16 **);
604 PCRE_EXP_DECL int  pcre32_get_substring_list(PCRE_SPTR32, int *, int,
605                   PCRE_SPTR32 **);
606 PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
607 PCRE_EXP_DECL const unsigned char *pcre16_maketables(void);
608 PCRE_EXP_DECL const unsigned char *pcre32_maketables(void);
609 PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
610 PCRE_EXP_DECL int  pcre16_refcount(pcre16 *, int);
611 PCRE_EXP_DECL int  pcre32_refcount(pcre32 *, int);
612 PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
613 PCRE_EXP_DECL pcre16_extra *pcre16_study(const pcre16 *, int, const char **);
614 PCRE_EXP_DECL pcre32_extra *pcre32_study(const pcre32 *, int, const char **);
615 PCRE_EXP_DECL void pcre_free_study(pcre_extra *);
616 PCRE_EXP_DECL void pcre16_free_study(pcre16_extra *);
617 PCRE_EXP_DECL void pcre32_free_study(pcre32_extra *);
618 PCRE_EXP_DECL const char *pcre_version(void);
619 PCRE_EXP_DECL const char *pcre16_version(void);
620 PCRE_EXP_DECL const char *pcre32_version(void);
621 
622 /* Utility functions for byte order swaps. */
623 PCRE_EXP_DECL int  pcre_pattern_to_host_byte_order(pcre *, pcre_extra *,
624                   const unsigned char *);
625 PCRE_EXP_DECL int  pcre16_pattern_to_host_byte_order(pcre16 *, pcre16_extra *,
626                   const unsigned char *);
627 PCRE_EXP_DECL int  pcre32_pattern_to_host_byte_order(pcre32 *, pcre32_extra *,
628                   const unsigned char *);
629 PCRE_EXP_DECL int  pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *,
630                   PCRE_SPTR16, int, int *, int);
631 PCRE_EXP_DECL int  pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *,
632                   PCRE_SPTR32, int, int *, int);
633 
634 /* JIT compiler related functions. */
635 
636 PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int);
637 PCRE_EXP_DECL pcre16_jit_stack *pcre16_jit_stack_alloc(int, int);
638 PCRE_EXP_DECL pcre32_jit_stack *pcre32_jit_stack_alloc(int, int);
639 PCRE_EXP_DECL void pcre_jit_stack_free(pcre_jit_stack *);
640 PCRE_EXP_DECL void pcre16_jit_stack_free(pcre16_jit_stack *);
641 PCRE_EXP_DECL void pcre32_jit_stack_free(pcre32_jit_stack *);
642 PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *,
643                   pcre_jit_callback, void *);
644 PCRE_EXP_DECL void pcre16_assign_jit_stack(pcre16_extra *,
645                   pcre16_jit_callback, void *);
646 PCRE_EXP_DECL void pcre32_assign_jit_stack(pcre32_extra *,
647                   pcre32_jit_callback, void *);
648 
649 #ifdef __cplusplus
650 }  /* extern "C" */
651 #endif
652 
653 #endif /* End of pcre.h */
654