|
|
| version 1.41, 2001/09/15 14:22:47 | version 1.52, 2001/10/13 17:42:52 |
|---|---|
| Line 2 | Line 2 |
| Parser: IIS extension. | Parser: IIS extension. |
| Copyright (c) 2000,2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2000,2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) |
| $Id$ | |
| */ | */ |
| static const char *RCSId="$Id$"; | |
| #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)] |
| #endif | #endif |
| #include "pa_config_includes.h" | |
| #include <windows.h> | #include <windows.h> |
| #include <process.h> | #include <process.h> |
| Line 23 static const char *RCSId="$Id$"; | Line 25 static const char *RCSId="$Id$"; |
| #include "pool_storage.h" | #include "pool_storage.h" |
| #include "pa_socks.h" | #include "pa_socks.h" |
| #ifdef XML | |
| #include <XalanTransformer/XalanCAPI.h> | |
| #endif | |
| #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") | #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") |
| // consts | |
| extern const char *main_RCSIds[]; | |
| #ifdef USE_SMTP | |
| extern const char *smtp_RCSIds[]; | |
| #endif | |
| extern const char *gd_RCSIds[]; | |
| extern const char *classes_RCSIds[]; | |
| extern const char *types_RCSIds[]; | |
| extern const char *parser3isapi_RCSIds[]; | |
| #ifdef XML | |
| extern const char *xalan_patched_RCSIds[]; | |
| #endif | |
| const char **RCSIds[]={ | |
| main_RCSIds, | |
| #ifdef USE_SMTP | |
| smtp_RCSIds, | |
| #endif | |
| gd_RCSIds, | |
| classes_RCSIds, | |
| types_RCSIds, | |
| parser3isapi_RCSIds, | |
| #ifdef XML | |
| xalan_patched_RCSIds, | |
| #endif | |
| 0 | |
| }; | |
| // SAPI | // SAPI |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| Line 39 struct SAPI_func_context { | Line 73 struct SAPI_func_context { |
| }; | }; |
| #endif | #endif |
| #ifdef XML | |
| /** | |
| * Terminate Xalan and Xerces. | |
| * | |
| * Should be called only once per process after deleting all | |
| * instances of XalanTransformer. Once a process has called | |
| * this function, it cannot use the API for the remaining | |
| * lifetime of the process. | |
| this requirement is fullfilled by using Pool::register_cleanup | |
| */ | |
| void callXalanTerminate(void *) { | |
| //_asm int 3; | |
| XalanTerminate(); | |
| } | |
| #endif | |
| // goes to 'cs-uri-query' log file field. webmaster: switch it ON[default OFF]. | // goes to 'cs-uri-query' log file field. webmaster: switch it ON[default OFF]. |
| void SAPI::log(Pool& pool, const char *fmt, ...) { | void SAPI::log(Pool& pool, const char *fmt, ...) { |
| SAPI_func_context& ctx=*static_cast<SAPI_func_context *>(pool.context()); | SAPI_func_context& ctx=*static_cast<SAPI_func_context *>(pool.context()); |
| Line 48 void SAPI::log(Pool& pool, const char *f | Line 100 void SAPI::log(Pool& pool, const char *f |
| char buf[MAX_STRING]; | char buf[MAX_STRING]; |
| const char *prefix="PARSER_ERROR:"; | const char *prefix="PARSER_ERROR:"; |
| strcpy(buf, prefix); | strcpy(buf, prefix); |
| DWORD size=vsnprintf(buf+strlen(prefix), MAX_STRING-strlen(prefix), fmt, args); | char *start=buf+strlen(prefix); |
| DWORD size=vsnprintf(start, MAX_STRING-strlen(prefix), fmt, args); | |
| remove_crlf(start, start+size); | |
| ctx.lpECB->ServerSupportFunction(ctx.lpECB->ConnID, | ctx.lpECB->ServerSupportFunction(ctx.lpECB->ConnID, |
| HSE_APPEND_LOG_PARAMETER, buf, &size, 0); | HSE_APPEND_LOG_PARAMETER, buf, &size, 0); |
| } | } |
| Line 181 static bool parser_init() { | Line 235 static bool parser_init() { |
| // init socks | // init socks |
| init_socks(pool); | init_socks(pool); |
| #ifdef XML | |
| /** | |
| * Initialize Xerces and Xalan. | |
| * | |
| * Should be called only once per process before making | |
| * any other API calls. | |
| */ | |
| //_asm int 3; | |
| XalanInitialize(); | |
| pool.register_cleanup(callXalanTerminate, 0); | |
| #endif | |
| // init global classes | // init global classes |
| init_methoded_array(pool); | init_methoded_array(pool); |
| // init global variables | // init global variables |
| Line 227 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 293 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| _asm nop; // int 3; | _asm nop; // int 3; |
| pool.set_context(&ctx);// no allocations before this line! | pool.set_context(&ctx);// no allocations before this line! |
| #ifdef XML | |
| /** | |
| * Initialize Xerces and Xalan. | |
| * | |
| * Should be called only once per process before making | |
| * any other API calls. | |
| */ | |
| //_asm int 3; | |
| XalanInitialize(); | |
| pool.register_cleanup(callXalanTerminate, 0); | |
| #endif | |
| bool header_only=strcasecmp(lpECB->lpszMethod, "HEAD")==0; | bool header_only=strcasecmp(lpECB->lpszMethod, "HEAD")==0; |
| PTRY { // global try | PTRY { // global try |
| ctx.header=new(pool) String(pool); | ctx.header=new(pool) String(pool); |
| Line 235 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 314 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| Request::Info request_info; | Request::Info request_info; |
| size_t path_translated_buf_size=strlen(lpECB->lpszPathTranslated)+1; | size_t path_translated_buf_size=strlen(lpECB->lpszPathTranslated)+1; |
| char *filespec_to_process=(char *)malloc(path_translated_buf_size); | char *filespec_to_process=(char *)pool.malloc(path_translated_buf_size); |
| memcpy(filespec_to_process, lpECB->lpszPathTranslated, path_translated_buf_size); | memcpy(filespec_to_process, lpECB->lpszPathTranslated, path_translated_buf_size); |
| #ifdef WIN32 | #ifdef WIN32 |
| back_slashes_to_slashes(filespec_to_process); | back_slashes_to_slashes(filespec_to_process); |
| Line 256 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 335 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| request_info.method=lpECB->lpszMethod; | request_info.method=lpECB->lpszMethod; |
| request_info.query_string=lpECB->lpszQueryString; | request_info.query_string=lpECB->lpszQueryString; |
| if(lpECB->lpszQueryString && *lpECB->lpszQueryString) { | if(lpECB->lpszQueryString && *lpECB->lpszQueryString) { |
| char *reconstructed_uri=(char *)malloc( | char *reconstructed_uri=(char *)pool.malloc( |
| strlen(lpECB->lpszPathInfo)+1/*'?'*/+ | strlen(lpECB->lpszPathInfo)+1/*'?'*/+ |
| strlen(lpECB->lpszQueryString)+1/*0*/); | strlen(lpECB->lpszQueryString)+1/*0*/); |
| strcpy(reconstructed_uri, lpECB->lpszPathInfo); | strcpy(reconstructed_uri, lpECB->lpszPathInfo); |
| Line 280 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 359 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| // some root-controlled location | // some root-controlled location |
| // c:\windows | // c:\windows |
| char root_config_path[MAX_STRING]; | |
| GetWindowsDirectory(root_config_path, MAX_STRING); | |
| // must be dynamic: rethrowing from request.core | // must be dynamic: rethrowing from request.core |
| // may return 'source' which can be inside of 'root auto.p@exeception' | // may return 'source' which can be inside of 'root auto.p@exeception' |
| char *root_auto_path=(char *)pool.malloc(MAX_STRING); | char *root_config_filespec=(char *)pool.malloc(MAX_STRING); |
| GetWindowsDirectory(root_auto_path, MAX_STRING); | snprintf(root_config_filespec, MAX_STRING, |
| "%s/%s", | |
| root_config_path, CONFIG_FILE_NAME); | |
| // process the request | // process the request |
| request.core( | request.core( |
| root_auto_path, false/*may be abcent*/, // /path/to/admin/auto.p | root_config_filespec, false/*may be abcent*/, // /path/to/admin/auto.p |
| 0/*parser_site_auto_path*/, false, // /path/to/site/auto.p | 0/*parser_site_auto_path*/, false, // /path/to/site/auto.p |
| header_only); | header_only); |
| // successful finish | // successful finish |