Annotation of parser3/src/targets/apache13/modules/extra/mod_parser3.C, revision 1.45

1.2       paf         1: /** @file
1.7       paf         2:        Parser: apache 1.3 module.
1.2       paf         3: 
                      4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.44      parser      5:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.2       paf         6: 
1.45    ! parser      7:        $Id: mod_parser3.C,v 1.44 2001/09/26 10:32:26 parser Exp $
1.2       paf         8: */
                      9: 
                     10: #include "httpd.h"
                     11: #include "http_config.h"
                     12: #include "http_core.h"
                     13: #include "http_log.h"
                     14: #include "http_main.h"
                     15: #include "http_protocol.h"
                     16: #include "util_script.h"
1.41      parser     17: #include "multithread.h"
1.2       paf        18: 
1.15      paf        19: #include "pa_sapi.h"
1.32      paf        20: #include "classes.h"
1.2       paf        21: #include "pa_common.h"
                     22: #include "pa_globals.h"
                     23: #include "pa_request.h"
1.8       paf        24: #include "pa_version.h"
1.22      paf        25: #include "pa_socks.h"
1.2       paf        26: 
1.36      parser     27: #ifdef _DEBUG
                     28: #      define DEBUG_PREFIX "debug_"
                     29: #      define PARSER3_MODULE debug_parser3_module
                     30: #else
                     31: #      define DEBUG_PREFIX
                     32: #      define PARSER3_MODULE parser3_module
                     33: #endif
1.44      parser     34: 
                     35: // consts
                     36: 
                     37: extern const char *main_RCSIds[];
1.45    ! parser     38: #ifdef SMTP
1.44      parser     39: extern const char *smtp_RCSIds[];
1.45    ! parser     40: #endif
1.44      parser     41: extern const char *gd_RCSIds[];
                     42: extern const char *classes_RCSIds[];
                     43: extern const char *types_RCSIds[];
                     44: extern const char *ApacheModuleParser3_RCSIds[];
                     45: const char **RCSIds[]={
                     46:        main_RCSIds,
1.45    ! parser     47: #ifdef SMTP
1.44      parser     48:        smtp_RCSIds,
1.45    ! parser     49: #endif
1.44      parser     50:        gd_RCSIds,
                     51:        classes_RCSIds,
                     52:        types_RCSIds,
                     53:        ApacheModuleParser3_RCSIds,
                     54:        0
                     55: };
1.36      parser     56: 
                     57: 
1.33      paf        58: /// apache parser module configuration [httpd.conf + .htaccess-es]
1.8       paf        59: struct Parser_module_config {
1.42      parser     60:     const char* parser_root_config_filespec; ///< filespec of admin's config file
                     61:     const char* parser_site_config_filespec; ///< filespec of site's config file
1.8       paf        62: };
1.2       paf        63: 
                     64: /*
                     65:  * Declare ourselves so the configuration routines can find and know us.
                     66:  * We'll fill it in at the end of the module.
                     67:  */
1.36      parser     68: extern "C" module MODULE_VAR_EXPORT PARSER3_MODULE;
1.2       paf        69: 
                     70: /*
                     71:  * Locate our directory configuration record for the current request.
                     72:  */
1.14      paf        73: static Parser_module_config *our_dconfig(request_rec *r) {
                     74:     return (Parser_module_config *) 
1.36      parser     75:                ap_get_module_config(r->per_dir_config, &PARSER3_MODULE);
1.2       paf        76: }
                     77: 
1.42      parser     78: static const char *cmd_parser_config(cmd_parms *cmd, void *mconfig, char *file_spec) {
1.8       paf        79:     Parser_module_config *cfg = (Parser_module_config *) mconfig;
1.2       paf        80: 
1.8       paf        81:        // remember assigned filespec into cfg
1.42      parser     82:        (cmd->info?cfg->parser_root_config_filespec:cfg->parser_site_config_filespec)=file_spec;
1.2       paf        83: 
                     84:     return NULL;
                     85: }
                     86: 
1.8       paf        87: 
1.2       paf        88: /*--------------------------------------------------------------------------*/
                     89: /*                                                                          */
                     90: /* Now we declare our content handlers, which are invoked when the server   */
                     91: /* encounters a document which our module is supposed to have a chance to   */
                     92: /* see.  (See mod_mime's SetHandler and AddHandler directives, and the      */
                     93: /* mod_info and mod_status examples, for more details.)                     */
                     94: /*                                                                          */
                     95: /* Since content handlers are dumping data directly into the connexion      */
                     96: /* (using the r*() routines, such as rputs() and rprintf()) without         */
                     97: /* intervention by other parts of the server, they need to make             */
                     98: /* sure any accumulated HTTP headers are sent first.  This is done by       */
                     99: /* calling send_http_header().  Otherwise, no header will be sent at all,   */
                    100: /* and the output sent to the client will actually be HTTP-uncompliant.     */
                    101: /*--------------------------------------------------------------------------*/
                    102: /* 
                    103:  * Sample content handler.  All this does is display the call list that has
                    104:  * been built up so far.
                    105:  *
                    106:  * The return value instructs the caller concerning what happened and what to
                    107:  * do next:
                    108:  *  OK ("we did our thing")
                    109:  *  DECLINED ("this isn't something with which we want to get involved")
                    110:  *  HTTP_mumble ("an error status should be reported")
                    111:  */
                    112: 
                    113: 
1.8       paf       114: //@{
1.15      paf       115: /// SAPI func decl
1.26      paf       116: void SAPI::log(Pool& pool, const char *fmt, ...) {
                    117:        request_rec *r=static_cast<request_rec *>(pool.context());
                    118: 
                    119:     va_list args;
                    120:     va_start(args,fmt);
                    121:        char buf[MAX_STRING];
                    122:        vsnprintf(buf, MAX_STRING, fmt, args);
                    123:        ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf);
                    124:     va_end(args);
                    125: }
                    126: 
1.15      paf       127: const char *SAPI::get_env(Pool& pool, const char *name) {
1.10      paf       128:        request_rec *r=static_cast<request_rec *>(pool.context());
1.4       paf       129:        return (const char *)ap_table_get(r->subprocess_env, name);
                    130: }
                    131: 
1.24      paf       132: size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) {
1.10      paf       133:        request_rec *r=static_cast<request_rec *>(pool.context());
1.5       paf       134: 
                    135: /*    ap_log_error(APLOG_MARK, APLOG_DEBUG, r->server, 
1.15      paf       136:                "mod_parser3: SAPI::read_post(max=%u)", max_bytes);
1.5       paf       137: */
                    138:        int retval;
                    139:     if((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
                    140:                return 0;
                    141:        if(!ap_should_client_block(r))
                    142:                return 0;
                    143: 
                    144:        uint total_read_bytes=0;
                    145:        void (*handler)(int)=signal(SIGPIPE, SIG_IGN);
                    146:        while (total_read_bytes<max_bytes) {
                    147:                ap_hard_timeout("Read POST information", r); /* start timeout timer */
                    148:                uint read_bytes=
                    149:                        ap_get_client_block(r, buf+total_read_bytes, max_bytes-total_read_bytes);
                    150:                ap_reset_timeout(r);
                    151:                if (read_bytes<=0)
1.2       paf       152:                        break;
1.5       paf       153:                total_read_bytes+=read_bytes;
                    154:        }
                    155:        signal(SIGPIPE, handler);       
                    156:        return total_read_bytes;
1.2       paf       157: }
                    158: 
1.15      paf       159: void SAPI::add_header_attribute(Pool& pool, const char *key, const char *value) {
1.10      paf       160:        request_rec *r=static_cast<request_rec *>(pool.context());
1.2       paf       161: 
1.37      parser    162:        if(strcasecmp(key, "location")==0) 
                    163:                r->status=302;
                    164: 
1.3       paf       165:        if(strcasecmp(key, "content-type")==0) {
1.2       paf       166:                /* r->content_type, *not* r->headers_out("Content-type").  If you don't
                    167:                 * set it, it will be filled in with the server's default type (typically
                    168:                 * "text/plain").  You *must* also ensure that r->content_type is lower
                    169:                 * case.
                    170:                 */
                    171:                r->content_type = value;
1.37      parser    172:        } else if(strcasecmp(key, "status")==0) 
                    173:                r->status=atoi(value);
                    174:        else
1.38      parser    175:                ap_table_addn(r->headers_out, key, value);
1.2       paf       176: }
                    177: 
1.15      paf       178: void SAPI::send_header(Pool& pool) {
1.10      paf       179:        request_rec *r=static_cast<request_rec *>(pool.context());
1.5       paf       180: 
1.8       paf       181:     ap_hard_timeout("Send header", r);
1.2       paf       182:     ap_send_http_header(r);
1.5       paf       183:        ap_kill_timeout(r);
1.2       paf       184: }
                    185: 
1.21      paf       186: void SAPI::send_body(Pool& pool, const void *buf, size_t size) {
1.10      paf       187:        request_rec *r=static_cast<request_rec *>(pool.context());
1.5       paf       188: 
1.8       paf       189:     ap_hard_timeout("Send body", r);
1.2       paf       190:        ap_rwrite(buf, size, r);
1.5       paf       191:        ap_kill_timeout(r);
1.2       paf       192: }
1.18      paf       193: 
1.8       paf       194: //@}
                    195: 
1.11      paf       196: /**
                    197:        main workhorse
                    198:        
1.21      paf       199:        @todo intelligent cache-control
1.11      paf       200: */
1.40      parser    201: static int parser_handler(request_rec *r) {
                    202: //     _asm int 3;
                    203:     if(r->finfo.st_mode == 0) 
                    204:                return NOT_FOUND;
                    205:        
1.16      paf       206:        Pool pool(r->pool);
1.10      paf       207:        pool.set_context(r);
1.2       paf       208: 
1.8       paf       209:     Parser_module_config *dcfg=our_dconfig(r);
1.2       paf       210: 
                    211: 
                    212:        /* A flag which modules can set, to indicate that the data being
                    213:         * returned is volatile, and clients should be told not to cache it.
                    214:         */
                    215:        r->no_cache=1;
                    216: 
                    217:        PTRY { // global try
1.4       paf       218:                ap_add_common_vars(r);
                    219:                ap_add_cgi_vars(r);
                    220: 
1.2       paf       221:                // Request info
                    222:                Request::Info request_info;
1.20      paf       223:                request_info.document_root=SAPI::get_env(pool, "DOCUMENT_ROOT");
1.14      paf       224:                request_info.path_translated=r->filename;
1.2       paf       225:                request_info.method=r->method;
                    226:                request_info.query_string=r->args;
1.20      paf       227:                request_info.uri=SAPI::get_env(pool, "REQUEST_URI");
                    228:                request_info.content_type=SAPI::get_env(pool, "CONTENT_TYPE");
                    229:                const char *content_length=SAPI::get_env(pool, "CONTENT_LENGTH");
1.42      parser    230:                request_info.content_length=content_length?atoi(content_length):0;
1.20      paf       231:                request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE");
                    232:                request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT");
1.2       paf       233: 
1.42      parser    234:                //_asm int 3;
1.2       paf       235:                // prepare to process request
                    236:                Request request(pool,
                    237:                        request_info,
1.30      paf       238:                        String::UL_USER_HTML
1.2       paf       239:                        );
                    240:                
                    241:                // process the request
                    242:                request.core(
1.42      parser    243:                        dcfg->parser_root_config_filespec, true, // /path/to/admin/config
                    244:                        dcfg->parser_site_config_filespec, true, // /path/to/site/config
1.2       paf       245:                        r->header_only!=0);
                    246:                // no actions with request' data past this point
                    247:                // request.exception not not handled here, but all
                    248:                // request' data are associated with it's pool=exception
                    249: 
                    250:                // successful finish
                    251:        } PCATCH(e) { // global problem 
1.18      paf       252:                // don't allocate anything on pool here:
                    253:                //   possible pool' exception not catch-ed now
                    254:                //   and there could be out-of-memory exception
1.2       paf       255:                const char *body=e.comment();
1.18      paf       256:                // log it
                    257:                SAPI::log(pool, "exception in request exception handler: %s", body);
                    258: 
                    259:                //
1.2       paf       260:                int content_length=strlen(body);
                    261: 
                    262:                // prepare header
1.15      paf       263:                SAPI::add_header_attribute(pool, "content-type", "text/plain");
1.2       paf       264:                char content_length_cstr[MAX_NUMBER];
1.25      paf       265:                snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length);
1.15      paf       266:                SAPI::add_header_attribute(pool, "content-length", content_length_cstr);
1.2       paf       267: 
                    268:                // send header
1.15      paf       269:                SAPI::send_header(pool);
1.2       paf       270: 
                    271:                // send body
                    272:                if(!r->header_only)
1.15      paf       273:                        SAPI::send_body(pool, body, content_length);
1.2       paf       274: 
                    275:                // unsuccessful finish
                    276:        }
                    277:        PEND_CATCH
                    278: 
                    279:     /*
                    280:      * We did what we wanted to do, so tell the rest of the server we
                    281:      * succeeded.
                    282:      */
                    283:     return OK;
                    284: }
                    285: 
                    286: /*--------------------------------------------------------------------------*/
                    287: /*                                                                          */
                    288: /* Now let's declare routines for each of the callback phase in order.      */
                    289: /* (That's the order in which they're listed in the callback list, *not     */
                    290: /* the order in which the server calls them!  See the command_rec           */
                    291: /* declaration near the bottom of this file.)  Note that these may be       */
                    292: /* called for situations that don't relate primarily to our function - in   */
                    293: /* other words, the fixup handler shouldn't assume that the request has     */
                    294: /* to do with "example" stuff.                                              */
                    295: /*                                                                          */
                    296: /* With the exception of the content handler, all of our routines will be   */
                    297: /* called for each request, unless an earlier handler from another module   */
                    298: /* aborted the sequence.                                                    */
                    299: /*                                                                          */
                    300: /* Handlers that are declared as "int" can return the following:            */
                    301: /*                                                                          */
                    302: /*  OK          Handler accepted the request and did its thing with it.     */
                    303: /*  DECLINED    Handler took no action.                                     */
                    304: /*  HTTP_mumble Handler looked at request and found it wanting.             */
                    305: /*                                                                          */
                    306: /* What the server does after calling a module handler depends upon the     */
                    307: /* handler's return value.  In all cases, if the handler returns            */
                    308: /* DECLINED, the server will continue to the next module with an handler    */
                    309: /* for the current phase.  However, if the handler return a non-OK,         */
                    310: /* non-DECLINED status, the server aborts the request right there.  If      */
                    311: /* the handler returns OK, the server's next action is phase-specific;      */
                    312: /* see the individual handler comments below for details.                   */
                    313: /*                                                                          */
                    314: /*--------------------------------------------------------------------------*/
                    315: /* 
                    316:  * This function is called during server initialisation.  Any information
                    317:  * that needs to be recorded must be in static cells, since there's no
                    318:  * configuration record.
                    319:  *
                    320:  * There is no return value.
                    321:  */
1.14      paf       322: 
                    323: static void setup_module_cells() {
1.39      parser    324:        static bool  globals_inited=false;
1.2       paf       325:        if(globals_inited)
                    326:                return;
                    327:        globals_inited=true;
                    328: 
1.14      paf       329:        /*
                    330:      * allocate our module-private pool.
                    331:      */
1.16      paf       332:        static Pool pool(ap_make_sub_pool(NULL)); // global pool
1.2       paf       333:        PTRY {
1.27      paf       334:                // init socks
                    335:                init_socks(pool);
                    336: 
1.29      paf       337:                // init global classes
                    338:                init_methoded_array(pool);
1.2       paf       339:                // init global variables
1.15      paf       340:                pa_globals_init(pool);
1.2       paf       341:        } PCATCH(e) { // global problem 
1.18      paf       342:                ap_log_error(APLOG_MARK, APLOG_EMERG, 0, 
                    343:                        "setup_module_cells failed: ", e.comment());
                    344:                exit(1);
1.2       paf       345:        }
                    346:        PEND_CATCH
                    347: }
                    348: 
1.14      paf       349: static void parser_server_init(server_rec *s, pool *p) {
                    350: #if MODULE_MAGIC_NUMBER >= 19980527
1.17      paf       351:        ap_add_version_component("Parser/"PARSER_VERSION);
1.14      paf       352: #endif 
1.2       paf       353: 
                    354:     /*
1.14      paf       355:      * Set up any module cells that ought to be initialised.
1.2       paf       356:      */
1.14      paf       357:     setup_module_cells();
1.2       paf       358: }
                    359: 
                    360: /*
                    361:  * This function gets called to create a per-directory configuration
                    362:  * record.  This will be called for the "default" server environment, and for
                    363:  * each directory for which the parser finds any of our directives applicable.
                    364:  * If a directory doesn't have any of our directives involved (i.e., they
                    365:  * aren't in the .htaccess file, or a <Location>, <Directory>, or related
                    366:  * block), this routine will *not* be called - the configuration for the
                    367:  * closest ancestor is used.
                    368:  *
                    369:  * The return value is a pointer to the created module-specific
                    370:  * structure.
                    371:  */
1.14      paf       372: static void *parser_create_dir_config(pool *p, char *dirspec) {
                    373:        /*
1.2       paf       374:      * Allocate the space for our record from the pool supplied.
                    375:      */
1.14      paf       376:     Parser_module_config *cfg=
                    377:                (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config));
1.2       paf       378:     /*
                    379:      * Now fill in the defaults.  If there are any `parent' configuration
                    380:      * records, they'll get merged as part of a separate callback.
                    381:      */
1.42      parser    382:     cfg->parser_root_config_filespec = 0;
                    383:        cfg->parser_site_config_filespec = 0;
1.2       paf       384:     return (void *) cfg;
                    385: }
                    386: 
                    387: /*
                    388:  * This function gets called to merge two per-directory configuration
                    389:  * records.  This is typically done to cope with things like .htaccess files
                    390:  * or <Location> directives for directories that are beneath one for which a
                    391:  * configuration record was already created.  The routine has the
                    392:  * responsibility of creating a new record and merging the contents of the
                    393:  * other two into it appropriately.  If the module doesn't declare a merge
                    394:  * routine, the record for the closest ancestor location (that has one) is
                    395:  * used exclusively.
                    396:  *
                    397:  * The routine MUST NOT modify any of its arguments!
                    398:  *
                    399:  * The return value is a pointer to the created module-specific structure
                    400:  * containing the merged values.
                    401:  */
1.8       paf       402: static void *parser_merge_dir_config(pool *p, void *parent_conf,
1.14      paf       403:                                       void *newloc_conf) {
                    404:     Parser_module_config *merged_config = 
                    405:                (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config));
1.8       paf       406:     Parser_module_config *pconf = (Parser_module_config *) parent_conf;
                    407:     Parser_module_config *nconf = (Parser_module_config *) newloc_conf;
                    408: 
                    409:        // always from parent
1.42      parser    410:     merged_config->parser_root_config_filespec = ap_pstrdup(p, pconf->parser_root_config_filespec);
1.2       paf       411:     /*
                    412:      * Some things get copied directly from the more-specific record, rather
                    413:      * than getting merged.
                    414:      */
1.42      parser    415:     merged_config->parser_site_config_filespec = ap_pstrdup(p, nconf->parser_site_config_filespec?
                    416:                nconf->parser_site_config_filespec:pconf->parser_site_config_filespec);
1.8       paf       417: 
1.2       paf       418:     return (void *) merged_config;
                    419: }
                    420: 
                    421: /*
                    422:  * This function gets called to create a per-server configuration
                    423:  * record.  It will always be called for the "default" server.
                    424:  *
                    425:  * The return value is a pointer to the created module-specific
                    426:  * structure.
                    427:  */
