|
|
| version 1.83, 2003/07/24 11:31:25 | version 1.89, 2004/04/01 11:43:54 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: IIS extension. | Parser: IIS extension. |
| Copyright (c) 2000,2001-2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2000,2001-2004 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| static const char* IDENT_PARSER3ISAPI_C="$Date$"; | static const char * const IDENT_PARSER3ISAPI_C="$Date$"; |
| #ifndef _MSC_VER | #ifndef _MSC_VER |
| # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] | # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] |
| Line 81 void SAPI::log(SAPI_Info& SAPI_info, con | Line 81 void SAPI::log(SAPI_Info& SAPI_info, con |
| } | } |
| /// @todo event log | /// @todo event log |
| static void die_or_abort(const char* fmt, va_list args, bool write_core) { | static void abort(const char* fmt, va_list args) { |
| if(FILE *log=fopen("c:\\parser3die.log", "at")) { | if(FILE *log=fopen("c:\\parser3die.log", "at")) { |
| vfprintf(log, fmt, args); | vfprintf(log, fmt, args); |
| fclose(log); | fclose(log); |
| Line 92 static void die_or_abort(const char* fmt | Line 92 static void die_or_abort(const char* fmt |
| void SAPI::die(const char* fmt, ...) { | void SAPI::die(const char* fmt, ...) { |
| va_list args; | va_list args; |
| va_start(args, fmt); | va_start(args, fmt); |
| die_or_abort(fmt, args, false/*write core?*/); | ::abort(fmt, args); |
| va_end(args); | va_end(args); |
| } | } |
| void SAPI::abort(const char* fmt, ...) { | void SAPI::abort(const char* fmt, ...) { |
| va_list args; | va_list args; |
| va_start(args, fmt); | va_start(args, fmt); |
| die_or_abort(fmt, args, true/*write core?*/); | ::abort(fmt, args); |
| va_end(args); | va_end(args); |
| } | } |
| Line 258 static bool parser_init() { | Line 258 static bool parser_init() { |
| try { | try { |
| // init socks | // init socks |
| pa_init_socks(); | pa_socks_init(); |
| // init global variables | // init global variables |
| pa_globals_init(); | pa_globals_init(); |
| // successful finish | // successful finish |
| return true; | return true; |
| } catch(const Exception& e) { // global problem | } catch(const Exception& e) { // global problem |
| const char* body=e.comment(); | //const char* body=e.comment(); |
| // unsuccessful finish | // unsuccessful finish |
| return false; | return false; |
| } | } |
| } | } |
| static void parser_done() { | |
| // finalize global variables | |
| pa_globals_done(); | |
| // | |
| pa_socks_done(); | |
| } | |
| /// ISAPI // | /// ISAPI // |
| BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) { | BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) { |
| pVer->dwExtensionVersion = HSE_VERSION; | pVer->dwExtensionVersion = HSE_VERSION; |
| Line 279 BOOL WINAPI GetExtensionVersion(HSE_VERS | Line 287 BOOL WINAPI GetExtensionVersion(HSE_VERS |
| pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1]=0; | pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1]=0; |
| return parser_init(); | return parser_init(); |
| } | } |
| // dwFlags & HSE_TERM_MUST_UNLOAD means we can't return false | |
| BOOL WINAPI TerminateExtension( | |
| DWORD /*dwFlags*/ | |
| ) | |
| { | |
| parser_done(); | |
| return TRUE; | |
| } | |
| /** | /** |
| ISAPI // main workhorse | ISAPI // main workhorse |
| Line 293 BOOL WINAPI GetExtensionVersion(HSE_VERS | Line 310 BOOL WINAPI GetExtensionVersion(HSE_VERS |
| */ | */ |
| void real_parser_handler(SAPI_Info& SAPI_info, bool header_only) { | void real_parser_handler(SAPI_Info& SAPI_info, bool header_only) { |
| // collect garbage from prev request | |
| #ifndef PA_DEBUG_DISABLE_GC | |
| { | |
| int saved=GC_dont_gc; | |
| GC_dont_gc=0; | |
| GC_gcollect(); | |
| GC_dont_gc=saved; | |
| } | |
| #endif | |
| SAPI_info.header=new String; | SAPI_info.header=new String; |
| LPEXTENSION_CONTROL_BLOCK lpECB=SAPI_info.lpECB; | LPEXTENSION_CONTROL_BLOCK lpECB=SAPI_info.lpECB; |
| Line 414 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 441 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| char header_buf[MAX_STRING]; | char header_buf[MAX_STRING]; |
| int header_len=snprintf(header_buf, MAX_STRING, | int header_len=snprintf(header_buf, MAX_STRING, |
| "content-type: text/plain\r\n" | "content-type: text/plain\r\n" |
| "content-length: %lu\r\n" | "content-length: %u\r\n" |
| // "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n" | // "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n" |
| "\r\n", | "\r\n", |
| content_length); | content_length); |
| Line 447 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 474 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| char header_buf[MAX_STRING]; | char header_buf[MAX_STRING]; |
| int header_len=snprintf(header_buf, MAX_STRING, | int header_len=snprintf(header_buf, MAX_STRING, |
| "content-type: text/plain\r\n" | "content-type: text/plain\r\n" |
| "content-length: %lu\r\n" | "content-length: %u\r\n" |
| "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n" | "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n" |
| "\r\n", | "\r\n", |
| content_length); | content_length); |
| Line 473 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 500 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| BOOL WINAPI DllMain( | BOOL WINAPI DllMain( |
| HINSTANCE hinstDLL, // handle to the DLL module | HINSTANCE hinstDLL, // handle to the DLL module |
| DWORD fdwReason, // reason for calling function | DWORD /*fdwReason*/, // reason for calling function |
| LPVOID lpvReserved // reserved | LPVOID /*lpvReserved*/ // reserved |
| ) { | ) { |
| GetModuleFileName( | GetModuleFileName( |