Created
July 27, 2023 19:11
-
-
Save loqs/f79a4095875defb294f6617ba06dcd41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/alarm.c b/core/alarm.c | |
index 4ab9fbcc..5dc89f3e 100644 | |
--- a/core/alarm.c | |
+++ b/core/alarm.c | |
@@ -170,7 +170,11 @@ static int uwsgi_alarm_log_add(char *alarms, char *regexp, int negate) { | |
} | |
ual = uwsgi_calloc(sizeof(struct uwsgi_alarm_log)); | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(regexp, &ual->pattern)) { | |
+#else | |
+ if (uwsgi_regexp_build(regexp, &ual->pattern, &ual->pattern_extra)) { | |
+#endif | |
free(ual); | |
return -1; | |
} | |
@@ -384,7 +388,11 @@ void uwsgi_alarm_log_check(char *msg, size_t len) { | |
return; | |
struct uwsgi_alarm_log *ual = uwsgi.alarm_logs; | |
while (ual) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(ual->pattern, msg, len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(ual->pattern, ual->pattern_extra, msg, len) >= 0) { | |
+#endif | |
if (!ual->negate) { | |
struct uwsgi_alarm_ll *uall = ual->alarms; | |
while (uall) { | |
diff --git a/core/logging.c b/core/logging.c | |
index 638c6391..2f07cb0b 100644 | |
--- a/core/logging.c | |
+++ b/core/logging.c | |
@@ -1447,7 +1447,11 @@ int uwsgi_master_log(void) { | |
uwsgi_alarm_log_check(uwsgi.log_master_buf, rlen); | |
struct uwsgi_regexp_list *url = uwsgi.log_drain_rules; | |
while (url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, uwsgi.log_master_buf, rlen) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, uwsgi.log_master_buf, rlen) >= 0) { | |
+#endif | |
return 0; | |
} | |
url = url->next; | |
@@ -1456,7 +1460,11 @@ int uwsgi_master_log(void) { | |
int show = 0; | |
url = uwsgi.log_filter_rules; | |
while (url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, uwsgi.log_master_buf, rlen) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, uwsgi.log_master_buf, rlen) >= 0) { | |
+#endif | |
show = 1; | |
break; | |
} | |
@@ -1469,7 +1477,11 @@ int uwsgi_master_log(void) { | |
url = uwsgi.log_route; | |
int finish = 0; | |
while (url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, uwsgi.log_master_buf, rlen) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, uwsgi.log_master_buf, rlen) >= 0) { | |
+#endif | |
struct uwsgi_logger *ul_route = (struct uwsgi_logger *) url->custom_ptr; | |
if (ul_route) { | |
uwsgi_log_func_do(uwsgi.requested_log_encoders, ul_route, uwsgi.log_master_buf, rlen); | |
@@ -1513,7 +1525,11 @@ int uwsgi_master_req_log(void) { | |
struct uwsgi_regexp_list *url = uwsgi.log_req_route; | |
int finish = 0; | |
while (url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, uwsgi.log_master_buf, rlen) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, uwsgi.log_master_buf, rlen) >= 0) { | |
+#endif | |
struct uwsgi_logger *ul_route = (struct uwsgi_logger *) url->custom_ptr; | |
if (ul_route) { | |
uwsgi_log_func_do(uwsgi.requested_log_req_encoders, ul_route, uwsgi.log_master_buf, rlen); | |
diff --git a/core/regexp.c b/core/regexp.c | |
index ac8357f0..4a2b2a30 100644 | |
--- a/core/regexp.c | |
+++ b/core/regexp.c | |
@@ -13,34 +13,64 @@ void uwsgi_opt_pcre_jit(char *opt, char *value, void *foobar) { | |
#endif | |
} | |
+#ifdef UWSGI_PCRE2 | |
int uwsgi_regexp_build(char *re, pcre2_code ** pattern) { | |
int errnbr; | |
long unsigned int erroff; | |
*pattern = pcre2_compile((const unsigned char *) re, PCRE2_ZERO_TERMINATED, 0, &errnbr, &erroff, NULL); | |
+#else | |
+int uwsgi_regexp_build(char *re, pcre ** pattern, pcre_extra ** pattern_extra) { | |
+ | |
+ const char *errstr; | |
+ int erroff; | |
+ | |
+ *pattern = pcre_compile((const char *) re, 0, &errstr, &erroff, NULL); | |
+#endif | |
if (!*pattern) { | |
+#ifdef UWSGI_PCRE2 | |
uwsgi_log("pcre error: code %d at offset %d\n", errnbr, erroff); | |
+#else | |
+ uwsgi_log("pcre error: %s at offset %d\n", errstr, erroff); | |
+#endif | |
return -1; | |
} | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi.pcre_jit) { | |
errnbr = pcre2_jit_compile(*pattern, PCRE2_JIT_COMPLETE); | |
if (errnbr) { | |
uwsgi_log("pcre JIT compile error code %d\n", errnbr); | |
return -1; | |
} | |
+#else | |
+ int opt = uwsgi.pcre_jit; | |
+ | |
+ *pattern_extra = (pcre_extra *) pcre_study((const pcre *) *pattern, opt, &errstr); | |
+ if (*pattern_extra == NULL && errstr != NULL) { | |
+ pcre_free(*pattern); | |
+ uwsgi_log("pcre (study) error: %s\n", errstr); | |
+ return -1; | |
+#endif | |
} | |
return 0; | |
} | |
+#ifdef UWSGI_PCRE2 | |
int uwsgi_regexp_match(pcre2_code *pattern, const char *subject, int length) { | |
return pcre2_match(pattern, (const unsigned char *)subject, length, 0, 0, NULL, NULL); | |
+#else | |
+int uwsgi_regexp_match(pcre * pattern, pcre_extra * pattern_extra, char *subject, int length) { | |
+ | |
+ return pcre_exec((const pcre *) pattern, (const pcre_extra *) pattern_extra, subject, length, 0, 0, NULL, 0); | |
+#endif | |
} | |
+#ifdef UWSGI_PCRE2 | |
int uwsgi_regexp_match_ovec(pcre2_code *pattern, const char *subject, int length, int *ovec, int n) { | |
int rc; | |
@@ -50,28 +80,48 @@ int uwsgi_regexp_match_ovec(pcre2_code *pattern, const char *subject, int length | |
match_data = pcre2_match_data_create_from_pattern(pattern, NULL); | |
rc = pcre2_match(pattern, (const unsigned char *)subject, length, 0, 0, match_data, NULL); | |
+#else | |
+int uwsgi_regexp_match_ovec(pcre * pattern, pcre_extra * pattern_extra, char *subject, int length, int *ovec, int n) { | |
+#endif | |
if (n > 0) { | |
+#ifdef UWSGI_PCRE2 | |
// copy pcre2 output vector to uwsgi output vector | |
pcre2_ovec = pcre2_get_ovector_pointer(match_data); | |
for (i=0;i<2*n+1;i++) { | |
ovec[i] = pcre2_ovec[i]; | |
} | |
+#else | |
+ return pcre_exec((const pcre *) pattern, (const pcre_extra *) pattern_extra, subject, length, 0, 0, ovec, (n + 1) * 3); | |
+#endif | |
} | |
+#ifdef UWSGI_PCRE2 | |
pcre2_match_data_free(match_data); | |
return rc; | |
+#else | |
+ return pcre_exec((const pcre *) pattern, (const pcre_extra *) pattern_extra, subject, length, 0, 0, NULL, 0); | |
+#endif | |
} | |
+#ifdef UWSGI_PCRE2 | |
int uwsgi_regexp_ovector(pcre2_code *pattern) { | |
+#else | |
+int uwsgi_regexp_ovector(pcre * pattern, pcre_extra * pattern_extra) { | |
+#endif | |
int n; | |
+#ifdef UWSGI_PCRE2 | |
pcre2_match_data *match_data; | |
match_data = pcre2_match_data_create_from_pattern(pattern, NULL); | |
n = pcre2_get_ovector_count(match_data); | |
pcre2_match_data_free(match_data); | |
+#else | |
+ if (pcre_fullinfo((const pcre *) pattern, (const pcre_extra *) pattern_extra, PCRE_INFO_CAPTURECOUNT, &n)) | |
+ return 0; | |
+#endif | |
return n; | |
} | |
diff --git a/core/routing.c b/core/routing.c | |
index 7ff42c3f..a934dc29 100644 | |
--- a/core/routing.c | |
+++ b/core/routing.c | |
@@ -211,7 +211,11 @@ int uwsgi_apply_routes_do(struct uwsgi_route *routes, struct wsgi_request *wsgi_ | |
subject = *subject2 ; | |
subject_len = *subject_len2; | |
} | |
+#ifdef UWSGI_PCRE2 | |
n = uwsgi_regexp_match_ovec(routes->pattern, subject, subject_len, routes->ovector[wsgi_req->async_id], routes->ovn[wsgi_req->async_id]); | |
+#else | |
+ n = uwsgi_regexp_match_ovec(routes->pattern, routes->pattern_extra, subject, subject_len, routes->ovector[wsgi_req->async_id], routes->ovn[wsgi_req->async_id]); | |
+#endif | |
} | |
else { | |
int ret = routes->if_func(wsgi_req, routes); | |
@@ -506,15 +510,27 @@ void uwsgi_fixup_routes(struct uwsgi_route *ur) { | |
// fill them if needed... (this is an optimization for route with a static subject) | |
if (ur->subject && ur->subject_len) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(ur->orig_route, &ur->pattern)) { | |
+#else | |
+ if (uwsgi_regexp_build(ur->orig_route, &ur->pattern, &ur->pattern_extra)) { | |
+#endif | |
exit(1); | |
} | |
int i; | |
for(i=0;i<uwsgi.cores;i++) { | |
+#ifdef UWSGI_PCRE2 | |
ur->ovn[i] = uwsgi_regexp_ovector(ur->pattern); | |
+#else | |
+ ur->ovn[i] = uwsgi_regexp_ovector(ur->pattern, ur->pattern_extra); | |
+#endif | |
if (ur->ovn[i] > 0) { | |
+#ifdef UWSGI_PCRE2 | |
ur->ovector[i] = uwsgi_calloc(sizeof(int) * (2 * (ur->ovn[i] + 1))); | |
+#else | |
+ ur->ovector[i] = uwsgi_calloc(sizeof(int) * (3 * (ur->ovn[i] + 1))); | |
+#endif | |
} | |
} | |
} | |
@@ -1484,26 +1500,58 @@ static int uwsgi_route_condition_regexp(struct wsgi_request *wsgi_req, struct uw | |
ur->condition_ub[wsgi_req->async_id] = uwsgi_routing_translate(wsgi_req, ur, NULL, 0, ur->subject_str, semicolon - ur->subject_str); | |
if (!ur->condition_ub[wsgi_req->async_id]) return -1; | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *pattern; | |
+#else | |
+ pcre *pattern; | |
+ pcre_extra *pattern_extra; | |
+#endif | |
char *re = uwsgi_concat2n(semicolon+1, ur->subject_str_len - ((semicolon+1) - ur->subject_str), "", 0); | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(re, &pattern)) { | |
+#else | |
+ if (uwsgi_regexp_build(re, &pattern, &pattern_extra)) { | |
+#endif | |
free(re); | |
return -1; | |
} | |
free(re); | |
// a condition has no initialized vectors, let's create them | |
+#ifdef UWSGI_PCRE2 | |
ur->ovn[wsgi_req->async_id] = uwsgi_regexp_ovector(pattern); | |
+#else | |
+ ur->ovn[wsgi_req->async_id] = uwsgi_regexp_ovector(pattern, pattern_extra); | |
+#endif | |
if (ur->ovn[wsgi_req->async_id] > 0) { | |
ur->ovector[wsgi_req->async_id] = uwsgi_calloc(sizeof(int) * (3 * (ur->ovn[wsgi_req->async_id] + 1))); | |
} | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match_ovec(pattern, ur->condition_ub[wsgi_req->async_id]->buf, ur->condition_ub[wsgi_req->async_id]->pos, ur->ovector[wsgi_req->async_id], ur->ovn[wsgi_req->async_id] ) >= 0) { | |
pcre2_code_free(pattern); | |
+#else | |
+ if (uwsgi_regexp_match_ovec(pattern, pattern_extra, ur->condition_ub[wsgi_req->async_id]->buf, ur->condition_ub[wsgi_req->async_id]->pos, ur->ovector[wsgi_req->async_id], ur->ovn[wsgi_req->async_id] ) >= 0) { | |
+ pcre_free(pattern); | |
+#ifdef PCRE_STUDY_JIT_COMPILE | |
+ pcre_free_study(pattern_extra); | |
+#else | |
+ pcre_free(pattern_extra); | |
+#endif | |
+#endif | |
return 1; | |
} | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code_free(pattern); | |
+#else | |
+ pcre_free(pattern); | |
+#ifdef PCRE_STUDY_JIT_COMPILE | |
+ pcre_free_study(pattern_extra); | |
+#else | |
+ pcre_free(pattern_extra); | |
+#endif | |
+#endif | |
return 0; | |
} | |
diff --git a/core/ssl.c b/core/ssl.c | |
index c46dd177..92ae0909 100644 | |
--- a/core/ssl.c | |
+++ b/core/ssl.c | |
@@ -148,7 +148,11 @@ static int uwsgi_sni_cb(SSL *ssl, int *ad, void *arg) { | |
#ifdef UWSGI_PCRE | |
struct uwsgi_regexp_list *url = uwsgi.sni_regexp; | |
while(url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, (char *)servername, servername_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, (char *)servername, servername_len) >= 0) { | |
+#endif | |
SSL_set_SSL_CTX(ssl, url->custom_ptr); | |
return SSL_TLSEXT_ERR_OK; | |
} | |
diff --git a/core/static.c b/core/static.c | |
index 51cfa27f..d1debaee 100644 | |
--- a/core/static.c | |
+++ b/core/static.c | |
@@ -39,7 +39,11 @@ int uwsgi_static_want_gzip(struct wsgi_request *wsgi_req, char *filename, size_t | |
// check for regexp | |
struct uwsgi_regexp_list *url = uwsgi.static_gzip; | |
while(url) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(url->pattern, filename, *filename_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(url->pattern, url->pattern_extra, filename, *filename_len) >= 0) { | |
+#endif | |
goto gzip; | |
} | |
url = url->next; | |
@@ -229,7 +233,11 @@ int uwsgi_add_expires(struct wsgi_request *wsgi_req, char *filename, int filenam | |
char expires[31]; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, filename, filename_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, filename, filename_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(now + delta, expires); | |
if (size > 0) { | |
@@ -242,7 +250,11 @@ int uwsgi_add_expires(struct wsgi_request *wsgi_req, char *filename, int filenam | |
udd = uwsgi.static_expires_mtime; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, filename, filename_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, filename, filename_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(st->st_mtime + delta, expires); | |
if (size > 0) { | |
@@ -264,7 +276,11 @@ int uwsgi_add_expires_path_info(struct wsgi_request *wsgi_req, struct stat *st) | |
char expires[31]; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, wsgi_req->path_info, wsgi_req->path_info_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, wsgi_req->path_info, wsgi_req->path_info_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(now + delta, expires); | |
if (size > 0) { | |
@@ -277,7 +293,11 @@ int uwsgi_add_expires_path_info(struct wsgi_request *wsgi_req, struct stat *st) | |
udd = uwsgi.static_expires_path_info_mtime; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, wsgi_req->path_info, wsgi_req->path_info_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, wsgi_req->path_info, wsgi_req->path_info_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(st->st_mtime + delta, expires); | |
if (size > 0) { | |
@@ -299,7 +319,11 @@ int uwsgi_add_expires_uri(struct wsgi_request *wsgi_req, struct stat *st) { | |
char expires[31]; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(now + delta, expires); | |
if (size > 0) { | |
@@ -312,7 +336,11 @@ int uwsgi_add_expires_uri(struct wsgi_request *wsgi_req, struct stat *st) { | |
udd = uwsgi.static_expires_uri_mtime; | |
while (udd) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(udd->pattern, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(udd->pattern, udd->pattern_extra, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#endif | |
int delta = uwsgi_str_num(udd->value, udd->vallen); | |
int size = uwsgi_http_date(st->st_mtime + delta, expires); | |
if (size > 0) { | |
diff --git a/core/utils.c b/core/utils.c | |
index 043fee6e..738dc68b 100644 | |
--- a/core/utils.c | |
+++ b/core/utils.c | |
@@ -2359,7 +2359,11 @@ struct uwsgi_regexp_list *uwsgi_regexp_custom_new_list(struct uwsgi_regexp_list | |
old_url->next = url; | |
} | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(value, &url->pattern)) { | |
+#else | |
+ if (uwsgi_regexp_build(value, &url->pattern, &url->pattern_extra)) { | |
+#endif | |
exit(1); | |
} | |
url->next = NULL; | |
@@ -2372,11 +2376,24 @@ struct uwsgi_regexp_list *uwsgi_regexp_custom_new_list(struct uwsgi_regexp_list | |
int uwsgi_regexp_match_pattern(char *pattern, char *str) { | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *regexp; | |
+#else | |
+ pcre *regexp; | |
+ pcre_extra *regexp_extra; | |
+#endif | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(pattern, ®exp)) | |
+#else | |
+ if (uwsgi_regexp_build(pattern, ®exp, ®exp_extra)) | |
+#endif | |
return 1; | |
+#ifdef UWSGI_PCRE2 | |
return !uwsgi_regexp_match(regexp, str, strlen(str)); | |
+#else | |
+ return !uwsgi_regexp_match(regexp, regexp_extra, str, strlen(str)); | |
+#endif | |
} | |
diff --git a/core/uwsgi.c b/core/uwsgi.c | |
index e0aac355..891ce8d5 100755 | |
--- a/core/uwsgi.c | |
+++ b/core/uwsgi.c | |
@@ -4583,7 +4583,11 @@ void uwsgi_opt_add_regexp_dyn_dict(char *opt, char *value, void *dict) { | |
char *regexp = uwsgi_concat2n(value, space - value, "", 0); | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_build(regexp, &new_udd->pattern)) { | |
+#else | |
+ if (uwsgi_regexp_build(regexp, &new_udd->pattern, &new_udd->pattern_extra)) { | |
+#endif | |
exit(1); | |
} | |
diff --git a/plugins/php/php_plugin.c b/plugins/php/php_plugin.c | |
index 44327ca1..61b3e358 100644 | |
--- a/plugins/php/php_plugin.c | |
+++ b/plugins/php/php_plugin.c | |
@@ -875,7 +875,11 @@ int uwsgi_php_request(struct wsgi_request *wsgi_req) { | |
#ifdef UWSGI_PCRE | |
struct uwsgi_regexp_list *bypass = uphp.app_bypass; | |
while (bypass) { | |
+#ifdef UWSGI_PCRE2 | |
if (uwsgi_regexp_match(bypass->pattern, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#else | |
+ if (uwsgi_regexp_match(bypass->pattern, bypass->pattern_extra, wsgi_req->uri, wsgi_req->uri_len) >= 0) { | |
+#endif | |
goto oldstyle; | |
} | |
bypass = bypass->next; | |
diff --git a/uwsgi.h b/uwsgi.h | |
index 412a31dc..0c531c79 100755 | |
--- a/uwsgi.h | |
+++ b/uwsgi.h | |
@@ -450,8 +450,12 @@ struct uwsgi_lock_ops { | |
#define uwsgi_wait_write_req(x) uwsgi.wait_write_hook(x->fd, uwsgi.socket_timeout) ; x->switches++ | |
#ifdef UWSGI_PCRE | |
+#ifdef UWSGI_PCRE2 | |
#define PCRE2_CODE_UNIT_WIDTH 8 | |
#include <pcre2.h> | |
+#else | |
+#include <pcre.h> | |
+#endif | |
#endif | |
struct uwsgi_dyn_dict { | |
@@ -468,7 +472,12 @@ struct uwsgi_dyn_dict { | |
struct uwsgi_dyn_dict *next; | |
#ifdef UWSGI_PCRE | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *pattern; | |
+#else | |
+ pcre *pattern; | |
+ pcre_extra *pattern_extra; | |
+#endif | |
#endif | |
}; | |
@@ -482,7 +491,12 @@ struct uwsgi_hook { | |
#ifdef UWSGI_PCRE | |
struct uwsgi_regexp_list { | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *pattern; | |
+#else | |
+ pcre *pattern; | |
+ pcre_extra *pattern_extra; | |
+#endif | |
uint64_t custom; | |
char *custom_str; | |
@@ -1100,10 +1114,17 @@ struct uwsgi_plugin { | |
}; | |
#ifdef UWSGI_PCRE | |
+#ifdef UWSGI_PCRE2 | |
int uwsgi_regexp_build(char *, pcre2_code **); | |
int uwsgi_regexp_match(pcre2_code *, const char *, int); | |
int uwsgi_regexp_match_ovec(pcre2_code *, const char *, int, int *, int); | |
int uwsgi_regexp_ovector(pcre2_code *); | |
+#else | |
+int uwsgi_regexp_build(char *, pcre **, pcre_extra **); | |
+int uwsgi_regexp_match(pcre *, pcre_extra *, char *, int); | |
+int uwsgi_regexp_match_ovec(pcre *, pcre_extra *, char *, int, int *, int); | |
+int uwsgi_regexp_ovector(pcre *, pcre_extra *); | |
+#endif | |
char *uwsgi_regexp_apply_ovec(char *, int, char *, int, int *, int); | |
int uwsgi_regexp_match_pattern(char *pattern, char *str); | |
@@ -1194,7 +1215,12 @@ struct uwsgi_spooler { | |
struct uwsgi_route { | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *pattern; | |
+#else | |
+ pcre *pattern; | |
+ pcre_extra *pattern_extra; | |
+#endif | |
char *orig_route; | |
@@ -1310,7 +1336,12 @@ struct uwsgi_alarm_ll { | |
}; | |
struct uwsgi_alarm_log { | |
+#ifdef UWSGI_PCRE2 | |
pcre2_code *pattern; | |
+#else | |
+ pcre *pattern; | |
+ pcre_extra *pattern_extra; | |
+#endif | |
int negate; | |
struct uwsgi_alarm_ll *alarms; | |
struct uwsgi_alarm_log *next; | |
diff --git a/uwsgiconfig.py b/uwsgiconfig.py | |
index 57353994..231a15d3 100644 | |
--- a/uwsgiconfig.py | |
+++ b/uwsgiconfig.py | |
@@ -1102,7 +1102,7 @@ class uConf(object): | |
pcre_libs = spcall('pcre2-config --libs8') | |
if pcre_libs: | |
pcre_cflags = spcall("pcre2-config --cflags") | |
- pcre_define = "-DUWSGI_PCRE" | |
+ pcre_define = "-DUWSGI_PCRE -DUWSGI_PCRE2" | |
else: | |
pcre_libs = spcall('pcre-config --libs') | |
pcre_cflags = spcall("pcre-config --cflags") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment