1 |
/*************************************************
|
2 |
* Perl-Compatible Regular Expressions *
|
3 |
*************************************************/
|
4 |
|
5 |
/* Copyright (c) 1997-2003 University of Cambridge */
|
6 |
|
7 |
#ifndef _PCRE_H
|
8 |
#define _PCRE_H
|
9 |
|
10 |
/* The file pcre.h is build by "configure". Do not edit it; instead
|
11 |
make changes to pcre.in. */
|
12 |
|
13 |
#define PCRE_MAJOR @PCRE_MAJOR@
|
14 |
#define PCRE_MINOR @PCRE_MINOR@
|
15 |
#define PCRE_DATE @PCRE_DATE@
|
16 |
|
17 |
/* Win32 uses DLL by default */
|
18 |
|
19 |
#ifdef _WIN32
|
20 |
# ifdef PCRE_DEFINITION
|
21 |
# ifdef DLL_EXPORT
|
22 |
# define PCRE_DATA_SCOPE __declspec(dllexport)
|
23 |
# endif
|
24 |
# else
|
25 |
# ifndef PCRE_STATIC
|
26 |
# define PCRE_DATA_SCOPE extern __declspec(dllimport)
|
27 |
# endif
|
28 |
# endif
|
29 |
#endif
|
30 |
#ifndef PCRE_DATA_SCOPE
|
31 |
# define PCRE_DATA_SCOPE extern
|
32 |
#endif
|
33 |
|
34 |
/* Have to include stdlib.h in order to ensure that size_t is defined;
|
35 |
it is needed here for malloc. */
|
36 |
|
37 |
#include <stdlib.h>
|
38 |
|
39 |
/* Allow for C++ users */
|
40 |
|
41 |
#ifdef __cplusplus
|
42 |
extern "C" {
|
43 |
#endif
|
44 |
|
45 |
/* Options */
|
46 |
|
47 |
#define PCRE_CASELESS 0x0001
|
48 |
#define PCRE_MULTILINE 0x0002
|
49 |
#define PCRE_DOTALL 0x0004
|
50 |
#define PCRE_EXTENDED 0x0008
|
51 |
#define PCRE_ANCHORED 0x0010
|
52 |
#define PCRE_DOLLAR_ENDONLY 0x0020
|
53 |
#define PCRE_EXTRA 0x0040
|
54 |
#define PCRE_NOTBOL 0x0080
|
55 |
#define PCRE_NOTEOL 0x0100
|
56 |
#define PCRE_UNGREEDY 0x0200
|
57 |
#define PCRE_NOTEMPTY 0x0400
|
58 |
#define PCRE_UTF8 0x0800
|
59 |
#define PCRE_NO_AUTO_CAPTURE 0x1000
|
60 |
#define PCRE_NO_UTF8_CHECK 0x2000
|
61 |
|
62 |
/* Exec-time and get/set-time error codes */
|
63 |
|
64 |
#define PCRE_ERROR_NOMATCH (-1)
|
65 |
#define PCRE_ERROR_NULL (-2)
|
66 |
#define PCRE_ERROR_BADOPTION (-3)
|
67 |
#define PCRE_ERROR_BADMAGIC (-4)
|
68 |
#define PCRE_ERROR_UNKNOWN_NODE (-5)
|
69 |
#define PCRE_ERROR_NOMEMORY (-6)
|
70 |
#define PCRE_ERROR_NOSUBSTRING (-7)
|
71 |
#define PCRE_ERROR_MATCHLIMIT (-8)
|
72 |
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
|
73 |
#define PCRE_ERROR_BADUTF8 (-10)
|
74 |
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
|
75 |
|
76 |
/* Request types for pcre_fullinfo() */
|
77 |
|
78 |
#define PCRE_INFO_OPTIONS 0
|
79 |
#define PCRE_INFO_SIZE 1
|
80 |
#define PCRE_INFO_CAPTURECOUNT 2
|
81 |
#define PCRE_INFO_BACKREFMAX 3
|
82 |
#define PCRE_INFO_FIRSTBYTE 4
|
83 |
#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
|
84 |
#define PCRE_INFO_FIRSTTABLE 5
|
85 |
#define PCRE_INFO_LASTLITERAL 6
|
86 |
#define PCRE_INFO_NAMEENTRYSIZE 7
|
87 |
#define PCRE_INFO_NAMECOUNT 8
|
88 |
#define PCRE_INFO_NAMETABLE 9
|
89 |
#define PCRE_INFO_STUDYSIZE 10
|
90 |
|
91 |
/* Request types for pcre_config() */
|
92 |
|
93 |
#define PCRE_CONFIG_UTF8 0
|
94 |
#define PCRE_CONFIG_NEWLINE 1
|
95 |
#define PCRE_CONFIG_LINK_SIZE 2
|
96 |
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
|
97 |
#define PCRE_CONFIG_MATCH_LIMIT 4
|
98 |
#define PCRE_CONFIG_STACKRECURSE 5
|
99 |
|
100 |
/* Bit flags for the pcre_extra structure */
|
101 |
|
102 |
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
103 |
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
|
104 |
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
105 |
|
106 |
/* Types */
|
107 |
|
108 |
struct real_pcre; /* declaration; the definition is private */
|
109 |
typedef struct real_pcre pcre;
|
110 |
|
111 |
/* The structure for passing additional data to pcre_exec(). This is defined in
|
112 |
such as way as to be extensible. */
|
113 |
|
114 |
typedef struct pcre_extra {
|
115 |
unsigned long int flags; /* Bits for which fields are set */
|
116 |
void *study_data; /* Opaque data from pcre_study() */
|
117 |
unsigned long int match_limit; /* Maximum number of calls to match() */
|
118 |
void *callout_data; /* Data passed back in callouts */
|
119 |
} pcre_extra;
|
120 |
|
121 |
/* The structure for passing out data via the pcre_callout_function. We use a
|
122 |
structure so that new fields can be added on the end in future versions,
|
123 |
without changing the API of the function, thereby allowing old clients to work
|
124 |
without modification. */
|
125 |
|
126 |
typedef struct pcre_callout_block {
|
127 |
int version; /* Identifies version of block */
|
128 |
/* ------------------------ Version 0 ------------------------------- */
|
129 |
int callout_number; /* Number compiled into pattern */
|
130 |
int *offset_vector; /* The offset vector */
|
131 |
const char *subject; /* The subject being matched */
|
132 |
int subject_length; /* The length of the subject */
|
133 |
int start_match; /* Offset to start of this match attempt */
|
134 |
int current_position; /* Where we currently are */
|
135 |
int capture_top; /* Max current capture */
|
136 |
int capture_last; /* Most recently closed capture */
|
137 |
void *callout_data; /* Data passed in with the call */
|
138 |
/* ------------------------------------------------------------------ */
|
139 |
} pcre_callout_block;
|
140 |
|
141 |
/* Indirection for store get and free functions. These can be set to
|
142 |
alternative malloc/free functions if required. Special ones are used in the
|
143 |
non-recursive case for "frames". There is also an optional callout function
|
144 |
that is triggered by the (?) regex item. Some magic is required for Win32 DLL;
|
145 |
it is null on other OS. For Virtual Pascal, these have to be different again.
|
146 |
*/
|
147 |
|
148 |
#ifndef VPCOMPAT
|
149 |
PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
|
150 |
PCRE_DATA_SCOPE void (*pcre_free)(void *);
|
151 |
PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
|
152 |
PCRE_DATA_SCOPE void (*pcre_stack_free)(void *);
|
153 |
PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
|
154 |
#else /* VPCOMPAT */
|
155 |
extern void *pcre_malloc(size_t);
|
156 |
extern void pcre_free(void *);
|
157 |
extern void *pcre_stack_malloc(size_t);
|
158 |
extern void pcre_stack_free(void *);
|
159 |
extern int pcre_callout(pcre_callout_block *);
|
160 |
#endif /* VPCOMPAT */
|
161 |
|
162 |
/* Exported PCRE functions */
|
163 |
|
164 |
extern pcre *pcre_compile(const char *, int, const char **,
|
165 |
int *, const unsigned char *);
|
166 |
extern int pcre_config(int, void *);
|
167 |
extern int pcre_copy_named_substring(const pcre *, const char *,
|
168 |
int *, int, const char *, char *, int);
|
169 |
extern int pcre_copy_substring(const char *, int *, int, int,
|
170 |
char *, int);
|
171 |
extern int pcre_exec(const pcre *, const pcre_extra *,
|
172 |
const char *, int, int, int, int *, int);
|
173 |
extern void pcre_free_substring(const char *);
|
174 |
extern void pcre_free_substring_list(const char **);
|
175 |
extern int pcre_fullinfo(const pcre *, const pcre_extra *, int,
|
176 |
void *);
|
177 |
extern int pcre_get_named_substring(const pcre *, const char *,
|
178 |
int *, int, const char *, const char **);
|
179 |
extern int pcre_get_stringnumber(const pcre *, const char *);
|
180 |
extern int pcre_get_substring(const char *, int *, int, int,
|
181 |
const char **);
|
182 |
extern int pcre_get_substring_list(const char *, int *, int,
|
183 |
const char ***);
|
184 |
extern int pcre_info(const pcre *, int *, int *);
|
185 |
extern const unsigned char *pcre_maketables(void);
|
186 |
extern pcre_extra *pcre_study(const pcre *, int, const char **);
|
187 |
extern const char *pcre_version(void);
|
188 |
|
189 |
#ifdef __cplusplus
|
190 |
} /* extern "C" */
|
191 |
#endif
|
192 |
|
193 |
#endif /* End of pcre.h */
|