pcre.h 31 KB

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