|
|
| version 1.13, 2012/04/18 13:34:39 | version 1.22, 2021/01/20 16:48:34 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: apache 1.3 and 2.2 module | Parser: apache 1.3 and 2.2 module |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| #ifdef WIN32 | |
| #include <winsock2.h> | |
| #endif | |
| #include "httpd.h" | #include "httpd.h" |
| #include "http_config.h" | #include "http_config.h" |
| #include "http_core.h" | #include "http_core.h" |
| Line 29 volatile const char * IDENT_MOD_PARSER3_ | Line 25 volatile const char * IDENT_MOD_PARSER3_ |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| #include "apr_strings.h" | #include "apr_strings.h" |
| #include "ap_mpm.h" | |
| #define ap_pcalloc apr_pcalloc | #define ap_pcalloc apr_pcalloc |
| #define ap_pstrdup apr_pstrdup | #define ap_pstrdup apr_pstrdup |
| Line 54 volatile const char * IDENT_MOD_PARSER3_ | Line 51 volatile const char * IDENT_MOD_PARSER3_ |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| module AP_MODULE_DECLARE_DATA parser3_module; | module AP_MODULE_DECLARE_DATA parser3_module; |
| static int is_threaded = 0; | |
| #else | #else |
| module MODULE_VAR_EXPORT parser3_module; | module MODULE_VAR_EXPORT parser3_module; |
| #endif | #endif |
| Line 79 static int parser_handler(request_rec *r | Line 77 static int parser_handler(request_rec *r |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| if(strcmp(r->handler, PARSER3_HANDLER)) | if(strcmp(r->handler, PARSER3_HANDLER)) |
| return DECLINED; | return DECLINED; |
| if(is_threaded){ | |
| const char *message="Parser3 module requires 'a2enmod mpm_prefork'"; | |
| r->status=HTTP_INTERNAL_SERVER_ERROR; | |
| r->content_type="text/plain"; | |
| ap_rwrite(message, strlen(message), r); | |
| return OK; | |
| } | |
| #endif | #endif |
| // we setup module here to avoid GPF on init with php5-xsl installed | // we setup module here to avoid GPF on init with php5-xsl installed |
| pa_setup_module_cells(); | pa_setup_module_cells(); |
| // converting to parser version | { |
| pa_request_rec pr={ | // converting to parser version |
| r, | pa_request_rec pr={ |
| r->pool, | r, |
| r->header_only, | r->pool, |
| &r->status, | r->header_only, |
| r->method, | &r->status, |
| r->headers_out, | r->method, |
| r->subprocess_env, | r->headers_out, |
| &r->content_type, | r->subprocess_env, |
| r->uri, | &r->content_type, |
| r->filename, | r->uri, |
| r->path_info, | r->filename, |
| r->args, | r->path_info, |
| r->args, | |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| r->finfo.filetype == 0 | r->finfo.filetype == 0 |
| #else | #else |
| r->finfo.st_mode == 0 | r->finfo.st_mode == 0 |
| #endif | #endif |
| }; | }; |
| return pa_parser_handler(&pr, our_dconfig(r)); | return pa_parser_handler(&pr, our_dconfig(r)); |
| } | |
| } | } |
| /* | /* |
| Line 177 static const handler_rec parser_handlers | Line 185 static const handler_rec parser_handlers |
| */ | */ |
| static void parser_register_hooks(apr_pool_t* pool) | static void parser_register_hooks(apr_pool_t* pool) |
| { | { |
| int mpm_query_info; | |
| is_threaded = ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_query_info) == APR_SUCCESS && mpm_query_info != AP_MPMQ_NOT_SUPPORTED; | |
| ap_hook_handler(parser_handler, NULL, NULL, APR_HOOK_MIDDLE); | ap_hook_handler(parser_handler, NULL, NULL, APR_HOOK_MIDDLE); |
| ap_hook_child_init(parser_child_init, NULL, NULL, APR_HOOK_MIDDLE); | ap_hook_child_init(parser_child_init, NULL, NULL, APR_HOOK_MIDDLE); |
| }; | }; |
| Line 213 module MODULE_VAR_EXPORT parser3_module | Line 223 module MODULE_VAR_EXPORT parser3_module |
| }; | }; |
| #if defined(_MSC_VER) | #if defined(_MSC_VER) |
| # define APACHE_WIN32_SRC "../../../../win32/apache13/src" | # define APACHE_WIN32_SRC "../../../../win32/apache22/" |
| # ifdef _DEBUG | # ifdef _DEBUG |
| # pragma comment(lib, APACHE_WIN32_SRC "/CoreD/ApacheCore.lib") | # pragma comment(lib, APACHE_WIN32_SRC "srclib/apr/Debug/libapr-1.lib") |
| # pragma comment(lib, APACHE_WIN32_SRC "Debug/libhttpd.lib") | |
| # else | # else |
| # pragma comment(lib, APACHE_WIN32_SRC "/CoreR/ApacheCore.lib") | # pragma comment(lib, APACHE_WIN32_SRC "srclib/apr/Release/libapr-1.lib") |
| # pragma comment(lib, APACHE_WIN32_SRC "Release/libhttpd.lib") | |
| # endif | # endif |
| #endif | #endif |
| Line 231 void pa_ap_log_rerror(const char *file, | Line 243 void pa_ap_log_rerror(const char *file, |
| str=va_arg(l, const char*); | str=va_arg(l, const char*); |
| va_end(l); | va_end(l); |
| ap_log_rerror(file, line, level, | ap_log_rerror(file, line, |
| #if (AP_SERVER_MAJORVERSION_NUMBER == 2) && (AP_SERVER_MINORVERSION_NUMBER >= 4) | |
| APLOG_MODULE_INDEX, | |
| #endif | |
| level, | |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| 0, | 0, |
| #endif | #endif |
| Line 246 void pa_ap_log_error(const char *file, i | Line 262 void pa_ap_log_error(const char *file, i |
| str=va_arg(l, const char*); | str=va_arg(l, const char*); |
| va_end(l); | va_end(l); |
| ap_log_error(file, line, level, | ap_log_error(file, line, |
| #if (AP_SERVER_MAJORVERSION_NUMBER == 2) && (AP_SERVER_MINORVERSION_NUMBER >= 4) | |
| APLOG_MODULE_INDEX, | |
| #endif | |
| level, | |
| #ifdef STANDARD20_MODULE_STUFF | #ifdef STANDARD20_MODULE_STUFF |
| 0, | 0, |
| #endif | #endif |
| Line 267 int pa_ap_table_size(const pa_table *t) | Line 287 int pa_ap_table_size(const pa_table *t) |
| } | } |
| void pa_ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, const pa_table *t, ...) { | void pa_ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, const pa_table *t, ...) { |
| ap_table_do(comp, rec, (apr_table_t*)t, 0); | ap_table_do(comp, rec, (apr_table_t*)t, NULL); |
| } | } |
| char * pa_ap_pstrdup(pa_pool *p, const char *s) { | char * pa_ap_pstrdup(pa_pool *p, const char *s) { |
| Line 325 void pa_ap_add_common_vars(pa_request_re | Line 345 void pa_ap_add_common_vars(pa_request_re |
| ap_add_common_vars((request_rec*)r->real_request_rec); | ap_add_common_vars((request_rec*)r->real_request_rec); |
| } | } |
| #ifndef WIN32 | |
| // signal.h | // signal.h |
| void (*pa_signal (int sig, void (*disp)(int)))(int) { | void (*pa_signal (int sig, void (*disp)(int)))(int) { |
| #ifndef _MSC_VER | |
| if(sig==PA_SIGPIPE && disp==PA_SIG_IGN) | if(sig==PA_SIGPIPE && disp==PA_SIG_IGN) |
| return signal(SIGPIPE, SIG_IGN); | return signal(SIGPIPE, SIG_IGN); |
| #endif | |
| return 0; | return 0; |
| } | } |
| #endif |