--- parser3/src/targets/cgi/parser3.C 2001/04/09 14:02:05 1.60 +++ parser3/src/targets/cgi/parser3.C 2001/04/17 19:00:59 1.64 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3.C,v 1.60 2001/04/09 14:02:05 paf Exp $ + $Id: parser3.C,v 1.64 2001/04/17 19:00:59 paf Exp $ */ #include "pa_config_includes.h" @@ -14,18 +14,11 @@ # include #endif -#include -#include -#include -#include -#include - #include "pa_sapi.h" #include "pa_common.h" #include "pa_globals.h" #include "pa_request.h" #include "pa_socks.h" -#include "pa_exec.h" /// IIS refuses to read bigger chunks const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M @@ -55,6 +48,39 @@ static LONG WINAPI TopLevelExceptionFilt #endif // SAPI +// appends to parser3.log located beside my binary +void SAPI::log(Pool& pool, const char *fmt, ...) { + bool opened; + FILE *f=0; + + if(argv0) { + // beside by binary + char file_spec[MAX_STRING]; + strncpy(file_spec, argv0, MAX_STRING); // filespec of my binary + rsplit(file_spec, '/'); rsplit(file_spec, '\\');// strip filename + strcat(file_spec, "/parser3.log"); + f=fopen(file_spec, "at"); + } + opened=f!=0; + if(!opened) + f=stderr; + + // prefix + time_t t=time(0); + const char *stamp=ctime(&t); + fprintf(f, "[%.*s] ", strlen(stamp)-1, stamp); + // message + va_list args; + va_start(args,fmt); + vfprintf(f, fmt, args); + va_end(args); + // newline + fprintf(f, "\n"); + + if(opened) + fclose(f); +} + const char *SAPI::get_env(Pool& pool, const char *name) { return getenv(name); } @@ -91,46 +117,6 @@ void SAPI::send_body(Pool& pool, const v stdout_write(buf, size); } -// appends to parser3.log located beside my binary -void SAPI::log(Pool& pool, const char *fmt, ...) { - bool opened; - FILE *f=0; - - if(argv0) { - // beside by binary - char file_spec[MAX_STRING]; - strncpy(file_spec, argv0, MAX_STRING); // filespec of my binary - rsplit(file_spec, '/'); rsplit(file_spec, '\\');// strip filename - strcat(file_spec, "/parser3.log"); - f=fopen(file_spec, "at"); - } - opened=f!=0; - if(!opened) - f=stderr; - - // prefix - time_t t=time(0); - const char *stamp=ctime(&t); - fprintf(f, "[%.*s] ", strlen(stamp)-1, stamp); - // message - va_list args; - va_start(args,fmt); - vfprintf(f, fmt, args); - va_end(args); - // newline - fprintf(f, "\n"); - - if(opened) - fclose(f); -} - -int SAPI::execute(const String& file_spec, - const Hash *env, - const Array *argv, - const String& in, String& out, String& err) { - return pa_exec(file_spec, env, argv, in, out, err); -} - /** main workhorse @@ -175,10 +161,9 @@ int main(int argc, char *argv[]) { // must be first in PTRY{}PCATCH #ifdef WIN32 SetUnhandledExceptionFilter(&TopLevelExceptionFilter); - //TODO: initSocks(); #endif - // + // init socks init_socks(pool); // init global variables @@ -245,7 +230,7 @@ int main(int argc, char *argv[]) { // prepare to process request Request request(pool, request_info, - 1||cgi ? String::UL_HTML_TYPO : String::UL_CLEAN + 1||cgi ? String::UL_HTML_TYPO : String::UL_AS_IS ); // some root-controlled location @@ -255,7 +240,7 @@ int main(int argc, char *argv[]) { GetWindowsDirectory(root_auto_path, MAX_STRING); #else // ~nobody todo: figure out a better place - char *root_auto_path=SAPI::get_env(pool, "HOME"); + const char *root_auto_path=SAPI::get_env(pool, "HOME"); #endif // beside by binary