1.14      paf       428: static void *parser_create_server_config(pool *p, server_rec *s) {
1.2       paf       429:     /*
1.8       paf       430:      * As with the parser_create_dir_config() reoutine, we allocate and fill
1.2       paf       431:      * in an empty record.
                    432:      */
1.14      paf       433:     Parser_module_config *cfg=
                    434:                (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config));
                    435: 
1.42      parser    436:     cfg->parser_root_config_filespec = 0;
                    437:        cfg->parser_site_config_filespec = 0;
1.14      paf       438: 
1.2       paf       439:     return (void *) cfg;
                    440: }
                    441: 
                    442: /*
                    443:  * This function gets called to merge two per-server configuration
                    444:  * records.  This is typically done to cope with things like virtual hosts and
                    445:  * the default server configuration  The routine has the responsibility of
                    446:  * creating a new record and merging the contents of the other two into it
                    447:  * appropriately.  If the module doesn't declare a merge routine, the more
                    448:  * specific existing record is used exclusively.
                    449:  *
                    450:  * The routine MUST NOT modify any of its arguments!
                    451:  *
                    452:  * The return value is a pointer to the created module-specific structure
                    453:  * containing the merged values.
                    454:  */
1.8       paf       455: static void *parser_merge_server_config(pool *p, void *server1_conf,
1.2       paf       456:                                          void *server2_conf)
                    457: {
                    458: 
1.14      paf       459:     Parser_module_config *merged_config = 
                    460:                (Parser_module_config *) ap_pcalloc(p, sizeof(Parser_module_config));
1.8       paf       461:     Parser_module_config *s1conf = (Parser_module_config *) server1_conf;
                    462:     Parser_module_config *s2conf = (Parser_module_config *) server2_conf;
1.2       paf       463: 
                    464:     /*
                    465:      * Our inheritance rules are our own, and part of our module's semantics.
                    466:      * Basically, just note whence we came.
                    467:      */
1.42      parser    468:     merged_config->parser_root_config_filespec = ap_pstrdup(p, s2conf->parser_root_config_filespec?
                    469:                s2conf->parser_root_config_filespec:s1conf->parser_root_config_filespec);
                    470:     merged_config->parser_site_config_filespec = ap_pstrdup(p, s2conf->parser_site_config_filespec?
                    471:                s2conf->parser_site_config_filespec:s1conf->parser_site_config_filespec);
1.8       paf       472:  
                    473:        return (void *) merged_config;
1.2       paf       474: }
                    475: 
                    476: /*
                    477:  * This routine gives our module an opportunity to translate the URI into an
                    478:  * actual filename.  If we don't do anything special, the server's default
                    479:  * rules (Alias directives and the like) will continue to be followed.
                    480:  *
                    481:  * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
                    482:  * further modules are called for this phase.
                    483:  */
1.14      paf       484: static int parser_translate_handler(request_rec *r) {
                    485:     Parser_module_config *cfg=our_dconfig(r);
1.2       paf       486:     return DECLINED;
                    487: }
                    488: 
                    489: /*
                    490:  * This routine is called to check the authentication information sent with
                    491:  * the request (such as looking up the user in a database and verifying that
                    492:  * the [encrypted] password sent matches the one in the database).
                    493:  *
                    494:  * The return value is OK, DECLINED, or some HTTP_mumble error (typically
                    495:  * HTTP_UNAUTHORIZED).  If we return OK, no other modules are given a chance
                    496:  * at the request during this phase.
                    497:  */
1.14      paf       498: static int parser_check_user_id(request_rec *r) {
                    499:     Parser_module_config *cfg=our_dconfig(r);
1.2       paf       500:     return DECLINED;
                    501: }
                    502: 
                    503: /*
                    504:  * This routine is called to check to see if the resource being requested
                    505:  * requires authorisation.
                    506:  *
                    507:  * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
                    508:  * other modules are called during this phase.
                    509:  *
                    510:  * If *all* modules return DECLINED, the request is aborted with a server
                    511:  * error.
                    512:  */
1.14      paf       513: static int parser_auth_checker(request_rec *r) {
                    514:     Parser_module_config *cfg=our_dconfig(r);
1.2       paf       515:     return DECLINED;
                    516: }
                    517: 
                    518: /*
                    519:  * This routine is called to check for any module-specific restrictions placed
                    520:  * upon the requested resource.  (See the mod_access module for an example.)
                    521:  *
                    522:  * The return value is OK, DECLINED, or HTTP_mumble.  All modules with an
                    523:  * handler for this phase are called regardless of whether their predecessors
                    524:  * return OK or DECLINED.  The first one to return any other status, however,
                    525:  * will abort the sequence (and the request) as usual.
                    526:  */
1.14      paf       527: static int parser_access_checker(request_rec *r) {
1.2       paf       528: 
1.14      paf       529:     Parser_module_config *cfg=our_dconfig(r);
1.2       paf       530:     return DECLINED;
                    531: }
                    532: 
                    533: /*--------------------------------------------------------------------------*/
                    534: /*                                                                          */
                    535: /* All of the routines have been declared now.  Here's the list of          */
                    536: /* directives specific to our module, and information about where they      */
                    537: /* may appear and how the command parser should pass them to us for         */
                    538: /* processing.  Note that care must be taken to ensure that there are NO    */
                    539: /* collisions of directive names between modules.                           */
                    540: /*                                                                          */
                    541: /*--------------------------------------------------------------------------*/
                    542: /* 
                    543:  * List of directives specific to our module.
                    544:  */
