--- parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/03/26 09:09:45 1.19 +++ parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/06/28 07:44:17 1.35 @@ -4,9 +4,8 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: mod_parser3.C,v 1.19 2001/03/26 09:09:45 paf Exp $ */ +static const char *RCSId="$Id: mod_parser3.C,v 1.35 2001/06/28 07:44:17 parser Exp $"; #include "httpd.h" #include "http_config.h" @@ -17,14 +16,17 @@ #include "util_script.h" #include "pa_sapi.h" +#include "classes.h" #include "pa_common.h" #include "pa_globals.h" #include "pa_request.h" #include "pa_version.h" +#include "pa_socks.h" +/// apache parser module configuration [httpd.conf + .htaccess-es] struct Parser_module_config { - const char* parser_root_auto_path; /// filespec of admin's auto.p file - const char* parser_site_auto_path; /// filespec of site's auto.p file + const char* parser_root_auto_path; ///< filespec of admin's auto.p file + const char* parser_site_auto_path; ///< filespec of site's auto.p file }; /* @@ -79,12 +81,23 @@ static const char *cmd_parser_auto_path( //@{ /// SAPI func decl +void SAPI::log(Pool& pool, const char *fmt, ...) { + request_rec *r=static_cast(pool.context()); + + va_list args; + va_start(args,fmt); + char buf[MAX_STRING]; + vsnprintf(buf, MAX_STRING, fmt, args); + ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf); + va_end(args); +} + const char *SAPI::get_env(Pool& pool, const char *name) { request_rec *r=static_cast(pool.context()); return (const char *)ap_table_get(r->subprocess_env, name); } -uint SAPI::read_post(Pool& pool, char *buf, uint max_bytes) { +size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) { request_rec *r=static_cast(pool.context()); /* ap_log_error(APLOG_MARK, APLOG_DEBUG, r->server, @@ -133,7 +146,7 @@ void SAPI::send_header(Pool& pool) { ap_kill_timeout(r); } -void SAPI::send_body(Pool& pool, const char *buf, size_t size) { +void SAPI::send_body(Pool& pool, const void *buf, size_t size) { request_rec *r=static_cast(pool.context()); ap_hard_timeout("Send body", r); @@ -141,22 +154,12 @@ void SAPI::send_body(Pool& pool, const c ap_kill_timeout(r); } -void SAPI::log(Pool& pool, const char *fmt, ...) { - request_rec *r=static_cast(pool.context()); - - va_list args; - va_start(args,fmt); - char buf[MAX_STRING]; - vsnprintf(buf, MAX_STRING, fmt, args); - ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf); - va_end(args); -} //@} /** main workhorse - @todo parser4: intelligent cache-control + @todo intelligent cache-control */ static int parser_handler(request_rec *r) { @@ -177,25 +180,21 @@ static int parser_handler(request_rec *r // Request info Request::Info request_info; - request_info.document_root=(const char *) - ap_table_get(r->subprocess_env, "DOCUMENT_ROOT"); + request_info.document_root=SAPI::get_env(pool, "DOCUMENT_ROOT"); request_info.path_translated=r->filename; request_info.method=r->method; request_info.query_string=r->args; - request_info.uri=(const char *) - ap_table_get(r->subprocess_env, "REQUEST_URI"); - request_info.content_type=(const char *) - ap_table_get(r->subprocess_env, "CONTENT_TYPE"); - const char *content_length=(const char *) - ap_table_get(r->subprocess_env, "CONTENT_LENGTH"); + request_info.uri=SAPI::get_env(pool, "REQUEST_URI"); + request_info.content_type=SAPI::get_env(pool, "CONTENT_TYPE"); + const char *content_length=SAPI::get_env(pool, "CONTENT_LENGTH"); request_info.content_length=(content_length?atoi(content_length):0); - request_info.cookie=(const char *) - ap_table_get(r->subprocess_env, "HTTP_COOKIE"); + request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); + request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); // prepare to process request Request request(pool, request_info, - String::UL_HTML_TYPO + String::UL_USER_HTML ); // process the request @@ -222,7 +221,7 @@ static int parser_handler(request_rec *r // prepare header SAPI::add_header_attribute(pool, "content-type", "text/plain"); char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%lu", content_length); + snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); SAPI::add_header_attribute(pool, "content-length", content_length_cstr); // send header @@ -291,6 +290,11 @@ static void setup_module_cells() { */ static Pool pool(ap_make_sub_pool(NULL)); // global pool PTRY { + // init socks + init_socks(pool); + + // init global classes + init_methoded_array(pool); // init global variables pa_globals_init(pool); } PCATCH(e) { // global problem