Diff for /parser3/src/targets/cgi/parser3.C between versions 1.78 and 1.97

version 1.78, 2001/05/15 11:36:15 version 1.97, 2001/08/27 13:27:26
Line 4 Line 4
         Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)          Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
   
         $Id$  
 */  */
   static const char *RCSId="$Id$"; 
   
 #include "pa_config_includes.h"  #include "pa_config_includes.h"
   
Line 21 Line 20
 #include "pa_socks.h"  #include "pa_socks.h"
 #include "pa_version.h"  #include "pa_version.h"
   
   //#define DEBUG_POOL_MALLOC
   
   
 /// IIS refuses to read bigger chunks  /// IIS refuses to read bigger chunks
 const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M   const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M 
   
Line 49  static LONG WINAPI TopLevelExceptionFilt Line 51  static LONG WINAPI TopLevelExceptionFilt
 #endif  #endif
   
 // SAPI  // SAPI
 // appends to parser3.log located beside my binary  
   // appends to parser3.log located beside my binary if openable, to stderr otherwize
 void SAPI::log(Pool& pool, const char *fmt, ...) {  void SAPI::log(Pool& pool, const char *fmt, ...) {
         bool opened;          bool opened;
         FILE *f=0;          FILE *f=0;
Line 80  void SAPI::log(Pool& pool, const char *f Line 83  void SAPI::log(Pool& pool, const char *f
   
         if(opened)          if(opened)
                 fclose(f);                  fclose(f);
           else
                   fflush(f);
 }  }
   
 const char *SAPI::get_env(Pool& pool, const char *name) {  const char *SAPI::get_env(Pool& pool, const char *name) {
Line 118  void SAPI::send_body(Pool& pool, const v Line 123  void SAPI::send_body(Pool& pool, const v
         stdout_write(buf, size);          stdout_write(buf, size);
 }  }
   
   //
   
   char *full_file_spec(char *file_name) {
           if(!strchr(file_name, '/')) {
                   static char cwd[MAX_STRING];  getcwd(cwd, MAX_STRING);
                   static char buf[MAX_STRING];
                   snprintf(buf, MAX_STRING, "%s/%s", cwd, file_name);
                   return buf;
           }
           return file_name;
   }
   
 /**  /**
         main workhorse          main workhorse
   
Line 161  int main(int argc, char *argv[]) { Line 178  int main(int argc, char *argv[]) {
 #ifdef WIN32  #ifdef WIN32
         back_slashes_to_slashes(filespec_to_process);          back_slashes_to_slashes(filespec_to_process);
 #endif  #endif
           filespec_to_process=full_file_spec(filespec_to_process);
   
         const char *request_method=getenv("REQUEST_METHOD");          const char *request_method=getenv("REQUEST_METHOD");
         bool header_only=request_method && strcasecmp(request_method, "HEAD")==0;          bool header_only=request_method && strcasecmp(request_method, "HEAD")==0;
Line 266  int main(int argc, char *argv[]) { Line 284  int main(int argc, char *argv[]) {
                                   
                 // beside by binary                  // beside by binary
                 static char site_auto_path[MAX_STRING];                  static char site_auto_path[MAX_STRING];
                 strncpy(site_auto_path, argv[0], MAX_STRING);  // filespec of my binary                  strncpy(site_auto_path, argv0, MAX_STRING);  // filespec of my binary
                 rsplit(site_auto_path, '/');  rsplit(site_auto_path, '\\');// strip filename                  if(!(
                           rsplit(site_auto_path, '/') || 
                           rsplit(site_auto_path, '\\'))) { // strip filename
                           // no path, just filename
                           site_auto_path[0]='.'; site_auto_path[1]=0;
                   }
                                   
                 // process the request                  // process the request
                 request.core(                  request.core(
Line 278  int main(int argc, char *argv[]) { Line 301  int main(int argc, char *argv[]) {
                 //                  //
                 done_socks();                  done_socks();
   
   #ifdef DEBUG_POOL_MALLOC
                 extern void log_pool_stats(Pool& pool);                  extern void log_pool_stats(Pool& pool);
                 log_pool_stats(pool);                  log_pool_stats(pool);
   #endif
   
                 // must be last in PTRY{}PCATCH                  // must be last in PTRY{}PCATCH
 #ifdef WIN32  #ifdef WIN32
                 SetUnhandledExceptionFilter(0);                  SetUnhandledExceptionFilter(0);
 #endif  #endif
                   // 
                   if(!cgi)
                           SAPI::send_body(pool, "\n", 1);
   
                 // successful finish                  // successful finish
                 return 0;                  return 0;
         } PCATCH(e) { // global problem           } PCATCH(e) { // global problem 
Line 316  int main(int argc, char *argv[]) { Line 345  int main(int argc, char *argv[]) {
                 if(!header_only)                  if(!header_only)
                         SAPI::send_body(pool, body, content_length);                          SAPI::send_body(pool, body, content_length);
   
                   // 
                   if(!cgi)
                           SAPI::send_body(pool, "\n", 1);
   
                 // unsuccessful finish                  // unsuccessful finish
                 return 1;                  return 1;
         }          }

Removed from v.1.78  
changed lines
  Added in v.1.97


E-mail: