Annotation of parser3/src/targets/apache13/mod_parser3.C, revision 1.6

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

E-mail: