--- parser3/src/targets/apache13/Attic/mod_parser3.c 2003/07/23 11:49:07 1.1.2.1 +++ parser3/src/targets/apache13/Attic/mod_parser3.c 2003/08/19 14:16:28 1.2 @@ -5,7 +5,11 @@ Parser: apache 1.3 module, part, compile Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MOD_PARSER3_C="$Date: 2003/07/23 11:49:07 $"; +static const char* IDENT_MOD_PARSER3_C="$Date: 2003/08/19 14:16:28 $"; + +#if _MSC_VER +#include +#endif #include "httpd.h" #include "http_config.h" @@ -13,10 +17,11 @@ static const char* IDENT_MOD_PARSER3_C=" #include "http_log.h" #include "http_main.h" #include "http_protocol.h" -#include "util_script.h" +#include "util_script.h" #include "ap_md5.h" - -#include "pa_httpd.h" +#include "ap_alloc.h" + +#include "pa_httpd.h" /* * Declare ourselves so the configuration routines can find and know us. @@ -44,7 +49,7 @@ static const char* cmd_parser_status_all //_asm int 3; Parser_module_config *cfg = (Parser_module_config *) mconfig; - cfg->parser_status_allowed=true; + cfg->parser_status_allowed=1; return NULL; } @@ -105,31 +110,31 @@ static const char* cmd_parser_status_all /* see the individual handler comments below for details. */ /* */ /*--------------------------------------------------------------------------*/ - -static int parser_handler(request_rec *ar) { - // record clone - struct pa_request_rec lr={ - ar, - ar->pool, - ar->header_only, - ar->status, - ar->method, - ar->headers_out, - ar->subprocess_env, - ar->content_type, - ar->uri, - ar->filename, - ar->path_info, - ar->args, - &ar->finfo - }; - - // config - Parser_module_config *dcfg=our_dconfig(ar); - - return pa_parser_handler(&lr, dcfg); -} - + +static int parser_handler(request_rec *ar) { + // record clone + pa_request_rec lr={ + ar, + ar->pool, + ar->header_only, + &ar->status, + ar->method, + ar->headers_out, + ar->subprocess_env, + ar->content_type, + ar->uri, + ar->filename, + ar->path_info, + ar->args, + &ar->finfo + }; + + // config + Parser_module_config *dcfg=our_dconfig(ar); + + return pa_parser_handler(&lr, dcfg); +} + /* * This function is called during server initialisation. Any information * that needs to be recorded must be in static cells, since there's no @@ -426,118 +431,134 @@ module MODULE_VAR_EXPORT parser3_module # pragma comment(lib, APACHE_WIN32_SRC "/CoreR/ApacheCore.lib") # endif #endif - - -// interface to C++ - -#define PA_APLOG_EMERG 0 /* system is unusable */ -#define PA_APLOG_ALERT 1 /* action must be taken immediately */ -#define PA_APLOG_CRIT 2 /* critical conditions */ -#define PA_APLOG_ERR 3 /* error conditions */ -#define PA_APLOG_WARNING 4 /* warning conditions */ -#define PA_APLOG_NOTICE 5 /* normal but significant condition */ -#define PA_APLOG_INFO 6 /* informational */ -#define PA_APLOG_DEBUG 7 /* debug-level messages */ - -#define PA_APLOG_LEVELMASK 7 /* mask off the level value */ - -#define PA_APLOG_NOERRNO (PA_APLOG_LEVELMASK + 1) - -#define PA_APLOG_MARK __FILE__,__LINE__ - -void pa_ap_log_rerror(const char *file, int line, int level, - const pa_request_rec *s, const char *fmt, ...) { - va_list l; - va_start(l, fmt); - const char* str=va_arg(l, const char*); - va_end(l); - - ap_log_rerror(file, line, level, - (request_rec*)s->real_request_rec, "%s", str); -} - - -void pa_ap_log_error(const char *file, int line, int level, - const pa_server_rec *s, const char *fmt, ...) { - va_list l; - va_start(l, fmt); - const char* str=va_arg(l, const char*); - va_end(l); - - ap_log_error(file, line, level, - (server_rec*)s, "%s", str); -} - -// ap_alloc.h - -const char * pa_ap_table_get(const pa_table *, const char *); -void pa_ap_table_addn(pa_table *, const char *name, const char *val); - -int pa_ap_table_size(const pa_table *); - -void pa_ap_table_do(int (*comp) (void *, const char *, const char *), - void *rec, const pa_table *t,...); - -char * pa_ap_pstrdup(pa_pool *, const char *s); - -// http_protocol.h - -/* Possible values for request_rec.read_body (set by handling module): - * REQUEST_NO_BODY Send 413 error if message has any body - * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length - * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. - * REQUEST_CHUNKED_PASS Pass the chunks to me without removal. - */ -#define PA_REQUEST_NO_BODY 0 -#define PA_REQUEST_CHUNKED_ERROR 1 -#define PA_REQUEST_CHUNKED_DECHUNK 2 -#define PA_REQUEST_CHUNKED_PASS 3 - -int pa_ap_setup_client_block(pa_request_rec *r, int read_policy); -int pa_ap_should_client_block(pa_request_rec *r); -long pa_ap_get_client_block(pa_request_rec *r, char *buffer, int bufsiz); -void pa_ap_send_http_header(pa_request_rec *l); -int pa_ap_rwrite(const void *buf, int nbyte, pa_request_rec *r); - - -// http_main.h - -void pa_ap_hard_timeout(char *, pa_request_rec *); -void pa_ap_reset_timeout(pa_request_rec *); -void pa_ap_kill_timeout(pa_request_rec *); - - -// util_script.h - -void pa_ap_add_cgi_vars(pa_request_rec *r); -void pa_ap_add_common_vars(pa_request_rec *r); - -// httpd.h - -#define PA_HTTP_NOT_FOUND 404 -#define PA_OK 0 /* Module has handled this stage. */ - - -// ap_md5.h - -void pa_MD5Init(AP_MD5_CTX *context) { ap_MD5Init((AP_MD5_CTX*)context); } -void pa_MD5Update(AP_MD5_CTX *context, const unsigned char *input, - unsigned int inputLen) { ap_MD5Update((AP_MD5_CTX *)context, input, inputLen); } -void pa_MD5Final(unsigned char digest[MD5_DIGESTSIZE], - AP_MD5_CTX *context) { ap_MD5Final(digest, (AP_MD5_CTX *)context); } -void pa_MD5Encode(const unsigned char *password, - const unsigned char *salt, - char *result, size_t nbytes) { ap_MD5Encode(password, salt, result, nbytes); } -void pa_to64(char *s, unsigned long v, int n) { ap_to64(s, v, n); } - - -// signal.h - -#define PA_SIGPIPE 1 /* must translate to real one */ -#define PA_SIG_IGN (void (__cdecl *)(int))1 /* must translate to real one */ - -void (*pa_signal (int sig, void (*disp)(int)))(int); - - - - + + +// interface to C++ + +#define PA_APLOG_EMERG 0 /* system is unusable */ +#define PA_APLOG_ALERT 1 /* action must be taken immediately */ +#define PA_APLOG_CRIT 2 /* critical conditions */ +#define PA_APLOG_ERR 3 /* error conditions */ +#define PA_APLOG_WARNING 4 /* warning conditions */ +#define PA_APLOG_NOTICE 5 /* normal but significant condition */ +#define PA_APLOG_INFO 6 /* informational */ +#define PA_APLOG_DEBUG 7 /* debug-level messages */ + +#define PA_APLOG_LEVELMASK 7 /* mask off the level value */ + +#define PA_APLOG_NOERRNO (PA_APLOG_LEVELMASK + 1) + +#define PA_APLOG_MARK __FILE__,__LINE__ + +void pa_ap_log_rerror(const char *file, int line, int level, + const pa_request_rec *s, const char *fmt, ...) { + const char* str; + va_list l; + va_start(l, fmt); + str=va_arg(l, const char*); + va_end(l); + + ap_log_rerror(file, line, level, + (request_rec*)s->real_request_rec, "%s", str); +} + + +void pa_ap_log_error(const char *file, int line, int level, + const pa_server_rec *s, const char *fmt, ...) { + const char* str; + va_list l; + va_start(l, fmt); + str=va_arg(l, const char*); + va_end(l); + + ap_log_error(file, line, level, + (server_rec*)s, "%s", str); +} + +// ap_alloc.h + +const char* pa_ap_table_get(const pa_table *t, const char *name) { + return ap_table_get((const table*)t, name); +} +void pa_ap_table_addn(pa_table *t, const char *name, const char *val) { + ap_table_addn((table*)t, name, val); +} + +int pa_ap_table_size(const pa_table *t) { + return ap_table_elts((const table*)t)->nelts; +} + +void pa_ap_table_do(int (*comp) (void *, const char *, const char *), + void *rec, const pa_table *t, ...) { + ap_table_do(comp, rec, (table*)t, 0); +} + +char * pa_ap_pstrdup(pa_pool *p, const char *s) { + return ap_pstrdup((pool*)p, s); +} + +// http_protocol.h + +int pa_ap_setup_client_block(pa_request_rec *r, int read_policy) { + return ap_setup_client_block((request_rec*)r->real_request_rec, + read_policy); +} +int pa_ap_should_client_block(pa_request_rec *r) { + return ap_should_client_block((request_rec*)r->real_request_rec); +} +long pa_ap_get_client_block(pa_request_rec *r, char *buffer, int bufsiz) { + return ap_get_client_block((request_rec*)r->real_request_rec, + buffer, bufsiz); +} +void pa_ap_send_http_header(pa_request_rec *r) { + ap_send_http_header((request_rec*)r->real_request_rec); +} +int pa_ap_rwrite(const void *buf, int nbyte, pa_request_rec *r) { + return ap_rwrite(buf, nbyte, (request_rec*)r->real_request_rec); +} + + +// http_main.h + +void pa_ap_hard_timeout(char *s, pa_request_rec *r) { + ap_hard_timeout(s, (request_rec*)r->real_request_rec); +} +void pa_ap_reset_timeout(pa_request_rec *r) { + ap_reset_timeout((request_rec*)r->real_request_rec); +} +void pa_ap_kill_timeout(pa_request_rec *r) { + ap_kill_timeout((request_rec*)r->real_request_rec); +} + + +// util_script.h + +void pa_ap_add_cgi_vars(pa_request_rec *r) { + ap_add_cgi_vars((request_rec*)r->real_request_rec); +} +void pa_ap_add_common_vars(pa_request_rec *r) { + ap_add_common_vars((request_rec*)r->real_request_rec); +} + + +// ap_md5.h + +void pa_MD5Init(PA_MD5_CTX *context) { ap_MD5Init((AP_MD5_CTX*)context); } +void pa_MD5Update(PA_MD5_CTX *context, const unsigned char *input, + unsigned int inputLen) { ap_MD5Update((AP_MD5_CTX *)context, input, inputLen); } +void pa_MD5Final(unsigned char digest[MD5_DIGESTSIZE], + PA_MD5_CTX *context) { ap_MD5Final(digest, (AP_MD5_CTX *)context); } +void pa_MD5Encode(const unsigned char *password, + const unsigned char *salt, + char *result, size_t nbytes) { ap_MD5Encode(password, salt, result, nbytes); } +void pa_to64(char *s, unsigned long v, int n) { ap_to64(s, v, n); } + + +// signal.h + +void (*pa_signal (int sig, void (*disp)(int)))(int) { + if(sig==PA_SIGPIPE && disp==PA_SIG_IGN) + return signal(SIGPIPE, SIG_IGN); + + return 0; +}