1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 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_BUNDLED_PCRE 23 #include "pcre2lib/pcre2.h" 24 #else 25 #include "pcre2.h" 26 #endif 27 28 #include <locale.h> 29 30 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); 31 PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count); 32 PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions); 33 34 extern zend_module_entry pcre_module_entry; 35 #define pcre_module_ptr &pcre_module_entry 36 37 #include "php_version.h" 38 #define PHP_PCRE_VERSION PHP_VERSION 39 40 typedef struct _pcre_cache_entry pcre_cache_entry; 41 42 PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex); 43 PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, int locale_aware); 44 45 PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, 46 zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset); 47 48 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, 49 size_t limit, size_t *replace_count); 50 51 PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, 52 zend_long limit_val, zend_long flags); 53 54 PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, 55 zend_long flags); 56 57 PHPAPI pcre2_match_context *php_pcre_mctx(void); 58 PHPAPI pcre2_general_context *php_pcre_gctx(void); 59 PHPAPI pcre2_compile_context *php_pcre_cctx(void); 60 PHPAPI void php_pcre_pce_incref(pcre_cache_entry *); 61 PHPAPI void php_pcre_pce_decref(pcre_cache_entry *); 62 PHPAPI pcre2_code *php_pcre_pce_re(pcre_cache_entry *); 63 /* capture_count can be ignored, re is required. */ 64 PHPAPI pcre2_match_data *php_pcre_create_match_data(uint32_t, pcre2_code *); 65 PHPAPI void php_pcre_free_match_data(pcre2_match_data *); 66 67 ZEND_BEGIN_MODULE_GLOBALS(pcre) 68 HashTable pcre_cache; 69 zend_long backtrack_limit; 70 zend_long recursion_limit; 71 #ifdef HAVE_PCRE_JIT_SUPPORT 72 zend_bool jit; 73 #endif 74 zend_bool per_request_cache; 75 int error_code; 76 /* Used for unmatched subpatterns in OFFSET_CAPTURE mode */ 77 zval unmatched_null_pair; 78 zval unmatched_empty_pair; 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 #define phpext_pcre_ptr pcre_module_ptr 85 86 #endif /* PHP_PCRE_H */ 87