• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*************************************************
2*       Perl-Compatible Regular Expressions      *
3*************************************************/
4
5/* This is the public header file for the PCRE library, second API, to be
6#included by applications that call PCRE2 functions.
7
8           Copyright (c) 2016 University of Cambridge
9
10-----------------------------------------------------------------------------
11Redistribution and use in source and binary forms, with or without
12modification, 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
25THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36-----------------------------------------------------------------------------
37*/
38
39#ifndef _PCRE2_H
40#define _PCRE2_H
41
42/* The current PCRE version information. */
43
44#define PCRE2_MAJOR          10
45#define PCRE2_MINOR          22
46#define PCRE2_PRERELEASE
47#define PCRE2_DATE           2016-07-29
48
49/* When an application links to a PCRE DLL in Windows, the symbols that are
50imported have to be identified as such. When building PCRE2, the appropriate
51export setting is defined in pcre2_internal.h, which includes this file. So we
52don't change existing definitions of PCRE2_EXP_DECL. */
53
54#if defined(_WIN32) && !defined(PCRE2_STATIC)
55#  ifndef PCRE2_EXP_DECL
56#    define PCRE2_EXP_DECL  extern __declspec(dllimport)
57#  endif
58#endif
59
60/* By default, we use the standard "extern" declarations. */
61
62#ifndef PCRE2_EXP_DECL
63#  ifdef __cplusplus
64#    define PCRE2_EXP_DECL  extern "C"
65#  else
66#    define PCRE2_EXP_DECL  extern
67#  endif
68#endif
69
70/* Have to include limits.h, stdlib.h and stdint.h to ensure that size_t and
71uint8_t, UCHAR_MAX, etc are defined. */
72
73#include <limits.h>
74#include <stdlib.h>
75#include <stdint.h>
76
77/* Allow for C++ users compiling this directly. */
78
79#ifdef __cplusplus
80extern "C" {
81#endif
82
83/* The following option bits can be passed to pcre2_compile(), pcre2_match(),
84or pcre2_dfa_match(). PCRE2_NO_UTF_CHECK affects only the function to which it
85is passed. Put these bits at the most significant end of the options word so
86others can be added next to them */
87
88#define PCRE2_ANCHORED            0x80000000u
89#define PCRE2_NO_UTF_CHECK        0x40000000u
90
91/* The following option bits can be passed only to pcre2_compile(). However,
92they may affect compilation, JIT compilation, and/or interpretive execution.
93The following tags indicate which:
94
95C   alters what is compiled by pcre2_compile()
96J   alters what is compiled by pcre2_jit_compile()
97M   is inspected during pcre2_match() execution
98D   is inspected during pcre2_dfa_match() execution
99*/
100
101#define PCRE2_ALLOW_EMPTY_CLASS   0x00000001u  /* C       */
102#define PCRE2_ALT_BSUX            0x00000002u  /* C       */
103#define PCRE2_AUTO_CALLOUT        0x00000004u  /* C       */
104#define PCRE2_CASELESS            0x00000008u  /* C       */
105#define PCRE2_DOLLAR_ENDONLY      0x00000010u  /*   J M D */
106#define PCRE2_DOTALL              0x00000020u  /* C       */
107#define PCRE2_DUPNAMES            0x00000040u  /* C       */
108#define PCRE2_EXTENDED            0x00000080u  /* C       */
109#define PCRE2_FIRSTLINE           0x00000100u  /*   J M D */
110#define PCRE2_MATCH_UNSET_BACKREF 0x00000200u  /* C J M   */
111#define PCRE2_MULTILINE           0x00000400u  /* C       */
112#define PCRE2_NEVER_UCP           0x00000800u  /* C       */
113#define PCRE2_NEVER_UTF           0x00001000u  /* C       */
114#define PCRE2_NO_AUTO_CAPTURE     0x00002000u  /* C       */
115#define PCRE2_NO_AUTO_POSSESS     0x00004000u  /* C       */
116#define PCRE2_NO_DOTSTAR_ANCHOR   0x00008000u  /* C       */
117#define PCRE2_NO_START_OPTIMIZE   0x00010000u  /*   J M D */
118#define PCRE2_UCP                 0x00020000u  /* C J M D */
119#define PCRE2_UNGREEDY            0x00040000u  /* C       */
120#define PCRE2_UTF                 0x00080000u  /* C J M D */
121#define PCRE2_NEVER_BACKSLASH_C   0x00100000u  /* C       */
122#define PCRE2_ALT_CIRCUMFLEX      0x00200000u  /*   J M D */
123#define PCRE2_ALT_VERBNAMES       0x00400000u  /* C       */
124#define PCRE2_USE_OFFSET_LIMIT    0x00800000u  /*   J M D */
125
126/* These are for pcre2_jit_compile(). */
127
128#define PCRE2_JIT_COMPLETE        0x00000001u  /* For full matching */
129#define PCRE2_JIT_PARTIAL_SOFT    0x00000002u
130#define PCRE2_JIT_PARTIAL_HARD    0x00000004u
131
132/* These are for pcre2_match(), pcre2_dfa_match(), and pcre2_jit_match(). Note
133that PCRE2_ANCHORED and PCRE2_NO_UTF_CHECK can also be passed to these
134functions (though pcre2_jit_match() ignores the latter since it bypasses all
135sanity checks). */
136
137#define PCRE2_NOTBOL              0x00000001u
138#define PCRE2_NOTEOL              0x00000002u
139#define PCRE2_NOTEMPTY            0x00000004u  /* ) These two must be kept */
140#define PCRE2_NOTEMPTY_ATSTART    0x00000008u  /* ) adjacent to each other. */
141#define PCRE2_PARTIAL_SOFT        0x00000010u
142#define PCRE2_PARTIAL_HARD        0x00000020u
143
144/* These are additional options for pcre2_dfa_match(). */
145
146#define PCRE2_DFA_RESTART         0x00000040u
147#define PCRE2_DFA_SHORTEST        0x00000080u
148
149/* These are additional options for pcre2_substitute(), which passes any others
150through to pcre2_match(). */
151
152#define PCRE2_SUBSTITUTE_GLOBAL           0x00000100u
153#define PCRE2_SUBSTITUTE_EXTENDED         0x00000200u
154#define PCRE2_SUBSTITUTE_UNSET_EMPTY      0x00000400u
155#define PCRE2_SUBSTITUTE_UNKNOWN_UNSET    0x00000800u
156#define PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  0x00001000u
157
158/* A further option for pcre2_match(), not allowed for pcre2_dfa_match(),
159ignored for pcre2_jit_match(). */
160
161#define PCRE2_NO_JIT              0x00002000u
162
163/* Newline and \R settings, for use in compile contexts. The newline values
164must be kept in step with values set in config.h and both sets must all be
165greater than zero. */
166
167#define PCRE2_NEWLINE_CR          1
168#define PCRE2_NEWLINE_LF          2
169#define PCRE2_NEWLINE_CRLF        3
170#define PCRE2_NEWLINE_ANY         4
171#define PCRE2_NEWLINE_ANYCRLF     5
172
173#define PCRE2_BSR_UNICODE         1
174#define PCRE2_BSR_ANYCRLF         2
175
176/* Error codes: no match and partial match are "expected" errors. */
177
178#define PCRE2_ERROR_NOMATCH          (-1)
179#define PCRE2_ERROR_PARTIAL          (-2)
180
181/* Error codes for UTF-8 validity checks */
182
183#define PCRE2_ERROR_UTF8_ERR1        (-3)
184#define PCRE2_ERROR_UTF8_ERR2        (-4)
185#define PCRE2_ERROR_UTF8_ERR3        (-5)
186#define PCRE2_ERROR_UTF8_ERR4        (-6)
187#define PCRE2_ERROR_UTF8_ERR5        (-7)
188#define PCRE2_ERROR_UTF8_ERR6        (-8)
189#define PCRE2_ERROR_UTF8_ERR7        (-9)
190#define PCRE2_ERROR_UTF8_ERR8       (-10)
191#define PCRE2_ERROR_UTF8_ERR9       (-11)
192#define PCRE2_ERROR_UTF8_ERR10      (-12)
193#define PCRE2_ERROR_UTF8_ERR11      (-13)
194#define PCRE2_ERROR_UTF8_ERR12      (-14)
195#define PCRE2_ERROR_UTF8_ERR13      (-15)
196#define PCRE2_ERROR_UTF8_ERR14      (-16)
197#define PCRE2_ERROR_UTF8_ERR15      (-17)
198#define PCRE2_ERROR_UTF8_ERR16      (-18)
199#define PCRE2_ERROR_UTF8_ERR17      (-19)
200#define PCRE2_ERROR_UTF8_ERR18      (-20)
201#define PCRE2_ERROR_UTF8_ERR19      (-21)
202#define PCRE2_ERROR_UTF8_ERR20      (-22)
203#define PCRE2_ERROR_UTF8_ERR21      (-23)
204
205/* Error codes for UTF-16 validity checks */
206
207#define PCRE2_ERROR_UTF16_ERR1      (-24)
208#define PCRE2_ERROR_UTF16_ERR2      (-25)
209#define PCRE2_ERROR_UTF16_ERR3      (-26)
210
211/* Error codes for UTF-32 validity checks */
212
213#define PCRE2_ERROR_UTF32_ERR1      (-27)
214#define PCRE2_ERROR_UTF32_ERR2      (-28)
215
216/* Error codes for pcre2[_dfa]_match(), substring extraction functions, context
217functions, and serializing functions. They are in numerical order. Originally
218they were in alphabetical order too, but now that PCRE2 is released, the
219numbers must not be changed. */
220
221#define PCRE2_ERROR_BADDATA           (-29)
222#define PCRE2_ERROR_MIXEDTABLES       (-30)  /* Name was changed */
223#define PCRE2_ERROR_BADMAGIC          (-31)
224#define PCRE2_ERROR_BADMODE           (-32)
225#define PCRE2_ERROR_BADOFFSET         (-33)
226#define PCRE2_ERROR_BADOPTION         (-34)
227#define PCRE2_ERROR_BADREPLACEMENT    (-35)
228#define PCRE2_ERROR_BADUTFOFFSET      (-36)
229#define PCRE2_ERROR_CALLOUT           (-37)  /* Never used by PCRE2 itself */
230#define PCRE2_ERROR_DFA_BADRESTART    (-38)
231#define PCRE2_ERROR_DFA_RECURSE       (-39)
232#define PCRE2_ERROR_DFA_UCOND         (-40)
233#define PCRE2_ERROR_DFA_UFUNC         (-41)
234#define PCRE2_ERROR_DFA_UITEM         (-42)
235#define PCRE2_ERROR_DFA_WSSIZE        (-43)
236#define PCRE2_ERROR_INTERNAL          (-44)
237#define PCRE2_ERROR_JIT_BADOPTION     (-45)
238#define PCRE2_ERROR_JIT_STACKLIMIT    (-46)
239#define PCRE2_ERROR_MATCHLIMIT        (-47)
240#define PCRE2_ERROR_NOMEMORY          (-48)
241#define PCRE2_ERROR_NOSUBSTRING       (-49)
242#define PCRE2_ERROR_NOUNIQUESUBSTRING (-50)
243#define PCRE2_ERROR_NULL              (-51)
244#define PCRE2_ERROR_RECURSELOOP       (-52)
245#define PCRE2_ERROR_RECURSIONLIMIT    (-53)
246#define PCRE2_ERROR_UNAVAILABLE       (-54)
247#define PCRE2_ERROR_UNSET             (-55)
248#define PCRE2_ERROR_BADOFFSETLIMIT    (-56)
249#define PCRE2_ERROR_BADREPESCAPE      (-57)
250#define PCRE2_ERROR_REPMISSINGBRACE   (-58)
251#define PCRE2_ERROR_BADSUBSTITUTION   (-59)
252#define PCRE2_ERROR_BADSUBSPATTERN    (-60)
253#define PCRE2_ERROR_TOOMANYREPLACE    (-61)
254#define PCRE2_ERROR_BADSERIALIZEDDATA (-62)
255
256/* Request types for pcre2_pattern_info() */
257
258#define PCRE2_INFO_ALLOPTIONS            0
259#define PCRE2_INFO_ARGOPTIONS            1
260#define PCRE2_INFO_BACKREFMAX            2
261#define PCRE2_INFO_BSR                   3
262#define PCRE2_INFO_CAPTURECOUNT          4
263#define PCRE2_INFO_FIRSTCODEUNIT         5
264#define PCRE2_INFO_FIRSTCODETYPE         6
265#define PCRE2_INFO_FIRSTBITMAP           7
266#define PCRE2_INFO_HASCRORLF             8
267#define PCRE2_INFO_JCHANGED              9
268#define PCRE2_INFO_JITSIZE              10
269#define PCRE2_INFO_LASTCODEUNIT         11
270#define PCRE2_INFO_LASTCODETYPE         12
271#define PCRE2_INFO_MATCHEMPTY           13
272#define PCRE2_INFO_MATCHLIMIT           14
273#define PCRE2_INFO_MAXLOOKBEHIND        15
274#define PCRE2_INFO_MINLENGTH            16
275#define PCRE2_INFO_NAMECOUNT            17
276#define PCRE2_INFO_NAMEENTRYSIZE        18
277#define PCRE2_INFO_NAMETABLE            19
278#define PCRE2_INFO_NEWLINE              20
279#define PCRE2_INFO_RECURSIONLIMIT       21
280#define PCRE2_INFO_SIZE                 22
281#define PCRE2_INFO_HASBACKSLASHC        23
282
283/* Request types for pcre2_config(). */
284
285#define PCRE2_CONFIG_BSR                     0
286#define PCRE2_CONFIG_JIT                     1
287#define PCRE2_CONFIG_JITTARGET               2
288#define PCRE2_CONFIG_LINKSIZE                3
289#define PCRE2_CONFIG_MATCHLIMIT              4
290#define PCRE2_CONFIG_NEWLINE                 5
291#define PCRE2_CONFIG_PARENSLIMIT             6
292#define PCRE2_CONFIG_RECURSIONLIMIT          7
293#define PCRE2_CONFIG_STACKRECURSE            8
294#define PCRE2_CONFIG_UNICODE                 9
295#define PCRE2_CONFIG_UNICODE_VERSION        10
296#define PCRE2_CONFIG_VERSION                11
297
298/* Types for code units in patterns and subject strings. */
299
300typedef uint8_t  PCRE2_UCHAR8;
301typedef uint16_t PCRE2_UCHAR16;
302typedef uint32_t PCRE2_UCHAR32;
303
304typedef const PCRE2_UCHAR8  *PCRE2_SPTR8;
305typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
306typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
307
308/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE2,
309including pattern offsets for errors and subject offsets after a match. We
310define special values to indicate zero-terminated strings and unset offsets in
311the offset vector (ovector). */
312
313#define PCRE2_SIZE            size_t
314#define PCRE2_SIZE_MAX        SIZE_MAX
315#define PCRE2_ZERO_TERMINATED (~(PCRE2_SIZE)0)
316#define PCRE2_UNSET           (~(PCRE2_SIZE)0)
317
318/* Generic types for opaque structures and JIT callback functions. These
319declarations are defined in a macro that is expanded for each width later. */
320
321#define PCRE2_TYPES_LIST \
322struct pcre2_real_general_context; \
323typedef struct pcre2_real_general_context pcre2_general_context; \
324\
325struct pcre2_real_compile_context; \
326typedef struct pcre2_real_compile_context pcre2_compile_context; \
327\
328struct pcre2_real_match_context; \
329typedef struct pcre2_real_match_context pcre2_match_context; \
330\
331struct pcre2_real_code; \
332typedef struct pcre2_real_code pcre2_code; \
333\
334struct pcre2_real_match_data; \
335typedef struct pcre2_real_match_data pcre2_match_data; \
336\
337struct pcre2_real_jit_stack; \
338typedef struct pcre2_real_jit_stack pcre2_jit_stack; \
339\
340typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *);
341
342
343/* The structure for passing out data via the pcre_callout_function. We use a
344structure so that new fields can be added on the end in future versions,
345without changing the API of the function, thereby allowing old clients to work
346without modification. Define the generic version in a macro; the width-specific
347versions are generated from this macro below. */
348
349#define PCRE2_STRUCTURE_LIST \
350typedef struct pcre2_callout_block { \
351  uint32_t      version;           /* Identifies version of block */ \
352  /* ------------------------ Version 0 ------------------------------- */ \
353  uint32_t      callout_number;    /* Number compiled into pattern */ \
354  uint32_t      capture_top;       /* Max current capture */ \
355  uint32_t      capture_last;      /* Most recently closed capture */ \
356  PCRE2_SIZE   *offset_vector;     /* The offset vector */ \
357  PCRE2_SPTR    mark;              /* Pointer to current mark or NULL */ \
358  PCRE2_SPTR    subject;           /* The subject being matched */ \
359  PCRE2_SIZE    subject_length;    /* The length of the subject */ \
360  PCRE2_SIZE    start_match;       /* Offset to start of this match attempt */ \
361  PCRE2_SIZE    current_position;  /* Where we currently are in the subject */ \
362  PCRE2_SIZE    pattern_position;  /* Offset to next item in the pattern */ \
363  PCRE2_SIZE    next_item_length;  /* Length of next item in the pattern */ \
364  /* ------------------- Added for Version 1 -------------------------- */ \
365  PCRE2_SIZE    callout_string_offset; /* Offset to string within pattern */ \
366  PCRE2_SIZE    callout_string_length; /* Length of string compiled into pattern */ \
367  PCRE2_SPTR    callout_string;    /* String compiled into pattern */ \
368  /* ------------------------------------------------------------------ */ \
369} pcre2_callout_block; \
370\
371typedef struct pcre2_callout_enumerate_block { \
372  uint32_t      version;           /* Identifies version of block */ \
373  /* ------------------------ Version 0 ------------------------------- */ \
374  PCRE2_SIZE    pattern_position;  /* Offset to next item in the pattern */ \
375  PCRE2_SIZE    next_item_length;  /* Length of next item in the pattern */ \
376  uint32_t      callout_number;    /* Number compiled into pattern */ \
377  PCRE2_SIZE    callout_string_offset; /* Offset to string within pattern */ \
378  PCRE2_SIZE    callout_string_length; /* Length of string compiled into pattern */ \
379  PCRE2_SPTR    callout_string;    /* String compiled into pattern */ \
380  /* ------------------------------------------------------------------ */ \
381} pcre2_callout_enumerate_block;
382
383
384/* List the generic forms of all other functions in macros, which will be
385expanded for each width below. Start with functions that give general
386information. */
387
388#define PCRE2_GENERAL_INFO_FUNCTIONS \
389PCRE2_EXP_DECL int       pcre2_config(uint32_t, void *);
390
391
392/* Functions for manipulating contexts. */
393
394#define PCRE2_GENERAL_CONTEXT_FUNCTIONS \
395PCRE2_EXP_DECL \
396  pcre2_general_context *pcre2_general_context_copy(pcre2_general_context *); \
397PCRE2_EXP_DECL \
398  pcre2_general_context *pcre2_general_context_create( \
399                           void *(*)(PCRE2_SIZE, void *), \
400                           void (*)(void *, void *), void *); \
401PCRE2_EXP_DECL void      pcre2_general_context_free(pcre2_general_context *);
402
403#define PCRE2_COMPILE_CONTEXT_FUNCTIONS \
404PCRE2_EXP_DECL \
405  pcre2_compile_context *pcre2_compile_context_copy(pcre2_compile_context *); \
406PCRE2_EXP_DECL \
407  pcre2_compile_context *pcre2_compile_context_create(pcre2_general_context *);\
408PCRE2_EXP_DECL void      pcre2_compile_context_free(pcre2_compile_context *); \
409PCRE2_EXP_DECL int       pcre2_set_bsr(pcre2_compile_context *, uint32_t); \
410PCRE2_EXP_DECL int       pcre2_set_character_tables(pcre2_compile_context *, \
411                           const unsigned char *); \
412PCRE2_EXP_DECL int       pcre2_set_max_pattern_length(pcre2_compile_context *, \
413                           PCRE2_SIZE); \
414PCRE2_EXP_DECL int       pcre2_set_newline(pcre2_compile_context *, uint32_t); \
415PCRE2_EXP_DECL int       pcre2_set_parens_nest_limit(pcre2_compile_context *, \
416                           uint32_t); \
417PCRE2_EXP_DECL int       pcre2_set_compile_recursion_guard(\
418                           pcre2_compile_context *, int (*)(uint32_t, void *), \
419                           void *);
420
421#define PCRE2_MATCH_CONTEXT_FUNCTIONS \
422PCRE2_EXP_DECL \
423  pcre2_match_context   *pcre2_match_context_copy(pcre2_match_context *); \
424PCRE2_EXP_DECL \
425  pcre2_match_context   *pcre2_match_context_create(pcre2_general_context *); \
426PCRE2_EXP_DECL void      pcre2_match_context_free(pcre2_match_context *); \
427PCRE2_EXP_DECL int       pcre2_set_callout(pcre2_match_context *, \
428                           int (*)(pcre2_callout_block *, void *), void *); \
429PCRE2_EXP_DECL int       pcre2_set_match_limit(pcre2_match_context *, \
430                           uint32_t); \
431PCRE2_EXP_DECL int       pcre2_set_offset_limit(pcre2_match_context *, \
432                           PCRE2_SIZE); \
433PCRE2_EXP_DECL int       pcre2_set_recursion_limit(pcre2_match_context *, \
434                           uint32_t); \
435PCRE2_EXP_DECL int       pcre2_set_recursion_memory_management( \
436                           pcre2_match_context *, void *(*)(PCRE2_SIZE, void *), \
437                           void (*)(void *, void *), void *);
438
439
440/* Functions concerned with compiling a pattern to PCRE internal code. */
441
442#define PCRE2_COMPILE_FUNCTIONS \
443PCRE2_EXP_DECL \
444  pcre2_code            *pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, \
445                           int *, PCRE2_SIZE *, pcre2_compile_context *); \
446PCRE2_EXP_DECL void      pcre2_code_free(pcre2_code *); \
447PCRE2_EXP_DECL \
448  pcre2_code            *pcre2_code_copy(const pcre2_code *);
449
450
451/* Functions that give information about a compiled pattern. */
452
453#define PCRE2_PATTERN_INFO_FUNCTIONS \
454PCRE2_EXP_DECL int       pcre2_pattern_info(const pcre2_code *, uint32_t, \
455                           void *); \
456PCRE2_EXP_DECL int       pcre2_callout_enumerate(const pcre2_code *, \
457                           int (*)(pcre2_callout_enumerate_block *, void *), \
458                           void *);
459
460
461/* Functions for running a match and inspecting the result. */
462
463#define PCRE2_MATCH_FUNCTIONS \
464PCRE2_EXP_DECL \
465  pcre2_match_data        *pcre2_match_data_create(uint32_t, \
466                             pcre2_general_context *); \
467PCRE2_EXP_DECL \
468  pcre2_match_data        *pcre2_match_data_create_from_pattern(\
469                             const pcre2_code *, \
470                             pcre2_general_context *); \
471PCRE2_EXP_DECL int         pcre2_dfa_match(const pcre2_code *, PCRE2_SPTR, \
472                             PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
473                             pcre2_match_data *, pcre2_match_context *, int *, \
474                             PCRE2_SIZE); \
475PCRE2_EXP_DECL int         pcre2_match(const pcre2_code *, \
476                             PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
477                             pcre2_match_data *, pcre2_match_context *); \
478PCRE2_EXP_DECL void        pcre2_match_data_free(pcre2_match_data *); \
479PCRE2_EXP_DECL PCRE2_SPTR  pcre2_get_mark(pcre2_match_data *); \
480PCRE2_EXP_DECL uint32_t    pcre2_get_ovector_count(pcre2_match_data *); \
481PCRE2_EXP_DECL PCRE2_SIZE *pcre2_get_ovector_pointer(pcre2_match_data *); \
482PCRE2_EXP_DECL PCRE2_SIZE  pcre2_get_startchar(pcre2_match_data *);
483
484
485/* Convenience functions for handling matched substrings. */
486
487#define PCRE2_SUBSTRING_FUNCTIONS \
488PCRE2_EXP_DECL int       pcre2_substring_copy_byname(pcre2_match_data *, \
489                           PCRE2_SPTR, PCRE2_UCHAR *, PCRE2_SIZE *); \
490PCRE2_EXP_DECL int       pcre2_substring_copy_bynumber(pcre2_match_data *, \
491                           uint32_t, PCRE2_UCHAR *, PCRE2_SIZE *); \
492PCRE2_EXP_DECL void      pcre2_substring_free(PCRE2_UCHAR *); \
493PCRE2_EXP_DECL int       pcre2_substring_get_byname(pcre2_match_data *, \
494                           PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_SIZE *); \
495PCRE2_EXP_DECL int       pcre2_substring_get_bynumber(pcre2_match_data *, \
496                           uint32_t, PCRE2_UCHAR **, PCRE2_SIZE *); \
497PCRE2_EXP_DECL int       pcre2_substring_length_byname(pcre2_match_data *, \
498                           PCRE2_SPTR, PCRE2_SIZE *); \
499PCRE2_EXP_DECL int       pcre2_substring_length_bynumber(pcre2_match_data *, \
500                           uint32_t, PCRE2_SIZE *); \
501PCRE2_EXP_DECL int       pcre2_substring_nametable_scan(const pcre2_code *, \
502                           PCRE2_SPTR, PCRE2_SPTR *, PCRE2_SPTR *); \
503PCRE2_EXP_DECL int       pcre2_substring_number_from_name(\
504                           const pcre2_code *, PCRE2_SPTR); \
505PCRE2_EXP_DECL void      pcre2_substring_list_free(PCRE2_SPTR *); \
506PCRE2_EXP_DECL int       pcre2_substring_list_get(pcre2_match_data *, \
507                           PCRE2_UCHAR ***, PCRE2_SIZE **);
508
509/* Functions for serializing / deserializing compiled patterns. */
510
511#define PCRE2_SERIALIZE_FUNCTIONS \
512PCRE2_EXP_DECL int32_t   pcre2_serialize_encode(const pcre2_code **, \
513                           int32_t, uint8_t **, PCRE2_SIZE *, \
514                           pcre2_general_context *); \
515PCRE2_EXP_DECL int32_t   pcre2_serialize_decode(pcre2_code **, int32_t, \
516                           const uint8_t *, pcre2_general_context *); \
517PCRE2_EXP_DECL int32_t   pcre2_serialize_get_number_of_codes(const uint8_t *); \
518PCRE2_EXP_DECL void      pcre2_serialize_free(uint8_t *);
519
520
521/* Convenience function for match + substitute. */
522
523#define PCRE2_SUBSTITUTE_FUNCTION \
524PCRE2_EXP_DECL int       pcre2_substitute(const pcre2_code *, \
525                           PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
526                           pcre2_match_data *, pcre2_match_context *, \
527                           PCRE2_SPTR, PCRE2_SIZE, PCRE2_UCHAR *, \
528                           PCRE2_SIZE *);
529
530
531/* Functions for JIT processing */
532
533#define PCRE2_JIT_FUNCTIONS \
534PCRE2_EXP_DECL int       pcre2_jit_compile(pcre2_code *, uint32_t); \
535PCRE2_EXP_DECL int       pcre2_jit_match(const pcre2_code *, \
536                           PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
537                           pcre2_match_data *, pcre2_match_context *); \
538PCRE2_EXP_DECL void      pcre2_jit_free_unused_memory(pcre2_general_context *); \
539PCRE2_EXP_DECL \
540  pcre2_jit_stack       *pcre2_jit_stack_create(PCRE2_SIZE, PCRE2_SIZE, \
541                           pcre2_general_context *); \
542PCRE2_EXP_DECL void      pcre2_jit_stack_assign(pcre2_match_context *, \
543                           pcre2_jit_callback, void *); \
544PCRE2_EXP_DECL void      pcre2_jit_stack_free(pcre2_jit_stack *);
545
546
547/* Other miscellaneous functions. */
548
549#define PCRE2_OTHER_FUNCTIONS \
550PCRE2_EXP_DECL int       pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \
551PCRE2_EXP_DECL \
552  const uint8_t         *pcre2_maketables(pcre2_general_context *); \
553
554
555/* Define macros that generate width-specific names from generic versions. The
556three-level macro scheme is necessary to get the macros expanded when we want
557them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for
558generating three versions of everything below. After that, PCRE2_SUFFIX will be
559re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as
560pcre2_compile are called by application code. */
561
562#define PCRE2_JOIN(a,b) a ## b
563#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b)
564#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
565
566
567/* Data types */
568
569#define PCRE2_UCHAR                 PCRE2_SUFFIX(PCRE2_UCHAR)
570#define PCRE2_SPTR                  PCRE2_SUFFIX(PCRE2_SPTR)
571
572#define pcre2_code                  PCRE2_SUFFIX(pcre2_code_)
573#define pcre2_jit_callback          PCRE2_SUFFIX(pcre2_jit_callback_)
574#define pcre2_jit_stack             PCRE2_SUFFIX(pcre2_jit_stack_)
575
576#define pcre2_real_code             PCRE2_SUFFIX(pcre2_real_code_)
577#define pcre2_real_general_context  PCRE2_SUFFIX(pcre2_real_general_context_)
578#define pcre2_real_compile_context  PCRE2_SUFFIX(pcre2_real_compile_context_)
579#define pcre2_real_match_context    PCRE2_SUFFIX(pcre2_real_match_context_)
580#define pcre2_real_jit_stack        PCRE2_SUFFIX(pcre2_real_jit_stack_)
581#define pcre2_real_match_data       PCRE2_SUFFIX(pcre2_real_match_data_)
582
583
584/* Data blocks */
585
586#define pcre2_callout_block            PCRE2_SUFFIX(pcre2_callout_block_)
587#define pcre2_callout_enumerate_block  PCRE2_SUFFIX(pcre2_callout_enumerate_block_)
588#define pcre2_general_context          PCRE2_SUFFIX(pcre2_general_context_)
589#define pcre2_compile_context          PCRE2_SUFFIX(pcre2_compile_context_)
590#define pcre2_match_context            PCRE2_SUFFIX(pcre2_match_context_)
591#define pcre2_match_data               PCRE2_SUFFIX(pcre2_match_data_)
592
593
594/* Functions: the complete list in alphabetical order */
595
596#define pcre2_callout_enumerate               PCRE2_SUFFIX(pcre2_callout_enumerate_)
597#define pcre2_code_copy                       PCRE2_SUFFIX(pcre2_code_copy_)
598#define pcre2_code_free                       PCRE2_SUFFIX(pcre2_code_free_)
599#define pcre2_compile                         PCRE2_SUFFIX(pcre2_compile_)
600#define pcre2_compile_context_copy            PCRE2_SUFFIX(pcre2_compile_context_copy_)
601#define pcre2_compile_context_create          PCRE2_SUFFIX(pcre2_compile_context_create_)
602#define pcre2_compile_context_free            PCRE2_SUFFIX(pcre2_compile_context_free_)
603#define pcre2_config                          PCRE2_SUFFIX(pcre2_config_)
604#define pcre2_dfa_match                       PCRE2_SUFFIX(pcre2_dfa_match_)
605#define pcre2_general_context_copy            PCRE2_SUFFIX(pcre2_general_context_copy_)
606#define pcre2_general_context_create          PCRE2_SUFFIX(pcre2_general_context_create_)
607#define pcre2_general_context_free            PCRE2_SUFFIX(pcre2_general_context_free_)
608#define pcre2_get_error_message               PCRE2_SUFFIX(pcre2_get_error_message_)
609#define pcre2_get_mark                        PCRE2_SUFFIX(pcre2_get_mark_)
610#define pcre2_get_ovector_pointer             PCRE2_SUFFIX(pcre2_get_ovector_pointer_)
611#define pcre2_get_ovector_count               PCRE2_SUFFIX(pcre2_get_ovector_count_)
612#define pcre2_get_startchar                   PCRE2_SUFFIX(pcre2_get_startchar_)
613#define pcre2_jit_compile                     PCRE2_SUFFIX(pcre2_jit_compile_)
614#define pcre2_jit_match                       PCRE2_SUFFIX(pcre2_jit_match_)
615#define pcre2_jit_free_unused_memory          PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
616#define pcre2_jit_stack_assign                PCRE2_SUFFIX(pcre2_jit_stack_assign_)
617#define pcre2_jit_stack_create                PCRE2_SUFFIX(pcre2_jit_stack_create_)
618#define pcre2_jit_stack_free                  PCRE2_SUFFIX(pcre2_jit_stack_free_)
619#define pcre2_maketables                      PCRE2_SUFFIX(pcre2_maketables_)
620#define pcre2_match                           PCRE2_SUFFIX(pcre2_match_)
621#define pcre2_match_context_copy              PCRE2_SUFFIX(pcre2_match_context_copy_)
622#define pcre2_match_context_create            PCRE2_SUFFIX(pcre2_match_context_create_)
623#define pcre2_match_context_free              PCRE2_SUFFIX(pcre2_match_context_free_)
624#define pcre2_match_data_create               PCRE2_SUFFIX(pcre2_match_data_create_)
625#define pcre2_match_data_create_from_pattern  PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_)
626#define pcre2_match_data_free                 PCRE2_SUFFIX(pcre2_match_data_free_)
627#define pcre2_pattern_info                    PCRE2_SUFFIX(pcre2_pattern_info_)
628#define pcre2_serialize_decode                PCRE2_SUFFIX(pcre2_serialize_decode_)
629#define pcre2_serialize_encode                PCRE2_SUFFIX(pcre2_serialize_encode_)
630#define pcre2_serialize_free                  PCRE2_SUFFIX(pcre2_serialize_free_)
631#define pcre2_serialize_get_number_of_codes   PCRE2_SUFFIX(pcre2_serialize_get_number_of_codes_)
632#define pcre2_set_bsr                         PCRE2_SUFFIX(pcre2_set_bsr_)
633#define pcre2_set_callout                     PCRE2_SUFFIX(pcre2_set_callout_)
634#define pcre2_set_character_tables            PCRE2_SUFFIX(pcre2_set_character_tables_)
635#define pcre2_set_compile_recursion_guard     PCRE2_SUFFIX(pcre2_set_compile_recursion_guard_)
636#define pcre2_set_match_limit                 PCRE2_SUFFIX(pcre2_set_match_limit_)
637#define pcre2_set_max_pattern_length          PCRE2_SUFFIX(pcre2_set_max_pattern_length_)
638#define pcre2_set_newline                     PCRE2_SUFFIX(pcre2_set_newline_)
639#define pcre2_set_parens_nest_limit           PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
640#define pcre2_set_offset_limit                PCRE2_SUFFIX(pcre2_set_offset_limit_)
641#define pcre2_set_recursion_limit             PCRE2_SUFFIX(pcre2_set_recursion_limit_)
642#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
643#define pcre2_substitute                      PCRE2_SUFFIX(pcre2_substitute_)
644#define pcre2_substring_copy_byname           PCRE2_SUFFIX(pcre2_substring_copy_byname_)
645#define pcre2_substring_copy_bynumber         PCRE2_SUFFIX(pcre2_substring_copy_bynumber_)
646#define pcre2_substring_free                  PCRE2_SUFFIX(pcre2_substring_free_)
647#define pcre2_substring_get_byname            PCRE2_SUFFIX(pcre2_substring_get_byname_)
648#define pcre2_substring_get_bynumber          PCRE2_SUFFIX(pcre2_substring_get_bynumber_)
649#define pcre2_substring_length_byname         PCRE2_SUFFIX(pcre2_substring_length_byname_)
650#define pcre2_substring_length_bynumber       PCRE2_SUFFIX(pcre2_substring_length_bynumber_)
651#define pcre2_substring_list_get              PCRE2_SUFFIX(pcre2_substring_list_get_)
652#define pcre2_substring_list_free             PCRE2_SUFFIX(pcre2_substring_list_free_)
653#define pcre2_substring_nametable_scan        PCRE2_SUFFIX(pcre2_substring_nametable_scan_)
654#define pcre2_substring_number_from_name      PCRE2_SUFFIX(pcre2_substring_number_from_name_)
655
656
657/* Now generate all three sets of width-specific structures and function
658prototypes. */
659
660#define PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS \
661PCRE2_TYPES_LIST \
662PCRE2_STRUCTURE_LIST \
663PCRE2_GENERAL_INFO_FUNCTIONS \
664PCRE2_GENERAL_CONTEXT_FUNCTIONS \
665PCRE2_COMPILE_CONTEXT_FUNCTIONS \
666PCRE2_MATCH_CONTEXT_FUNCTIONS \
667PCRE2_COMPILE_FUNCTIONS \
668PCRE2_PATTERN_INFO_FUNCTIONS \
669PCRE2_MATCH_FUNCTIONS \
670PCRE2_SUBSTRING_FUNCTIONS \
671PCRE2_SERIALIZE_FUNCTIONS \
672PCRE2_SUBSTITUTE_FUNCTION \
673PCRE2_JIT_FUNCTIONS \
674PCRE2_OTHER_FUNCTIONS
675
676#define PCRE2_LOCAL_WIDTH 8
677PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
678#undef PCRE2_LOCAL_WIDTH
679
680#define PCRE2_LOCAL_WIDTH 16
681PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
682#undef PCRE2_LOCAL_WIDTH
683
684#define PCRE2_LOCAL_WIDTH 32
685PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
686#undef PCRE2_LOCAL_WIDTH
687
688/* Undefine the list macros; they are no longer needed. */
689
690#undef PCRE2_TYPES_LIST
691#undef PCRE2_STRUCTURE_LIST
692#undef PCRE2_GENERAL_INFO_FUNCTIONS
693#undef PCRE2_GENERAL_CONTEXT_FUNCTIONS
694#undef PCRE2_COMPILE_CONTEXT_FUNCTIONS
695#undef PCRE2_MATCH_CONTEXT_FUNCTIONS
696#undef PCRE2_COMPILE_FUNCTIONS
697#undef PCRE2_PATTERN_INFO_FUNCTIONS
698#undef PCRE2_MATCH_FUNCTIONS
699#undef PCRE2_SUBSTRING_FUNCTIONS
700#undef PCRE2_SERIALIZE_FUNCTIONS
701#undef PCRE2_SUBSTITUTE_FUNCTION
702#undef PCRE2_JIT_FUNCTIONS
703#undef PCRE2_OTHER_FUNCTIONS
704#undef PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
705
706/* PCRE2_CODE_UNIT_WIDTH must be defined. If it is 8, 16, or 32, redefine
707PCRE2_SUFFIX to use it. If it is 0, undefine the other macros and make
708PCRE2_SUFFIX a no-op. Otherwise, generate an error. */
709
710#undef PCRE2_SUFFIX
711#ifndef PCRE2_CODE_UNIT_WIDTH
712#error PCRE2_CODE_UNIT_WIDTH must be defined before including pcre2.h.
713#error Use 8, 16, or 32; or 0 for a multi-width application.
714#else  /* PCRE2_CODE_UNIT_WIDTH is defined */
715#if PCRE2_CODE_UNIT_WIDTH == 8 || \
716    PCRE2_CODE_UNIT_WIDTH == 16 || \
717    PCRE2_CODE_UNIT_WIDTH == 32
718#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
719#elif PCRE2_CODE_UNIT_WIDTH == 0
720#undef PCRE2_JOIN
721#undef PCRE2_GLUE
722#define PCRE2_SUFFIX(a) a
723#else
724#error PCRE2_CODE_UNIT_WIDTH must be 0, 8, 16, or 32.
725#endif
726#endif  /* PCRE2_CODE_UNIT_WIDTH is defined */
727
728#ifdef __cplusplus
729}  /* extern "C" */
730#endif
731
732#endif /* End of pcre2.h */
733