--- parser3/src/targets/cgi/parser3.C 2001/12/13 10:37:04 1.147 +++ parser3/src/targets/cgi/parser3.C 2002/02/18 12:45:46 1.159 @@ -1,20 +1,19 @@ /** @file Parser: scripting and CGI main. - Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: parser3.C,v 1.147 2001/12/13 10:37:04 paf Exp $ + $Id: parser3.C,v 1.159 2002/02/18 12:45:46 paf Exp $ */ #include "pa_config_includes.h" -#ifdef WIN32 -# include -#endif - #if _MSC_VER # include +# include +#else +# include "pa_config_paths.h" #endif #include "pa_sapi.h" @@ -25,8 +24,8 @@ #include "pa_version.h" #include "pool_storage.h" -#ifdef XML -#include +#ifdef WIN32 +# include #endif //#define DEBUG_POOL_MALLOC @@ -41,9 +40,6 @@ extern const char *gd_RCSIds[]; extern const char *classes_RCSIds[]; extern const char *types_RCSIds[]; extern const char *parser3_RCSIds[]; -#ifdef XML -extern const char *xalan_patched_RCSIds[]; -#endif const char **RCSIds[]={ main_RCSIds, #ifdef USE_SMTP @@ -53,12 +49,11 @@ const char **RCSIds[]={ classes_RCSIds, types_RCSIds, parser3_RCSIds, -#ifdef XML - xalan_patched_RCSIds, -#endif 0 }; +const char *PARSER_ROOT_CONFIG_ENV_NAME="PARSER_ROOT_CONFIG"; + /// IIS refuses to read bigger chunks const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M @@ -215,17 +210,6 @@ void real_parser_handler( // 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(); -#endif - // init global classes init_methoded_array(pool); // init global variables @@ -311,22 +295,29 @@ void real_parser_handler( true /* status_allowed */); // some root-controlled location -#ifdef SYSCONFDIR - const char *root_config_filespec=SYSCONFDIR "/" CONFIG_FILE_NAME; + const char *root_config_filespec; + if(const char *root_config_by_env=getenv(PARSER_ROOT_CONFIG_ENV_NAME)) + root_config_filespec=root_config_by_env; + else { +#ifdef ROOT_CONFIG_DIR + root_config_filespec=ROOT_CONFIG_DIR "/" CONFIG_FILE_NAME; #else # ifdef WIN32 - // c:\windows - char root_config_path[MAX_STRING]; - GetWindowsDirectory(root_config_path, MAX_STRING); - - char root_config_filespec[MAX_STRING]; - snprintf(root_config_filespec, MAX_STRING, - "%s/%s", - root_config_path, CONFIG_FILE_NAME); + // c:\windows + char windows_dir[MAX_STRING]; + GetWindowsDirectory(windows_dir, MAX_STRING); + + char buf[MAX_STRING]; + snprintf(buf, MAX_STRING, + "%s/%s", + windows_dir, CONFIG_FILE_NAME); + + root_config_filespec=buf; # else #error must be compiled either configure/make or MSVC++ # endif #endif + } // beside by binary // @todo full path, not ./! @@ -417,8 +408,8 @@ int main(int argc, char *argv[]) { if(!cgi) { if(argc<2) { printf( - "Parser/%s Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)\n" - "Author: Alexander Petrosyan (http://paf.design.ru)\n" + "Parser/%s Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)\n" + "Author: Alexandr Petrosian (http://paf.design.ru)\n" "\n" "Usage: %s \n", PARSER_VERSION, @@ -435,6 +426,20 @@ int main(int argc, char *argv[]) { #if _MSC_VER _set_new_handler(failed_new); + +#ifdef _DEBUG + // Get current flag + int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); + + // Turn on leak-checking bit + tmpFlag |= _CRTDBG_LEAK_CHECK_DF; + + // Set flag to the new value + _CrtSetDbgFlag( tmpFlag ); +// _CrtSetBreakAlloc(471); + +#endif + #endif #ifdef HAVE_SET_NEW_HANDLER @@ -472,5 +477,6 @@ int main(int argc, char *argv[]) { if(!cgi) SAPI::send_body(pool, "\n", 1); #endif +//_asm int 3; return 0; }