Index: /trunk/gsdl/src/w32server/cgiwrapper.cpp
===================================================================
--- /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 6022)
+++ /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 6023)
@@ -175,13 +175,4 @@
   return 0;
 }
-
-receptionist recpt;
-nullproto nproto;
-textstreambuf textstream;
-logstreambuf logstream;
-DWORD lastlibaccesstime;
-DWORD baseavailvirtual;
-text_t current_gsdlhome;
-colinfo_tmap translated_collectinfo;
 
 static void page_errormaincfg (const text_t &gsdlhome, const text_t &collection) {
@@ -333,13 +324,49 @@
 
 
-// returns 1 if successful, 0 if unsuccessful
-int gsdl_init () {
+receptionist recpt;
+nullproto nproto;
+collectset *cservers = NULL;
+
+textstreambuf textstream;
+logstreambuf logstream;
+DWORD lastlibaccesstime;
+DWORD baseavailvirtual;
+text_t current_gsdlhome;
+colinfo_tmap translated_collectinfo;
+  
+statusaction *astatusaction = NULL;
+pageaction *apageaction = NULL;
+pingaction *apingaction = NULL;
+tipaction *atipaction = NULL;
+queryaction *aqueryaction = NULL;
+documentaction *adocumentaction = NULL;
+usersaction *ausersaction = NULL;
+extlinkaction *anextlinkaction = NULL;
+collectoraction *acollectoraction = NULL;
+authenaction *aauthenaction = NULL;
+phindaction *aphindaction = NULL;
+configaction *aconfigaction = NULL;
+vlistbrowserclass *avlistbrowserclass = NULL;
+hlistbrowserclass *ahlistbrowserclass = NULL;
+datelistbrowserclass *adatelistbrowserclass = NULL;
+invbrowserclass *ainvbrowserclass = NULL;
+pagedbrowserclass *apagedbrowserclass = NULL;
+htmlbrowserclass *ahtmlbrowserclass = NULL;
+phindbrowserclass *aphindbrowserclass = NULL;
+
+// returns 1 if successful, 0 if unsuccessful (note that as well as being
+// called when the server first starts up this function is called when the
+// "restart library" button is pressed)
+int gsdl_init (bool atStartup) {
+
+  if (atStartup) {
 #if defined (GSDL_USE_IOS_H)
-  cerr = &logstream;
-  cout = &textstream;
+    cerr = &logstream;
+    cout = &textstream;
 #else
-  cerr.rdbuf(&logstream);
-  cout.rdbuf(&textstream);
+    cerr.rdbuf(&logstream);
+    cout.rdbuf(&textstream);
 #endif
+  }
 
   // collection should be set to "" unless in collection specific mode -
@@ -350,18 +377,22 @@
   text_tset collections;
 
-  // 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;
-
-  collectset *cservers = new collectset();
+  if (atStartup) {
+    // 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;
+  }    
+
+  // deleting cservers clears all the collection servers 
+  if (cservers != NULL) delete cservers;
+
+  cservers = new collectset();
 
   // get all collections from each gsdlhome (this relies 
   // on there not being more than one collection with the same 
   // name)
-
   if (!collection.empty()) {
     // collection specific receptionist - one collection, one gsdlhome
@@ -459,73 +490,111 @@
   
   // add the protocol to the receptionist
-  recpt.add_protocol (&nproto);
+  if (atStartup) recpt.add_protocol (&nproto);
   
   // the list of actions.
-  statusaction *astatusaction = new statusaction();
-  astatusaction->set_receptionist (&recpt);
-  recpt.add_action (astatusaction);
-  
-  pageaction *apageaction = new pageaction();
-  apageaction->set_receptionist (&recpt);
-  recpt.add_action (apageaction);
-  
-  pingaction *apingaction = new pingaction();
-  recpt.add_action (apingaction);
-  
-  tipaction *atipaction = new tipaction();
-  recpt.add_action (atipaction);
-  
-  queryaction *aqueryaction = new queryaction();
-  aqueryaction->set_receptionist (&recpt);
-  recpt.add_action (aqueryaction);
-  
-  documentaction *adocumentaction = new documentaction();
-  adocumentaction->set_receptionist (&recpt);
-  recpt.add_action (adocumentaction);
-  
-  usersaction *ausersaction = new usersaction();
-  recpt.add_action (ausersaction);
-
-  extlinkaction *anextlinkaction = new extlinkaction();
-  recpt.add_action (anextlinkaction);
-
-  collectoraction *acollectoraction = new collectoraction();
-  acollectoraction->set_receptionist (&recpt);
-  recpt.add_action (acollectoraction);
-  
-  authenaction *aauthenaction = new authenaction();
-  aauthenaction->set_receptionist(&recpt);
-  recpt.add_action (aauthenaction);
-
-  phindaction *aphindaction = new phindaction();
-  recpt.add_action (aphindaction);
-  
-  configaction *aconfigaction = new configaction();
-  aconfigaction->set_receptionist(&recpt);
-  recpt.add_action (aconfigaction);
+  if (astatusaction == NULL) {
+    astatusaction = new statusaction();
+    astatusaction->set_receptionist (&recpt);
+    recpt.add_action (astatusaction);
+  }
+  
+  if (apageaction == NULL) {
+    apageaction = new pageaction();
+    apageaction->set_receptionist (&recpt);
+    recpt.add_action (apageaction);
+  }
+  
+  if (apingaction == NULL) {
+    apingaction = new pingaction();
+    recpt.add_action (apingaction);
+  }
+  
+  if (atipaction == NULL) {
+    atipaction = new tipaction();
+    recpt.add_action (atipaction);
+  }
+  
+  if (aqueryaction == NULL) {
+    aqueryaction = new queryaction();
+    aqueryaction->set_receptionist (&recpt);
+    recpt.add_action (aqueryaction);
+  }
+  
+  if (adocumentaction == NULL) {
+    adocumentaction = new documentaction();
+    adocumentaction->set_receptionist (&recpt);
+    recpt.add_action (adocumentaction);
+  }
+  
+  if (ausersaction == NULL) {
+    ausersaction = new usersaction();
+    recpt.add_action (ausersaction);
+  }
+
+  if (anextlinkaction == NULL) {
+    anextlinkaction = new extlinkaction();
+    recpt.add_action (anextlinkaction);
+  }
+
+  if (acollectoraction == NULL) {
+    acollectoraction = new collectoraction();
+    acollectoraction->set_receptionist (&recpt);
+    recpt.add_action (acollectoraction);
+  }
+  
+  if (aauthenaction == NULL) {
+    aauthenaction = new authenaction();
+    aauthenaction->set_receptionist(&recpt);
+    recpt.add_action (aauthenaction);
+  }
+
+  if (aphindaction == NULL) {
+    aphindaction = new phindaction();
+    recpt.add_action (aphindaction);
+  }
+  
+  if (aconfigaction == NULL) {
+    aconfigaction = new configaction();
+    aconfigaction->set_receptionist(&recpt);
+    recpt.add_action (aconfigaction);
+  }
 
 
   // 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);
-
-  phindbrowserclass *aphindbrowserclass = new phindbrowserclass();;
-  recpt.add_browser (aphindbrowserclass);
+  if (avlistbrowserclass == NULL) {
+    avlistbrowserclass = new vlistbrowserclass();
+    recpt.add_browser (avlistbrowserclass);
+    recpt.setdefaultbrowser ("VList");
+  }
+
+  if (ahlistbrowserclass == NULL) {
+    ahlistbrowserclass = new hlistbrowserclass();
+    recpt.add_browser (ahlistbrowserclass);
+  }
+
+  if (adatelistbrowserclass == NULL) {
+    adatelistbrowserclass = new datelistbrowserclass();
+    recpt.add_browser (adatelistbrowserclass);
+  }
+
+  if (ainvbrowserclass == NULL) {
+    ainvbrowserclass = new invbrowserclass();
+    recpt.add_browser (ainvbrowserclass);
+  }
+
+  if (apagedbrowserclass == NULL) {
+    apagedbrowserclass = new pagedbrowserclass();
+    recpt.add_browser (apagedbrowserclass);
+  }
+
+  if (ahtmlbrowserclass == NULL) {
+    ahtmlbrowserclass = new htmlbrowserclass();
+    recpt.add_browser (ahtmlbrowserclass);
+  }
+
+  if (aphindbrowserclass == NULL) {
+    aphindbrowserclass = new phindbrowserclass();;
+    recpt.add_browser (aphindbrowserclass);
+  }
   
   // set defaults
Index: /trunk/gsdl/src/w32server/cgiwrapper.h
===================================================================
--- /trunk/gsdl/src/w32server/cgiwrapper.h	(revision 6022)
+++ /trunk/gsdl/src/w32server/cgiwrapper.h	(revision 6023)
@@ -40,5 +40,5 @@
 // sets up the library
 // returns 1 if successful, 0 if unsuccessful
-int gsdl_init ();
+int gsdl_init (bool atStartup = true);
 
 // returns 0 if the directories cant be found
Index: /trunk/gsdl/src/w32server/fnord.cpp
===================================================================
--- /trunk/gsdl/src/w32server/fnord.cpp	(revision 6022)
+++ /trunk/gsdl/src/w32server/fnord.cpp	(revision 6023)
@@ -322,4 +322,11 @@
   int res;
   
+  if (infostring == strrestartlib) {
+
+    // the "restart library" button was pressed so we want to reinitialize
+    // greenstone, read in all the macrofiles again, etc.
+    gsdl_init(false);
+  }
+
   // get the url and attempt to start a browser
   char *localname = GetLocalName(NULL);
