--- parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/04/09 15:48:59 1.26 +++ parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/09/07 16:51:43 1.41.4.1 @@ -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.26 2001/04/09 15:48:59 paf Exp $ */ +static const char *RCSId="$Id: mod_parser3.C,v 1.41.4.1 2001/09/07 16:51:43 parser Exp $"; #include "httpd.h" #include "http_config.h" @@ -15,33 +14,43 @@ #include "http_main.h" #include "http_protocol.h" #include "util_script.h" +#include "multithread.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" -/// @todo init_socks +#ifdef _DEBUG +# define DEBUG_PREFIX "debug_" +# define PARSER3_MODULE debug_parser3_module +#else +# define DEBUG_PREFIX +# define PARSER3_MODULE parser3_module +#endif + +/// 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 }; /* * Declare ourselves so the configuration routines can find and know us. * We'll fill it in at the end of the module. */ -extern "C" module MODULE_VAR_EXPORT parser3_module; +extern "C" module MODULE_VAR_EXPORT PARSER3_MODULE; /* * Locate our directory configuration record for the current request. */ static Parser_module_config *our_dconfig(request_rec *r) { return (Parser_module_config *) - ap_get_module_config(r->per_dir_config, &parser3_module); + ap_get_module_config(r->per_dir_config, &PARSER3_MODULE); } static const char *cmd_parser_auto_path(cmd_parms *cmd, void *mconfig, char *file_spec) { @@ -128,6 +137,9 @@ size_t SAPI::read_post(Pool& pool, char void SAPI::add_header_attribute(Pool& pool, const char *key, const char *value) { request_rec *r=static_cast(pool.context()); + if(strcasecmp(key, "location")==0) + r->status=302; + if(strcasecmp(key, "content-type")==0) { /* r->content_type, *not* r->headers_out("Content-type"). If you don't * set it, it will be filled in with the server's default type (typically @@ -135,8 +147,10 @@ void SAPI::add_header_attribute(Pool& po * case. */ r->content_type = value; - } else - ap_table_merge(r->headers_out, key, value); + } else if(strcasecmp(key, "status")==0) + r->status=atoi(value); + else + ap_table_addn(r->headers_out, key, value); } void SAPI::send_header(Pool& pool) { @@ -155,29 +169,6 @@ void SAPI::send_body(Pool& pool, const v ap_kill_timeout(r); } -int SAPI::execute(Pool& pool, - const String& file_spec, - const Hash *env, - const Array *argv, - const String& in, String& out, String& err) { - request_rec *r=static_cast(pool.context()); - - /* - * we spawn out of r->main if it's there so that we can avoid - * waiting for free_proc_chain to cleanup in the middle of an - * SSI request -djg - */ - if(!ap_bspawn_child(r->main ? r->main->pool : r->pool, cgi_child, - (void *) &cld, kill_after_timeout, - &script_out, &script_in, &script_err)) - PTHROW(0, 0, - &file_spec, - "could not spawn child process"); - - - return pa_exec(file_spec, env, argv, in, out, err); -} - //@} /** @@ -185,8 +176,11 @@ int SAPI::execute(Pool& pool, @todo intelligent cache-control */ -static int parser_handler(request_rec *r) -{ +static int parser_handler(request_rec *r) { +// _asm int 3; + if(r->finfo.st_mode == 0) + return NOT_FOUND; + Pool pool(r->pool); pool.set_context(r); @@ -211,14 +205,15 @@ static int parser_handler(request_rec *r 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.content_length=content_length?atoi(content_length):0; request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); + //_asm int 3; // prepare to process request Request request(pool, request_info, - String::UL_HTML_TYPO + String::UL_USER_HTML ); // process the request @@ -304,7 +299,7 @@ static int parser_handler(request_rec *r */ static void setup_module_cells() { - static bool globals_inited=false; + static bool globals_inited=false; if(globals_inited) return; globals_inited=true; @@ -314,6 +309,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 @@ -523,7 +523,7 @@ static int parser_access_checker(request static const command_rec parser_cmds[] = { { - "parser_root_auto_path", /* directive name */ + DEBUG_PREFIX"parser_root_auto_path", /* directive name */ (const char *(*)(void))((void *)cmd_parser_auto_path), // config action routine (void*)true, /* argument to include in call */ (int)(ACCESS_CONF|RSRC_CONF), /* where available */ @@ -531,7 +531,7 @@ static const command_rec parser_cmds[] = "Parser root auto.p filespec (Admin)" // directive description }, { - "parser_site_auto_path", /* directive name */ + DEBUG_PREFIX"parser_site_auto_path", /* directive name */ (const char *(*)(void))((void *)cmd_parser_auto_path), // config action routine (void*)false, /* argument to include in call */ (int)(OR_OPTIONS), /* where available */ @@ -560,7 +560,7 @@ static const command_rec parser_cmds[] = */ static const handler_rec parser_handlers[] = { - {"parser3-handler", parser_handler}, + {DEBUG_PREFIX"parser3-handler", parser_handler}, {NULL} }; @@ -578,7 +578,7 @@ static const handler_rec parser_handlers * during request processing. Note that not all routines are necessarily * called (such as if a resource doesn't have access restrictions). */ -module MODULE_VAR_EXPORT parser3_module = +module MODULE_VAR_EXPORT PARSER3_MODULE = { STANDARD_MODULE_STUFF, parser_server_init, /* module initializer */