Index: main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp	(revision 22187)
+++ main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp	(revision 22188)
@@ -46,163 +46,2 @@
 
 
-
-
-#if 0
-
-#include "os_process_windows.h"
-#include "os_process_unix.h"
-#include <iostream>
-using namespace std;
-
-
-
-void test_uni_write_pipe()
-{
-#ifdef __WIN32__
-  char* prog_name = "type";
-  char* argv[] = { "type", NULL } ;
-  
-#else
-  char* prog_name = "tr";
-  char* argv[] = { "tr", "[A-Z]", "[a-z]", NULL };
-#endif
-
-  cout << "<hr>" << endl;
-  cout << "<p>Unidirectional Write Test" << endl;
-  cout << "<p>  Converts uppercase letters to lowercase" << endl;
-  cout << "<p>  These are then sent to whereever the stdout of the child process goes" << endl;
-  cout << "<p>" << endl;
-
-#ifdef __WIN32__
-  osprocesswindows* process = new osprocesswindows(uniWrite,prog_name,argv);
-#else
-  osprocessunix* process = new osprocessunix(uniWrite,prog_name,argv);
-#endif
-  
-  char* buffer = "TESTING uniWirite IN CAP\nTesting uniWrite in Mixed Case\n";
-  int buffer_len = strlen(buffer);
-
-  if (!process->write(buffer,buffer_len)) {
-    cerr << "Error: failed to write to child process\n";
-  }
-
-  process->close();
-
-  process->wait();
-
-  delete process;
-}
-
-
-void test_uni_read_pipe()
-{
-  char* prog_name = "java";
-  char* argv[] = { "java", NULL };
-
-  cout << "<hr>" << endl;
-  cout << "<p>Unidirectional Read Test" << endl;
-  cout << "<p>  The output of 'java' is read in by this process and then sent to stdout" << endl;
-  cout << "<p>" << endl;
-
-
-#ifdef __WIN32__
-  osprocess* process = new osprocesswindows(uniRead,prog_name,argv);
-#else
-  osprocess* process = new osprocessunix(uniRead,prog_name,argv);
-#endif
-  
-  const int BufferSize = 1024;
-  char buffer[BufferSize];
-
-  int bytes_read = 0;
-  do {
-    bytes_read = process->read(buffer,BufferSize);
-    if (bytes_read>0) {
-      fwrite(buffer,1,bytes_read,stdout);
-    }
-  } while (bytes_read==BufferSize);
-
-
-  // deleting object will also have the effect of closing any open handles
-  delete process;
-
-}
-
-
-
-void test_bi_read_write_pipe()
-{
-#ifdef __WIN32__
-  char* prog_name = "type";
-  char* argv[] = NULL ;
-  
-#else
-  char* prog_name = "tr";
-  char* argv[] = { "tr", "[A-Z]", "[a-z]", NULL };
-#endif
-
-  // Converts uppercase letters to lowercase
-  // Answer is read back and then printed to STDOUT by this process
-
-  cout << "<hr>" << endl;
-  cout << "<p>Bidirectional Read/Write Test" << endl;
-  cout << "<p>  Converts uppercase letters to lowercase" << endl;
-  cout << "<p>  Data is sent to child process down pipe by this process" << endl;
-  cout << "<p>  Answer is read back from child process and printed to stdout" << endl;
-  cout << "<p>" << endl;
-
-#ifdef __WIN32__
-  osprocesswindows* process = new osprocesswindows(biReadWrite,prog_name,argv);
-#else
-  osprocessunix* process = new osprocessunix(biReadWrite,prog_name,argv);
-#endif
-  
-  char* write_buffer = "TESTING biReadWrite IN CAP\nTesting biReadWrite in Mixed Case\n";
-  int write_buffer_len = strlen(write_buffer);
-
-  if (!process->write(write_buffer,write_buffer_len)) {
-    cerr << "Error: failed to write to child process\n";
-  }
-
-  const int BufferSize = 1024;
-  char read_buffer[BufferSize];
-  process->close_write_pipe();
-
-  int bytes_read = 0;
-  do {
-    bytes_read = process->read(read_buffer,BufferSize);
-    if (bytes_read>0) {
-      fwrite(read_buffer,1,bytes_read,stdout);
-    }
-  } while (bytes_read==BufferSize);
-
-
-  process->close();
-
-  delete process;
-
-}
-
-
-int main()
-{
-  printf("Content-type: text/html\n\n");
-  
-  printf( "<html>\n");
-  printf( "  <head>\n");
-  printf( "    <title>Testing</title>\n");
-  printf( "  </head>\n");
-  printf( "  <body>\n");
-
-  test_uni_read_pipe();
-  test_uni_write_pipe();
-  test_bi_read_write_pipe();
-
-  printf( "  </body>\n");
-  printf( "</html>\n");
-  
-  return 0;
-}
-
-#endif
-
Index: main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.cpp	(revision 22187)
+++ main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.cpp	(revision 22188)
@@ -37,14 +37,10 @@
 #endif
 
+#include "text_t.h"
 #include "os_process_windows.h"
 
-//#include <stdio.h>
-
-osprocesswindows::osprocesswindows(char* cmdline)
-  : osprocess(cmdline)
-{}
 
 osprocesswindows::osprocesswindows(OSProcessPipeMode mode,
-				   char* prog_name, char* argv[]=NULL, 
+				   char* prog_name, char* argv[], 
 				   char* envp[])
   : child_stdout_read_(NULL), child_stdin_write_(NULL),
