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

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

E-mail: