Index: /trunk/gsdl/src/w32server/cgiwrapper.cpp
===================================================================
--- /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 901)
+++ /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 902)
@@ -9,4 +9,5 @@
 #include "wincgiutils.h"
 #include "settings.h"
+#include "fileutil.h"
 
 #include "gsdlconf.h"
@@ -31,14 +32,24 @@
 #include "mggdbmsource.h"
 
-
 // actions
+#include "action.h"
+#include "statusaction.h"
 #include "pageaction.h"
 #include "pingaction.h"
 #include "queryaction.h"
 #include "documentaction.h"
-#include "statusaction.h"
+#include "authenaction.h"
 #include "usersaction.h"
-#include "authenaction.h"
-#include "tipaction.h"
+#include "extlinkaction.h"
+//#include "buildaction.h"
+
+// browsers
+#include "browserclass.h"
+#include "vlistbrowserclass.h"
+#include "hlistbrowserclass.h"
+#include "datelistbrowserclass.h"
+#include "invbrowserclass.h"
+#include "pagedbrowserclass.h"
+#include "htmlbrowserclass.h"
 
 // filters
@@ -115,5 +126,5 @@
 
 int logstreambuf::sync () {
-  if (gs_keep_log || gs_show_console) {
+  if (gsdl_keep_log || gsdl_show_console) {
     log_message ("LOCAL LIB MESSAGE: ");
 		log_message_N (pbase(), out_waiting());
@@ -143,5 +154,4 @@
 DWORD lastlibaccesstime;
 DWORD baseavailvirtual;
-
 
 static void page_errorsitecfg (const text_t &gsdlhome, const text_t &collection) {
@@ -318,36 +328,44 @@
   cerr = &logstream;
   cout = &textstream;
-  
+
   // collection should be set to "" unless in 
   // collection specific mode
   text_t collection = "";
+  text_tset gsdlhomes;
+  text_tarray collections;
+  colinfo_tmap::const_iterator this_info = gsdl_collectinfo.begin();
+  colinfo_tmap::const_iterator end_info = gsdl_collectinfo.end();
 
   // note the current time
   lastlibaccesstime = GetTickCount();
-  
+
   // before we do the init we should make sure
   // that we can find the relevant directories
-  if (!checkdir (GSDL_GSDLHOME "\\")) return 0;
-  if (!checkdir (GSDL_GSDLHOME "\\macros\\")) return 0;
-  
-  // add a collection server for each collection
-  text_tarray collections;
-  ifstream collist (GSDL_GSDLHOME "/etc/collections.txt");
-  if (!collist) {
-    exit(1);
-  }
-  char col[100];
-  while (!collist.eof()) {
-    collist.getline (col, 100);
-    if (col[0] != '\0')
-      collections.push_back (col);
-  }
-  collist.close();
-
+  if (!checkdir (gsdl_gsdlhome + "\\")) return 0;
+  if (!checkdir (gsdl_gsdlhome + "\\macros\\")) return 0;
+
+  if (collection.empty()) {
+
+    // get all collections from each gsdlhome (this relies 
+    // on there not being more than one collection with the same 
+    // name)
+    read_dir (filename_cat (gsdl_gsdlhome, "collect"), collections);
+    gsdlhomes.insert (gsdl_gsdlhome);
+    while (this_info != end_info) {
+      if (gsdlhomes.find ((*this_info).second.gsdl_gsdlhome) == gsdlhomes.end()) {
+	read_dir (filename_cat ((*this_info).second.gsdl_gsdlhome, "collect"), collections);
+	gsdlhomes.insert ((*this_info).second.gsdl_gsdlhome);
+      }
+      this_info ++;
+    }
+  } else {
+    collections.push_back (collection);
+  }
+  
   text_tarray::const_iterator thiscol = collections.begin();
   text_tarray::const_iterator endcol = collections.end();
-  
+
   while (thiscol != endcol) {
-    
+
     // this memory is created but never destroyed
     // we're also not doing any error checking to make sure we didn't
@@ -396,7 +414,7 @@
   
   mapinconvertclass *gbinconvert = new mapinconvertclass();
-  gbinconvert->setmapfile (GSDL_GSDLHOME, "gbku", 0x25a1);
+  gbinconvert->setmapfile (gsdl_gsdlhome, "gbku", 0x25a1);
   mapoutconvertclass *gboutconvert = new mapoutconvertclass();
-  gboutconvert->setmapfile (GSDL_GSDLHOME, "ugbk", 0xa1f5);
+  gboutconvert->setmapfile (gsdl_gsdlhome, "ugbk", 0xa1f5);
   recpt.add_converter ("g", gbinconvert, gboutconvert);
   
@@ -407,5 +425,4 @@
   
   pageaction *apageaction = new pageaction();
-  apageaction->set_receptionist (&recpt);
   recpt.add_action (apageaction);
   
@@ -421,25 +438,81 @@
   usersaction *ausersaction = new usersaction();
   recpt.add_action (ausersaction);
+
+  extlinkaction *anextlinkaction = new extlinkaction();
+  recpt.add_action (anextlinkaction);
+
+  //  buildaction *abuildaction = new buildaction();
+  //  abuildaction->set_receptionist (&recpt);
+  //  recpt.add_action (abuildaction);
   
   authenaction *aauthenaction = new authenaction();
   aauthenaction->set_receptionist(&recpt);
   recpt.add_action (aauthenaction);
-  
-  tipaction *atipaction = new tipaction();
-  recpt.add_action (atipaction);
+
+
+  // list of browsers
+  vlistbrowserclass *avlistbrowserclass = new vlistbrowserclass();
+  recpt.add_browser (avlistbrowserclass);
+  recpt.setdefaultbrowser ("VList");
+
+  hlistbrowserclass *ahlistbrowserclass = new hlistbrowserclass();
+  recpt.add_browser (ahlistbrowserclass);
+
+  datelistbrowserclass *adatelistbrowserclass = new datelistbrowserclass();
+  recpt.add_browser (adatelistbrowserclass);
+
+  invbrowserclass *ainvbrowserclass = new invbrowserclass();
+  recpt.add_browser (ainvbrowserclass);
+
+  pagedbrowserclass *apagedbrowserclass = new pagedbrowserclass();
+  recpt.add_browser (apagedbrowserclass);
+
+  htmlbrowserclass *ahtmlbrowserclass = new htmlbrowserclass();
+  recpt.add_browser (ahtmlbrowserclass);
   
   // set defaults
-  recpt.configure ("gsdlhome", GSDL_GSDLHOME);
+  recpt.configure ("gsdlhome", gsdl_gsdlhome);
   recpt.configure ("collection", collection);
 
   int maxrequests = 1;
-  if (!site_cfg_read (recpt, GSDL_GSDLHOME, collection, maxrequests)) {
-    // couldn't find the site configuration file
-    page_errorsitecfg (GSDL_GSDLHOME, collection);
-    return 0;
-  } else if (!main_cfg_read (recpt, GSDL_GSDLHOME, collection)) {
-    // couldn't find the main configuration file
-    page_errormaincfg (GSDL_GSDLHOME, collection);
-    return 0;
+  text_tset seenhomes;
+  this_info = gsdl_collectinfo.begin();
+
+  // configure any collections with gsdlhome (or gdbmhome) 
+  // different from the default
+  while (this_info != end_info) {
+    if (((*this_info).second.gsdl_gsdlhome != gsdl_gsdlhome) ||
+	((*this_info).second.gsdl_gdbmhome != gsdl_gdbmhome) &&
+	(seenhomes.find ((*this_info).second.gsdl_gsdlhome + 
+			 (*this_info).second.gsdl_gdbmhome) == seenhomes.end())) {
+      text_tarray tmpconf;
+      tmpconf.push_back ((*this_info).first);
+      tmpconf.push_back ((*this_info).second.gsdl_gsdlhome);
+      tmpconf.push_back ((*this_info).second.gsdl_gdbmhome);
+      recpt.configure ("collectinfo", tmpconf);
+      seenhomes.insert ((*this_info).second.gsdl_gsdlhome + 
+			(*this_info).second.gsdl_gdbmhome);
+    }
+    this_info ++;
+  }
+
+  // read in config files of each gsdlhome (in no particular order)
+  // those read in last will override those read earlier
+  // collections being used together in this way should be 
+  // careful not to have site.cfg or main.cfg files that might 
+  // screw with each other.
+  text_tset::const_iterator thome = gsdlhomes.begin();
+  text_tset::const_iterator ehome = gsdlhomes.end();
+  while (thome != ehome) {
+    if (!site_cfg_read (recpt, *thome, collection, maxrequests)) {
+      // couldn't find the site configuration file
+      page_errorsitecfg (*thome, collection);
+      return 0;
+    } else if (!main_cfg_read (recpt, *thome, collection)) {
+      // couldn't find the main configuration file
+      page_errormaincfg (*thome, collection);
+      return 0;
+    }
+    thome ++;
   }
 
@@ -450,5 +523,5 @@
   if (!recpt.init(cerr)) {
     // an error occurred during the initialisation
-    page_errorinit(GSDL_GSDLHOME);
+    page_errorinit(gsdl_gsdlhome);
     return 0;
   }
@@ -465,8 +538,6 @@
 
 static void rememberpref (char *tailstr) {
-  strcpy(gs_enterlib, tailstr);
-
-  // add "a=p&p=home"
-  strcat(gs_enterlib, "&a=p&p=home");
+
+  //  gsdl_enterlib = tailstr;
 }
 
@@ -493,5 +564,5 @@
 
   // set up file name
-  text_t filenamet = text_t(GSDL_GSDLHOME) + filename;
+  text_t filenamet = text_t(gsdl_gsdlhome) + filename;
   text_t::iterator here = filenamet.begin();
   text_t::iterator end = filenamet.end();
@@ -538,6 +609,7 @@
   // has been no errors so far
   cgiargsclass args;
-  if (!recpt.parse_cgi_args (TailStr, args, cerr)) {
-    page_errorparseargs(GSDL_GSDLHOME);
+  text_tmap empty; // don't use this (it's for fastcgi on unix)
+  if (!recpt.parse_cgi_args (TailStr, args, cerr, empty)) {
+    page_errorparseargs(gsdl_gsdlhome);
     return;
   } 
@@ -547,14 +619,21 @@
   text_t response_data;
 
-  recpt.get_cgihead_info (args, response, response_data, cerr);
-  char *response_data_c = response_data.getcstr();
+  recpt.get_cgihead_info (args, response, response_data, cerr, empty);
 
   if (response == location) {
     // location response
-    if (send_header(strcat("@", response_data_c), RInfo) < 0) return;
-    // textstream << text_t2ascii << "Location: " << response_data << "\n\n";
+    response_data = "@" + recpt.expandmacros (response_data, args, cerr);
+    char *response_data_c = response_data.getcstr();
+    send_header(response_data_c, RInfo);
+    delete response_data_c;
+    return;
   } else if (response == content) {
     // content response
-    if (send_header(response_data_c, RInfo) < 0) return;
+    char *response_data_c = response_data.getcstr();
+    if (send_header(response_data_c, RInfo) < 0) {
+      delete response_data_c;
+      return;
+    }
+    delete response_data_c;
   } else {
     // unknown response
@@ -565,11 +644,10 @@
   textstream.tsbreset();
   textstream.setrequestinfo (RInfo);
-  delete response_data_c;
   
   if (!recpt.produce_content (args, cout, cerr)) {
-    page_errorcgipage(GSDL_GSDLHOME);
+    page_errorcgipage(gsdl_gsdlhome);
     return;
   } 
-  recpt.log_cgi_args (args, cerr);
+  recpt.log_cgi_args (args, cerr, empty);
 
   cout << flush;
@@ -598,5 +676,5 @@
     // log the difference in access times
     DWORD thislibaccesstime = GetTickCount();
-    if (gs_keep_log||gs_show_console) {
+    if (gsdl_keep_log||gsdl_show_console) {
       sprintf(tmpstr, "DELTA LIB ACCESS TIME: %i\n", (int)(thislibaccesstime - lastlibaccesstime));
       log_message (tmpstr);
@@ -605,5 +683,5 @@
     
     // log this request
-    if (gs_keep_log||gs_show_console) {
+    if (gsdl_keep_log||gsdl_show_console) {
       sprintf (tmpstr, "LOCAL LIB: %s\n", tailstr);
       log_message (tmpstr);
@@ -616,5 +694,5 @@
     
     // log memory information
-    if (gs_keep_log||gs_show_console) {
+    if (gsdl_keep_log||gsdl_show_console) {
       MEMORYSTATUS memstatus;
       memstatus.dwLength = sizeof(MEMORYSTATUS);
@@ -627,5 +705,5 @@
   } else {
     // local file
-    if (gs_keep_log||gs_show_console) {
+    if (gsdl_keep_log||gsdl_show_console) {
       sprintf (tmpstr, "LOCAL FILE: %s\n", tailstr);
       log_message (tmpstr);
Index: /trunk/gsdl/src/w32server/cgiwrapper.h
===================================================================
--- /trunk/gsdl/src/w32server/cgiwrapper.h	(revision 901)
+++ /trunk/gsdl/src/w32server/cgiwrapper.h	(revision 902)
@@ -4,7 +4,10 @@
 #include "httpreq.h"
 #include "locate.h"
+#include "receptionist.h"
 
 // the number of times the library has been accessed
 extern int libaccessnum;
+
+//void configure_httpprefix ();
 
 int ExamineURIStr(char *URIStr,RequestInfoT *RequestInfo,
Index: /trunk/gsdl/src/w32server/fnord.cpp
===================================================================
--- /trunk/gsdl/src/w32server/fnord.cpp	(revision 901)
+++ /trunk/gsdl/src/w32server/fnord.cpp	(revision 902)
@@ -77,5 +77,5 @@
 #define ENTERBUTTONY ((MAINWINDOWHEIGHT-RESTHEIGHT)+5)
 
-#define VERSIONSTRING "version 1.1"
+#define VERSIONSTRING "version 1.0"
 const char versionstring[] = VERSIONSTRING;
 
@@ -196,5 +196,5 @@
   
   // decide what we want to draw
-  if (gs_show_console) {
+  if (gsdl_show_console) {
     // we want to draw a "console" window
     if (window_state != console_window ||
@@ -278,25 +278,22 @@
 // returns 1 on success, 0 otherwise
 int enter_library (HWND Window) {
-  char url[256], numbuf[20];
   int res;
   
   // get the url and attempt to start a browser
+  char *localname = GetLocalName(NULL);
   if (have_networking) {
-    strcpy(url, "http://");
-    strcat(url, GetLocalName(NULL));
-    if (gs_port_num != 80) {
-      itoa(gs_port_num,numbuf,10);
-      strcat(url,":");
-      strcat(url,numbuf);
-    }
-    strcat(url, gs_enterlib);
-    
+    text_t url = "http://" + text_t(localname);
+    if (gsdl_port_num != 80)
+      url += ":" + text_t(gsdl_port_num);
+    
+    url += gsdl_enterlib;
+
     // add a unique ending so it will always result in a request
-    if (strstr (gs_enterlib, "?") == NULL) strcat (url, "?");
-    else strcat (url, "&");
-    
-    strcat (url, "uq=");
-    itoa ((int)GetTickCount(), numbuf, 10);
-    strcat (url, numbuf);
+    text_t::const_iterator it = 
+      findchar (gsdl_enterlib.begin(), gsdl_enterlib.end(), '?');
+    if (it == gsdl_enterlib.end()) url.push_back ('?');
+    else url.push_back ('&');
+    int tcount = GetTickCount();
+    url += "uq=" + text_t(tcount);
     
     // remember the library access number for later proxy checking
@@ -305,16 +302,20 @@
     // do a quick check to make sure we're using netscape when
     // we should be (it might have been just installed)
-    if (netscapeneeded) gs_check_browser_settings (netscapeneeded);
-    
+    if (netscapeneeded) gsdl_check_browser_settings (netscapeneeded);
+    
+    char *cstr_url = url.getcstr();
     if (strlen (startbrowserdir) <= 0) {
-      res = startbrowser (url, gs_browser_exe, NULL);
+      res = startbrowser (cstr_url, gsdl_browser_exe, NULL);
       
-    } else res = startbrowser (url, gs_browser_exe, startbrowserdir);
-    
+    } else res = startbrowser (cstr_url, gsdl_browser_exe, startbrowserdir);
+    
+    delete cstr_url;
+
   } else {
+    /*
     char staticpath[256];
     
     // try to find the static pages
-    strcpy (url, gs_staticpages);
+    strcpy (url, gsdl_staticpages);
     
     // remove any slashes from the static pathname
@@ -341,6 +342,7 @@
     strcat (url, "niupepa.htm");
     
-    res = startbrowser (url, gs_browser_exe, NULL);
+    res = startbrowser (url, gsdl_browser_exe, NULL);
     startbrowserdir[0] = '\0'; // doesn't make sense for non-networked case
+    */
   }
   
@@ -393,5 +395,7 @@
   
   // try to find the browser directory
-  strcpy (installpath, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive...
+  char *gsdlhome = gsdl_gsdlhome.getcstr();
+  strcpy (installpath, gsdlhome); // use gsdlhome to find the CD-ROM drive...
+  delete gsdlhome;
   
   // remove any slashes from the pathname
@@ -457,5 +461,7 @@
   
   // try to find the browser directory
-  strcpy (topdir, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive...
+  char *gsdlhome = gsdl_gsdlhome.getcstr();
+  strcpy (topdir, gsdlhome); // use gsdlhome to find the CD-ROM drive...
+  delete gsdlhome;
   strcpy (cmd, "notepad ");
   
@@ -486,5 +492,5 @@
     // repeat key press then attempt to start a browser
     if ((WParam == '\r') && !(LParam & 0xe0000000)) {
-      if (enter_library (Window) && !gs_show_console) 
+      if (enter_library (Window) && !gsdl_show_console) 
 	ShowWindow(Window,SW_MINIMIZE);
     }
@@ -493,5 +499,5 @@
     if ((HWND)LParam == GoButton) {
       // attempt to start a browser
-      if (enter_library (Window) && !gs_show_console) 
+      if (enter_library (Window) && !gsdl_show_console) 
 	ShowWindow(Window,SW_MINIMIZE);
 
@@ -591,6 +597,6 @@
   startbrowserdir[0] = '\0';
   netscapeneeded = 0;
-  //	int err = tryinitnetwork (Instance, MsgWindow, NULL);
-  int err = 1;
+  int err = tryinitnetwork (Instance, MsgWindow, NULL);
+  //int err = 1;
   
   // if an error occurred, try again with billsock
@@ -624,9 +630,9 @@
 	netscapeneeded = 1;
 	// make sure the browser state is in step with the network condition
-	gs_check_browser_settings (netscapeneeded);
+	gsdl_check_browser_settings (netscapeneeded);
       }
       
       // check to see if a browser is running
-      if (browserrunning(gs_browser_exe) == NO_ERROR) {
+      if (browserrunning(gsdl_browser_exe) == NO_ERROR) {
 	MessageBox (NULL, 
 		    "The Greenstone Digital Library software has detected a\n"
@@ -748,5 +754,5 @@
   
   // get various information about this computer
-  if (gs_keep_log || gs_show_console) {
+  if (gsdl_keep_log || gsdl_show_console) {
     // get operating system information
     OSVERSIONINFO osver;
@@ -856,10 +862,12 @@
   // init various modules
   read_settings (0); // don't know if netscape is needed at this point
-  if (!gsdl_init()) // quit if can't initialise the library correctly
-    exit (0);
-  initstartbrowser();
-  log_computer_info ();
-  
+
   // attempt to initialise the network
+  // we do this first now as gsdl_init 
+  // needs networking initialized to 
+  // set httpprefix - Stefan.
+  // -- gsdl_init doesn't currently set httpprefix,
+  // it did for a brief time when I was using some
+  // scary html that didn't like relative links
   have_networking = initnetwork (Instance, MainWindow);
   if (!have_networking) {
@@ -869,4 +877,10 @@
     exit (0); // there is no static library for this collection
   }
+
+  if (!gsdl_init()) // quit if can't initialise the library correctly
+    exit (0);
+  initstartbrowser();
+  log_computer_info ();
+
   // show the initialising message for at least 1 second
   while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) {
@@ -875,9 +889,9 @@
   
   // if autoenter is enabled attempt to start a browser
-  if (have_networking && gs_auto_enter) {
+  if (have_networking && gsdl_auto_enter) {
     infostring = strsb;
     paint_window (pdc, windowRect);
     lastcheck = GetTickCount();
-    if (enter_library (MainWindow) && !gs_show_console) {
+    if (enter_library (MainWindow) && !gsdl_show_console) {
       // stay maximised for at least 1 second
       while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) Sleep (1);
@@ -916,7 +930,7 @@
   // we will ask if they want to close the
   // the library down
-  char last_gs_browser_exe[MAX_FILENAME_SIZE]; // need to notice when the
+  char last_gsdl_browser_exe[MAX_FILENAME_SIZE]; // need to notice when the
   // browser setting changes
-  strcpy (last_gs_browser_exe, gs_browser_exe);
+  strcpy (last_gsdl_browser_exe, gsdl_browser_exe);
   
   for (;;) {
@@ -929,12 +943,12 @@
       if (DiffTickCounts (lastcheck, GetTickCount()) > 500) {
 	// make sure the browser hasn't changed
-	if (strcmp (last_gs_browser_exe, gs_browser_exe) != 0) {
+	if (strcmp (last_gsdl_browser_exe, gsdl_browser_exe) != 0) {
 	  seenbrowser = 0;
-	  strcpy (last_gs_browser_exe, gs_browser_exe);
+	  strcpy (last_gsdl_browser_exe, gsdl_browser_exe);
 	}
 	
 	// do check
 	lastcheck = GetTickCount();
-	if (browserrunning(gs_browser_exe) == NO_ERROR) {
+	if (browserrunning(gsdl_browser_exe) == NO_ERROR) {
 	  // we were able to connect to a browser
 	  seenbrowser = 1;
Index: /trunk/gsdl/src/w32server/httpsrv.cpp
===================================================================
--- /trunk/gsdl/src/w32server/httpsrv.cpp	(revision 901)
+++ /trunk/gsdl/src/w32server/httpsrv.cpp	(revision 902)
@@ -50,5 +50,5 @@
   MsgWindow = PassedMsgWindow;
   //Create the server socket
-  return CreateListeningSocket(gs_port_num, MsgWindow, HTTP_SERVER_MSG, ServerSocket);
+  return CreateListeningSocket(gsdl_port_num, MsgWindow, HTTP_SERVER_MSG, ServerSocket);
 }
 
@@ -64,5 +64,5 @@
 	log_message("accept message arrived\n");
 	if (Socket != ServerSocket) {
-		if (gs_keep_log || gs_show_console) log_message("Incorrect socket sent in message");
+		if (gsdl_keep_log || gsdl_show_console) log_message("Incorrect socket sent in message");
 		}
 	switch (WSAGETSELECTEVENT(MsgInfo)) {
Index: /trunk/gsdl/src/w32server/locate.cpp
===================================================================
--- /trunk/gsdl/src/w32server/locate.cpp	(revision 901)
+++ /trunk/gsdl/src/w32server/locate.cpp	(revision 902)
@@ -52,5 +52,5 @@
 {
   if (log_file != NULL) fclose(log_file);
-  log_file = fopen(gs_log_name, "a");
+  log_file = fopen(gsdl_log_name, "a");
   if (log_file != NULL) {
 	  fprintf (log_file, "\n\n-----------\n");
@@ -75,5 +75,5 @@
 void activate_console(void)
 {
-  gs_show_console = 1;
+  gsdl_show_console = 1;
   next_console = console_buffer;
   *next_console = 0;
@@ -86,5 +86,5 @@
 void deactivate_console(void)
 {
-  gs_show_console = 0;
+  gsdl_show_console = 0;
   InvalidateRect(GSDL_Window,NULL,TRUE);
 }
@@ -189,5 +189,5 @@
     fflush(log_file);
     }
-  if (gs_show_console) {
+  if (gsdl_show_console) {
     char buffer[1024];  HDC dc;
     sprintf(buffer,"%s",msg);
@@ -210,5 +210,5 @@
 
   // these messages are not send to the console
-  if (gs_show_console) {
+  if (gsdl_show_console) {
     HDC dc;
     dc = GetDC(GSDL_Window);
Index: /trunk/gsdl/src/w32server/resource.h
===================================================================
--- /trunk/gsdl/src/w32server/resource.h	(revision 901)
+++ /trunk/gsdl/src/w32server/resource.h	(revision 902)
@@ -10,4 +10,5 @@
 #define GSDL_LOGO                       108
 #define GSDL_COL_TITLE                  109
+#define IDD_DIALOG1                     118
 #define APPLY_BUTTON                    1000
 #define REMOTE_CHECK                    1001
@@ -41,5 +42,5 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        118
+#define _APS_NEXT_RESOURCE_VALUE        119
 #define _APS_NEXT_COMMAND_VALUE         40008
 #define _APS_NEXT_CONTROL_VALUE         1024
Index: /trunk/gsdl/src/w32server/settings.cpp
===================================================================
--- /trunk/gsdl/src/w32server/settings.cpp	(revision 901)
+++ /trunk/gsdl/src/w32server/settings.cpp	(revision 902)
@@ -8,39 +8,29 @@
 
 #include <windows.h>
-//#include <stdlib.h>
-//#include <stdio.h>
-//#include <string.h>
-//#include <memory.h>
-//#pragma hdrstop
 #include "httpsrv.h"
 #include "settings.h"
 #include "locate.h"
 #include "resource.h"
-
-#include "text_t.h"
-#include "conftools.h"
-
+#include "cgiwrapper.h"
 
 // library settings
-char gs_enterlib[MAX_FILENAME_SIZE] = "";
-char gs_gsdlhome[MAX_FILENAME_SIZE] = "";
-char gs_macroshome[MAX_FILENAME_SIZE] = "";
-char gs_gdbmhome[MAX_FILENAME_SIZE] = "";
-char gs_indexhome[MAX_FILENAME_SIZE] = "";
-
-char gs_staticpages[MAX_FILENAME_SIZE] = "d:\\static";
-
+text_t gsdl_enterlib;
+text_t gsdl_gsdlhome;
+text_t gsdl_gdbmhome;
+text_t gsdl_collections;
+colinfo_tmap gsdl_collectinfo;
+
+char gsdl_staticpages[MAX_FILENAME_SIZE];
 
 // debug settings
-char gs_log_name[MAX_FILENAME_SIZE] = "c:\\gsdl.log";
-int gs_keep_log = 0;
-int gs_show_console = 0;
+char gsdl_log_name[MAX_FILENAME_SIZE] = "c:\\gsdl.log";
+int gsdl_keep_log = 0;
+int gsdl_show_console = 0;
 
 // general settings
-int gs_port_num = 80;
-int gs_auto_enter = 0;
-int gs_browser = GS_NETSCAPE;
-char gs_browser_exe[MAX_FILENAME_SIZE]="";
-
+int gsdl_port_num = 80;
+int gsdl_auto_enter = 0;
+int gsdl_browser = GS_NETSCAPE;
+char gsdl_browser_exe[MAX_FILENAME_SIZE] = "";
 
 
@@ -56,30 +46,35 @@
 
 // whether netscape is needed (used in the settings dialog box)
-static int gs_netscapeneeded = 0;
-
+static int gsdl_netscapeneeded = 0;
 
 static void remove_end_slashes(char *str) {
-	int len = strlen (str);
-	while ((len > 0) && ((str[len-1] == '\\') || (str[len-1] == '/'))) {
-		len --;
-	}
-	str[len] = '\0';
-}
-
+  int len = strlen (str);
+  while ((len > 0) && ((str[len-1] == '\\') || (str[len-1] == '/'))) {
+    len --;
+  }
+  str[len] = '\0';
+}
+
+static void remove_end_slashes (text_t &str) {
+  char *cstr = str.getcstr();
+  remove_end_slashes (cstr);
+  str = cstr;
+  delete cstr;
+}
 
 // returns 1 if successful, 0 otherwise
 // checks for a file's existence
 static int check_program_exe (char *path) {
-	UINT curerrormode;
-	OFSTRUCT reOpenBuff;
-	int retvalue = 0;
-
-	reOpenBuff.cBytes = sizeof (OFSTRUCT);
-
-	curerrormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
-	if (OpenFile(path, &reOpenBuff, OF_EXIST) != HFILE_ERROR) retvalue = 1;
-	SetErrorMode(curerrormode);
-
-	return retvalue;
+  UINT curerrormode;
+  OFSTRUCT reOpenBuff;
+  int retvalue = 0;
+  
+  reOpenBuff.cBytes = sizeof (OFSTRUCT);
+  
+  curerrormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+  if (OpenFile(path, &reOpenBuff, OF_EXIST) != HFILE_ERROR) retvalue = 1;
+  SetErrorMode(curerrormode);
+  
+  return retvalue;
 }
 
@@ -87,67 +82,66 @@
 // returns 1 if successful, 0 otherwise
 static int get_default_browser_path (char *providedhtmltype, char *path, int maxsize) {
-	HKEY hk1, hk2;
-	char htmltype[256];
-	long size;
-	int retval = 0;
-
-	htmltype[0] = '\0';
-	path[0] = '\0';
-
-
-	// try and get information about the default browser from the 
-	// registry
-
-	if (providedhtmltype != NULL) strcpy (htmltype, providedhtmltype);
-
-	else if (RegOpenKey(HKEY_CLASSES_ROOT, ".htm", &hk1) == ERROR_SUCCESS) {
-		size = 256;
-		RegQueryValue(hk1, NULL, htmltype, &size);
-		RegCloseKey(hk1);
+  HKEY hk1, hk2;
+  char htmltype[256];
+  long size;
+  int retval = 0;
+  
+  htmltype[0] = '\0';
+  path[0] = '\0';
+  
+  // try and get information about the default browser from the 
+  // registry
+  
+  if (providedhtmltype != NULL) strcpy (htmltype, providedhtmltype);
+  
+  else if (RegOpenKey(HKEY_CLASSES_ROOT, ".htm", &hk1) == ERROR_SUCCESS) {
+    size = 256;
+    RegQueryValue(hk1, NULL, htmltype, &size);
+    RegCloseKey(hk1);
+  }
+  
+  if (RegOpenKey(HKEY_CLASSES_ROOT, htmltype, &hk1) == ERROR_SUCCESS) {
+    if (RegOpenKey(hk1, "shell\\open", &hk2) == ERROR_SUCCESS) {
+      // look for the command to start the browser
+      size = maxsize;
+      if (RegQueryValue(hk2,"command",path,&size) == ERROR_SUCCESS) {
+				// strip all excess stuff off the command
+	char endchar = ' ';
+	int i = 0, len = 0;
+	int state = 0; // 0=strip initial white-space and quotes, 1=grab path
+	while (path[i] != '\0') {
+	  if (state == 0) {
+	    if (path[i] == ' ') {
+	      // do nothing
+	    } else if (path[i] == '"') {
+	      endchar = '"';
+	      state = 1;
+	    } else {
+	      state = 1;
+	      path[len] = path[i];
+	      len++;
+	    }
+	  } else {
+	    if (path[i] == endchar) break;
+	    path[len] = path[i];
+	    len++;
+	  }
+	  i++;
 	}
-
-	if (RegOpenKey(HKEY_CLASSES_ROOT, htmltype, &hk1) == ERROR_SUCCESS) {
-		if (RegOpenKey(hk1, "shell\\open", &hk2) == ERROR_SUCCESS) {
-			// look for the command to start the browser
-			size = maxsize;
-			if (RegQueryValue(hk2,"command",path,&size) == ERROR_SUCCESS) {
-				// strip all excess stuff off the command
-				char endchar = ' ';
-				int i = 0, len = 0;
-				int state = 0; // 0=strip initial white-space and quotes, 1=grab path
-				while (path[i] != '\0') {
-					if (state == 0) {
-						if (path[i] == ' ') {
-							// do nothing
-						} else if (path[i] == '"') {
-							endchar = '"';
-							state = 1;
-						} else {
-							state = 1;
-							path[len] = path[i];
-							len++;
-						}
-					} else {
-						if (path[i] == endchar) break;
-						path[len] = path[i];
-						len++;
-					}
-					i++;
-				}
-				path[len] = '\0';
-
-				// check the resulting pathname
-				if (check_program_exe (path)) {
-					retval = 1; // succeeded
-				} else {
-					path[0] = '\0'; // failed (must have been deleted or something...)
-				}
-			}
-		    RegCloseKey(hk2);
-		}
-		RegCloseKey(hk1);
+	path[len] = '\0';
+	
+	// check the resulting pathname
+	if (check_program_exe (path)) {
+	  retval = 1; // succeeded
+	} else {
+	  path[0] = '\0'; // failed (must have been deleted or something...)
 	}
-
-	return retval;
+      }
+      RegCloseKey(hk2);
+    }
+    RegCloseKey(hk1);
+  }
+  
+  return retval;
 }
 
@@ -156,124 +150,134 @@
 // note that appname should include .exe (e.g. netscape.exe)
 static int registry_get_app_paths (char *appname, char *path, int maxsize) {
-	HKEY hk1;
-	long size;
-	int retval = 0;
-
-	path[0] = '\0';
-
-	if (RegOpenKey(HKEY_LOCAL_MACHINE, 
-			"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths", 
-			&hk1) == ERROR_SUCCESS) {
-		size = maxsize;
-		if (RegQueryValue (hk1, appname, path, &size) == ERROR_SUCCESS &&
-				check_program_exe (path));
-			retval = 1;
-
-		RegCloseKey(hk1);
+  HKEY hk1;
+  long size;
+  int retval = 0;
+  
+  path[0] = '\0';
+  
+  if (RegOpenKey(HKEY_LOCAL_MACHINE, 
+		 "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths", 
+		 &hk1) == ERROR_SUCCESS) {
+    size = maxsize;
+    if (RegQueryValue (hk1, appname, path, &size) == ERROR_SUCCESS &&
+	check_program_exe (path));
+    retval = 1;
+    
+    RegCloseKey(hk1);
+  }
+  
+  return retval;
+}
+
+static void check_installed_browsers (int netscapeneeded) {
+  netscape_exe[0] = '\0';
+  iexplore_exe[0] = '\0';
+  default_browser_exe[0] = '\0';
+  
+  // update the default browser information (if netscape isn't needed)
+  if (!netscapeneeded) {
+    get_default_browser_path (NULL, default_browser_exe, MAX_FILENAME_SIZE);
+    _strlwr (default_browser_exe);
+  }
+  
+  // look for netscape
+  
+  // first look for netscape in the registry
+  if (!registry_get_app_paths("netscape.exe", netscape_exe, MAX_FILENAME_SIZE)) {
+    // next look for "NetscapeMarkup"
+    if (get_default_browser_path ("NetscapeMarkup", netscape_exe, MAX_FILENAME_SIZE)) {
+      _strlwr (netscape_exe);
+      if (!strstr (netscape_exe, "netscape.exe")) {
+	netscape_exe[0] = '\0';
+	
+	// next look for \netscape\netscape.exe
+	
+	// get drive letter of the windows directory
+	GetWindowsDirectory(netscape_exe, MAX_FILENAME_SIZE);
+	netscape_exe[1] = '\0';
+	strcat (netscape_exe, ":\\netscape\\netscape.exe");
+	
+	if (!check_program_exe (netscape_exe)) {
+	  // lastly look for \netscape\program\netscape.exe
+	  netscape_exe[1] = '\0';
+	  strcat (netscape_exe, ":\\netscape\\program\\netscape.exe");
+	  
 	}
-
-	return retval;
-}
-
-static void check_installed_browsers (int netscapeneeded) {
-	netscape_exe[0] = '\0';
+      }
+    }
+  }
+  _strlwr (netscape_exe);
+  if ((strlen (netscape_exe) > 0) && !check_program_exe (netscape_exe)) {
+    netscape_exe[0] = '\0';  // couldn't find netscape
+  }
+  
+  // look for internet explorer (if netscape isn't needed)
+  
+  // first look for iexplore in the registry
+  if (!netscapeneeded && !registry_get_app_paths("iexplore.exe", 
+						 iexplore_exe, MAX_FILENAME_SIZE)) {
+    // next look for "htmlfile"
+    if (get_default_browser_path ("htmlfile", iexplore_exe, MAX_FILENAME_SIZE)) {
+      _strlwr (iexplore_exe);
+      if (!strstr (iexplore_exe, "iexplore.exe")) {
 	iexplore_exe[0] = '\0';
-	default_browser_exe[0] = '\0';
-
-	// update the default browser information (if netscape isn't needed)
-	if (!netscapeneeded) {
-		get_default_browser_path (NULL, default_browser_exe, MAX_FILENAME_SIZE);
-		_strlwr (default_browser_exe);
-	}
-
-
-	// look for netscape
-
-	// first look for netscape in the registry
-	if (!registry_get_app_paths("netscape.exe", netscape_exe, MAX_FILENAME_SIZE)) {
-		// next look for "NetscapeMarkup"
-		if (get_default_browser_path ("NetscapeMarkup", netscape_exe, MAX_FILENAME_SIZE)) {
-			_strlwr (netscape_exe);
-			if (!strstr (netscape_exe, "netscape.exe")) {
-				netscape_exe[0] = '\0';
-
-				// next look for \netscape\netscape.exe
-
-				// get drive letter of the windows directory
-				GetWindowsDirectory(netscape_exe, MAX_FILENAME_SIZE);
-				netscape_exe[1] = '\0';
-				strcat (netscape_exe, ":\\netscape\\netscape.exe");
-
-				if (!check_program_exe (netscape_exe)) {
-					// lastly look for \netscape\program\netscape.exe
-					netscape_exe[1] = '\0';
-					strcat (netscape_exe, ":\\netscape\\program\\netscape.exe");
-					
-				}
-			}
-		}
-	}
-	_strlwr (netscape_exe);
-	if ((strlen (netscape_exe) > 0) && !check_program_exe (netscape_exe)) {
-		netscape_exe[0] = '\0';  // couldn't find netscape
-	}
-
-
-	// look for internet explorer (if netscape isn't needed)
-
-	// first look for iexplore in the registry
-	if (!netscapeneeded && !registry_get_app_paths("iexplore.exe", 
-			iexplore_exe, MAX_FILENAME_SIZE)) {
-		// next look for "htmlfile"
-		if (get_default_browser_path ("htmlfile", iexplore_exe, MAX_FILENAME_SIZE)) {
-			_strlwr (iexplore_exe);
-			if (!strstr (iexplore_exe, "iexplore.exe")) {
-				iexplore_exe[0] = '\0';
-
-				// next look for \iexplore\iexplore.exe
-
-				// get drive letter of the windows directory
-				GetWindowsDirectory(iexplore_exe, MAX_FILENAME_SIZE);
-				iexplore_exe[1] = '\0';
-				strcat (iexplore_exe, ":\\iexplore\\iexplore.exe");
-			}
-		}
-	}
-	_strlwr (iexplore_exe);
-	if ((strlen (iexplore_exe) > 0) && !check_program_exe (iexplore_exe)) {
-		iexplore_exe[0] = '\0';  // couldn't find internet explorer
-	}
-
-}
-
+	
+	// next look for \iexplore\iexplore.exe
+	
+	// get drive letter of the windows directory
+	GetWindowsDirectory(iexplore_exe, MAX_FILENAME_SIZE);
+	iexplore_exe[1] = '\0';
+	strcat (iexplore_exe, ":\\iexplore\\iexplore.exe");
+      }
+    }
+  }
+  _strlwr (iexplore_exe);
+  if ((strlen (iexplore_exe) > 0) && !check_program_exe (iexplore_exe)) {
+    iexplore_exe[0] = '\0';  // couldn't find internet explorer
+  }
+}
 
 void write_settings () {
-	char conffile[MAX_FILENAME_SIZE];
-
-	strcpy (conffile, data_location);
-	remove_end_slashes (conffile);
-	strcat (conffile, "\\gsdl.ini");
-
-	ofstream fout (conffile);
-	if (fout) {
-		write_confline(fout, "enterlib", gs_enterlib);
-		write_confline(fout, "gsdlhome", gs_gsdlhome);
-		write_confline(fout, "macroshome", gs_macroshome);
-		write_confline(fout, "gdbmhome", gs_gdbmhome);
-		write_confline(fout, "indexhome", gs_indexhome);
-
-		write_confline(fout, "staticpages", gs_staticpages);
-
-		write_confline(fout, "logfilename", gs_log_name);
-		write_confline(fout, "keeplog", text_t(gs_keep_log));
-		write_confline(fout, "consolelog", text_t(gs_show_console));
-
-		write_confline(fout, "portnumber", text_t(gs_port_num));
-		write_confline(fout, "autoenter", text_t(gs_auto_enter));
-		write_confline(fout, "browser", text_t(gs_browser));
-		write_confline(fout, "browserexe", gs_browser_exe);
-		
-		fout.close();
-	}
+  char conffile[MAX_FILENAME_SIZE];
+  
+  strcpy (conffile, data_location);
+  remove_end_slashes (conffile);
+  strcat (conffile, "\\gsdl.ini");
+  
+  ofstream fout (conffile);
+  if (fout) {
+    
+    outconvertclass text_t2ascii;
+
+    // top (gsdl) level stuff
+    fout << "[gsdl]\n";
+    write_ini_line(fout, "enterlib", gsdl_enterlib);
+    write_ini_line(fout, "gsdlhome", gsdl_gsdlhome);
+    write_ini_line(fout, "gdbmhome", gsdl_gdbmhome);
+    
+    write_ini_line(fout, "logfilename", gsdl_log_name);
+    write_ini_line(fout, "keeplog", text_t(gsdl_keep_log));
+    write_ini_line(fout, "consolelog", text_t(gsdl_show_console));
+    
+    write_ini_line(fout, "portnumber", text_t(gsdl_port_num));
+    write_ini_line(fout, "autoenter", text_t(gsdl_auto_enter));
+    write_ini_line(fout, "browser", text_t(gsdl_browser));
+    write_ini_line(fout, "browserexe", gsdl_browser_exe);
+    write_ini_line(fout, "collections", gsdl_collections);
+    
+    // collection levels
+    colinfo_tmap::iterator here = gsdl_collectinfo.begin();
+    colinfo_tmap::iterator end = gsdl_collectinfo.end();
+    while (here != end) {
+      fout << text_t2ascii << "[" << (*here).first << "]\n";
+      if (!(*here).second.gsdl_gsdlhome.empty()) 
+	write_ini_line(fout, "gsdlhome", (*here).second.gsdl_gsdlhome);
+      if (!(*here).second.gsdl_gdbmhome.empty()) 
+	write_ini_line(fout, "gdbmhome", (*here).second.gsdl_gdbmhome);
+      
+      here ++;
+    }
+    fout.close();
+  }
 }
 
@@ -281,8 +285,8 @@
 // browser_compare assumes that check_exe is in lowercase
 static int browser_compare (char *browser_exe_path, char *check_exe) {
-	char tmp_exe[MAX_FILENAME_SIZE];
-	strcpy (tmp_exe, browser_exe_path);
-	_strlwr (tmp_exe);
-	return (strstr (tmp_exe, check_exe) != NULL);
+  char tmp_exe[MAX_FILENAME_SIZE];
+  strcpy (tmp_exe, browser_exe_path);
+  _strlwr (tmp_exe);
+  return (strstr (tmp_exe, check_exe) != NULL);
 }
 
@@ -292,443 +296,438 @@
 // enough to receive any path names to any browser
 static void check_browser_settings (int &browser, char *browser_exe, 
-							 int netscapeneeded) {
-
-	// sort out which browser to use
-	if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0'))
-		browser = GS_IEXPLORE;
-	if ((browser == GS_IEXPLORE) && (netscapeneeded || (iexplore_exe[0] == '\0'))) {
-		if (netscape_exe[0] != '\0') browser = GS_NETSCAPE;
-		else browser = GS_OTHER;
+				    int netscapeneeded) {
+  
+  // sort out which browser to use
+  if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0'))
+    browser = GS_IEXPLORE;
+  if ((browser == GS_IEXPLORE) && (netscapeneeded || (iexplore_exe[0] == '\0'))) {
+    if (netscape_exe[0] != '\0') browser = GS_NETSCAPE;
+    else browser = GS_OTHER;
+  }
+  if ((browser == GS_OTHER) && netscapeneeded && 
+      !browser_compare (browser_exe, "netscape.exe") && (netscape_exe[0] != '\0')) {
+    // this other browser isn't netscape and netscape is available
+    browser = GS_NETSCAPE;
+  }
+  
+  
+  // get the browser's executable
+  if (browser == GS_NETSCAPE) {
+    strcpy (browser_exe, netscape_exe);
+  } else if (browser == GS_IEXPLORE) {
+    strcpy (browser_exe, iexplore_exe);
+  } else {
+    browser = GS_OTHER;
+    
+    // if the browser should be netscape then check to
+    // make sure it is
+    if (netscapeneeded && !browser_compare (browser_exe, "netscape.exe")) {
+      // not netscape, set to no browser
+      browser_exe[0] = '\0';
+    }
+  }
+}
+
+
+static void revert_defaults (int netscapeneeded) {
+  find_location();
+  
+  // library settings
+  gsdl_enterlib = "/cgi-bin/gw";
+  gsdl_gsdlhome = data_location;
+  gsdl_gdbmhome = data_location;
+  
+  // debug settings
+  gsdl_keep_log = 0;
+  strcpy (gsdl_log_name, "c:\\gsdl.log");
+  gsdl_show_console = 0;
+  
+  // general settings
+  gsdl_port_num = 80;
+  gsdl_auto_enter = 0;
+  
+  check_installed_browsers (netscapeneeded);
+  gsdl_browser = GS_NETSCAPE;
+  strcpy (gsdl_browser_exe, default_browser_exe);
+  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded);
+}
+
+void read_settings (int netscapeneeded) {
+  char conffile[MAX_FILENAME_SIZE];
+  
+  find_location();
+  
+  strcpy (conffile, data_location);
+  remove_end_slashes (conffile);
+  strcat (conffile, "\\gsdl.ini");
+  
+  // set up defaults
+  revert_defaults (netscapeneeded);
+  
+  text_t key, value, section;
+  char *cstr_value;
+  ifstream conf (conffile, ios::nocreate);
+  if (conf) {
+    while (read_ini_line(conf, key, value) >= 0) {
+      if (value.empty()) {
+	// should be a section title
+	section = key;
+	// remove square brackets
+	section.erase (section.begin());
+	section.erase (section.end()-1);
+
+      } else {
+
+	cstr_value = value.getcstr ();
+      
+	if (section == "gsdl") {
+
+	  if (key == "enterlib") {
+	    gsdl_enterlib = value;
+	  
+	    // 'logfilename' should occur in the configuration file
+	    // before 'keeplog'
+	  } else if (key == "logfilename") {
+	    strcpy (gsdl_log_name, cstr_value);
+	  
+	  } else if (key == "keeplog") {
+	    gsdl_keep_log = value.getint();
+	    if (gsdl_keep_log) open_log_file();
+	
+	  } else if (key == "consolelog") {
+	    if (value.getint()) activate_console();
+	    else deactivate_console();
+	
+	  } else if (key == "portnumber") {
+	    gsdl_port_num = value.getint();
+	    
+	  } else if (key == "autoenter") {
+	    gsdl_auto_enter = value.getint();
+	
+	  } else if (key == "browser") {
+	    gsdl_browser = value.getint();
+	
+	  } else if (key == "browserexe") {
+	    strcpy (gsdl_browser_exe, cstr_value);
+
+	  } else if (key == "collections") {
+	    gsdl_collections = value;
+
+	  // gsdlhome must occur in file before gdbmhome	    
+	  } else if (key == "gsdlhome") {
+	    gsdl_gsdlhome = value;
+	    gsdl_gdbmhome = value;
+	  
+	  } else if (key == "gdbmhome") {
+	    gsdl_gdbmhome = value;
+	  }
+	} else {
+	  
+	  // gsdlhome must occur in file before gdbmhome
+	  if (key == "gsdlhome") {
+	    gsdl_collectinfo[section].gsdl_gsdlhome = value;
+	    gsdl_collectinfo[section].gsdl_gdbmhome = value;
+	  } else if (key == "gdbmhome") {
+	    gsdl_collectinfo[section].gsdl_gdbmhome = value;
+	  }
 	}
-	if ((browser == GS_OTHER) && netscapeneeded && 
-		!browser_compare (browser_exe, "netscape.exe") && (netscape_exe[0] != '\0')) {
-		// this other browser isn't netscape and netscape is available
-		browser = GS_NETSCAPE;
+	delete cstr_value;
+      }
+    }
+    conf.close();
+  }
+  
+  // check the homes to make sure they don't contain
+  // extra slashes at the end
+  remove_end_slashes (gsdl_gsdlhome);
+  remove_end_slashes (gsdl_gdbmhome);
+  colinfo_tmap::iterator here = gsdl_collectinfo.begin();
+  colinfo_tmap::iterator end = gsdl_collectinfo.end();
+  while (here != end) {
+    remove_end_slashes ((*here).second.gsdl_gsdlhome);
+    remove_end_slashes ((*here).second.gsdl_gdbmhome);
+    here ++;
+  }
+
+  // check the browser settings
+  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded);
+}
+
+void gsdl_check_browser_settings (int netscapeneeded) {
+  check_installed_browsers (netscapeneeded);
+  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded);
+}
+
+
+static void dialog_update_enables (HWND hwndDlg) {
+  int res;
+  
+  // if they want to use another browser, they should be able
+  // edit its filename
+  res = SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_GETCHECK,0,0);
+  SendDlgItemMessage(hwndDlg, ID_OTHER_NAME, WM_ENABLE, (res == 1), 0);
+}
+
+
+static int read_dialog_browser_field (HWND hwndDlg) {
+  if (SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE,
+			 BM_GETCHECK, 0, 0) == 1) return GS_NETSCAPE;
+  if (SendDlgItemMessage(hwndDlg, ID_RADIO_IE,
+			 BM_GETCHECK, 0, 0) == 1) return GS_IEXPLORE;
+  if (SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER,
+			 BM_GETCHECK, 0, 0) == 1) return GS_OTHER;
+  return GS_NETSCAPE;
+}
+
+
+
+static void set_dialog_browser_field (HWND hwndDlg, int browser, char *othername) {
+  // if we are trying to set the browser to netscape or
+  // internet explorer and we can't find them, set the browser
+  // to 'other'
+  if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0'))
+    browser = GS_IEXPLORE;
+  if ((browser == GS_IEXPLORE) && (iexplore_exe[0] == '\0')) {
+    if (netscape_exe[0] != '\0') browser = GS_NETSCAPE;
+    else browser = GS_OTHER;
+  }
+  
+  // update the radio buttons
+  SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, BM_SETCHECK,
+		     (browser == GS_NETSCAPE) ? BST_CHECKED : BST_UNCHECKED, 0);
+  SendDlgItemMessage(hwndDlg, ID_RADIO_IE, BM_SETCHECK,
+		     (browser == GS_IEXPLORE) ? BST_CHECKED : BST_UNCHECKED, 0);
+  SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_SETCHECK,
+		     (browser == GS_OTHER) ? BST_CHECKED : BST_UNCHECKED, 0);
+  
+  // update the other name field
+  if (browser == GS_NETSCAPE) {
+    SetDlgItemText(hwndDlg, ID_OTHER_NAME, netscape_exe);
+  } else if (browser == GS_IEXPLORE) {
+    SetDlgItemText(hwndDlg, ID_OTHER_NAME, iexplore_exe);
+  } else if (othername != NULL) {
+    SetDlgItemText(hwndDlg, ID_OTHER_NAME, othername);
+  }
+}
+
+
+static void read_browser_exe_field (HWND hwndDlg, char *filename, int maxsize) {
+  filename[0] = '\0';
+  GetDlgItemText(hwndDlg, ID_OTHER_NAME, filename, maxsize);
+}
+
+
+static void read_dialog_fields (HWND hwndDlg) {
+  int res;  BOOL bres;
+  
+  // port number
+  gsdl_port_num = GetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, &bres, 0);
+  if (!bres) gsdl_port_num = 80;
+  
+  // whether to enter the library automatically on startup
+  res = SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_GETCHECK, 0, 0);
+  gsdl_auto_enter = (res == 1);
+  
+  // which browser to use
+  gsdl_browser = read_dialog_browser_field (hwndDlg);
+  
+  // find out where the browser exe lives
+  read_browser_exe_field (hwndDlg, gsdl_browser_exe, MAX_FILENAME_SIZE);
+}
+
+
+
+
+static BOOL CALLBACK dialog_proc(HWND hwndDlg, UINT uMsg, 
+				 WPARAM wParam,LPARAM  lParam) {
+  int wNotifyCode = HIWORD(wParam);
+  int wID = LOWORD(wParam);
+  char *filefilter = "Program Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0";
+  OPENFILENAME fname;
+  char filename[MAX_FILENAME_SIZE];
+  
+  switch (uMsg) {
+  case WM_INITDIALOG:
+    // set current values
+    SetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, gsdl_port_num, FALSE);
+    SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_SETCHECK,
+		       gsdl_auto_enter ? 1 : 0, 0);
+    set_dialog_browser_field (hwndDlg, gsdl_browser, gsdl_browser_exe);
+    dialog_update_enables(hwndDlg);
+    
+    // make sure that the netscape and internet explorer
+    // radio buttons are only enabled if they could be found
+    if (netscape_exe[0] == '\0')
+      EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_NETSCAPE), FALSE);
+    if (iexplore_exe[0] == '\0')
+      EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_IE), FALSE);
+    
+    return 1;
+    
+  case WM_COMMAND:
+    if (wNotifyCode == BN_CLICKED) {
+      switch (wID) {
+      case ID_CANCEL_BUTTON:
+	EndDialog(hwndDlg, 0);
+	return 1;
+	
+      case ID_OK_BUTTON:
+	// check to make sure we can find the browser
+	filename[0] = '\0';
+	read_browser_exe_field (hwndDlg, filename, MAX_FILENAME_SIZE);
+	if (check_program_exe (filename)) { 
+	  // the file exists
+	  // if netscape is needed, make sure the browser is netscape
+	  _strlwr(filename);
+	  if (!gsdl_netscapeneeded || strstr (filename, "netscape.exe") != NULL) {
+	    // everything is ok
+	    read_dialog_fields(hwndDlg);
+	    EndDialog(hwndDlg, 1);
+	    
+	  } else {
+	    // message: must use netscape with this version
+	    MessageBox(hwndDlg,
+		       "You are using this software on a machine which\n"
+		       "currently does not have a working TCP/IP network layer.\n"
+		       "To allow the Greenstone Digital Library software to use\n"
+		       "its own TCP/IP network layer you must use a Netscape\n"
+		       "browser. If you do not have Netscape installed, please\n"
+		       "choose 'Install Netscape 4.05' from the 'Files' menu.",
+		       "Greenstone Digital Library Software",
+		       MB_OK|MB_APPLMODAL);
+	  }
+	} else {
+	  // message: the file did not exist
+	  MessageBox(hwndDlg,
+		     "Could not find the selected browser. If you do not\n"
+		     "have a browser installed, please choose\n"
+		     "'Install Netscape 4.05' from the 'Files' menu.",
+		     "Greenstone Digital Library Software",
+		     MB_OK|MB_APPLMODAL);
 	}
-
-
-	// get the browser's executable
-	if (browser == GS_NETSCAPE) {
-		strcpy (browser_exe, netscape_exe);
-	} else if (browser == GS_IEXPLORE) {
-		strcpy (browser_exe, iexplore_exe);
-	} else {
-		browser = GS_OTHER;
-		
-		// if the browser should be netscape then check to
-		// make sure it is
-		if (netscapeneeded && !browser_compare (browser_exe, "netscape.exe")) {
-			// not netscape, set to no browser
-			browser_exe[0] = '\0';
-		}
+	return 1;
+	
+      case ID_RADIO_NETSCAPE:
+	set_dialog_browser_field (hwndDlg, GS_NETSCAPE, NULL);
+	dialog_update_enables(hwndDlg);
+	return 1;
+	
+      case ID_RADIO_IE:
+	set_dialog_browser_field (hwndDlg, GS_IEXPLORE, NULL);
+	dialog_update_enables(hwndDlg);
+	return 1;
+	
+      case ID_RADIO_OTHER:
+	set_dialog_browser_field (hwndDlg, GS_OTHER, NULL);
+	dialog_update_enables(hwndDlg);
+	return 1;
+	
+      case ID_BROWSE_BUTTON:
+	filename[0] = '\0';
+	memset(&fname, 0, sizeof(OPENFILENAME));
+	fname.lStructSize = sizeof(OPENFILENAME);
+	fname.hwndOwner = hwndDlg;
+	fname.hInstance = NULL;
+	fname.lpstrFilter = filefilter;
+	fname.lpstrCustomFilter = NULL;
+	fname.nMaxCustFilter = 0;
+	fname.nFilterIndex = 1;
+	fname.lpstrFile = filename;
+	fname.nMaxFile = MAX_FILENAME_SIZE-1;
+	fname.lpstrFileTitle = NULL;
+	fname.nMaxFileTitle = 0;
+	fname.lpstrInitialDir = NULL;
+	fname.lpstrTitle = "Choose Web Browser";
+	fname.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+	
+	if(GetOpenFileName(&fname)) {
+	  set_dialog_browser_field (hwndDlg, GS_OTHER, filename);
+	  dialog_update_enables(hwndDlg);
 	}
-}
-
-
-static void revert_defaults (int netscapeneeded) {
-	find_location();
-	
-	// library settings
-	strcpy (gs_enterlib,"/cgi-bin/gw");
-	strcpy (gs_gsdlhome, data_location);
-	strcpy (gs_macroshome, data_location);
-	strcpy (gs_gdbmhome, data_location);
-	strcpy (gs_indexhome, data_location);
-
-	strcpy (gs_staticpages, "d:\\static");
-
-	// debug settings
-	gs_keep_log = 0;
-	strcpy (gs_log_name, "c:\\gsdl.log");
-	gs_show_console = 0;
-
-	// general settings
-	gs_port_num = 80;
-	gs_auto_enter = 0;
-
-	check_installed_browsers (netscapeneeded);
-	gs_browser = GS_NETSCAPE;
-	strcpy (gs_browser_exe, default_browser_exe);
-	check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded);
-}
-
-
-// debug settings
-
-// general settings
-extern int gs_port_num;                        // portnumber
-extern int gs_auto_enter;                      // autoenter
-extern int gs_browser;                         // browser
-extern char gs_browser_exe[MAX_FILENAME_SIZE]; // browserexe
-
-
-
-void read_settings (int netscapeneeded) {
-	char conffile[MAX_FILENAME_SIZE];
-
-	find_location();
-
-	strcpy (conffile, data_location);
-	remove_end_slashes (conffile);
-	strcat (conffile, "\\gsdl.ini");
-
-	// set up defaults
-	revert_defaults (netscapeneeded);
-
-	text_t key, value;
-	char *cstr_value;
-	ifstream conf (conffile, ios::nocreate);
-	if (conf) {
-		while (get_confline(conf, key, value) >= 0) {
-			cstr_value = value.getcstr ();
-
-			if (key == "enterlib") {
-				strcpy (gs_enterlib, cstr_value);
-
-			} else if (key == "gsdlhome") {
-				strcpy (gs_gsdlhome, cstr_value);
-				strcpy (gs_macroshome, cstr_value);
-				strcpy (gs_gdbmhome, cstr_value);
-				strcpy (gs_indexhome, cstr_value);
-
-			} else if (key == "macroshome") {
-				strcpy (gs_macroshome, cstr_value);
-
-			} else if (key == "gdbmhome") {
-				strcpy (gs_gdbmhome, cstr_value);
-
-			} else if (key == "indexhome") {
-				strcpy (gs_indexhome, cstr_value);
-
-
-			} else if (key == "staticpages") {
-				strcpy (gs_staticpages, cstr_value);
-
-
-			// 'logfilename' should occur in the configuration file
-			// before 'keeplog'
-			} else if (key == "logfilename") {
-				strcpy (gs_log_name, cstr_value);
-
-			} else if (key == "keeplog") {
-				gs_keep_log = value.getint();
-				if (gs_keep_log) open_log_file();
-
-			} else if (key == "consolelog") {
-				if (value.getint()) activate_console();
-				else deactivate_console();
-
-			
-			} else if (key == "portnumber") {
-				gs_port_num = value.getint();
-
-			} else if (key == "autoenter") {
-				gs_auto_enter = value.getint();
-
-			} else if (key == "browser") {
-				gs_browser = value.getint();
-
-			} else if (key == "browserexe") {
-				strcpy (gs_browser_exe, cstr_value);
-			}
-
-			delete cstr_value;
-		}
-		conf.close();
-	}
-
-	// check the homes to make sure they don't contain
-	// extra slashes at the end
-	remove_end_slashes (gs_gsdlhome);
-	remove_end_slashes (gs_macroshome);
-	remove_end_slashes (gs_gdbmhome);
-	remove_end_slashes (gs_indexhome);
-	remove_end_slashes (gs_staticpages);
-
-	// check the browser settings
-	check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded);
-}
-
-
-
-
-void gs_check_browser_settings (int netscapeneeded) {
-	check_installed_browsers (netscapeneeded);
-	check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded);
-}
-
-
-static void dialog_update_enables (HWND hwndDlg) {
-	int res;
-
-	// if they want to use another browser, they should be able
-	// edit its filename
-	res = SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_GETCHECK,0,0);
-	SendDlgItemMessage(hwndDlg, ID_OTHER_NAME, WM_ENABLE, (res == 1), 0);
-}
-
-
-static int read_dialog_browser_field (HWND hwndDlg) {
-	if (SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE,
-			BM_GETCHECK, 0, 0) == 1) return GS_NETSCAPE;
-	if (SendDlgItemMessage(hwndDlg, ID_RADIO_IE,
-			BM_GETCHECK, 0, 0) == 1) return GS_IEXPLORE;
-	if (SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER,
-			BM_GETCHECK, 0, 0) == 1) return GS_OTHER;
-	return GS_NETSCAPE;
-}
-
-
-
-static void set_dialog_browser_field (HWND hwndDlg, int browser, char *othername) {
-	// if we are trying to set the browser to netscape or
-	// internet explorer and we can't find them, set the browser
-	// to 'other'
-	if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0'))
-		browser = GS_IEXPLORE;
-	if ((browser == GS_IEXPLORE) && (iexplore_exe[0] == '\0')) {
-		if (netscape_exe[0] != '\0') browser = GS_NETSCAPE;
-		else browser = GS_OTHER;
-	}
-
-	// update the radio buttons
-	SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, BM_SETCHECK,
-		(browser == GS_NETSCAPE) ? BST_CHECKED : BST_UNCHECKED, 0);
-	SendDlgItemMessage(hwndDlg, ID_RADIO_IE, BM_SETCHECK,
-		(browser == GS_IEXPLORE) ? BST_CHECKED : BST_UNCHECKED, 0);
-	SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_SETCHECK,
-		(browser == GS_OTHER) ? BST_CHECKED : BST_UNCHECKED, 0);
-
-	// update the other name field
-	if (browser == GS_NETSCAPE) {
-		SetDlgItemText(hwndDlg, ID_OTHER_NAME, netscape_exe);
-	} else if (browser == GS_IEXPLORE) {
-		SetDlgItemText(hwndDlg, ID_OTHER_NAME, iexplore_exe);
-	} else if (othername != NULL) {
-		SetDlgItemText(hwndDlg, ID_OTHER_NAME, othername);
-	}
-}
-
-
-static void read_browser_exe_field (HWND hwndDlg, char *filename, int maxsize) {
-	filename[0] = '\0';
-	GetDlgItemText(hwndDlg, ID_OTHER_NAME, filename, maxsize);
-}
-
-
-static void read_dialog_fields (HWND hwndDlg) {
-	int res;  BOOL bres;
-
-	// port number
-	gs_port_num = GetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, &bres, 0);
-	if (!bres) gs_port_num = 80;
-	
-	// whether to enter the library automatically on startup
-	res = SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_GETCHECK, 0, 0);
-	gs_auto_enter = (res == 1);
-
-	// which browser to use
-	gs_browser = read_dialog_browser_field (hwndDlg);
-
-	// find out where the browser exe lives
-	read_browser_exe_field (hwndDlg, gs_browser_exe, MAX_FILENAME_SIZE);
-}
-
-
-
-
-static BOOL CALLBACK dialog_proc(HWND hwndDlg, UINT uMsg, 
-								WPARAM wParam,LPARAM  lParam) {
-	int wNotifyCode = HIWORD(wParam);
-	int wID = LOWORD(wParam);
-	char *filefilter = "Program Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0";
-	OPENFILENAME fname;
-	char filename[MAX_FILENAME_SIZE];
-
-	switch (uMsg) {
-	case WM_INITDIALOG:
-		// set current values
-		SetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, gs_port_num, FALSE);
-		SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_SETCHECK,
-			gs_auto_enter ? 1 : 0, 0);
-		set_dialog_browser_field (hwndDlg, gs_browser, gs_browser_exe);
-		dialog_update_enables(hwndDlg);
-
-		// make sure that the netscape and internet explorer
-		// radio buttons are only enabled if they could be found
-		if (netscape_exe[0] == '\0')
-			EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_NETSCAPE), FALSE);
-		if (iexplore_exe[0] == '\0')
-			EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_IE), FALSE);
-
-		return 1;
-
-	case WM_COMMAND:
-		if (wNotifyCode == BN_CLICKED) {
-			switch (wID) {
-			case ID_CANCEL_BUTTON:
-				EndDialog(hwndDlg, 0);
-				return 1;
-
-			case ID_OK_BUTTON:
-				// check to make sure we can find the browser
-				filename[0] = '\0';
-				read_browser_exe_field (hwndDlg, filename, MAX_FILENAME_SIZE);
-				if (check_program_exe (filename)) { 
-					// the file exists
-					// if netscape is needed, make sure the browser is netscape
-					_strlwr(filename);
-					if (!gs_netscapeneeded || strstr (filename, "netscape.exe") != NULL) {
-						// everything is ok
-						read_dialog_fields(hwndDlg);
-						EndDialog(hwndDlg, 1);
-
-					} else {
-						// message: must use netscape with this version
-						MessageBox(hwndDlg,
-								"You are using this software on a machine which\n"
-								"currently does not have a working TCP/IP network layer.\n"
-								"To allow the Greenstone Digital Library software to use\n"
-								"its own TCP/IP network layer you must use a Netscape\n"
-								"browser. If you do not have Netscape installed, please\n"
-								"choose 'Install Netscape 4.05' from the 'Files' menu.",
-								"Greenstone Digital Library Software",
-								MB_OK|MB_APPLMODAL);
-					}
-				} else {
-					// message: the file did not exist
-					MessageBox(hwndDlg,
-							"Could not find the selected browser. If you do not\n"
-							"have a browser installed, please choose\n"
-							"'Install Netscape 4.05' from the 'Files' menu.",
-							"Greenstone Digital Library Software",
-							MB_OK|MB_APPLMODAL);
-				}
-				return 1;
-
-			case ID_RADIO_NETSCAPE:
-				set_dialog_browser_field (hwndDlg, GS_NETSCAPE, NULL);
-				dialog_update_enables(hwndDlg);
-				return 1;
-
-			case ID_RADIO_IE:
-				set_dialog_browser_field (hwndDlg, GS_IEXPLORE, NULL);
-				dialog_update_enables(hwndDlg);
-				return 1;
-
-			case ID_RADIO_OTHER:
-				set_dialog_browser_field (hwndDlg, GS_OTHER, NULL);
-				dialog_update_enables(hwndDlg);
-				return 1;
-
-			case ID_BROWSE_BUTTON:
-				filename[0] = '\0';
-				memset(&fname, 0, sizeof(OPENFILENAME));
-				fname.lStructSize = sizeof(OPENFILENAME);
-				fname.hwndOwner = hwndDlg;
-				fname.hInstance = NULL;
-				fname.lpstrFilter = filefilter;
-				fname.lpstrCustomFilter = NULL;
-				fname.nMaxCustFilter = 0;
-				fname.nFilterIndex = 1;
-				fname.lpstrFile = filename;
-				fname.nMaxFile = MAX_FILENAME_SIZE-1;
-				fname.lpstrFileTitle = NULL;
-				fname.nMaxFileTitle = 0;
-				fname.lpstrInitialDir = NULL;
-				fname.lpstrTitle = "Choose Web Browser";
-				fname.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
-
-				if(GetOpenFileName(&fname)) {
-					set_dialog_browser_field (hwndDlg, GS_OTHER, filename);
-					dialog_update_enables(hwndDlg);
-				}
-				return 1;
-			}
-		}
-		return 0;
-
-	case WM_CLOSE:
-	case WM_DESTROY:
-	    EndDialog(hwndDlg, 0);
-		return 1;
-	}
-
-	return 0;
-}
-
-
+	return 1;
+      }
+    }
+    return 0;
+    
+  case WM_CLOSE:
+  case WM_DESTROY:
+    EndDialog(hwndDlg, 0);
+    return 1;
+  }
+  
+  return 0;
+}
 
 static void dialog_debug_update_enables (HWND hwndDlg) {
-	int res;
-
-	// if they want a log of program use allow them to
-	// edit its filename
-	res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0);
-	SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, WM_ENABLE, (res == 1), 0);
+  int res;
+  
+  // if they want a log of program use allow them to
+  // edit its filename
+  res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0);
+  SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, WM_ENABLE, (res == 1), 0);
 }
 
 
 static void read_dialog_debug_fields (HWND hwndDlg) {
-	int res;
-
-	// whether to log program use
-	res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0);
-	gs_keep_log = (res == 1);
-
-	// log filename
-	res = SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, EM_GETMODIFY,0,0);
-	if (res != 0) {
-		res = GetDlgItemText(hwndDlg, LOG_NAME_BOX, gs_log_name, MAX_FILENAME_SIZE);
-	}
-
-	// whether to display log information on console
-	res = SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_GETCHECK,0,0);
-	gs_show_console = (res == 1);
+  int res;
+  
+  // whether to log program use
+  res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0);
+  gsdl_keep_log = (res == 1);
+  
+  // log filename
+  res = SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, EM_GETMODIFY,0,0);
+  if (res != 0) {
+    res = GetDlgItemText(hwndDlg, LOG_NAME_BOX, gsdl_log_name, MAX_FILENAME_SIZE);
+  }
+  
+  // whether to display log information on console
+  res = SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_GETCHECK,0,0);
+  gsdl_show_console = (res == 1);
 }
 
 
 static BOOL CALLBACK dialog_debug_proc(HWND hwndDlg, UINT uMsg, 
-										WPARAM wParam,LPARAM  lParam) {
-	int wNotifyCode = HIWORD(wParam);
-	int wID = LOWORD(wParam);
-
-	switch (uMsg) {
-	case WM_INITDIALOG:
-		// set current values
-		SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_SETCHECK,
-			gs_keep_log ? 1 : 0, 0);
-		SetDlgItemText(hwndDlg, LOG_NAME_BOX, gs_log_name);
-		SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_SETCHECK,
-			gs_show_console ? 1 : 0, 0);
-		dialog_debug_update_enables(hwndDlg);
-		return 1;
-
-	case WM_COMMAND:
-		if (wNotifyCode == BN_CLICKED) {
-			switch (wID) {
-			case ID_CANCEL_BUTTON:
-				EndDialog(hwndDlg, 0);
-				return 1;
-
-			case ID_OK_BUTTON:
-				read_dialog_debug_fields(hwndDlg);
-				EndDialog(hwndDlg, 1);
-				return 1;
-
-			case LOG_CHECK:
-				dialog_debug_update_enables(hwndDlg);
-				return 1;
-			}
-		}
-		return 0;
-
-	case WM_CLOSE:
-	case WM_DESTROY:
-	    EndDialog(hwndDlg, 0);
-		return 1;
-	}
-
-	return 0;
+				       WPARAM wParam,LPARAM  lParam) {
+  int wNotifyCode = HIWORD(wParam);
+  int wID = LOWORD(wParam);
+  
+  switch (uMsg) {
+  case WM_INITDIALOG:
+    // set current values
+    SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_SETCHECK,
+		       gsdl_keep_log ? 1 : 0, 0);
+    SetDlgItemText(hwndDlg, LOG_NAME_BOX, gsdl_log_name);
+    SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_SETCHECK,
+		       gsdl_show_console ? 1 : 0, 0);
+    dialog_debug_update_enables(hwndDlg);
+    return 1;
+    
+  case WM_COMMAND:
+    if (wNotifyCode == BN_CLICKED) {
+      switch (wID) {
+      case ID_CANCEL_BUTTON:
+	EndDialog(hwndDlg, 0);
+	return 1;
+	
+      case ID_OK_BUTTON:
+	read_dialog_debug_fields(hwndDlg);
+	EndDialog(hwndDlg, 1);
+	return 1;
+	
+      case LOG_CHECK:
+	dialog_debug_update_enables(hwndDlg);
+	return 1;
+      }
+    }
+    return 0;
+    
+  case WM_CLOSE:
+  case WM_DESTROY:
+    EndDialog(hwndDlg, 0);
+    return 1;
+  }
+  
+  return 0;
 }
 
