--- parser3/src/targets/cgi/parser3.C 2001/11/05 11:46:30 1.128 +++ parser3/src/targets/cgi/parser3.C 2002/01/31 10:20:21 1.151 @@ -4,13 +4,16 @@ Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: parser3.C,v 1.128 2001/11/05 11:46:30 paf Exp $ + $Id: parser3.C,v 1.151 2002/01/31 10:20:21 paf Exp $ */ #include "pa_config_includes.h" -#ifdef WIN32 -# include +#if _MSC_VER +# include +# include +#else +# include "pa_config_paths.h" #endif #include "pa_sapi.h" @@ -21,8 +24,8 @@ #include "pa_version.h" #include "pool_storage.h" -#ifdef XML -#include +#ifdef WIN32 +# include #endif //#define DEBUG_POOL_MALLOC @@ -37,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 @@ -49,9 +49,6 @@ const char **RCSIds[]={ classes_RCSIds, types_RCSIds, parser3_RCSIds, -#ifdef XML - xalan_patched_RCSIds, -#endif 0 }; @@ -110,11 +107,41 @@ void SAPI::log(Pool& , const char *fmt, } void SAPI::die(const char *fmt, ...) { +#ifdef DEBUG_POOL_MALLOC + extern void log_pool_stats(Pool& pool); + log_pool_stats(pool); +#endif + va_list args; va_start(args,fmt); + // log + + // logging is more important than user + // she can cancel download, we'd get SIG_PIPE, + // nothing would be logged then ::log(fmt, args); + + // inform user + + char body[MAX_STRING]; + int content_length=vsnprintf(body, MAX_STRING, fmt, args); + va_end(args); + // prepare header + // let's be honest, that's bad we couldn't produce valid output + SAPI::add_header_attribute(pool, "status", "500"); + SAPI::add_header_attribute(pool, "content-type", "text/plain"); + char content_length_cstr[MAX_NUMBER]; + snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); + SAPI::add_header_attribute(pool, "content-length", content_length_cstr); + + // send header + SAPI::send_header(pool); + + // body + SAPI::send_body(pool, body, content_length); + exit(1); } @@ -127,7 +154,7 @@ size_t SAPI::read_post(Pool& , char *buf do { int chunk_size=read(fileno(stdin), buf+read_size, min(READ_POST_CHUNK_SIZE, max_bytes-read_size)); - if(chunk_size<0) + if(chunk_size<=0) break; read_size+=chunk_size; } while(read_size"); +#endif } @@ -431,5 +468,5 @@ int main(int argc, char *argv[]) { if(!cgi) SAPI::send_body(pool, "\n", 1); #endif - return result; + return 0; }