--- parser3/src/targets/cgi/parser3.C 2001/03/18 14:45:30 1.19 +++ parser3/src/targets/cgi/parser3.C 2001/03/19 19:17:45 1.25 @@ -3,7 +3,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3.C,v 1.19 2001/03/18 14:45:30 paf Exp $ + $Id: parser3.C,v 1.25 2001/03/19 19:17:45 paf Exp $ */ #ifdef HAVE_CONFIG_H @@ -20,11 +20,12 @@ #include #include +#include "pa_common.h" #include "pa_globals.h" #include "pa_request.h" -#include "pa_common.h" Pool pool; // global pool +bool cgi; #ifdef WIN32 # if _MSC_VER @@ -71,18 +72,21 @@ int read_post(char *buf, int max_bytes) } void output_header_attribute(const char *key, const char *value) { - printf("%s: %s\n", key, value); + if(cgi) + printf("%s: %s\n", key, value); } void output_body(const char *buf, size_t size) { - puts(""); // header | body delimiter + if(cgi) // header | body delimiter + puts(""); + stdout_write(buf, size); } // main int main(int argc, char *argv[]) { - //TODO: umask(2); + // TODO:umask(2); #ifdef WIN32 _setmode(fileno(stdin), _O_BINARY); _setmode(fileno(stdout), _O_BINARY); @@ -95,7 +99,7 @@ int main(int argc, char *argv[]) { service_funcs.output_body=output_body; // were we started as CGI? - bool cgi= + cgi= getenv("SERVER_SOFTWARE") || getenv("SERVER_NAME") || getenv("GATEWAY_INTERFACE") || @@ -146,11 +150,12 @@ int main(int argc, char *argv[]) { request_info.content_type=getenv("CONTENT_TYPE"); const char *content_length=getenv("CONTENT_LENGTH"); request_info.content_length=(content_length?atoi(content_length):0); + request_info.cookie=getenv("HTTP_COOKIE"); // prepare to process request Request request(Pool(), request_info, - 1||cgi ? String::Untaint_lang::HTML_TYPO : String::Untaint_lang::NO + cgi ? String::Untaint_lang::HTML_TYPO : String::Untaint_lang::NO ); // some root-controlled location @@ -179,20 +184,15 @@ int main(int argc, char *argv[]) { // request.exception not not handled here, but all // request' data are associated with it's pool=exception - // must be last in PTRY{}PCATCH + // must be last in PTRY{}PCATCH #ifdef WIN32 # if _MSC_VER SetUnhandledExceptionFilter(0); # endif +#endif // successful finish return 0; -#endif } PCATCH(e) { // global problem - // @globals fill - // @Request create - // @prepare to .core() - // @request.core when reporting request exception - // @write result const char *body=e.comment(); int content_length=strlen(body);