xref: /PHP-7.3/ext/pcre/php_pcre.h (revision a8f60ac9)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Andrei Zmievski <andrei@php.net>                             |
16    +----------------------------------------------------------------------+
17  */
18 
19 #ifndef PHP_PCRE_H
20 #define PHP_PCRE_H
21 
22 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
23 
24 #if HAVE_BUNDLED_PCRE
25 #include "pcre2lib/pcre2.h"
26 #else
27 #include "pcre2.h"
28 #endif
29 
30 #if HAVE_LOCALE_H
31 #include <locale.h>
32 #endif
33 
34 PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
35 PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count, uint32_t *options);
36 PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions);
37 
38 extern zend_module_entry pcre_module_entry;
39 #define pcre_module_ptr &pcre_module_entry
40 
41 #include "php_version.h"
42 #define PHP_PCRE_VERSION PHP_VERSION
43 
44 typedef struct _pcre_cache_entry pcre_cache_entry;
45 
46 PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex);
47 PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, int locale_aware);
48 
49 PHPAPI void  php_pcre_match_impl(  pcre_cache_entry *pce, char *subject, size_t subject_len, zval *return_value,
50 	zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset);
51 
52 PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str,
53 	size_t limit, size_t *replace_count);
54 
55 PHPAPI void  php_pcre_split_impl(  pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
56 	zend_long limit_val, zend_long flags);
57 
58 PHPAPI void  php_pcre_grep_impl(   pcre_cache_entry *pce, zval *input, zval *return_value,
59 	zend_long flags);
60 
61 PHPAPI pcre2_match_context *php_pcre_mctx(void);
62 PHPAPI pcre2_general_context *php_pcre_gctx(void);
63 PHPAPI pcre2_compile_context *php_pcre_cctx(void);
64 PHPAPI void php_pcre_pce_incref(pcre_cache_entry *);
65 PHPAPI void php_pcre_pce_decref(pcre_cache_entry *);
66 PHPAPI pcre2_code *php_pcre_pce_re(pcre_cache_entry *);
67 /* capture_count can be ignored, re is required. */
68 PHPAPI pcre2_match_data *php_pcre_create_match_data(uint32_t, pcre2_code *);
69 PHPAPI void php_pcre_free_match_data(pcre2_match_data *);
70 
71 ZEND_BEGIN_MODULE_GLOBALS(pcre)
72 	HashTable pcre_cache;
73 	zend_long backtrack_limit;
74 	zend_long recursion_limit;
75 #ifdef HAVE_PCRE_JIT_SUPPORT
76 	zend_bool jit;
77 #endif
78 	int  error_code;
79 ZEND_END_MODULE_GLOBALS(pcre)
80 
81 PHPAPI ZEND_EXTERN_MODULE_GLOBALS(pcre)
82 #define PCRE_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(pcre, v)
83 
84 #else
85 
86 #define pcre_module_ptr NULL
87 
88 #endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */
89 
90 #define phpext_pcre_ptr pcre_module_ptr
91 
92 #endif /* PHP_PCRE_H */
93