@@ -736,52 +735,53 @@
 void Settings_Dialog(HWND window, int netscapeneeded)
 {
-	int old_gs_show_console = gs_show_console;
-	int old_gs_port_num = gs_port_num;
-
-	int res = 0;
-	
-
-	gs_netscapeneeded = netscapeneeded;
-
-	if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && 
-		(GetAsyncKeyState(VkKeyScan('d')) & 0x8000)) {
-		// control-D was pressed, display debug settings
-		// dialog box
-		res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG_DEBUG),
-			window, (DLGPROC)dialog_debug_proc);
-
-		if (res == 1) {
-			// only update if exited via the OK button
-			if (gs_keep_log) open_log_file(); 
-			else close_log_file();
-
-			// turn the console on/off if we need to
-			if (gs_show_console != old_gs_show_console) {
-				if (gs_show_console) activate_console ();
-				else deactivate_console ();
-			}
-		}
-
-	} else {
-		// display normal settings dialog box
-
-		// make sure everything is up-to-date
-		gs_check_browser_settings (netscapeneeded);
-
-		res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG2),
-			window, (DLGPROC)dialog_proc);
-
-		if (res == 1) {
-			// only update if exited via the OK button
-			if (gs_port_num != old_gs_port_num) {
-				EndHTTPServer();
-				StartHTTPServer(window);
-			}
-		}
-	}
-
-	// save the settings if we exited via the ok button
-	if (res == 1) {
-		write_settings();
-	}
-}
+  int old_gsdl_show_console = gsdl_show_console;
+  int old_gsdl_port_num = gsdl_port_num;
+  
+  int res = 0;
+  
+  gsdl_netscapeneeded = netscapeneeded;
+  
+  if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && 
+      (GetAsyncKeyState(VkKeyScan('d')) & 0x8000)) {
+    // control-D was pressed, display debug settings
+    // dialog box
+    res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG_DEBUG),
+		     window, (DLGPROC)dialog_debug_proc);
+    
+    if (res == 1) {
+      // only update if exited via the OK button
+      if (gsdl_keep_log) open_log_file(); 
+      else close_log_file();
+      
+      // turn the console on/off if we need to
+      if (gsdl_show_console != old_gsdl_show_console) {
+	if (gsdl_show_console) activate_console ();
+	else deactivate_console ();
+      }
+    }
+    
+  } else {
+    // display normal settings dialog box
+    
+    // make sure everything is up-to-date
+    gsdl_check_browser_settings (netscapeneeded);
+    
+    res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG2),
+		     window, (DLGPROC)dialog_proc);
+
+    if (res == 1) {
+      // only update if exited via the OK button
+      if (gsdl_port_num != old_gsdl_port_num) {
+	EndHTTPServer();
+	StartHTTPServer(window);
+      }
+    }
+  }
+  
+  // save the settings if we exited via the ok button
+  if (res == 1) {
+    write_settings();
+    // reset httpprefix in case port number was changed
+    //    configure_httpprefix ();
+  }
+}
Index: /trunk/gsdl/src/w32server/settings.h
===================================================================
--- /trunk/gsdl/src/w32server/settings.h	(revision 901)
+++ /trunk/gsdl/src/w32server/settings.h	(revision 902)
@@ -10,25 +10,26 @@
 #define GS_OTHER    2
 
+#include "text_t.h"
+#include "cfgread.h"
 
 // library settings
-extern char gs_enterlib[MAX_FILENAME_SIZE];    // enterlib
-extern char gs_gsdlhome[MAX_FILENAME_SIZE];    // gsdlhome
-extern char gs_macroshome[MAX_FILENAME_SIZE];  // macroshome
-extern char gs_gdbmhome[MAX_FILENAME_SIZE];    // gdbmhome
-extern char gs_indexhome[MAX_FILENAME_SIZE];   // indexhome
+extern text_t gsdl_enterlib;
+extern text_t gsdl_gsdlhome;
+extern text_t gsdl_gdbmhome;
+extern text_t gsdl_collections;
+extern colinfo_tmap gsdl_collectinfo;
 
-extern char gs_staticpages[MAX_FILENAME_SIZE]; // staticpages
+extern char gsdl_staticpages[MAX_FILENAME_SIZE];
 
 // debug settings
-extern char gs_log_name[MAX_FILENAME_SIZE];    // logfilename
-extern int gs_keep_log;                        // keeplog
-extern int gs_show_console;                    // consolelog
+extern char gsdl_log_name[MAX_FILENAME_SIZE];
+extern int gsdl_keep_log;
+extern int gsdl_show_console;
 
 // general settings
-extern int gs_port_num;                        // portnumber
-extern int gs_auto_enter;                      // autoenter
-extern int gs_browser;                         // browser
-extern char gs_browser_exe[MAX_FILENAME_SIZE]; // browserexe
-
+extern int gsdl_port_num;
+extern int gsdl_auto_enter;
+extern int gsdl_browser;
+extern char gsdl_browser_exe[MAX_FILENAME_SIZE];
 
 void Settings_Dialog(HWND window, int netscapeneeded);
@@ -37,5 +38,5 @@
 void write_settings ();
 
-void gs_check_browser_settings (int netscapeneeded);
+void gsdl_check_browser_settings (int netscapeneeded);
 
 #endif
