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

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

E-mail: