1 #ifndef SP_PCRE_COMPAT_H 2 #define SP_PCRE_COMPAT_H 3 4 #include <stdlib.h> 5 #include <stdbool.h> 6 7 #undef pcre_exec 8 #undef pcre_compile 9 10 #define PCRE2_CODE_UNIT_WIDTH 8 11 #if PHP_VERSION_ID >= 70300 12 #define SP_HAS_PCRE2 13 #endif 14 #include "ext/pcre/php_pcre.h" // PCRE1 15 16 #ifdef SP_HAS_PCRE2 17 #define sp_pcre pcre2_code 18 #else 19 #define sp_pcre pcre 20 #endif 21 22 sp_pcre* sp_pcre_compile(const char* str); 23 #define sp_is_regexp_matching_zend(regexp, zstr) \ 24 sp_is_regexp_matching_len(regexp, ZSTR_VAL(zstr), ZSTR_LEN(zstr)) 25 #define sp_is_regexp_matching(regexp, str) \ 26 sp_is_regexp_matching_len(regexp, str, strlen(str)) 27 bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, 28 size_t len); 29 30 #endif // SP_PCRE_COMPAT_H 31