1.8       paf       545: static const command_rec parser_cmds[] =
1.2       paf       546: {
                    547:     {
1.42      parser    548:         DEBUG_PREFIX"ParserRootConfig",              /* directive name */
                    549:         (const char *(*)(void))((void *)cmd_parser_config), // config action routine
1.8       paf       550:         (void*)true,                   /* argument to include in call */
                    551:         (int)(ACCESS_CONF|RSRC_CONF),             /* where available */
                    552:         TAKE1,                /* arguments */
1.42      parser    553:         "Parser root config filespec (Admin)" // directive description
1.8       paf       554:     },
                    555:     {
1.42      parser    556:         DEBUG_PREFIX"ParserSiteConfig",              /* directive name */
                    557:         (const char *(*)(void))((void *)cmd_parser_config), // config action routine
1.8       paf       558:         (void*)false,                   /* argument to include in call */
                    559:         (int)(OR_OPTIONS),             /* where available */
                    560:         TAKE1,                /* arguments */
1.42      parser    561:         "Parser site config filespec" // directive description
1.2       paf       562:     },
                    563:     {NULL}
                    564: };
                    565: 
                    566: /*--------------------------------------------------------------------------*/
                    567: /*                                                                          */
                    568: /* Now the list of content handlers available from this module.             */
                    569: /*                                                                          */
                    570: /*--------------------------------------------------------------------------*/
                    571: /* 
                    572:  * List of content handlers our module supplies.  Each handler is defined by
                    573:  * two parts: a name by which it can be referenced (such as by
                    574:  * {Add,Set}Handler), and the actual routine name.  The list is terminated by
                    575:  * a NULL block, since it can be of variable length.
                    576:  *
                    577:  * Note that content-handlers are invoked on a most-specific to least-specific
                    578:  * basis; that is, a handler that is declared for "text/plain" will be
                    579:  * invoked before one that was declared for "text / *".  Note also that
                    580:  * if a content-handler returns anything except DECLINED, no other
                    581:  * content-handlers will be called.
                    582:  */
1.8       paf       583: static const handler_rec parser_handlers[] =
1.2       paf       584: {
1.36      parser    585:     {DEBUG_PREFIX"parser3-handler", parser_handler},
1.2       paf       586:     {NULL}
                    587: };
                    588: 
                    589: /*--------------------------------------------------------------------------*/
                    590: /*                                                                          */
                    591: /* Finally, the list of callback routines and data structures that          */
                    592: /* provide the hooks into our module from the other parts of the server.    */
                    593: /*                                                                          */
                    594: /*--------------------------------------------------------------------------*/
                    595: /* 
                    596:  * Module definition for configuration.  If a particular callback is not
                    597:  * needed, replace its routine name below with the word NULL.
                    598:  *
                    599:  * The number in brackets indicates the order in which the routine is called
                    600:  * during request processing.  Note that not all routines are necessarily
                    601:  * called (such as if a resource doesn't have access restrictions).
                    602:  */
1.36      parser    603: module MODULE_VAR_EXPORT PARSER3_MODULE =
1.2       paf       604: {
                    605:     STANDARD_MODULE_STUFF,
1.14      paf       606:     parser_server_init,          /* module initializer */
                    607:     parser_create_dir_config,    /* per-directory config creator */
                    608:     parser_merge_dir_config,     /* dir config merger */
                    609:     parser_create_server_config, /* server config creator */
                    610:     parser_merge_server_config,  /* server config merger */
                    611:     parser_cmds,                 /* command table */
                    612:     parser_handlers,             /* [9] list of handlers */
                    613:     parser_translate_handler,    /* [2] filename-to-URI translation */
                    614:     parser_check_user_id,        /* [5] check/validate user_id */
                    615:     parser_auth_checker,         /* [6] check user_id is valid *here* */
                    616:     parser_access_checker,       /* [4] check access by host address */
                    617:     0,                           /* [7] MIME type checker/setter */
                    618:     0,                           /* [8] fixups */
                    619:     0                            /* [10] logger */
1.2       paf       620: };
1.43      parser    621: 
                    622: #if defined(_MSC_VER)
                    623: #      define APACHE_WIN32_SRC "/parser3project/win32apache13/src"
                    624: #      ifdef _DEBUG
                    625: #              pragma comment(lib, APACHE_WIN32_SRC "/CoreD/ApacheCore.lib")
                    626: #      else
                    627: #              pragma comment(lib, APACHE_WIN32_SRC "/CoreR/ApacheCore.lib")
                    628: #      endif
                    629: #endif

E-mail: