Diff for /parser3/src/targets/cgi/parser3.C between versions 1.3 and 1.4

version 1.3, 2001/03/13 18:32:48 version 1.4, 2001/03/13 19:35:07
Line 13 Line 13
 #       include <io.h>  #       include <io.h>
 #endif  #endif
 #include <stdlib.h>  #include <stdlib.h>
   #include <stdio.h>
   #include <string.h>
   #include <fcntl.h>
   
 #include "core.h"  #include "core.h"
 #include "pa_request.h"  #include "pa_request.h"
Line 25 Line 28
 int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
 #ifdef WIN32  #ifdef WIN32
         _fmode=_O_BINARY;                       /*sets default for file streams to binary */          _fmode=_O_BINARY;                       /*sets default for file streams to binary */
         setmode(_fileno(stdin), O_BINARY);              /* make the stdio mode be binary */          setmode(_fileno(stdin), _O_BINARY);             /* make the stdio mode be binary */
         setmode(_fileno(stdout), O_BINARY);             /* make the stdio mode be binary */          setmode(_fileno(stdout), _O_BINARY);            /* make the stdio mode be binary */
         setmode(_fileno(stderr), O_BINARY);             /* make the stdio mode be binary */          setmode(_fileno(stderr), _O_BINARY);            /* make the stdio mode be binary */
   
         //TODO: SetUnhandledExceptionFilter(&TopLevelExceptionFilter);          //TODO: SetUnhandledExceptionFilter(&TopLevelExceptionFilter);
         //TODO: initSocks();          //TODO: initSocks();
Line 55  int main(int argc, char *argv[]) { Line 58  int main(int argc, char *argv[]) {
                 page_filespec                  page_filespec
                 );                  );
                   
         bool error;  
         // some root-controlled location          // some root-controlled location
         char *sys_auto_path1;          char *sys_auto_path1;
 #ifdef WIN32  #ifdef WIN32
         sys_auto_path1=(char *)pool.malloc(MAX_STRING);          sys_auto_path1=(char *)pool.malloc(MAX_STRING);
         GetWindowsDirectory(sys_auto_path1, MAX_STRING-1/*for \*/);          GetWindowsDirectory(sys_auto_path1, MAX_STRING-1/*for \*/);
         strcat(sys_auto_path1, '\\');          strcat(sys_auto_path1, "\\");
 #else  #else
         sys_auto_path1=getenv("HOME");          sys_auto_path1=getenv("HOME");
 #endif  #endif
                   
         // beside by binary          // beside by binary
         const char *sys_auto_path2=(char *)pool.malloc(MAX_STRING);          char *sys_auto_path2=(char *)pool.malloc(MAX_STRING);
         strncpy(sys_auto_path2, argv[0]);  // filespec of my binary          strncpy(sys_auto_path2, argv[0], MAX_STRING-20);  // filespec of my binary
         rsplit(sys_auto_path2, '\\');  rsplit(sys_auto_path2, '/'); // strip filename          rsplit(sys_auto_path2, '\\');  rsplit(sys_auto_path2, '/'); // strip filename
                   
         char *result=request.core(          char *result=request.core(
                 sys_auto_path1,                   sys_auto_path1, 
                 sys_auto_path2);                  sys_auto_path2);
                   
           const char *error="nested exception";
         if(cgi) {          if(cgi) {
                 const char *content_type="text/html";                  if(result) {
                 printf(                          const char *content_type="text/html";
                         "Content-type: %s\n"                          printf(
                         "Content-length: %d\n"                                  "Content-type: %s\n"
                         "\n",                                   "Content-length: %d\n"
                                   "\n", 
                                 content_type,                                  content_type,
                                 strlen(result));                                  strlen(result));
                 stdout_write(result);                          stdout_write(result);
                   } else {
                           printf(
                                   "Content-type: text/plain\n"
                                   "Content-length: %d\n"
                                   "\n", 
                                   strlen(error));
                           stdout_write(error);
                   }
         } else          } else
                 printf("%s", result);                  if(result)
                           printf("%s", result);
                   else
                           fputs(error, stderr);
   
         return 0;          return 0;
 }  }

Removed from v.1.3  
changed lines
  Added in v.1.4


E-mail: