Index: /trunk/gsdl/src/recpt/collectoraction.cpp
===================================================================
--- /trunk/gsdl/src/recpt/collectoraction.cpp	(revision 3006)
+++ /trunk/gsdl/src/recpt/collectoraction.cpp	(revision 3007)
@@ -45,4 +45,6 @@
 #include "argdb.h"
 #include "cgiutils.h"
+#include <stdio.h>
+#include <fcntl.h>
 
 #if !defined (__WIN32__)
@@ -581,17 +583,17 @@
     
     // now write cfg file back out
-#ifdef __WIN32__
-    ofstream cfg_out (cfgfilec, ios::binary);
-#else
-    ofstream cfg_out (cfgfilec);
+    int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC
+#if defined(__WIN32__)
+		| O_BINARY
 #endif
-    if (cfg_out) {
+		);
+
+    if (fd != -1) {
       // lock the file
-      int fd = GSDL_GET_FILEDESC(cfg_out);
       int lock_val = 1;
       GSDL_LOCK_FILE (fd);
       if (lock_val != 0) {
 	logout << "Error: Couldn't lock file " << cfgfilec << "\n";
-	cfg_out.close();
+	close(fd);
 	message = "tmpfail";
 	
@@ -601,9 +603,9 @@
 	vector<text_tarray>::const_iterator end_line = cfgarray.end();
 	while (this_line != end_line) {
-	  write_cfg_line (cfg_out, *this_line);
+	  write_cfg_line (fd, *this_line);
 	  this_line ++;
 	}
 	GSDL_UNLOCK_FILE (fd);
-	cfg_out.close();
+	close(fd);
       }
 
@@ -633,17 +635,19 @@
   // make sure collect.cfg isn't read-only
   _chmod (cfgfilec, _S_IREAD | _S_IWRITE);
-  ofstream cfg_out (cfgfilec, ios::binary);
-#else
-  ofstream cfg_out (cfgfilec);
 #endif
-  
-  if (cfg_out) {
+
+  int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC
+#if defined(__WIN32__)
+	      | O_BINARY
+#endif
+	      );
+
+  if (fd) {
     // lock the file
-    int fd = GSDL_GET_FILEDESC(cfg_out);
     int lock_val = 1;
     GSDL_LOCK_FILE (fd);
     if (lock_val != 0) {
       logout << "Error: Couldn't lock file " << cfgfilec << "\n";
-      cfg_out.close();
+      close(fd);
       message = "tmpfail";
       
@@ -651,7 +655,15 @@
       
       outconvertclass text_t2ascii;
-      cfg_out << text_t2ascii << args["cfgfile"];
+      text_t2ascii << args["cfgfile"];
+      size_t buffersize=args["cfgfile"].size();
+      char *buffer=new char[buffersize];
+      size_t num_chars;
+      convertclass::status_t status;
+      text_t2ascii.convert(buffer, buffersize, num_chars, status);
+      // ignore status - assume it is "finished" as buffer is big enough
+      write(fd, buffer, num_chars);
       GSDL_UNLOCK_FILE (fd);
-      cfg_out.close();
+      close(fd);
+      delete buffer;
       
       // now that we've written the file we'll read it back again and
@@ -1490,5 +1502,5 @@
       shortname.clear();
       int use_words = (num_words <= 6) ? num_words : 6;
-      int substr_len = 6 / use_words;
+      unsigned int substr_len = 6 / use_words;
       
       for (int i = 0; i < use_words; i++) {
Index: /trunk/gsdl/src/recpt/receptionist.cpp
===================================================================
--- /trunk/gsdl/src/recpt/receptionist.cpp	(revision 3006)
+++ /trunk/gsdl/src/recpt/receptionist.cpp	(revision 3007)
@@ -37,5 +37,6 @@
 #include <assert.h>
 #include <time.h>
-#include <stdio.h>
+#include <stdio.h> // for open()
+#include <fcntl.h> // for open() flags
 // following 2 are for printing Last-Modified http header.
 #include <sys/stat.h>
@@ -695,7 +696,7 @@
   char *lfile = filename.getcstr();
 
-  ofstream log (lfile, ios::app);
-  
-  if (!log) {
+  int fd = open(lfile,O_APPEND);
+  
+  if (fd == -1) {
     logout << "Error: Couldn't open file " << lfile << "\n";
     delete lfile;
@@ -703,5 +704,5 @@
   }
 
-  int fd = GSDL_GET_FILEDESC(log);
+  //int fd = GSDL_GET_FILEDESC(log);
 
   // lock_val is set to 0 if file is locked successfully
@@ -709,14 +710,21 @@
   GSDL_LOCK_FILE (fd);
   if (lock_val == 0) {
-    log << text_t2utf8 << logstr;
+    text_t2utf8 << logstr;
+    char *buffer=new char[logstr.size()];
+    size_t num_chars;
+    convertclass::status_t status;
+    text_t2utf8.convert(buffer, logstr.size(), num_chars, status);
+    // ignore status - assume it is "finished" as buffer is big enough
+    write(fd, buffer, num_chars);
     GSDL_UNLOCK_FILE (fd);
+    delete buffer;
   } else {
     logout << "Error: Couldn't lock file " << lfile << "\n";
-    log.close();
+    close(fd);
     delete lfile;
     return false;
   }
 
-  log.close();
+  close(fd);
 		
   delete lfile;
@@ -797,5 +805,5 @@
 	contentout << "Last-Modified: " << asctime(utc_latest);
       }
-    }
+    } // end of collection != ""
 
     /*
Index: /trunk/gsdl/src/recpt/statusaction.cpp
===================================================================
--- /trunk/gsdl/src/recpt/statusaction.cpp	(revision 3006)
+++ /trunk/gsdl/src/recpt/statusaction.cpp	(revision 3007)
@@ -32,5 +32,6 @@
 #include "gsdltools.h"
 #include <assert.h>
-
+#include <stdio.h>
+#include <fcntl.h> // for open() stuff
 
 void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp, 
@@ -885,26 +886,32 @@
   text_t cfgfile = filename_cat(gsdlhome, "etc", "main.cfg");
   char *cfgfilec = cfgfile.getcstr();
-#ifdef __WIN32__
-  ofstream cfg_out (cfgfilec, ios::binary);
-#else
-  ofstream cfg_out (cfgfilec);
+
+  int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC
+#if defined(__WIN32__)
+	      | O_BINARY
 #endif
-  
-  if (cfg_out) {
-    // lock the file
-    int fd = GSDL_GET_FILEDESC(cfg_out);
+	      );
+
+  if (fd != -1) {
+
     int lock_val = 1;
     GSDL_LOCK_FILE (fd);
     if (lock_val != 0) {
       logout << "statusaction::change_maincfg: Error: Couldn't lock file " << cfgfilec << "\n";
-      cfg_out.close();
       textout << outconvert << disp << "_status:changemaincfgfail_";
-      
+      close (fd);
     } else {
-      
       outconvertclass text_t2ascii;
-      cfg_out << text_t2ascii << args["cfgfile"];
+      text_t2ascii << args["cfgfile"];
+      size_t buffersize=args["cfgfile"].size();
+      char *buffer=new char[buffersize];
+      size_t num_chars;
+      convertclass::status_t status;
+      text_t2ascii.convert(buffer, buffersize, num_chars, status);
+      // ignore status - assume it is "finished" as buffer is big enough
+      write(fd, buffer, num_chars);
       GSDL_UNLOCK_FILE (fd);
-      cfg_out.close();
+      delete buffer;
+      close (fd);
       textout << outconvert << disp << "_status:changemaincfgsuccess_";
     }
@@ -913,4 +920,5 @@
     textout << outconvert << disp << "_status:changemaincfgfail_";
   }
+  delete cfgfilec;
 }
 
