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