--- parser3/src/targets/apache13/Attic/mod_parser3.C 2001/10/22 16:44:43 1.7 +++ parser3/src/targets/apache13/Attic/mod_parser3.C 2001/11/19 12:17:06 1.12 @@ -2,9 +2,9 @@ Parser: apache 1.3 module. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: mod_parser3.C,v 1.7 2001/10/22 16:44:43 parser Exp $ + $Id: mod_parser3.C,v 1.12 2001/11/19 12:17:06 paf Exp $ */ #include "httpd.h" @@ -15,6 +15,12 @@ #include "http_protocol.h" #include "util_script.h" +#include "pa_config_includes.h" + +#if _MSC_VER +# include +#endif + #include "pa_sapi.h" #include "classes.h" #include "pa_common.h" @@ -27,14 +33,6 @@ #include #endif -#ifdef _DEBUG -# define DEBUG_PREFIX "debug_" -# define PARSER3_MODULE debug_parser3_module -#else -# define DEBUG_PREFIX -# define PARSER3_MODULE parser3_module -#endif - // consts extern const char *main_RCSIds[]; @@ -68,6 +66,7 @@ const char **RCSIds[]={ 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 + bool parser_status_allowed; }; #ifdef XML @@ -92,14 +91,14 @@ void callXalanTerminate(void *) { * 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_config(cmd_parms *cmd, void *mconfig, char *file_spec) { @@ -110,6 +109,14 @@ static const char *cmd_parser_config(cmd return NULL; } +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; + + cfg->parser_status_allowed=true; + + return NULL; +} /*--------------------------------------------------------------------------*/ @@ -255,15 +262,18 @@ static void real_parser_handler(Pool& po request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); + // config + Parser_module_config *dcfg=our_dconfig(r); + //_asm int 3; // prepare to process request Request request(pool, request_info, - String::UL_USER_HTML + String::UL_HTML|String::UL_OPTIMIZE_BIT, + dcfg->parser_status_allowed ); // process the request - Parser_module_config *dcfg=our_dconfig(r); request.core( dcfg->parser_root_config_filespec, true, // /path/to/admin/config dcfg->parser_site_config_filespec, true, // /path/to/site/config @@ -357,6 +367,19 @@ static int parser_handler(request_rec *r return OK; } +#if _MSC_VER +int failed_new(size_t size) { + SAPI::die("out of memory in 'new', failed to allocated %u bytes", size); + return 0; // not reached +} +#endif + +#ifdef HAVE_SET_NEW_HANDLER +void failed_new() { + SAPI::die("out of memory in 'new'"); +} +#endif + /*--------------------------------------------------------------------------*/ /* */ /* Now let's declare routines for each of the callback phase in order. */ @@ -400,6 +423,14 @@ static void setup_module_cells() { return; globals_inited=true; +#ifdef WIN32 + _set_new_handler(failed_new); +#endif + +#ifdef HAVE_SET_NEW_HANDLER + std::set_new_handler(failed_new); +#endif + /* * allocate our module-private pool. */ @@ -464,6 +495,8 @@ static void *parser_create_dir_config(po */ cfg->parser_root_config_filespec = 0; cfg->parser_site_config_filespec = 0; + cfg->parser_status_allowed=false; + return (void *) cfg; } @@ -491,6 +524,9 @@ static void *parser_merge_dir_config(poo // always from parent merged_config->parser_root_config_filespec = ap_pstrdup(p, pconf->parser_root_config_filespec); + merged_config->parser_status_allowed= + pconf->parser_status_allowed || + nconf->parser_status_allowed; /* * Some things get copied directly from the more-specific record, rather * than getting merged. @@ -518,6 +554,7 @@ static void *parser_create_server_config cfg->parser_root_config_filespec = 0; cfg->parser_site_config_filespec = 0; + cfg->parser_status_allowed=false; return (void *) cfg; } @@ -552,6 +589,9 @@ static void *parser_merge_server_config( 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_status_allowed= + s1conf->parser_status_allowed || + s2conf->parser_status_allowed; return (void *) merged_config; } @@ -628,7 +668,7 @@ static int parser_access_checker(request static const command_rec parser_cmds[] = { { - DEBUG_PREFIX"ParserRootConfig", /* directive name */ + "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 */ @@ -636,13 +676,21 @@ static const command_rec parser_cmds[] = "Parser root config filespec (Admin)" // directive description }, { - DEBUG_PREFIX"ParserSiteConfig", /* directive name */ + "ParserSiteConfig", /* directive name */ (const char *(*)(void))((void *)cmd_parser_config), // config action routine (void*)false, /* argument to include in call */ (int)(OR_OPTIONS), /* where available */ TAKE1, /* arguments */ "Parser site config filespec" // directive description }, + { + "ParserStatusAllowed", /* directive name */ + (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 */ + "Parser status class can be used" // directive description + }, {NULL} }; @@ -665,7 +713,7 @@ static const command_rec parser_cmds[] = */ static const handler_rec parser_handlers[] = { - {DEBUG_PREFIX"parser3-handler", parser_handler}, + {"parser3-handler", parser_handler}, {NULL} }; @@ -683,7 +731,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 */