Index: trunk/gsdl/src/colservr/collectset.cpp
===================================================================
--- trunk/gsdl/src/colservr/collectset.cpp	(revision 2371)
+++ trunk/gsdl/src/colservr/collectset.cpp	(revision 2545)
@@ -105,5 +105,5 @@
 	  
 	  if (buildtype == "mg") {
-	    mgsearchclass *mgsearch = new mgsearchclass();
+	    mgsearch = new mgsearchclass();
 	    
 	    // add a query filter
@@ -118,15 +118,13 @@
 	    mggdbmsource->set_mgsearchptr (mgsearch);
 	    cserver->add_source (mggdbmsource);
-	  }
-#ifndef __WIN32__
-	  
-	  else if (buildtype == "mgpp") {
-	    
-	    mgppsearchclass *mgsearch = new mgppsearchclass();
+
+	  } else if (buildtype == "mgpp") {
+	    
+	    mgppsearch = new mgppsearchclass();
 	    
 	    // add a query filter
 	    mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
 	    queryfilter->set_gdbmptr (gdbmhandler);
-	    queryfilter->set_mgsearchptr (mgsearch);
+	    queryfilter->set_mgsearchptr (mgppsearch);
 	    cserver->add_filter (queryfilter);
 	    
@@ -137,5 +135,4 @@
 	    cserver->add_source (mggdbmsource);   
 	  }
-#endif
 	  
 	  // inform collection server and everything it contains about its
@@ -231,6 +228,5 @@
   // do this would be preferable though - Stefan.
   text_t buildtype = "mg"; // mg is default
-  // (for now we'll just ignore mgpp if on windows)
-#ifndef __WIN32__
+
   text_tarray cfgline;
   text_t key;
@@ -253,5 +249,4 @@
   }
   delete build_cfgc;
-#endif
 
   collectserver *cserver = new collectserver();
@@ -269,5 +264,5 @@
  
   if (buildtype == "mg") {
-    mgsearchclass *mgsearch = new mgsearchclass();
+    mgsearch = new mgsearchclass();
  
     // add a query filter
@@ -282,16 +277,13 @@
     mggdbmsource->set_mgsearchptr (mgsearch);
     cserver->add_source (mggdbmsource);
-  }
-
-#ifndef __WIN32__
-
-  else if (buildtype == "mgpp") {
+
+  } else if (buildtype == "mgpp") {
       
-    mgppsearchclass *mgsearch = new mgppsearchclass();
+    mgppsearch = new mgppsearchclass();
 
     // add a query filter
     mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
     queryfilter->set_gdbmptr (gdbmhandler);
-    queryfilter->set_mgsearchptr (mgsearch);
+    queryfilter->set_mgsearchptr (mgppsearch);
     cserver->add_filter (queryfilter);
       
@@ -303,5 +295,4 @@
     
   }
-#endif    
 
   // inform collection server and everything it contains about its
@@ -324,4 +315,12 @@
 // cleans up all collectservers when the program exits.
 void collectset::remove_collection (const text_t &collection, ostream &logout) {
+
+  // first unload any cached mg databases - we may need to do something
+  // similar to this for mgpp too
+  if (mgsearch != NULL) {
+    mgsearch->unload_database();
+  }
+
+  // now delete the collection server object
   collectservermapclass::iterator here = cservers.begin();
   collectservermapclass::iterator end = cservers.end();
Index: trunk/gsdl/src/colservr/collectset.h
===================================================================
--- trunk/gsdl/src/colservr/collectset.h	(revision 2371)
+++ trunk/gsdl/src/colservr/collectset.h	(revision 2545)
@@ -16,4 +16,6 @@
  protected:
   collectservermapclass cservers;
+  mgsearchclass         *mgsearch;
+  mgppsearchclass       *mgppsearch;
   int                   noofservers;
   text_t                httpdomain;
Index: trunk/gsdl/src/colservr/mgppsearch.cpp
===================================================================
--- trunk/gsdl/src/colservr/mgppsearch.cpp	(revision 2371)
+++ trunk/gsdl/src/colservr/mgppsearch.cpp	(revision 2545)
@@ -155,9 +155,9 @@
   // term info
   termfreqclass term;
-  for (int i=0; i<(int)queryResult.termFreqs.size(); i++) {
+  for (int k=0; k<(int)queryResult.termFreqs.size(); k++) {
     term.clear();
-    term.termstr = GetCStr(queryResult.termFreqs[i].term);
+    term.termstr = GetCStr(queryResult.termFreqs[k].term);
     term.termstemstr = term.termstr;
-    term.termfreq = queryResult.termFreqs[i].termFreq;
+    term.termfreq = queryResult.termFreqs[k].termFreq;
     queryresult.terms.push_back(term);
     queryresult.orgterms.push_back(term); // should this change??
Index: trunk/gsdl/src/colservr/mgsearch.cpp
===================================================================
--- trunk/gsdl/src/colservr/mgsearch.cpp	(revision 2371)
+++ trunk/gsdl/src/colservr/mgsearch.cpp	(revision 2545)
@@ -22,114 +22,5 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id$
- *
  *********************************************************************/
-
-/*
-   $Log$
-   Revision 1.33  2001/03/20 09:34:41  sjboddie
-   removed some debugging lines
-
-   Revision 1.32  2001/03/12 23:57:17  say1
-   added command to strip the corbaserver (makes it much smaller)
-
-   Revision 1.31  2001/02/19 02:02:00  sjboddie
-   Set mg's accumulator method back to 'list' as the recent change appeared
-   to introduce a new (and more serious) bug while fixing the old bug. For
-   now we'll just have to live with it the way it is.
-
-   Revision 1.30  2001/02/15 22:58:11  kjm18
-   added a comment
-
-   Revision 1.29  2001/02/15 03:57:02  kjm18
-   changed accumulator_method for mg to be array rather than list - it was
-   getting some weird results with ranked searches
-
-   Revision 1.28  2001/01/25 18:26:44  cs025
-   Included CORBA branch for first time
-
-   Revision 1.22.2.1  2000/04/04 15:02:32  cs025
-   Corba first commit
-
-   Revision 1.22  1999/09/24 02:41:21  rjmcnab
-   change to use has_unicode_letdig in text_t
-
-   Revision 1.21  1999/09/21 21:41:41  sjboddie
-   fixed an error in what I committed last
-
-   Revision 1.20  1999/09/21 11:59:26  sjboddie
-   added Maxdocs queryfilter option (which may be -1 for 'all)
-
-   Revision 1.19  1999/09/07 22:52:52  rjmcnab
-   Seems to be an error in mg for retrieving documents using a paragraph
-   based index for some cases. Just added a work around (loads the default
-   index every time).
-
-   Revision 1.18  1999/09/07 04:57:22  sjboddie
-   added gpl notice
-
-   Revision 1.17  1999/08/31 22:42:41  rjmcnab
-   A couple of minor things.
-
-   Revision 1.16  1999/08/25 04:51:06  sjboddie
-   small change to allow for searching using boolean operators
-
-   Revision 1.15  1999/07/16 08:35:03  rjmcnab
-   Fixed a weird bug to do with a faulty case statement.
-
-   Revision 1.14  1999/07/16 03:42:22  sjboddie
-   changed isApprox
-
-   Revision 1.13  1999/07/16 00:12:46  sjboddie
-   removed all the old post-processing stuff
-
-   Revision 1.12  1999/07/07 06:17:47  rjmcnab
-   broke search_index into index+subcollection+language
-   within mgsearch
-
-   Revision 1.11  1999/07/05 21:06:43  rjmcnab
-   Disabled quoted strings.
-
-   Revision 1.10  1999/07/01 09:29:19  rjmcnab
-   Changes for better reporting of number documents which match a query. Changes
-   should still work as before with older versions of mg.
-
-   Revision 1.9  1999/07/01 03:54:48  rjmcnab
-   Added code to plug in the equivalent terms of each of the query terms.
-   Also added a function to get a raw utf8 encoded mg document (for speeding
-   up a phrase matching function)
-
-   Revision 1.8  1999/06/30 04:04:12  rjmcnab
-   made stemming functions available from mgsearch and made the stems
-   for the query terms available in queryinfo
-
-   Revision 1.7  1999/06/27 22:07:27  sjboddie
-   got rid of all the old functions for dealing with dir indexes
-
-   Revision 1.6  1999/06/09 00:41:32  sjboddie
-   phrase searching now uses case-folding if it's turned on
-
-   Revision 1.5  1999/02/21 22:31:35  rjmcnab
-
-   Removed locateinfo.
-
-   Revision 1.4  1999/02/03 01:13:27  sjboddie
-
-   Got interface to handle subcollections and language subcollections -
-   committed changes made to some of the collections
-
-   Revision 1.3  1999/01/19 01:38:17  rjmcnab
-
-   Made the source more portable.
-
-   Revision 1.2  1999/01/12 01:51:02  rjmcnab
-
-   Standard header.
-
-   Revision 1.1  1999/01/08 09:02:16  rjmcnab
-
-   Moved from src/library.
-
- */
 
 #include "gsdlconf.h"
@@ -659,2 +550,9 @@
 }
 
+// unload_database simply calls mgq's close_all_databases function to clear
+// any cached databases - this is useful when attempting to completely
+// remove all trace of a collectionserver at runtime (when using a
+// persistent version of Greenstone like the windows local library)
+void mgsearchclass::unload_database () {
+  close_all_databases();
+}
Index: trunk/gsdl/src/colservr/mgsearch.h
===================================================================
--- trunk/gsdl/src/colservr/mgsearch.h	(revision 2371)
+++ trunk/gsdl/src/colservr/mgsearch.h	(revision 2545)
@@ -53,5 +53,5 @@
   // the search results are returned in queryresults
   // search returns 'true' if it was able to do a search
-   bool search(const queryparamclass &queryparams, 
+  bool search(const queryparamclass &queryparams, 
 	      queryresultsclass &queryresults);
   
@@ -79,4 +79,12 @@
 		   char *&UDoc, int &ULen);
 
+  // unload_database simply calls mgq's close_all_databases function to
+  // clear any cached databases - this is useful when attempting to
+  // completely remove all trace of a collectionserver at runtime (when
+  // using a persistent version of Greenstone like the windows local
+  // library)
+  void mgsearchclass::unload_database ();
+
+
 protected:
 
Index: trunk/gsdl/src/colservr/win32.mak
===================================================================
--- trunk/gsdl/src/colservr/win32.mak	(revision 2371)
+++ trunk/gsdl/src/colservr/win32.mak	(revision 2545)
@@ -35,4 +35,5 @@
 DEFS = -D__WIN32__ -DHAVE_CONFIG_H -DPARADOCNUM -D_LITTLE_ENDIAN -DSHORT_SUFFIX
 INCLUDES = -I"$(GSDLHOME)" -I"$(GSDLHOME)\lib" -I"$(GSDLHOME)\src\colservr" \
+	   -I"$(GSDLHOME)\src\mgpp\lib" -I"$(GSDLHOME)\src\mgpp\text" \
 	   -I"$(GSDLHOME)\src\recpt" -I"$(GSDLHOME)\packages\mg" \
 	   -I"$(GSDLHOME)\packages\mg\lib" -I"$(GSDLHOME)\packages\mg\src\text" \
@@ -60,5 +61,5 @@
           colservrconfig.h maptools.h filter.h source.h browsefilter.h \
           queryfilter.h mgqueryfilter.h mggdbmsource.h phrasesearch.h \
-	  phrasequeryfilter.h collectset.h
+	  phrasequeryfilter.h collectset.h mgppsearch.h mgppqueryfilter.h
 
 SOURCES = mgq.c search.cpp mgsearch.cpp querycache.cpp queryinfo.cpp \
@@ -66,5 +67,5 @@
 	  source.cpp browsefilter.cpp queryfilter.cpp mgqueryfilter.cpp \
 	  mggdbmsource.cpp phrasesearch.cpp phrasequeryfilter.cpp \
-	  collectset.cpp
+	  collectset.cpp mgppsearch.cpp mgppqueryfilter.cpp
 
 OBJECTS = mgq.obj search.obj mgsearch.obj querycache.obj queryinfo.obj \
@@ -72,5 +73,5 @@
 	  source.obj browsefilter.obj queryfilter.obj mgqueryfilter.obj \
 	  mggdbmsource.obj phrasesearch.obj phrasequeryfilter.obj \
-	  collectset.obj
+	  collectset.obj mgppsearch.obj mgppqueryfilter.obj
 
 all : gsdlcolservr.lib
