--- parser3/src/targets/apache13/Attic/mod_parser3.C 2002/02/28 14:31:48 1.18 +++ parser3/src/targets/apache13/Attic/mod_parser3.C 2003/01/31 16:05:59 1.28.2.2 @@ -1,12 +1,12 @@ /** @file Parser: apache 1.3 module. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - - $Id: mod_parser3.C,v 1.18 2002/02/28 14:31:48 paf Exp $ */ +static const char* IDENT_MOD_PARSER3_C="$Date: 2003/01/31 16:05:59 $"; + #include "pa_config_includes.h" #if _MSC_VER @@ -30,34 +30,9 @@ #include "pa_version.h" #include "pa_socks.h" - -// consts - -extern const char *main_RCSIds[]; -#ifdef USE_SMTP -extern const char *smtp_RCSIds[]; -#endif -extern const char *gd_RCSIds[]; -extern const char *classes_RCSIds[]; -extern const char *types_RCSIds[]; -extern const char *ApacheModuleParser3_RCSIds[]; -const char **RCSIds[]={ - main_RCSIds, -#ifdef USE_SMTP - smtp_RCSIds, -#endif - gd_RCSIds, - classes_RCSIds, - types_RCSIds, - ApacheModuleParser3_RCSIds, - 0 -}; - - /// apache parser module configuration [httpd.conf + .htaccess-es] struct Parser_module_config { - const char* parser_root_config_filespec; ///< filespec of admin's config file - const char* parser_site_config_filespec; ///< filespec of site's config file + const char* parser_config_filespec; ///< filespec of site's config file bool parser_status_allowed; }; @@ -75,15 +50,15 @@ static Parser_module_config *our_dconfig ap_get_module_config(r->per_dir_config, &parser3_module); } -static const char *cmd_parser_config(cmd_parms *cmd, void *mconfig, char *file_spec) { +static const char* cmd_parser_config(cmd_parms *cmd, void *mconfig, char *file_spec) { Parser_module_config *cfg = (Parser_module_config *) mconfig; // remember assigned filespec into cfg - (cmd->info?cfg->parser_root_config_filespec:cfg->parser_site_config_filespec)=file_spec; + cfg->parser_config_filespec=file_spec; return NULL; } -static const char *cmd_parser_status_allowed(cmd_parms *cmd, void *mconfig, char *file_spec) { +static const char* cmd_parser_status_allowed(cmd_parms *cmd, void *mconfig, char *file_spec) { //_asm int 3; Parser_module_config *cfg = (Parser_module_config *) mconfig; @@ -121,7 +96,7 @@ static const char *cmd_parser_status_all //@{ /// SAPI func decl -void SAPI::log(Pool& pool, const char *fmt, ...) { +void SAPI::log(Pool& pool, const char* fmt, ...) { request_rec *r=static_cast(pool.get_context()); va_list args; @@ -133,7 +108,7 @@ void SAPI::log(Pool& pool, const char *f va_end(args); } -void SAPI::die(const char *fmt, ...) { +void SAPI::die(const char* fmt, ...) { va_list args; va_start(args,fmt); char buf[MAX_STRING]; @@ -142,12 +117,42 @@ void SAPI::die(const char *fmt, ...) { ap_log_error(APLOG_MARK, APLOG_EMERG, 0, "%s", buf); va_end(args); - exit(1); + // exit & try to produce core dump + abort(); +} + +const char* SAPI::get_env(Pool& pool, const char* name) { + request_rec *r=static_cast(pool.get_context()); + return (const char* )ap_table_get(r->subprocess_env, name); } -const char *SAPI::get_env(Pool& pool, const char *name) { +#ifndef DOXYGEN +struct SAPI_environment_append_info { + Pool *pool; + const char* *cur; +}; +#endif +static const char* mk_env_pair(Pool& pool, const char* key, const char* value) { + char *result=(char *)pool.malloc(strlen(key)+1/*=*/+strlen(value)+1/*0*/); + strcpy(result, key); strcat(result, "="); strcat(result, value); + return result; +} +static int SAPI_environment_append(void *d, const char* k, const char* val) { + if( k && val ) { + SAPI_environment_append_info& info= + *static_cast(d); + *info.cur++=mk_env_pair(*info.pool, k, val); + } + return 1/*true*/; +} +const char* const *SAPI::environment(Pool& pool) { request_rec *r=static_cast(pool.get_context()); - return (const char *)ap_table_get(r->subprocess_env, name); + const table *t=r->subprocess_env; + const char* *result= + (const char* *)pool.malloc(sizeof(char *)*(ap_table_elts(t)->nelts+1/*0*/)); + SAPI_environment_append_info info={&pool, result}; + ap_table_do(SAPI_environment_append, &info, t, 0); *info.cur=0; // mark EOE + return result; } size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) { @@ -178,7 +183,8 @@ size_t SAPI::read_post(Pool& pool, char } /// @test location provide with protocol. think about internal redirects -void SAPI::add_header_attribute(Pool& pool, const char *key, const char *value) { +void SAPI::add_header_attribute(Pool& pool, + const char* dont_store_key, const char* dont_store_value) { request_rec *r=static_cast(pool.get_context()); if(strcasecmp(key, "location")==0) @@ -194,6 +200,7 @@ void SAPI::add_header_attribute(Pool& po } else if(strcasecmp(key, "status")==0) r->status=atoi(value); else +todo: copy dont_store_ to nonvilotile ap_table_addn(r->headers_out, key, value); } @@ -232,10 +239,10 @@ static void real_parser_handler(Pool& po request_info.query_string=r->args; 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"); + const char* content_length=SAPI::get_env(pool, "CONTENT_LENGTH"); 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"); + request_info.mail_received=false; // config Parser_module_config *dcfg=our_dconfig(r); @@ -250,8 +257,7 @@ static void real_parser_handler(Pool& po // process the request request.core( - dcfg->parser_root_config_filespec, true, // /path/to/admin/config - dcfg->parser_site_config_filespec, true, // /path/to/site/config + dcfg->parser_config_filespec, true, // /path/to/config r->header_only!=0); } @@ -269,13 +275,13 @@ void call_real_parser_handler__do_SEH(Po if(system_exception) if(_EXCEPTION_RECORD *er=system_exception->ExceptionRecord) - throw Exception(0, 0, + throw Exception(0, 0, "Exception 0x%08X at 0x%08X", er->ExceptionCode, er->ExceptionAddress); else - throw Exception(0, 0, 0, "Exception "); + throw Exception(0, 0, "Exception "); else - throw Exception(0, 0, 0, "Exception "); + throw Exception(0, 0, "Exception "); } #endif } @@ -301,7 +307,7 @@ static int parser_handler(request_rec *r // don't allocate anything on pool here: // possible pool' exception not catch-ed now // and there could be out-of-memory exception - const char *body=e.comment(); + const char* body=e.comment(); // log it SAPI::log(pool, "exception in request exception handler: %s", body); @@ -478,10 +484,8 @@ static void *parser_merge_dir_config(poo Parser_module_config *pconf = (Parser_module_config *) parent_conf; Parser_module_config *nconf = (Parser_module_config *) newloc_conf; - merged_config->parser_root_config_filespec = ap_pstrdup(p, nconf->parser_root_config_filespec? - nconf->parser_root_config_filespec:pconf->parser_root_config_filespec); - merged_config->parser_site_config_filespec = ap_pstrdup(p, nconf->parser_site_config_filespec? - nconf->parser_site_config_filespec:pconf->parser_site_config_filespec); + merged_config->parser_config_filespec = ap_pstrdup(p, nconf->parser_config_filespec? + nconf->parser_config_filespec:pconf->parser_config_filespec); merged_config->parser_status_allowed= pconf->parser_status_allowed || nconf->parser_status_allowed; @@ -540,10 +544,8 @@ static void *parser_merge_server_config( * Our inheritance rules are our own, and part of our module's semantics. * Basically, just note whence we came. */ - merged_config->parser_root_config_filespec = ap_pstrdup(p, s2conf->parser_root_config_filespec? - s2conf->parser_root_config_filespec:s1conf->parser_root_config_filespec); - merged_config->parser_site_config_filespec = ap_pstrdup(p, s2conf->parser_site_config_filespec? - s2conf->parser_site_config_filespec:s1conf->parser_site_config_filespec); + merged_config->parser_config_filespec = ap_pstrdup(p, s2conf->parser_config_filespec? + s2conf->parser_config_filespec:s1conf->parser_config_filespec); merged_config->parser_status_allowed= s1conf->parser_status_allowed || s2conf->parser_status_allowed; @@ -623,24 +625,16 @@ static int parser_access_checker(request static const command_rec parser_cmds[] = { { - "ParserRootConfig", /* directive name */ - (const char *(*)(void))((void *)cmd_parser_config), // config action routine - (void*)true, /* argument to include in call */ - (int)(ACCESS_CONF|RSRC_CONF), /* where available */ - TAKE1, /* arguments */ - "Parser root config filespec (Admin)" // directive description - }, - { - "ParserSiteConfig", /* directive name */ - (const char *(*)(void))((void *)cmd_parser_config), // config action routine - (void*)false, /* argument to include in call */ + "ParserConfig", /* directive name */ + (const char* (*)(void))((void *)cmd_parser_config), // config action routine + (void*)0, /* argument to include in call */ (int)(OR_OPTIONS), /* where available */ TAKE1, /* arguments */ - "Parser site config filespec" // directive description + "Parser config filespec" // directive description }, { "ParserStatusAllowed", /* directive name */ - (const char *(*)(void))((void *)cmd_parser_status_allowed), // config action routine + (const char* (*)(void))((void *)cmd_parser_status_allowed), // config action routine (void*)0, /* argument to include in call */ (int)(ACCESS_CONF), /* where available */ NO_ARGS, /* arguments */ @@ -706,7 +700,7 @@ module MODULE_VAR_EXPORT parser3_module }; #if defined(_MSC_VER) -# define APACHE_WIN32_SRC "/parser3project/win32apache13/src" +# define APACHE_WIN32_SRC "/parser3project/win32/apache13/src" # ifdef _DEBUG # pragma comment(lib, APACHE_WIN32_SRC "/CoreD/ApacheCore.lib") # else