--- parser3/src/targets/isapi/parser3isapi.C 2001/09/26 11:45:00 1.45 +++ parser3/src/targets/isapi/parser3isapi.C 2001/10/13 17:42:52 1.52 @@ -4,7 +4,7 @@ Copyright (c) 2000,2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3isapi.C,v 1.45 2001/09/26 11:45:00 parser Exp $ + $Id: parser3isapi.C,v 1.52 2001/10/13 17:42:52 parser Exp $ */ #ifndef _MSC_VER @@ -25,27 +25,37 @@ #include "pool_storage.h" #include "pa_socks.h" +#ifdef XML +#include +#endif + #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") // consts extern const char *main_RCSIds[]; -#ifdef SMTP +#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 SMTP +#ifdef USE_SMTP smtp_RCSIds, #endif gd_RCSIds, classes_RCSIds, types_RCSIds, parser3isapi_RCSIds, +#ifdef XML + xalan_patched_RCSIds, +#endif 0 }; @@ -63,6 +73,24 @@ struct SAPI_func_context { }; #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]. void SAPI::log(Pool& pool, const char *fmt, ...) { SAPI_func_context& ctx=*static_cast(pool.context()); @@ -72,8 +100,10 @@ void SAPI::log(Pool& pool, const char *f char buf[MAX_STRING]; const char *prefix="PARSER_ERROR:"; 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, HSE_APPEND_LOG_PARAMETER, buf, &size, 0); } @@ -205,6 +235,18 @@ static bool parser_init() { // init socks 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_methoded_array(pool); // init global variables @@ -251,6 +293,19 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI _asm nop; // int 3; 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; PTRY { // global try ctx.header=new(pool) String(pool); @@ -259,7 +314,7 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI Request::Info request_info; 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); #ifdef WIN32 back_slashes_to_slashes(filespec_to_process); @@ -280,7 +335,7 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI request_info.method=lpECB->lpszMethod; request_info.query_string=lpECB->lpszQueryString; if(lpECB->lpszQueryString && *lpECB->lpszQueryString) { - char *reconstructed_uri=(char *)malloc( + char *reconstructed_uri=(char *)pool.malloc( strlen(lpECB->lpszPathInfo)+1/*'?'*/+ strlen(lpECB->lpszQueryString)+1/*0*/); strcpy(reconstructed_uri, lpECB->lpszPathInfo);