--- parser3/src/targets/cgi/parser3.C 2001/08/31 15:35:34 1.99 +++ parser3/src/targets/cgi/parser3.C 2001/09/04 15:55:48 1.103 @@ -1,3 +1,4 @@ +//2 /** @file Parser: scripting and CGI main. @@ -5,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ -static const char *RCSId="$Id: parser3.C,v 1.99 2001/08/31 15:35:34 parser Exp $"; +static const char *RCSId="$Id: parser3.C,v 1.103 2001/09/04 15:55:48 parser Exp $"; #include "pa_config_includes.h" @@ -20,12 +21,6 @@ static const char *RCSId="$Id: parser3.C #include "pa_socks.h" #include "pa_version.h" -#ifdef WIN32 -# define EOL "\r\n" -#else -# define EOL "\n" -#endif - //#define DEBUG_POOL_MALLOC @@ -154,12 +149,6 @@ int main(int argc, char *argv[]) { umask(2); -#ifdef WIN32 - setmode(fileno(stdin), _O_BINARY); - setmode(fileno(stdout), _O_BINARY); - setmode(fileno(stderr), _O_BINARY); -#endif - // were we started as CGI? cgi= getenv("SERVER_SOFTWARE") || @@ -170,16 +159,22 @@ int main(int argc, char *argv[]) { if(!cgi) { if(argc<2) { printf( - "Parser/%s Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)"EOL - "Author: Alexander Petrosyan (http://design.ru/paf)"EOL - EOL - "Usage: %s "EOL, + "Parser/%s Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)\n" + "Author: Alexander Petrosyan (http://design.ru/paf)\n" + "\n" + "Usage: %s \n", PARSER_VERSION, argv0?argv0:"parser3"); return 1; } } +#ifdef WIN32 + setmode(fileno(stdin), _O_BINARY); + setmode(fileno(stdout), _O_BINARY); + setmode(fileno(stderr), _O_BINARY); +#endif + char *filespec_to_process=cgi?getenv("PATH_TRANSLATED"):argv[1]; #ifdef WIN32 back_slashes_to_slashes(filespec_to_process); @@ -278,13 +273,16 @@ int main(int argc, char *argv[]) { ); // some root-controlled location -#ifdef WIN32 +#ifdef SYSCONFDIR + const char *root_auto_path=SYSCONFDIR; +#else +# ifdef WIN32 // c:\windows static char root_auto_path[MAX_STRING]; GetWindowsDirectory(root_auto_path, MAX_STRING); -#else - // ~nobody todo: figure out a better place - const char *root_auto_path=SAPI::get_env(pool, "HOME"); +# else + #error must be compiled either configure/make or MSVC++ +# endif #endif // beside by binary @@ -315,9 +313,12 @@ int main(int argc, char *argv[]) { #ifdef WIN32 SetUnhandledExceptionFilter(0); #endif + +#ifndef WIN32 // if(!cgi) - SAPI::send_body(pool, EOL, strlen(EOL)); + SAPI::send_body(pool, "\n", 1); +#endif // successful finish return 0; @@ -350,9 +351,11 @@ int main(int argc, char *argv[]) { if(!header_only) SAPI::send_body(pool, body, content_length); +#ifndef WIN32 // if(!cgi) - SAPI::send_body(pool, EOL, strlen(EOL)); + SAPI::send_body(pool, "\n", 1); +#endif // unsuccessful finish return 1;