--- parser3/src/targets/apache13/Attic/mod_parser3.C 2001/10/12 12:15:32 1.2 +++ parser3/src/targets/apache13/Attic/mod_parser3.C 2003/08/19 13:52:18 1.30 @@ -1,12 +1,16 @@ /** @file - Parser: apache 1.3 module. +Parser: apache 1.3 module, part, compiled by Apache. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: mod_parser3.C,v 1.2 2001/10/12 12:15:32 parser Exp $ + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ +static const char* IDENT_MOD_PARSER3_C="$Date: 2003/08/19 13:52:18 $"; + +#if _MSC_VER +#include +#endif + #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -14,101 +18,40 @@ #include "http_main.h" #include "http_protocol.h" #include "util_script.h" +#include "ap_md5.h" +#include "ap_alloc.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 XML -#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[]; -#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[]; -#ifdef XML -extern const char *xalan_patched_RCSIds[]; -#endif -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_config_filespec; ///< filespec of admin's config file - const char* parser_site_config_filespec; ///< filespec of site's config file -}; - -#ifdef XML -/** - * Terminate Xalan and Xerces. - * - * Should be called only once per process after deleting all - * instances of XalanTransformer. Once a process has called - * this function, it cannot use the API for the remaining - * lifetime of the process. - - - this requirement is fullfilled by using Pool::register_cleanup - */ -void callXalanTerminate(void *) { - //_asm int 3; - XalanTerminate(); -} -#endif +#include "pa_httpd.h" /* - * 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; +* Declare ourselves so the configuration routines can find and know us. +* We'll fill it in at the end of the module. +*/ +extern module MODULE_VAR_EXPORT parser3_module; /* - * Locate our directory configuration record for the current request. - */ +* 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); + return (Parser_module_config *) + ap_get_module_config(r->per_dir_config, &parser3_module); } -static const char *cmd_parser_config(cmd_parms *cmd, void *mconfig, char *file_spec) { - Parser_module_config *cfg = (Parser_module_config *) mconfig; - +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; - - return NULL; + cfg->parser_config_filespec=file_spec; + + 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=1; + + return NULL; } @@ -127,202 +70,17 @@ static const char *cmd_parser_config(cmd /* and the output sent to the client will actually be HTTP-uncompliant. */ /*--------------------------------------------------------------------------*/ /* - * Sample content handler. All this does is display the call list that has - * been built up so far. - * - * The return value instructs the caller concerning what happened and what to - * do next: - * OK ("we did our thing") - * DECLINED ("this isn't something with which we want to get involved") - * HTTP_mumble ("an error status should be reported") - */ - - -//@{ -/// 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); -} - -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, - "mod_parser3: SAPI::read_post(max=%u)", max_bytes); -*/ - int retval; - if((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) - return 0; - if(!ap_should_client_block(r)) - return 0; - - uint total_read_bytes=0; - void (*handler)(int)=signal(SIGPIPE, SIG_IGN); - while (total_read_bytes(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 - * "text/plain"). You *must* also ensure that r->content_type is lower - * case. - */ - r->content_type = 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) { - request_rec *r=static_cast(pool.context()); - - ap_hard_timeout("Send header", r); - ap_send_http_header(r); - ap_kill_timeout(r); -} - -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); - ap_rwrite(buf, size, r); - ap_kill_timeout(r); -} - -//@} - -/** - main workhorse - - @todo intelligent cache-control -*/ -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); - -#ifdef XML - /** - * Initialize Xerces and Xalan. - * - * Should be called only once per process before making - * any other API calls. - */ - //_asm int 3; - XalanInitialize(); - pool.register_cleanup(callXalanTerminate, 0); -#endif - - Parser_module_config *dcfg=our_dconfig(r); +* Sample content handler. All this does is display the call list that has +* been built up so far. +* +* The return value instructs the caller concerning what happened and what to +* do next: +* OK ("we did our thing") +* DECLINED ("this isn't something with which we want to get involved") +* HTTP_mumble ("an error status should be reported") +*/ - /* A flag which modules can set, to indicate that the data being - * returned is volatile, and clients should be told not to cache it. - */ - r->no_cache=1; - - PTRY { // global try - ap_add_common_vars(r); - ap_add_cgi_vars(r); - - // Request info - Request::Info request_info; - 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=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=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_USER_HTML - ); - - // 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 - r->header_only!=0); - // no actions with request' data past this point - // request.exception not not handled here, but all - // request' data are associated with it's pool=exception - - // successful finish - } PCATCH(e) { // global problem - // 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(); - // log it - SAPI::log(pool, "exception in request exception handler: %s", body); - - // - int content_length=strlen(body); - - // prepare header - SAPI::add_header_attribute(pool, "content-type", "text/plain"); - char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); - SAPI::add_header_attribute(pool, "content-length", content_length_cstr); - - // send header - SAPI::send_header(pool); - - // send body - if(!r->header_only) - SAPI::send_body(pool, body, content_length); - - // unsuccessful finish - } - PEND_CATCH - - /* - * We did what we wanted to do, so tell the rest of the server we - * succeeded. - */ - return OK; -} - /*--------------------------------------------------------------------------*/ /* */ /* Now let's declare routines for each of the callback phase in order. */ @@ -352,233 +110,228 @@ static int parser_handler(request_rec *r /* see the individual handler comments below for details. */ /* */ /*--------------------------------------------------------------------------*/ -/* - * This function is called during server initialisation. Any information - * that needs to be recorded must be in static cells, since there's no - * configuration record. - * - * There is no return value. - */ - -static void setup_module_cells() { - static bool globals_inited=false; - if(globals_inited) - return; - globals_inited=true; - /* - * allocate our module-private pool. - */ - static Pool pool(ap_make_sub_pool(NULL)); // global pool - PTRY { - // init socks - init_socks(pool); - -#ifdef XML - /** - * Initialize Xerces and Xalan. - * - * Should be called only once per process before making - * any other API calls. - */ - XalanInitialize(); - pool.register_cleanup(callXalanTerminate, 0); -#endif +static int parser_handler(request_rec *ar) { + // record clone + pa_request_rec lr={ + ar, + ar->pool, + ar->header_only, + &ar->status, + ar->method, + ar->headers_out, + ar->subprocess_env, + ar->content_type, + ar->uri, + ar->filename, + ar->path_info, + ar->args, + &ar->finfo + }; - // init global classes - init_methoded_array(pool); - // init global variables - pa_globals_init(pool); - } PCATCH(e) { // global problem - ap_log_error(APLOG_MARK, APLOG_EMERG, 0, - "setup_module_cells failed: ", e.comment()); - exit(1); - } - PEND_CATCH + // config + Parser_module_config *dcfg=our_dconfig(ar); + + return pa_parser_handler(&lr, dcfg); } +/* +* This function is called during server initialisation. Any information +* that needs to be recorded must be in static cells, since there's no +* configuration record. +* +* There is no return value. +*/ + static void parser_server_init(server_rec *s, pool *p) { #if MODULE_MAGIC_NUMBER >= 19980527 - ap_add_version_component("Parser/"PARSER_VERSION); + ap_add_version_component(pa_version()); #endif - - /* - * Set up any module cells that ought to be initialised. - */ - setup_module_cells(); + + /* + * Set up any module cells that ought to be initialised. + */ + pa_setup_module_cells(); } /* - * This function gets called to create a per-directory configuration - * record. This will be called for the "default" server environment, and for - * each directory for which the parser finds any of our directives applicable. - * If a directory doesn't have any of our directives involved (i.e., they - * aren't in the .htaccess file, or a , , or related - * block), this routine will *not* be called - the configuration for the - * closest ancestor is used. - * - * The return value is a pointer to the created module-specific - * structure. - */ +* This function gets called to create a per-directory configuration +* record. This will be called for the "default" server environment, and for +* each directory for which the parser finds any of our directives applicable. +* If a directory doesn't have any of our directives involved (i.e., they +* aren't in the .htaccess file, or a , , or related +* block), this routine will *not* be called - the configuration for the +* closest ancestor is used. +* +* The return value is a pointer to the created module-specific +* structure. +*/ static void *parser_create_dir_config(pool *p, char *dirspec) { + //_asm int 3; /* - * Allocate the space for our record from the pool supplied. - */ - Parser_module_config *cfg= + * Allocate the space for our record from the pool supplied. + */ + Parser_module_config *cfg= (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config)); - /* - * 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_config_filespec = 0; - cfg->parser_site_config_filespec = 0; - return (void *) cfg; + /* + * Now fill in the defaults. If there are any `parent' configuration + * records, they'll get merged as part of a separate callback. + */ + + return (void *) cfg; } /* - * This function gets called to merge two per-directory configuration - * records. This is typically done to cope with things like .htaccess files - * or directives for directories that are beneath one for which a - * configuration record was already created. The routine has the - * responsibility of creating a new record and merging the contents of the - * other two into it appropriately. If the module doesn't declare a merge - * routine, the record for the closest ancestor location (that has one) is - * used exclusively. - * - * The routine MUST NOT modify any of its arguments! - * - * The return value is a pointer to the created module-specific structure - * containing the merged values. - */ +* This function gets called to merge two per-directory configuration +* records. This is typically done to cope with things like .htaccess files +* or directives for directories that are beneath one for which a +* configuration record was already created. The routine has the +* responsibility of creating a new record and merging the contents of the +* other two into it appropriately. If the module doesn't declare a merge +* routine, the record for the closest ancestor location (that has one) is +* used exclusively. +* +* The routine MUST NOT modify any of its arguments! +* +* The return value is a pointer to the created module-specific structure +* containing the merged values. + + 20011126 paf: noticed, that this is called even on virtual root merge with something "parent", + while thought that that is part of merge_server... + +*/ static void *parser_merge_dir_config(pool *p, void *parent_conf, - void *newloc_conf) { - Parser_module_config *merged_config = + void *newloc_conf) { + //_asm int 3; + Parser_module_config *merged_config = (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config)); - Parser_module_config *pconf = (Parser_module_config *) parent_conf; - Parser_module_config *nconf = (Parser_module_config *) newloc_conf; - - // always from parent - 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_config_filespec = ap_pstrdup(p, nconf->parser_site_config_filespec? - nconf->parser_site_config_filespec:pconf->parser_site_config_filespec); - - return (void *) merged_config; + Parser_module_config *pconf = (Parser_module_config *) parent_conf; + Parser_module_config *nconf = (Parser_module_config *) newloc_conf; + + 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; + + /* + * Some things get copied directly from the more-specific record, rather + * than getting merged. + */ + + return (void *) merged_config; } /* - * This function gets called to create a per-server configuration - * record. It will always be called for the "default" server. - * - * The return value is a pointer to the created module-specific - * structure. - */ +* This function gets called to create a per-server configuration +* record. It will always be called for the "default" server. +* +* The return value is a pointer to the created module-specific +* structure. +*/ static void *parser_create_server_config(pool *p, server_rec *s) { - /* - * As with the parser_create_dir_config() reoutine, we allocate and fill - * in an empty record. - */ - Parser_module_config *cfg= + //_asm int 3; + /* + * As with the parser_create_dir_config() routine, we allocate and fill + * in an empty record. + */ + Parser_module_config *cfg= (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config)); - - cfg->parser_root_config_filespec = 0; - cfg->parser_site_config_filespec = 0; - - return (void *) cfg; + + return (void *) cfg; } /* - * This function gets called to merge two per-server configuration - * records. This is typically done to cope with things like virtual hosts and - * the default server configuration The routine has the responsibility of - * creating a new record and merging the contents of the other two into it - * appropriately. If the module doesn't declare a merge routine, the more - * specific existing record is used exclusively. - * - * The routine MUST NOT modify any of its arguments! - * - * The return value is a pointer to the created module-specific structure - * containing the merged values. - */ +* This function gets called to merge two per-server configuration +* records. This is typically done to cope with things like virtual hosts and +* the default server configuration The routine has the responsibility of +* creating a new record and merging the contents of the other two into it +* appropriately. If the module doesn't declare a merge routine, the more +* specific existing record is used exclusively. +* +* The routine MUST NOT modify any of its arguments! +* +* The return value is a pointer to the created module-specific structure +* containing the merged values. +*/ static void *parser_merge_server_config(pool *p, void *server1_conf, - void *server2_conf) + void *server2_conf) { - - Parser_module_config *merged_config = + //_asm int 3; + + Parser_module_config *merged_config = (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config)); - Parser_module_config *s1conf = (Parser_module_config *) server1_conf; - Parser_module_config *s2conf = (Parser_module_config *) server2_conf; - - /* - * 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); - + Parser_module_config *s1conf = (Parser_module_config *) server1_conf; + Parser_module_config *s2conf = (Parser_module_config *) server2_conf; + + /* + * Our inheritance rules are our own, and part of our module's semantics. + * Basically, just note whence we came. + */ + 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; + return (void *) merged_config; } /* - * This routine gives our module an opportunity to translate the URI into an - * actual filename. If we don't do anything special, the server's default - * rules (Alias directives and the like) will continue to be followed. - * - * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no - * further modules are called for this phase. - */ +* This routine gives our module an opportunity to translate the URI into an +* actual filename. If we don't do anything special, the server's default +* rules (Alias directives and the like) will continue to be followed. +* +* The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no +* further modules are called for this phase. +*/ static int parser_translate_handler(request_rec *r) { - Parser_module_config *cfg=our_dconfig(r); - return DECLINED; + Parser_module_config *cfg=our_dconfig(r); + return DECLINED; } /* - * This routine is called to check the authentication information sent with - * the request (such as looking up the user in a database and verifying that - * the [encrypted] password sent matches the one in the database). - * - * The return value is OK, DECLINED, or some HTTP_mumble error (typically - * HTTP_UNAUTHORIZED). If we return OK, no other modules are given a chance - * at the request during this phase. - */ +* This routine is called to check the authentication information sent with +* the request (such as looking up the user in a database and verifying that +* the [encrypted] password sent matches the one in the database). +* +* The return value is OK, DECLINED, or some HTTP_mumble error (typically +* HTTP_UNAUTHORIZED). If we return OK, no other modules are given a chance +* at the request during this phase. +*/ static int parser_check_user_id(request_rec *r) { - Parser_module_config *cfg=our_dconfig(r); - return DECLINED; + Parser_module_config *cfg=our_dconfig(r); + return DECLINED; } /* - * This routine is called to check to see if the resource being requested - * requires authorisation. - * - * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no - * other modules are called during this phase. - * - * If *all* modules return DECLINED, the request is aborted with a server - * error. - */ +* This routine is called to check to see if the resource being requested +* requires authorisation. +* +* The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no +* other modules are called during this phase. +* +* If *all* modules return DECLINED, the request is aborted with a server +* error. +*/ static int parser_auth_checker(request_rec *r) { - Parser_module_config *cfg=our_dconfig(r); - return DECLINED; + Parser_module_config *cfg=our_dconfig(r); + return DECLINED; } /* - * This routine is called to check for any module-specific restrictions placed - * upon the requested resource. (See the mod_access module for an example.) - * - * The return value is OK, DECLINED, or HTTP_mumble. All modules with an - * handler for this phase are called regardless of whether their predecessors - * return OK or DECLINED. The first one to return any other status, however, - * will abort the sequence (and the request) as usual. - */ +* This routine is called to check for any module-specific restrictions placed +* upon the requested resource. (See the mod_access module for an example.) +* +* The return value is OK, DECLINED, or HTTP_mumble. All modules with an +* handler for this phase are called regardless of whether their predecessors +* return OK or DECLINED. The first one to return any other status, however, +* will abort the sequence (and the request) as usual. +*/ static int parser_access_checker(request_rec *r) { - - Parser_module_config *cfg=our_dconfig(r); - return DECLINED; + + Parser_module_config *cfg=our_dconfig(r); + return DECLINED; } /*--------------------------------------------------------------------------*/ @@ -591,27 +344,27 @@ static int parser_access_checker(request /* */ /*--------------------------------------------------------------------------*/ /* - * List of directives specific to our module. - */ +* List of directives specific to our module. +*/ static const command_rec parser_cmds[] = { - { - 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 config filespec (Admin)" // directive description - }, - { - 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 config filespec" // directive description - }, - {NULL} + { + "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 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} }; /*--------------------------------------------------------------------------*/ @@ -620,21 +373,21 @@ static const command_rec parser_cmds[] = /* */ /*--------------------------------------------------------------------------*/ /* - * List of content handlers our module supplies. Each handler is defined by - * two parts: a name by which it can be referenced (such as by - * {Add,Set}Handler), and the actual routine name. The list is terminated by - * a NULL block, since it can be of variable length. - * - * Note that content-handlers are invoked on a most-specific to least-specific - * basis; that is, a handler that is declared for "text/plain" will be - * invoked before one that was declared for "text / *". Note also that - * if a content-handler returns anything except DECLINED, no other - * content-handlers will be called. - */ +* List of content handlers our module supplies. Each handler is defined by +* two parts: a name by which it can be referenced (such as by +* {Add,Set}Handler), and the actual routine name. The list is terminated by +* a NULL block, since it can be of variable length. +* +* Note that content-handlers are invoked on a most-specific to least-specific +* basis; that is, a handler that is declared for "text/plain" will be +* invoked before one that was declared for "text / *". Note also that +* if a content-handler returns anything except DECLINED, no other +* content-handlers will be called. +*/ static const handler_rec parser_handlers[] = { - {DEBUG_PREFIX"parser3-handler", parser_handler}, - {NULL} + {"parser3-handler", parser_handler}, + {NULL} }; /*--------------------------------------------------------------------------*/ @@ -644,37 +397,168 @@ static const handler_rec parser_handlers /* */ /*--------------------------------------------------------------------------*/ /* - * Module definition for configuration. If a particular callback is not - * needed, replace its routine name below with the word NULL. - * - * The number in brackets indicates the order in which the routine is called - * 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 definition for configuration. If a particular callback is not +* needed, replace its routine name below with the word NULL. +* +* The number in brackets indicates the order in which the routine is called +* 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 = { - STANDARD_MODULE_STUFF, - parser_server_init, /* module initializer */ - parser_create_dir_config, /* per-directory config creator */ - parser_merge_dir_config, /* dir config merger */ - parser_create_server_config, /* server config creator */ - parser_merge_server_config, /* server config merger */ - parser_cmds, /* command table */ - parser_handlers, /* [9] list of handlers */ - parser_translate_handler, /* [2] filename-to-URI translation */ - parser_check_user_id, /* [5] check/validate user_id */ - parser_auth_checker, /* [6] check user_id is valid *here* */ - parser_access_checker, /* [4] check access by host address */ - 0, /* [7] MIME type checker/setter */ - 0, /* [8] fixups */ - 0 /* [10] logger */ + STANDARD_MODULE_STUFF, + parser_server_init, /* module initializer */ + parser_create_dir_config, /* per-directory config creator */ + parser_merge_dir_config, /* dir config merger */ + parser_create_server_config, /* server config creator */ + parser_merge_server_config, /* server config merger */ + parser_cmds, /* command table */ + parser_handlers, /* [9] list of handlers */ + parser_translate_handler, /* [2] filename-to-URI translation */ + parser_check_user_id, /* [5] check/validate user_id */ + parser_auth_checker, /* [6] check user_id is valid *here* */ + parser_access_checker, /* [4] check access by host address */ + 0, /* [7] MIME type checker/setter */ + 0, /* [8] fixups */ + 0 /* [10] logger */ }; #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 # pragma comment(lib, APACHE_WIN32_SRC "/CoreR/ApacheCore.lib") # endif #endif + + +// interface to C++ + +#define PA_APLOG_EMERG 0 /* system is unusable */ +#define PA_APLOG_ALERT 1 /* action must be taken immediately */ +#define PA_APLOG_CRIT 2 /* critical conditions */ +#define PA_APLOG_ERR 3 /* error conditions */ +#define PA_APLOG_WARNING 4 /* warning conditions */ +#define PA_APLOG_NOTICE 5 /* normal but significant condition */ +#define PA_APLOG_INFO 6 /* informational */ +#define PA_APLOG_DEBUG 7 /* debug-level messages */ + +#define PA_APLOG_LEVELMASK 7 /* mask off the level value */ + +#define PA_APLOG_NOERRNO (PA_APLOG_LEVELMASK + 1) + +#define PA_APLOG_MARK __FILE__,__LINE__ + +void pa_ap_log_rerror(const char *file, int line, int level, + const pa_request_rec *s, const char *fmt, ...) { + const char* str; + va_list l; + va_start(l, fmt); + str=va_arg(l, const char*); + va_end(l); + + ap_log_rerror(file, line, level, + (request_rec*)s->real_request_rec, "%s", str); +} + + +void pa_ap_log_error(const char *file, int line, int level, + const pa_server_rec *s, const char *fmt, ...) { + const char* str; + va_list l; + va_start(l, fmt); + str=va_arg(l, const char*); + va_end(l); + + ap_log_error(file, line, level, + (server_rec*)s, "%s", str); +} + +// ap_alloc.h + +const char* pa_ap_table_get(const pa_table *t, const char *name) { + return ap_table_get((const table*)t, name); +} +void pa_ap_table_addn(pa_table *t, const char *name, const char *val) { + ap_table_addn((table*)t, name, val); +} + +int pa_ap_table_size(const pa_table *t) { + return ap_table_elts((const table*)t)->nelts; +} + +void pa_ap_table_do(int (*comp) (void *, const char *, const char *), + void *rec, const pa_table *t, ...) { + ap_table_do(comp, rec, (table*)t, 0); +} + +char * pa_ap_pstrdup(pa_pool *p, const char *s) { + return ap_pstrdup((pool*)p, s); +} + +// http_protocol.h + +int pa_ap_setup_client_block(pa_request_rec *r, int read_policy) { + return ap_setup_client_block((request_rec*)r->real_request_rec, + read_policy); +} +int pa_ap_should_client_block(pa_request_rec *r) { + return ap_should_client_block((request_rec*)r->real_request_rec); +} +long pa_ap_get_client_block(pa_request_rec *r, char *buffer, int bufsiz) { + return ap_get_client_block((request_rec*)r->real_request_rec, + buffer, bufsiz); +} +void pa_ap_send_http_header(pa_request_rec *r) { + ap_send_http_header((request_rec*)r->real_request_rec); +} +int pa_ap_rwrite(const void *buf, int nbyte, pa_request_rec *r) { + return ap_rwrite(buf, nbyte, (request_rec*)r->real_request_rec); +} + + +// http_main.h + +void pa_ap_hard_timeout(char *s, pa_request_rec *r) { + ap_hard_timeout(s, (request_rec*)r->real_request_rec); +} +void pa_ap_reset_timeout(pa_request_rec *r) { + ap_reset_timeout((request_rec*)r->real_request_rec); +} +void pa_ap_kill_timeout(pa_request_rec *r) { + ap_kill_timeout((request_rec*)r->real_request_rec); +} + + +// util_script.h + +void pa_ap_add_cgi_vars(pa_request_rec *r) { + ap_add_cgi_vars((request_rec*)r->real_request_rec); +} +void pa_ap_add_common_vars(pa_request_rec *r) { + ap_add_common_vars((request_rec*)r->real_request_rec); +} + + +// ap_md5.h + +void pa_MD5Init(PA_MD5_CTX *context) { ap_MD5Init((AP_MD5_CTX*)context); } +void pa_MD5Update(PA_MD5_CTX *context, const unsigned char *input, + unsigned int inputLen) { ap_MD5Update((AP_MD5_CTX *)context, input, inputLen); } +void pa_MD5Final(unsigned char digest[MD5_DIGESTSIZE], + PA_MD5_CTX *context) { ap_MD5Final(digest, (AP_MD5_CTX *)context); } +void pa_MD5Encode(const unsigned char *password, + const unsigned char *salt, + char *result, size_t nbytes) { ap_MD5Encode(password, salt, result, nbytes); } +void pa_to64(char *s, unsigned long v, int n) { ap_to64(s, v, n); } + + +// signal.h + +void (*pa_signal (int sig, void (*disp)(int)))(int) { + if(sig==PA_SIGPIPE && disp==PA_SIG_IGN) + return signal(SIGPIPE, SIG_IGN); + + return 0; +}