Diff
Not logged in

Differences From:

File src/main.c part of check-in [55342eb9fb] - The bug report generator compiles but still does not work right. by drh on 2008-05-17 14:49:49. [view]

To:

File src/main.c part of check-in [e2e016c31f] - Get the "server" command running under windows. by drh on 2008-05-17 17:43:22. [view]

@@ -73,10 +73,12 @@
   char *zErrMsg;          /* Text of an error message */
   Blob cgiIn;             /* Input to an xfer www method */
   int cgiPanic;           /* Write error messages to CGI */
   Th_Interp *interp;      /* The TH1 interpreter */
-
-  int *aCommitFile;
+  FILE *httpIn;           /* Accept HTTP input from here */
+  FILE *httpOut;          /* Send HTTP output here */
+
+  int *aCommitFile;       /* Array of files to be committed */
 
   int urlIsFile;          /* True if a "file:" url */
   char *urlName;          /* Hostname for http: or filename for file: */
   char *urlHostname;      /* The HOST: parameter on http headers */
@@ -601,8 +603,14 @@
   process_one_web_page();
 }
 
 /*
+** undocumented format:
+**
+**        fossil http REPOSITORY INFILE OUTFILE IPADDR
+**
+** The argv==6 form is used by the win32 server only.
+**
 ** COMMAND: http
 **
 ** Usage: %fossil http REPOSITORY
 **
@@ -611,18 +619,26 @@
 ** handler from inetd, for example.  The argument is the name of the
 ** repository.
 */
 void cmd_http(void){
-  if( g.argc!=2 && g.argc!=3 ){
+  const char *zIpAddr = 0;
+  if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
     cgi_panic("no repository specified");
   }
   g.cgiPanic = 1;
-  if( g.argc==3 ){
+  g.httpIn = stdin;
+  g.httpOut = stdout;
+  if( g.argc>=3 ){
     db_open_repository(g.argv[2]);
+    if( g.argc==6 ){
+      g.httpIn = fopen(g.argv[3], "rb");
+      g.httpOut = fopen(g.argv[4], "wb");
+      zIpAddr = g.argv[5];
+    }
   }else{
     db_must_be_within_tree();
   }
-  cgi_handle_http_request();
+  cgi_handle_http_request(zIpAddr);
   process_one_web_page();
 }
 
 /*
@@ -659,9 +675,15 @@
   if( g.argc==2 ){
     db_must_be_within_tree();
     db_close();
   }
-  cgi_http_server(iPort);
+#ifndef __MINGW32__
+  /* Unix implementation */
+  if( cgi_http_server(iPort) ){
+    fossil_fatal("unable to listen on TCP socket %d", iPort);
+  }
+  g.httpIn = stdin;
+  g.httpOut = stdout;
   if( g.fHttpTrace ){
     fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
   }
   g.cgiPanic = 1;
@@ -669,7 +691,11 @@
     db_must_be_within_tree();
   }else{
     db_open_repository(g.argv[2]);
   }
-  cgi_handle_http_request();
+  cgi_handle_http_request(0);
   process_one_web_page();
+#else
+  /* Win32 implementation */
+  win32_http_server(iPort);
+#endif
 }