Index: /trunk/gsdl/lib/text_t.cpp
===================================================================
--- /trunk/gsdl/lib/text_t.cpp	(revision 2486)
+++ /trunk/gsdl/lib/text_t.cpp	(revision 2487)
@@ -28,4 +28,7 @@
 /*
    $Log$
+   Revision 1.21  2001/06/01 02:51:28  sjboddie
+   Changes to get phind working under windows
+
    Revision 1.20  2001/01/25 18:26:44  cs025
    Included CORBA branch for first time
@@ -262,5 +265,19 @@
 }
 
-
+unsigned long text_t::getulong () const
+{
+  unsigned long i = 0;
+
+  const_iterator here = text.begin();
+  const_iterator end = text.end();
+
+  while ((here != end) && (*here >= '0') && (*here <= '9'))
+    {
+      i = 10*i + (*here - '0');
+      here++;
+    }
+
+  return i;
+}
 
 void text_t::appendcarr (char *s, size_type len)
Index: /trunk/gsdl/lib/text_t.h
===================================================================
--- /trunk/gsdl/lib/text_t.h	(revision 2486)
+++ /trunk/gsdl/lib/text_t.h	(revision 2487)
@@ -147,4 +147,7 @@
   int getint () const;
 
+  // same as getint but returns an unsigned long
+  unsigned long getulong () const;
+
   // support for arrays of chars
   void appendcarr (char *s, size_type len);
Index: /trunk/gsdl/macros/document.dm
===================================================================
--- /trunk/gsdl/macros/document.dm	(revision 2486)
+++ /trunk/gsdl/macros/document.dm	(revision 2487)
@@ -76,6 +76,5 @@
 <APPLET CODEBASE="_httpprefix_/src/phind/client" CODE="Phind.class" WIDTH=500 HEIGHT=400>
   <PARAM NAME=library      VALUE="_gwcgi_">
-  <PARAM NAME=phindcgi     VALUE="phindcgi">
-
+  <PARAM NAME=phindcgi     VALUE="_gwcgi_?a=phind">
   <PARAM NAME=collection   VALUE="_cgiargc_">
   <PARAM NAME=classifier   VALUE="_phindnumber_">
Index: /trunk/gsdl/packages/mg/src/text/WIN32.MAK
===================================================================
--- /trunk/gsdl/packages/mg/src/text/WIN32.MAK	(revision 2486)
+++ /trunk/gsdl/packages/mg/src/text/WIN32.MAK	(revision 2487)
@@ -205,4 +205,5 @@
 	  copy %%i "$(GSDLHOME)\bin\windows"
 
+# words$o,  removed to avoid conflict with mgpp libtextin.a
 LIB_OBJS = \
 	query_term_list$o \
@@ -212,5 +213,5 @@
 	read_line$o mg_errors$o backend$o invf_get$o \
 	term_lists$o bool_tree$o bool_parser$o bool_optimiser$o \
-	bool_query$o words$o
+	bool_query$o
 
 libtextin.lib: $(LIB_OBJS)
Index: /trunk/gsdl/perllib/classify/phind.pm
===================================================================
--- /trunk/gsdl/perllib/classify/phind.pm	(revision 2486)
+++ /trunk/gsdl/perllib/classify/phind.pm	(revision 2487)
@@ -84,4 +84,20 @@
 
 
+%wanted_index_files = ('td'=>1,
+		       't'=>1,
+		       'ti'=>1,
+		       'tl'=>1,
+		       'tsd'=>1,
+		       'idb'=>1,
+		       'ib1'=>1,
+		       'ib2'=>1,
+		       'ib3'=>1,
+		       'i'=>1,
+		       'il'=>1,
+		       'w'=>1,
+		       'wa'=>1);
+
+
+
 # Phrase delimiter symbols - these should be abstracted out someplace
 
@@ -110,12 +126,7 @@
     print $out "Checking Phind phrase browser requirements...\n";
 
-    # Make sure we're not in windows
-    if ($ENV{'GSDLOS'} =~ /windows/i) {
-	print STDERR "Sorry - Phind currently only works under Unix";
-	exit(1);
-    }
-
     # Ensure the Phind generate scripts are in place
     my $file1 = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "suffix");
+    $file1 .= ".exe" if $ENV{'GSDLOS'} =~ /^windows$/;
     my $src = &util::filename_cat($ENV{'GSDLHOME'}, "src", "phind", "generate");
 
@@ -130,4 +141,5 @@
     # Ensure the Phind CGI script is in place
     $file1 = &util::filename_cat($ENV{'GSDLHOME'}, "cgi-bin", "phindcgi");
+    $file1 .= ".exe" if $ENV{'GSDLOS'} =~ /^windows$/;
     $src =  &util::filename_cat($ENV{'GSDLHOME'}, "src", "phind", "host");
 
@@ -184,4 +196,6 @@
     }
     $self->{'builddir'} = $builddir;
+
+    $self->{'total'} = 0;
    
     return bless $self, $class;
@@ -251,6 +265,6 @@
     
     # record this file
-    my $total++;
-    print "file $total: $file\n" if ($self->{'$verbosity'});
+    $self->{'total'} ++;
+    print "file $self->{'total'}: $file\n" if ($self->{'$verbosity'});
     
 
@@ -335,9 +349,14 @@
     my $self = shift (@_);
 
+    close $self->{'dochandle'};
     close $self->{'txthandle'};
     my $verbosity = $self->{'verbosity'};
     my $out = $self->{'outhandle'};
     my $phinddir = $self->{'phinddir'};
-    my $exe = &util::get_os_exe ();
+
+    my $osextra = "";
+    if ($ENV{'GSDLOS'} !~ /^windows$/i) {
+	$osextra = " -d /";
+    }
 
     if ($verbosity) {
@@ -362,55 +381,55 @@
     print $out "\nSorting and renumbering phrases for input to mgpp\n" if $verbosity;
     &renumber_phrases($self);
-    
-    # Create the mg phrase database
 
     print $out "\nCreating phrase databases\n";
     my $mg_input = &util::filename_cat($phinddir, "pdata.txt");
-    my $mg_stem = "pdata";
-
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T1 $mg_input", $verbosity, $out);
-    &execute("mgpp_compression_dict$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T2 $mg_input", $verbosity, $out);
+    my $mg_stem = &util::filename_cat($phinddir, "pdata");
+
+    &execute("mgpp_passes $osextra -f $mg_stem -T1 $mg_input", $verbosity, $out);
+    &execute("mgpp_compression_dict $osextra -f $mg_stem", $verbosity, $out);
+    &execute("mgpp_passes $osextra -f $mg_stem -T2 $mg_input", $verbosity, $out);
 
     # create the mg index of words
     print $out "\nCreating word-level search indexes\n";
     $mg_input = &util::filename_cat($phinddir, "pword.txt");
-    $mg_stem = "pword";
-
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T1 -I1 $mg_input", $verbosity, $out);
-    &execute("mgpp_compression_dict$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-    &execute("mgpp_perf_hash_build$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T2 -I2 $mg_input", $verbosity, $out);
-    &execute("mgpp_weights_build$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-    &execute("mgpp_invf_dict$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-
-    &execute("mgpp_stem_idx$exe -d $phinddir -f $mg_stem -s 1", $verbosity, $out);
-    &execute("mgpp_stem_idx$exe -d $phinddir -f $mg_stem -s 2", $verbosity, $out);
-    &execute("mgpp_stem_idx$exe -d $phinddir -f $mg_stem -s 3", $verbosity, $out);
+    $mg_stem = &util::filename_cat($phinddir, "pword");
+
+    &execute("mgpp_passes $osextra -f $mg_stem -T1 -I1 $mg_input", $verbosity, $out);
+    &execute("mgpp_compression_dict $osextra -f $mg_stem", $verbosity, $out);
+    &execute("mgpp_perf_hash_build $osextra -f $mg_stem", $verbosity, $out);
+    &execute("mgpp_passes $osextra -f $mg_stem -T2 -I2 $mg_input", $verbosity, $out);
+    &execute("mgpp_weights_build $osextra -f $mg_stem", $verbosity, $out);
+    &execute("mgpp_invf_dict $osextra -f $mg_stem", $verbosity, $out);
+
+    &execute("mgpp_stem_idx $osextra -f $mg_stem -s 1", $verbosity, $out);
+    &execute("mgpp_stem_idx $osextra -f $mg_stem -s 2", $verbosity, $out);
+    &execute("mgpp_stem_idx $osextra -f $mg_stem -s 3", $verbosity, $out);
 
     # create the mg document information database
     print $out "\nCreating document information databases\n";
     $mg_input = &util::filename_cat($phinddir, "docs.txt");
-    $mg_stem = "docs";
-
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T1 $mg_input", $verbosity, $out);
-    &execute("mgpp_compression_dict$exe -d $phinddir -f $mg_stem", $verbosity, $out);
-    &execute("mgpp_passes$exe -d $phinddir -f $mg_stem -T2 $mg_input", $verbosity, $out);
-
+    $mg_stem = &util::filename_cat($phinddir, "docs");
+
+    &execute("mgpp_passes $osextra -f $mg_stem -T1 $mg_input", $verbosity, $out);
+    &execute("mgpp_compression_dict $osextra -f $mg_stem", $verbosity, $out);
+    &execute("mgpp_passes $osextra -f $mg_stem -T2 $mg_input", $verbosity, $out);
 
     # Tidy up stray files
     if (!$self->{'untidy'}) {
 	print $out "\nCleaning up\n" if ($verbosity > 2);
-	&util::rm("$phinddir/clauses", "$phinddir/clauses.numbers", 
-		  "$phinddir/clauses.vocab", "$phinddir/clauses.stats", 
-		  "$phinddir/phrases", "$phinddir/phrases.3", "$phinddir/docs.txt",
-		  "$phinddir/pdata.txt", "$phinddir/pword.txt");
-	my $outfile = 1;
-	while (-e "$phinddir/outPhrase.$outfile") {
-	    &util::rm("$phinddir/outPhrase.$outfile");
-	    $outfile++;
-	}
-    }
-
+	opendir (DIR, $phinddir) || die;
+	my @files = readdir DIR;
+	closedir DIR;
+	
+	foreach $file (@files) {
+	    next if $file =~ /^\.\.?$/;
+	    my ($suffix) = $file =~ /\.([^\.]+)$/;
+	    if (!defined $suffix || !defined $wanted_index_files{$suffix}) {
+		# delete it!
+		print $out "deleting $file\n"; # if $verbosity > 2;
+		&util::rm (&util::filename_cat ($phinddir, $file));
+	    }
+	}
+    }
 
     # Return the information about the classifier that we'll later want to
@@ -591,7 +610,8 @@
     my ($command, $verbosity, $outhandle) = @_;
     print $outhandle "Executing: $command\n"  if ($verbosity > 2);
+    $! = 0;
     my $status = system($command);
     if ($status != 0) {
-	print STDERR "phind - Error executing $command: $!\n";
+	print STDERR "phind - Error executing '$command': $!\n";
 	exit($status);
     }
@@ -1264,4 +1284,5 @@
 	$thesaurusdata{$phindid} = "$symbols:$linkcounter:$relations";
     }
+    close TH;
 
     # 6. 
@@ -1346,5 +1367,5 @@
 	$symbol[$i++] = $_;
     }
-
+    close V;
 
     # 2. 
Index: /trunk/gsdl/src/phind/client/Phind.java
===================================================================
--- /trunk/gsdl/src/phind/client/Phind.java	(revision 2486)
+++ /trunk/gsdl/src/phind/client/Phind.java	(revision 2487)
@@ -403,10 +403,10 @@
 
 	// Build the query
-	String query = phindcgi_address + "x=1&c=" + collection + "&d=" + classifier;
+	String query = phindcgi_address + "pxml=1&c=" + collection + "&pc=" + classifier;
 
 	if (keyKnown) {
-	  query = query + "&n=" + word;
+	  query = query + "&ppnum=" + word;
 	} else {
-	  query = query + "&p=" + word;
+	  query = query + "&pptext=" + word;
 	}
 
@@ -448,7 +448,7 @@
 	}
 
-	query = query + "&e=" + first_e + "&f=" + last_e
-                      + "&h=" + first_d + "&i=" + last_d
-                      + "&k=" + first_l + "&l=" + last_l;
+	query = query + "&pfe=" + first_e + "&ple=" + last_e
+                      + "&pfd=" + first_d + "&pld=" + last_d
+                      + "&pfl=" + first_l + "&pll=" + last_l;
 
 	// Send the query to the phindcgi program 
@@ -497,12 +497,12 @@
 	    // there is not protocol and host
 	    URL document = getDocumentBase();
-	    address = "http://" + document.getHost() + address;
+	    address = "http://" + document.getHost() + ":" + document.getPort() + address;
 	} else {
-	    // this URL is relative to the dirwectory the document is in
+	    // this URL is relative to the directory the document is in
 	    URL document = getDocumentBase();
 	    String directory = document.getFile();
 	    int end = directory.lastIndexOf('/');
 	    directory = directory.substring(0,end + 1);
-	    address = "http://" + document.getHost() + directory + address;
+	    address = "http://" + document.getHost() + ":" + document.getPort() + directory + address;
 
 	}
Index: /trunk/gsdl/src/phind/generate/phrase.cpp
===================================================================
--- /trunk/gsdl/src/phind/generate/phrase.cpp	(revision 2486)
+++ /trunk/gsdl/src/phind/generate/phrase.cpp	(revision 2487)
@@ -26,8 +26,18 @@
  *********************************************************************/
 
-#include <iostream.h>
 #include <assert.h>
-#include <vector.h>
 #include <stdio.h>
+
+#if defined(GSDL_USE_STL_H)
+#  include <vector.h>
+#else
+#  include <vector>
+#endif
+
+#if defined(GSDL_USE_IOS_H)
+#  include <iostream.h>
+#else
+#  include <iostream>
+#endif
 
 #include "suffix.h"
Index: /trunk/gsdl/src/phind/generate/phrase.h
===================================================================
--- /trunk/gsdl/src/phind/generate/phrase.h	(revision 2486)
+++ /trunk/gsdl/src/phind/generate/phrase.h	(revision 2487)
@@ -25,4 +25,15 @@
  *
  *********************************************************************/
+
+#ifndef PHRASE_H
+#define PHRASE_H
+
+#if defined(GSDL_USE_STL_H)
+#  include <vector.h>
+#else
+#  include <vector>
+#endif
+
+#include "suffix.h"
 
 class Phrase {
@@ -61,4 +72,9 @@
   Phrase(symbol *words, cellcount size, int direction);
 
+  // An empty phrase can be created without arguments, but is 
+  // good for nothing and may not be used with any public fuctions.
+  // We therefore only use it internally.
+  Phrase();
+
   // Represent the phrase as  a string
   char *toString();
@@ -87,9 +103,4 @@
 
 private:
-
-  // An empty phrase can be created without arguments, but is 
-  // good for nothing and may not be used with any public fuctions.
-  // We therefore only use it internally.
-  Phrase();
 
   // Does the phrase have a unique suffix/prefix extension?
@@ -120,6 +131,4 @@
   int expandWhileUniqueSuffixExtension();
   int expandWhileUniquePrefixExtension();
-
-
 };
 
@@ -128,5 +137,3 @@
 bool isLonger(Phrase p1, Phrase p2);
 
-
-
-
+#endif
Index: /trunk/gsdl/src/phind/generate/suffix.cpp
===================================================================
--- /trunk/gsdl/src/phind/generate/suffix.cpp	(revision 2486)
+++ /trunk/gsdl/src/phind/generate/suffix.cpp	(revision 2487)
@@ -28,6 +28,4 @@
 
 #include <assert.h>
-#include <fstream.h>
-#include <iostream.h>
 #include <math.h>
 #include <stdio.h>
@@ -35,12 +33,28 @@
 #include <string.h>
 
-#include <algo.h>
-#include <heap.h>
-#include <vector.h>
+#if defined(GSDL_USE_IOS_H)
+#  include <fstream.h>
+#  include <iostream.h>
+#else
+#  include <fstream>
+#  include <iostream>
+#endif
+
+#if defined(GSDL_USE_STL_H)
+#  if defined(GSDL_USE_ALGO_H)
+#    include <algo.h>
+#  else
+#    include <algorithm.h>
+#  endif
+#  include <vector.h>
+#else
+#  include <algorithm>
+#  include <vector>
+#endif
+#include <stl_heap.h>
+
 
 #include "suffix.h"
 #include "phrase.h"
-
-
 
 // Global variables declared in suffix.h
@@ -138,8 +152,8 @@
 
   // Create the suffix & prefix arrays
-  suffixArray = new (symbol *)[inputLength];
-  prefixArray = new (symbol *)[inputLength];
-  suffixCheck = new (check)[inputLength];
-  prefixCheck = new (check)[inputLength];
+  suffixArray = new symbol *[inputLength];
+  prefixArray = new symbol *[inputLength];
+  suffixCheck = new check[inputLength];
+  prefixCheck = new check[inputLength];
   if (prefixCheck == NULL) {
     cerr << "Suffix error: not enough memory to hold " << inputLength
@@ -169,10 +183,10 @@
   // each phrase occurs in each document.  The number of documents in
   // which a phrase occurs is stored in df.
-  frequency documentFrequency[numberOfDocuments];
+  frequency *documentFrequency = new frequency[numberOfDocuments];
   frequency df;
 
   // documentArray will be searched in order to discover which document
   // each phrase occurs in.
-  documentArray = new (symbol *)[numberOfDocuments];  
+  documentArray = new symbol *[numberOfDocuments];  
 
   // Discover all the DOCUMENTSTART symbols and store as a phrase
@@ -250,14 +264,14 @@
   // Iterate over the different symbols by working through the suffix array
   vector<Phrase> result;
-  cellindex i = 0;
+  cellindex ij = 0;
   char *tmpString;
 
-  while (i < inputLength) {
+  while (ij < inputLength) {
 
     // make a new phrase of length 1
-    p = Phrase(suffixArray[i], 1, SUFFIX);
-    p.findFirstAndLastSuffix(i, inputLength-1);
-
-    // cout << "cell " << i << " - " << p.toString() << endl;
+    p = Phrase(suffixArray[ij], 1, SUFFIX);
+    p.findFirstAndLastSuffix(ij, inputLength-1);
+
+    // cout << "cell " << ij << " - " << p.toString() << endl;
 
     // We ignore this symbol if it occurs only once, if it is a delimiter,
@@ -271,7 +285,7 @@
     // it explodes the size of the indexes.  So: would it be useful?  
     if (!((p.suffixFrequency <= 1) ||
-	  // (*suffixArray[i] != 23054) ||
-	  (*suffixArray[i] <= LASTDELIMITER) ||
-	  ((phraseMode == STOPWORDS) && (*suffixArray[i] <= lastStopSymbol)))) {
+	  // (*suffixArray[ij] != 23054) ||
+	  (*suffixArray[ij] <= LASTDELIMITER) ||
+	  ((phraseMode == STOPWORDS) && (*suffixArray[ij] <= lastStopSymbol)))) {
 
       // Get minimal expansions of the phrase
@@ -281,19 +295,19 @@
 	
 	// Remember that we have expanded this phrase
-	rememberThisPhrase(i, 1);
+	rememberThisPhrase(ij, 1);
 
 	// write the phrase text
 	tmpString = p.toString();
-	phraseData << i << "-1:" << tmpString << ":" << p.suffixFrequency << ":"
+	phraseData << ij << "-1:" << tmpString << ":" << p.suffixFrequency << ":"
 		   << result.size() << ":";
 	delete [] tmpString;
 
 	// write the results
-	for (cellcount i = 0; i < result.size(); i++) {
-	  if (i) {
+	for (cellcount k = 0; k < result.size(); k++) {
+	  if (k) {
 	    phraseData << ",";
 	  }
-	  phraseData << result[i].firstSuffixIndex << "-" << result[i].length;
-	  outPhrase << result[i].firstSuffixIndex << " " << result[i].length << endl;
+	  phraseData << result[k].firstSuffixIndex << "-" << result[k].length;
+	  outPhrase << result[k].firstSuffixIndex << " " << result[k].length << endl;
 	  outPhraseCounter++;
 	}
@@ -305,6 +319,6 @@
 
 	// write the documents
-	for (cellcount i = 0, first = 1; i < numberOfDocuments; i++) {
-	  if (documentFrequency[i]) {
+	for (cellcount m = 0, first = 1; m < numberOfDocuments; m++) {
+	  if (documentFrequency[m]) {
 	    if (first) {
 	      first = 0;
@@ -315,9 +329,9 @@
 	    // N documents from 0 to N-1, but later they'll be 1-N.  Thus we
 	    // add 1 to the document id when we output it.
-	    phraseData << "d" << (i+1);
+	    phraseData << "d" << (m+1);
 	    // Next, output the frequency with which the document occurs, but
 	    // only if it is > 1.
-	    if (documentFrequency[i] > 1) {
-	      phraseData << "," << documentFrequency[i];
+	    if (documentFrequency[m] > 1) {
+	      phraseData << "," << documentFrequency[m];
 	    }
 	  }
@@ -338,5 +352,5 @@
       }
     }
-   i = p.lastSuffixIndex + 1;
+   ij = p.lastSuffixIndex + 1;
   }
   outPhrase.close();
@@ -472,4 +486,5 @@
   deletePhraseMemory();
 
+  delete [] documentFrequency;
   delete [] symbols;
   delete [] suffixArray;
@@ -548,6 +563,6 @@
 	  suffixCheck[i] = c.length;
 	}
-	for (cellcount i = c.firstPrefixIndex; i <= c.lastPrefixIndex; i++) {
-	  prefixCheck[i] = c.length;
+	for (cellcount ik = c.firstPrefixIndex; ik <= c.lastPrefixIndex; ik++) {
+	  prefixCheck[ik] = c.length;
 	}
       }
@@ -578,6 +593,6 @@
 	  suffixCheck[i] = c.length;
 	}
-	for (cellcount i = c.firstPrefixIndex; i <= c.lastPrefixIndex; i++) {
-	  prefixCheck[i] = c.length;
+	for (cellcount ijk = c.firstPrefixIndex; ijk <= c.lastPrefixIndex; ijk++) {
+	  prefixCheck[ijk] = c.length;
 	}
 
@@ -701,5 +716,5 @@
     cout << "Allocating symbol arrays for " << inputLength << " symbols" << endl;
   }
-  symbols = new (symbol)[inputLength];
+  symbols = new symbol[inputLength];
   if (symbols == NULL) {
     cerr << "Suffix error: not enough memory to hold " << inputLength
@@ -757,9 +772,9 @@
 
   // search for the document in which each occurence of the phrase is found
-  for (cellcount i = p.firstSuffixIndex; i <= p.lastSuffixIndex; i++) {
+  for (cellcount j = p.firstSuffixIndex; j <= p.lastSuffixIndex; j++) {
     
-    // cout << "looking for phrase at suffixArray[" << i << "]\n";
+    // cout << "looking for phrase at suffixArray[" << j << "]\n";
     
-    target = suffixArray[i];
+    target = suffixArray[j];
     begin = 0;
     end = numberOfDocuments - 1;
@@ -864,5 +879,5 @@
 void initialisePhraseMemory() {
 
-  phraseMemory = new (unsigned char)[inputLength];
+  phraseMemory = new unsigned char[inputLength];
 
   // to begin with, everything is empty
Index: /trunk/gsdl/src/phind/generate/suffix.h
===================================================================
--- /trunk/gsdl/src/phind/generate/suffix.h	(revision 2486)
+++ /trunk/gsdl/src/phind/generate/suffix.h	(revision 2487)
@@ -26,4 +26,6 @@
  *********************************************************************/
 
+#ifndef SUFFIX_H
+#define SUFFIX_H
 
 // Types
@@ -91,4 +93,3 @@
 #define LASTDELIMITER 4
 
-
-
+#endif
Index: /trunk/gsdl/src/phind/host/phindcgi.cpp
===================================================================
--- /trunk/gsdl/src/phind/host/phindcgi.cpp	(revision 2486)
+++ /trunk/gsdl/src/phind/host/phindcgi.cpp	(revision 2487)
@@ -37,13 +37,27 @@
  */
 
-
-#include <iostream.h>
-#include <fstream.h>
+#if defined(GSDL_USE_IOS_H)
+#  include <fstream.h>
+#  include <iostream.h>
+#else
+#  include <fstream>
+#  include <iostream>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
 
-#include <vector.h>
-#include <algo.h>
+#if defined(GSDL_USE_STL_H)
+#  if defined(GSDL_USE_ALGO_H)
+#    include <algo.h>
+#  else
+#    include <algorithm.h>
+#  endif
+#  include <vector.h>
+#else
+#  include <algorithm>
+#  include <vector>
+#endif
 
 // Include MGPP functionality.
@@ -55,5 +69,6 @@
 
 // Include GSDL's text_t object, which makes parsing cgi arguments easier.
-#include <text_t.h>
+#include "text_t.h"
+#include "fileutil.h"
 // Note that GSDL stores strings as text_t objects (vectors of 16-bit short int), 
 // while MGPP stores strings as UCArray objects (vectors of 8-bit unsigned char).
@@ -156,10 +171,8 @@
   }
   
-  char basepath[FILENAME_MAX] = "";
-  strcat(basepath, gsdlhome);
-  strcat(basepath, "/collect/");
-  strcat(basepath, collection);
-  strcat(basepath, "/index/phind");
-  strcat(basepath, classifier);
+  text_t basepathstr = filename_cat(gsdlhome, "collect", collection, 
+				    "index", text_t("phind") + classifier);
+
+  char *basepath = basepathstr.getcstr();
 
   // If we don't know the phrase number, look itup
@@ -183,8 +196,19 @@
   // Create a TextData object to read the phrase data (pdata)
   TextData textdata;
-  char filename[FILENAME_MAX] = "pdata";
-  if (!textdata.LoadData (basepath, filename)) {
-    FatalError (1, "Couldn't load text information for \"%s\"", filename);
-  }
+
+  text_t fullpath = filename_cat(basepath, "pdata");
+  char *fullpathc = fullpath.getcstr();
+#if defined __WIN32__
+  char *base = "";
+#else
+  char *base = "/";
+#endif
+
+  if (!textdata.LoadData (base, fullpathc)) {
+    FatalError (1, "Couldn't load text information for \"%s\"", fullpathc);
+  }
+
+  delete fullpathc;
+
   get_phrase_all_data(textdata, phrase, word, tf, ef, lf, df, el, 
 		      linkdest, linktype, docNums, docfreq);
@@ -404,4 +428,7 @@
 
   textdata.UnloadData ();
+
+  delete basepath;
+
   return 0;
 }
@@ -494,10 +521,22 @@
 		     unsigned long first, unsigned long last) {
   
+  //  _chdir(basepath);
+
   // Create a TextData object to read the document data
   TextData docdata;
-  char filename[FILENAME_MAX] = "docs";
-  if (!docdata.LoadData (basepath, filename)) {
-    FatalError (1, "Couldn't load text information for \"%s\"", filename);
-  }
+
+  text_t fullpath = filename_cat(basepath, "docs");
+  char *fullpathc = fullpath.getcstr();
+#if defined __WIN32__
+  char *base = "";
+#else
+  char *base = "/";
+#endif
+
+  if (!docdata.LoadData (base, fullpathc)) {
+    FatalError (1, "Couldn't load text information for \"%s\"", fullpathc);
+  }
+
+  delete fullpathc;
 
   UCArray title, hash;
@@ -795,5 +834,5 @@
       }
       // store the gsdlhome string
-      gsdlhome = new (char)[len-i];
+      gsdlhome = new char[len-i];
       strncpy(gsdlhome, &(buffer[i]), len-i);
     } 
@@ -916,5 +955,5 @@
   // if no classifier number is supplied, default to 1.
   if (classifier == NULL) {
-    classifier = new (char)[2];
+    classifier = new char[2];
     strcpy(classifier, "1");
   }
@@ -971,8 +1010,18 @@
   // Open the index file for searching
   IndexData indexData;
-  char indexfilename[FILENAME_MAX] = "pword";
-  if (!indexData.LoadData (basepath, indexfilename)) {
-    FatalError (1, "Couldn't load index information for \"%s\"", indexfilename);
-  }
+
+  text_t fullpath = filename_cat(basepath, "pword");
+  char *fullpathc = fullpath.getcstr();
+#if defined __WIN32__
+  char *base = "";
+#else
+  char *base = "/";
+#endif
+
+  if (!indexData.LoadData (base, fullpathc)) {
+    FatalError (1, "Couldn't load index information for \"%s\"", fullpathc);
+  }
+
+  delete fullpathc;
 
   // set up the query object
Index: /trunk/gsdl/src/recpt/librarymain.cpp
===================================================================
--- /trunk/gsdl/src/recpt/librarymain.cpp	(revision 2486)
+++ /trunk/gsdl/src/recpt/librarymain.cpp	(revision 2487)
@@ -56,4 +56,5 @@
 #include "collectoraction.h"
 #include "browseaction.h"
+#include "phindaction.h"
 
 #include "browserclass.h"
@@ -150,4 +151,7 @@
   recpt.add_action(&abrowseaction);
 
+  phindaction aphindaction;
+  recpt.add_action(&aphindaction);
+
   // list of browsers
   vlistbrowserclass avlistbrowserclass;
Index: /trunk/gsdl/src/w32server/cgiwrapper.cpp
===================================================================
--- /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 2486)
+++ /trunk/gsdl/src/w32server/cgiwrapper.cpp	(revision 2487)
@@ -66,4 +66,5 @@
 #include "extlinkaction.h"
 #include "collectoraction.h"
+#include "phindaction.h"
 
 // browsers
@@ -74,4 +75,5 @@
 #include "pagedbrowserclass.h"
 #include "htmlbrowserclass.h"
+#include "phindbrowserclass.h"
 
 // the number of times the library has been accessed
@@ -495,4 +497,7 @@
   recpt.add_action (aauthenaction);
 
+  phindaction *aphindaction = new phindaction();
+  recpt.add_action (aphindaction);
+
 
   // list of browsers
@@ -515,4 +520,7 @@
   htmlbrowserclass *ahtmlbrowserclass = new htmlbrowserclass();
   recpt.add_browser (ahtmlbrowserclass);
+
+  phindbrowserclass *aphindbrowserclass = new phindbrowserclass();;
+  recpt.add_browser (aphindbrowserclass);
   
   // set defaults