@@ -91,25 +87,40 @@
   
   si.dwFlags |= STARTF_USESTDHANDLES;
-  
-  // any error messages in child process to to same place as parent process
+
+  
+  // any error messages in the child process goes to same place as parent
   // e.g. in the case of running as a CGI script, the Web server error log
   si.hStdError  = GetStdHandle(STD_ERROR_HANDLE); 
   
-  // Output from the child process comes to the parent process, down the
-  // OUT pipe
-  si.hStdOutput = child_stdout_write;
-  
-  // Input to the child process can be sent from the parent process, down the
-  // In pipe
-  si.hStdInput = child_stdin_read;
-  
-  text_t cmd_line = "";
+  if ((mode==uniRead) || (mode==biReadWrite)) {
+    // Output from the child process comes to the parent process, down the
+    // OUT pipe
+    si.hStdOutput = child_stdout_write;
+  }
+  else {
+    // uniWrite
+    // Output from the chlid process goes to the same place as parent
+    si.hStdOutput  = GetStdHandle(STD_OUTPUT_HANDLE); 
+  }
+  
+  if ((mode==uniWrite) || (mode==biReadWrite)) {
+    // Input to the child process can be sent from the parent process, down the
+    // In pipe
+    si.hStdInput = child_stdin_read;
+  }
+  else {
+    // uniRead
+
+    // Input to the child process comes from same place as parent ?!?
+    si.hStdInput  = GetStdHandle(STD_INPUT_HANDLE); 
+  }
+  
+  text_t cmd_line = prog_name;
   if (argv != NULL) {
-    int i=0;
+    int i=1;
     while (argv[i] != NULL) {
-      if (i>0) {
-	cmd_line += " ";
-      }
-      cmd_line += "\"" + argv[i] + "\"";
+      cmd_line += " \"";
+      cmd_line += argv[i];
+      cmd_line += "\"";
       i++;
     }
@@ -162,5 +173,5 @@
 
 
-int osprocesswindows::write(const char* buffer, const int buffer_len) 
+int osprocesswindows::write(char* buffer, const int buffer_len) 
 { 
   DWORD actual_write_len;
@@ -195,9 +206,9 @@
 
   
-bool osprocessunix::close_write_pipe(OSProcessWarnStatus warn_status)
+bool osprocesswindows::close_write_pipe(OSProcessWarnStatus warn_status)
 {
   bool write_close_ok = true;
 
-  if (child_stdout_read_ != NULL) {
+  if (child_stdin_write_ != NULL) {
 
     write_close_ok = CloseHandle(child_stdin_write_);
@@ -211,5 +222,5 @@
     }
   }
-  else if (warning_status == withWarning) {
+  else if (warn_status == withWarning) {
     cerr << "osprocesswindows::close_write_pipe(): Warning - Tried to close already closed pipe" << endl;
   }
@@ -219,5 +230,5 @@
 
 
-bool osprocessunix::close_read_pipe(OSProcessWarnStatus warn_status)
+bool osprocesswindows::close_read_pipe(OSProcessWarnStatus warn_status)
 {
   bool read_close_ok = true;
Index: main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.h
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.h	(revision 22187)
+++ main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.h	(revision 22188)
@@ -43,10 +43,10 @@
 
   virtual int read(char* buffer, const int buffer_len);
-  virtual int write(const char* buffer, const int buffer_len);
+  virtual int write(char* buffer, const int buffer_len);
 
   virtual void wait();
 
-  virtual bool close_write_pipe(OSProcessWarnStatus warn_status);
-  virtual bool close_read_pipe(OSProcessWarnStatus warn_status);
+  virtual bool close_write_pipe(OSProcessWarnStatus warn_status=withWarning);
+  virtual bool close_read_pipe(OSProcessWarnStatus warn_status=withWarning);
 
 protected:
Index: main/trunk/greenstone2/runtime-src/src/recpt/win32.mak
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/win32.mak	(revision 22187)
+++ main/trunk/greenstone2/runtime-src/src/recpt/win32.mak	(revision 22188)
@@ -186,4 +186,12 @@
 .cpp.obj:
 	$(COMPILE) $< 
+
+OSPROCESS_SOURCES = \
+	os_process.cpp \
+	os_process_windows.cpp \
+
+OSPROCESS_OBJECTS = \
+	os_process.obj \
+	os_process_windows.obj \
 
 
@@ -218,4 +226,5 @@
 	librarymain.cpp \
 	maincfg.cpp \
+	$(OSPROCESS_SOURCES) \
 	pageaction.cpp \
 	pagedbrowserclass.cpp \
@@ -265,4 +274,5 @@
 	librarymain.obj \
 	maincfg.obj \
+	$(OSPROCESS_OBJECTS) \
 	pageaction.obj \
 	pagedbrowserclass.obj \
@@ -312,4 +322,7 @@
 	$(LINK) $(EXECUTABLE_OBJECTS) $(LIBS)
 
+osprocess-test.cgi: $(OSPROCESS_OBJECTS) os_process_test.obj
+	$(LINK) $(OSPROCESS_OBJECTS) os_process_test.obj ..\..\..\common-src\src\lib\gsdllib.lib
+
 !IF $(LOCAL_LIBRARY)
 install:
