1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2017 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 /* $Id$ */ 20 21 #ifndef PHP_PCRE_H 22 #define PHP_PCRE_H 23 24 #if HAVE_PCRE || HAVE_BUNDLED_PCRE 25 26 #if HAVE_BUNDLED_PCRE 27 #include "pcrelib/pcre.h" 28 #else 29 #include "pcre.h" 30 #endif 31 32 #if HAVE_LOCALE_H 33 #include <locale.h> 34 #endif 35 36 PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int limit, int *replace_count); 37 PHPAPI pcre* pcre_get_compiled_regex(zend_string *regex, pcre_extra **extra, int *options); 38 PHPAPI pcre* pcre_get_compiled_regex_ex(zend_string *regex, pcre_extra **extra, int *preg_options, int *coptions); 39 40 extern zend_module_entry pcre_module_entry; 41 #define pcre_module_ptr &pcre_module_entry 42 43 #include "php_version.h" 44 #define PHP_PCRE_VERSION PHP_VERSION 45 46 typedef struct { 47 pcre *re; 48 pcre_extra *extra; 49 int preg_options; 50 int capture_count; 51 int name_count; 52 #if HAVE_SETLOCALE 53 zend_string *locale; 54 unsigned const char *tables; 55 #endif 56 int compile_options; 57 int refcount; 58 } pcre_cache_entry; 59 60 PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex); 61 62 PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, 63 zval *subpats, int global, int use_flags, zend_long flags, zend_long start_offset); 64 65 PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, int subject_len, zval *return_value, 66 int is_callable_replace, int limit, int *replace_count); 67 68 PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, 69 zend_long limit_val, zend_long flags); 70 71 PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, 72 zend_long flags); 73 74 ZEND_BEGIN_MODULE_GLOBALS(pcre) 75 HashTable pcre_cache; 76 zend_long backtrack_limit; 77 zend_long recursion_limit; 78 #ifdef HAVE_PCRE_JIT_SUPPORT 79 zend_bool jit; 80 #endif 81 int error_code; 82 ZEND_END_MODULE_GLOBALS(pcre) 83 84 PHPAPI ZEND_EXTERN_MODULE_GLOBALS(pcre) 85 #define PCRE_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(pcre, v) 86 87 #else 88 89 #define pcre_module_ptr NULL 90 91 #endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */ 92 93 #define phpext_pcre_ptr pcre_module_ptr 94 95 #endif /* PHP_PCRE_H */ 96