Index: main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp	(revision 22177)
+++ main/trunk/greenstone2/runtime-src/src/recpt/os_process.cpp	(revision 22183)
@@ -26,5 +26,6 @@
 #include "os_process.h"
 
-osprocess::osprocess(char* cmdline, OSProcessPipeMode mode)
+osprocess::osprocess(OSProcessPipeMode mode,
+		     char* prog_name, char* argv[], char* envp[])
   : mode_(mode)
 {}
@@ -54,22 +55,59 @@
 using namespace std;
 
+
+
 void test_uni_write_pipe()
 {
 #ifdef __WIN32__
-  char* prog_name = "c:\\Windows\\system32\\java.exe";
-  char* cmd_line = "java";
-  
-  //char* input_line = "echo hi there\n";
-  //char* prog_name  = "c:\\cygwin\\bin\\cat.exe";
-  //char* cmd_line   = "cat";
-#else
-  char* cmd_line = "/usr/bin/java";
-  //char* cmd_line = "java";
-#endif
-
-#ifdef __WIN32__
-  osprocesswindows* process = new osprocesswindows(cmd_line,uniRead);
-#else
-  osprocessunix* process = new osprocessunix(cmd_line,uniRead);
+  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
   
@@ -86,7 +124,64 @@
 
 
+  // 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()
@@ -100,5 +195,7 @@
   printf( "  <body>\n");
 
+  test_uni_read_pipe();
   test_uni_write_pipe();
+  test_bi_read_write_pipe();
 
   printf( "  </body>\n");
