--- parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/04/03 07:32:47 1.21 +++ parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/10/09 14:25:30 1.48 @@ -2,10 +2,9 @@ Parser: apache 1.3 module. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) - $Id: mod_parser3.C,v 1.21 2001/04/03 07:32:47 paf Exp $ + $Id: mod_parser3.C,v 1.48 2001/10/09 14:25:30 parser Exp $ */ #include "httpd.h" @@ -15,37 +14,75 @@ #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" + +#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[]; +#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, +#ifdef XML + xalan_patched_RCSIds, +#endif + 0 +}; + +/// 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_config_filespec; ///< filespec of admin's config file + const char* parser_site_config_filespec; ///< filespec of site's config 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) { +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_auto_path:cfg->parser_site_auto_path)=file_spec; + (cmd->info?cfg->parser_root_config_filespec:cfg->parser_site_config_filespec)=file_spec; return NULL; } @@ -79,12 +116,24 @@ 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]; + size_t size=vsnprintf(buf, MAX_STRING, fmt, args); + remove_crlf(buf, buf+size); + 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, @@ -114,6 +163,9 @@ uint SAPI::read_post(Pool& pool, char *b 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 @@ -121,8 +173,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) { @@ -141,16 +195,6 @@ void SAPI::send_body(Pool& pool, const v 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); -} //@} /** @@ -158,8 +202,11 @@ void SAPI::log(Pool& pool, const char *f @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); @@ -184,20 +231,21 @@ 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 request.core( - dcfg->parser_root_auto_path, true, // /path/to/admin/auto.p - dcfg->parser_site_auto_path, true, // /path/to/site/auto.p + dcfg->parser_root_config_filespec, true, // /path/to/admin/config + dcfg->parser_site_config_filespec, true, // /path/to/site/config r->header_only!=0); // no actions with request' data past this point // request.exception not not handled here, but all @@ -218,7 +266,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 @@ -277,7 +325,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; @@ -287,6 +335,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 @@ -330,8 +383,8 @@ static void *parser_create_dir_config(po * Now fill in the defaults. If there are any `parent' configuration * records, they'll get merged as part of a separate callback. */ - cfg->parser_root_auto_path = 0; - cfg->parser_site_auto_path = 0; + cfg->parser_root_config_filespec = 0; + cfg->parser_site_config_filespec = 0; return (void *) cfg; } @@ -358,13 +411,13 @@ static void *parser_merge_dir_config(poo Parser_module_config *nconf = (Parser_module_config *) newloc_conf; // always from parent - merged_config->parser_root_auto_path = ap_pstrdup(p, pconf->parser_root_auto_path); + merged_config->parser_root_config_filespec = ap_pstrdup(p, pconf->parser_root_config_filespec); /* * Some things get copied directly from the more-specific record, rather * than getting merged. */ - merged_config->parser_site_auto_path = ap_pstrdup(p, nconf->parser_site_auto_path? - nconf->parser_site_auto_path:pconf->parser_site_auto_path); + merged_config->parser_site_config_filespec = ap_pstrdup(p, nconf->parser_site_config_filespec? + nconf->parser_site_config_filespec:pconf->parser_site_config_filespec); return (void *) merged_config; } @@ -384,8 +437,8 @@ static void *parser_create_server_config Parser_module_config *cfg= (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config)); - cfg->parser_root_auto_path = 0; - cfg->parser_site_auto_path = 0; + cfg->parser_root_config_filespec = 0; + cfg->parser_site_config_filespec = 0; return (void *) cfg; } @@ -416,10 +469,10 @@ 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_auto_path = ap_pstrdup(p, s2conf->parser_root_auto_path? - s2conf->parser_root_auto_path:s1conf->parser_root_auto_path); - merged_config->parser_site_auto_path = ap_pstrdup(p, s2conf->parser_site_auto_path? - s2conf->parser_site_auto_path:s1conf->parser_site_auto_path); + 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); return (void *) merged_config; } @@ -496,20 +549,20 @@ static int parser_access_checker(request static const command_rec parser_cmds[] = { { - "parser_root_auto_path", /* directive name */ - (const char *(*)(void))((void *)cmd_parser_auto_path), // config action routine + DEBUG_PREFIX"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 auto.p filespec (Admin)" // directive description + "Parser root config filespec (Admin)" // directive description }, { - "parser_site_auto_path", /* directive name */ - (const char *(*)(void))((void *)cmd_parser_auto_path), // config action routine + DEBUG_PREFIX"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 auto.p filespec" // directive description + "Parser site config filespec" // directive description }, {NULL} }; @@ -533,7 +586,7 @@ static const command_rec parser_cmds[] = */ static const handler_rec parser_handlers[] = { - {"parser3-handler", parser_handler}, + {DEBUG_PREFIX"parser3-handler", parser_handler}, {NULL} }; @@ -551,7 +604,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 */ @@ -569,3 +622,12 @@ module MODULE_VAR_EXPORT parser3_module 0, /* [8] fixups */ 0 /* [10] logger */ }; + +#if defined(_MSC_VER) +# define APACHE_WIN32_SRC "/parser3project/win32apache13/src" +# ifdef _DEBUG +# pragma comment(lib, APACHE_WIN32_SRC "/CoreD/ApacheCore.lib") +# else +# pragma comment(lib, APACHE_WIN32_SRC "/CoreR/ApacheCore.lib") +# endif +#endif