Index: /trunk/gsdl/lib/text_t.cpp
===================================================================
--- /trunk/gsdl/lib/text_t.cpp	(revision 137)
+++ /trunk/gsdl/lib/text_t.cpp	(revision 138)
@@ -12,4 +12,9 @@
 /*
    $Log$
+   Revision 1.6  1999/02/03 01:13:26  sjboddie
+
+   Got interface to handle subcollections and language subcollections -
+   committed changes made to some of the collections
+
    Revision 1.5  1999/01/19 01:38:14  rjmcnab
 
@@ -364,5 +369,14 @@
 }
 
-
+// return a substring of string from first up to but not including last
+text_t substr (text_t::const_iterator first, text_t::const_iterator last) {
+
+  text_t substr;
+  while (first != last) {
+    substr.push_back(*first);
+    first ++;
+  }
+  return substr;
+}
 
 ////////////////////////////////////
Index: /trunk/gsdl/lib/text_t.h
===================================================================
--- /trunk/gsdl/lib/text_t.h	(revision 137)
+++ /trunk/gsdl/lib/text_t.h	(revision 138)
@@ -221,8 +221,6 @@
 	       unsigned short c);
 
-
-
-
-
+// return a substring of string from first up to but not including last
+text_t substr (text_t::const_iterator first, text_t::const_iterator last);
 
 
Index: /trunk/gsdl/src/colservr/mgsearch.cpp
===================================================================
--- /trunk/gsdl/src/colservr/mgsearch.cpp	(revision 137)
+++ /trunk/gsdl/src/colservr/mgsearch.cpp	(revision 138)
@@ -12,4 +12,9 @@
 /*
    $Log$
+   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
 
@@ -73,7 +78,7 @@
 /////////////////////////
 
-void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex) {
-  realindex.clear ();
-  dirindex.clear();
+void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart) {
+  realpart.clear ();
+  dirpart.clear();
 
   text_t::const_iterator here = map.begin();
@@ -82,5 +87,5 @@
   // get the real index
   while (here != end && *here != '-') {
-    realindex.push_back(*here);
+    realpart.push_back(*here);
     here++;
   }
@@ -91,63 +96,221 @@
   // get the dir index
   while (here != end) {
-    dirindex.push_back(*here);
-    here++;
-  }
-}
-
-bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) {
+    dirpart.push_back(*here);
+    here++;
+  }
+}
+
+void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
+		      const text_t &languagemap, text_t &realindex, 
+		      text_t &dirindex) {
+  text_t real, dir;
+  realindex.clear();
+  dirindex.clear();
+
+  getrealdir (indexmap, real, dir);
+  realindex += real;
+  dirindex += dir;
+
+  getrealdir (subcollectionmap, real, dir);
+  realindex += real;
+  dirindex += dir;
+
+  getrealdir (languagemap, real, dir);
+  realindex += real;
+  dirindex += dir;
+}
+
+//bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) {
+// text_tarray::const_iterator here = indexmap.begin();
+//  text_tarray::const_iterator end = indexmap.end();
+//  text_t maprealindex, mapdirindex;
+
+//  while (here != end) {
+//    getrealdirindex (*here, maprealindex, mapdirindex);
+//    if (mapdirindex == dirindex) return true;
+//    here++;
+//  }
+
+//  return false;
+//}
+
+void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+			const text_tarray &languagemap, const text_t &realindex,
+			text_t &index, text_t &subcollection, text_t &language) {
+
+  index.clear();
+  subcollection.clear();
+  language.clear();
+
+  text_tarray parts;
+  splitchar (realindex.begin(), realindex.end(), ':', parts);
+  int numparts = parts.size();
+
+  if (numparts >= 2) {
+    index = parts[0] + ":" + parts[1];
+
+    if (numparts == 3) {
+      if (languagemap.empty()) 
+	subcollection = parts[2];
+      else 
+	language = parts[2];
+    } else if (numparts == 4) {
+      subcollection = parts[2];
+      language = parts[3];
+    }
+  }
+}
+
+
+void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		       const text_tarray &languagemap, const text_t &dirindex,
+		       text_t &index, text_t &subcollection, text_t &language) {
+
+  index.clear();
+  subcollection.clear();
+  language.clear();
+
+  int indexsize = dirindex.size();
+  if (indexsize != 3 && indexsize != 5 &&
+      indexsize != 7) return;
+  
+  text_t::const_iterator dibegin = dirindex.begin();
+  text_t::const_iterator diend = dirindex.end();  
+
+  // first three characters make up index part 
+  index = substr(dibegin, dibegin+3); 
+
+  if (indexsize == 5) {
+    if (languagemap.empty())
+      subcollection = substr(dibegin+3, dibegin+5);
+    else 
+      language = substr(dibegin+3, dibegin+5);
+  } else if (indexsize == 7) {
+    subcollection = substr(dibegin+3, dibegin+5);
+    language = substr(dibegin+5, diend);
+  }
+}
+  
+
+bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		  const text_tarray &languagemap, const text_t &realindex) {
+      
+  text_t index, subcollection, language, realpart, dirpart;
+  getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,
+		     index, subcollection, language);
+
+  // check index part
   text_tarray::const_iterator here = indexmap.begin();
   text_tarray::const_iterator end = indexmap.end();
-  text_t maprealindex, mapdirindex;
-
-  while (here != end) {
-    getrealdirindex (*here, maprealindex, mapdirindex);
-    if (mapdirindex == dirindex) return true;
-    here++;
-  }
-
-  return false;
-}
-
-bool isrealindex (const text_tarray &indexmap, const text_t &realindex) {
+  bool exists = false;
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (realpart == index) {exists = true; break;}
+    here++;
+  }
+  if (!exists) return false;
+
+  // check subcollection part if there is one
+  if (!subcollection.empty()) {
+    here = subcollectionmap.begin();
+    end = subcollectionmap.end();
+    exists = false;
+    while (here != end) {
+      getrealdir (*here, realpart, dirpart);
+      if (realpart == subcollection) {exists = true; break;}
+    here++;
+  }
+  if (!exists) return false;
+  }
+
+  // check language part if there is one
+  if (!language.empty()) {
+    here = languagemap.begin();
+    end = languagemap.end();
+    exists = false;
+    while (here != end) {
+      getrealdir (*here, realpart, dirpart);
+      if (realpart == language) {exists = true; break;}
+    here++;
+  }
+  if (!exists) return false;
+  }
+  return true;
+}
+
+text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		      const text_tarray &languagemap, const text_t &dirindex) {
+
+  text_t index, subcollection, language, realpart, dirpart, realindex;
+  getdirindexparts (indexmap, subcollectionmap, languagemap, dirindex,
+		    index, subcollection, language);
+
+  // get index part
   text_tarray::const_iterator here = indexmap.begin();
   text_tarray::const_iterator end = indexmap.end();
-  text_t maprealindex, mapdirindex;
-
-  while (here != end) {
-    getrealdirindex (*here, maprealindex, mapdirindex);
-    if (maprealindex == realindex) return true;
-    here++;
-  }
-
-  return false;
-}
-
-text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex) {
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (dirpart == index) {realindex += realpart; break;}
+    here++;
+  }
+  
+  if (realindex.empty()) return "";
+
+  // get subcollection part
+  here = subcollectionmap.begin();
+  end = subcollectionmap.end();
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (dirpart == subcollection) {realindex += ":" + realpart; break;}
+    here++;
+  }
+  
+  // get language part
+  here = languagemap.begin();
+  end = languagemap.end();
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (dirpart == language) {realindex += ":" + realpart; break;}
+    here++;
+  }
+  return realindex;
+}
+
+text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		      const text_tarray &languagemap, const text_t &realindex) {
+
+  text_t index, subcollection, language, realpart, dirpart, dirindex;
+  getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,
+		     index, subcollection, language);
+
+  // get index part
   text_tarray::const_iterator here = indexmap.begin();
   text_tarray::const_iterator end = indexmap.end();
-  text_t maprealindex, mapdirindex;
-
-  while (here != end) {
-    getrealdirindex (*here, maprealindex, mapdirindex);
-    if (mapdirindex == dirindex) return maprealindex;
-    here++;
-  }
-
-  return "";
-}
-
-text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex) {
-  text_tarray::const_iterator here = indexmap.begin();
-  text_tarray::const_iterator end = indexmap.end();
-  text_t maprealindex, mapdirindex;
-
-  while (here != end) {
-    getrealdirindex (*here, maprealindex, mapdirindex);
-    if (maprealindex == realindex) return mapdirindex;
-    here++;
-  }
-
-  return "";
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (realpart == index) {dirindex += dirpart; break;}
+    here++;
+  }
+  
+  if (dirindex.empty()) return "";
+
+  // get subcollection part
+  here = subcollectionmap.begin();
+  end = subcollectionmap.end();
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (realpart == subcollection) {dirindex += dirpart; break;}
+    here++;
+  }
+  
+  // get language part
+  here = languagemap.begin();
+  end = languagemap.end();
+  while (here != end) {
+    getrealdir (*here, realpart, dirpart);
+    if (realpart == language) {dirindex += dirpart; break;}
+    here++;
+  }
+  return dirindex;
 }
 
@@ -186,13 +349,13 @@
 
 text_t getdoclevelindex (const text_tarray &indexmap) {
-  text_tarray::const_iterator here = indexmap.begin();
-  text_tarray::const_iterator end = indexmap.end();
-  text_t maprealindex, mapdirindex;
-  
-  while (here != end) {
-    getrealdirindex (*here, maprealindex, mapdirindex);
-    if (isdoclevelindex (maprealindex)) return maprealindex;
-    here++;
-  }
+  //text_tarray::const_iterator here = indexmap.begin();
+  //text_tarray::const_iterator end = indexmap.end();
+  //text_t maprealindex, mapdirindex;
+  
+  //  while (here != end) {
+  //  getrealdirindex (*here, maprealindex, mapdirindex);
+  //  if (isdoclevelindex (maprealindex)) return maprealindex;
+  //  here++;
+  //}
   
   return "";
Index: /trunk/gsdl/src/colservr/mgsearch.h
===================================================================
--- /trunk/gsdl/src/colservr/mgsearch.h	(revision 137)
+++ /trunk/gsdl/src/colservr/mgsearch.h	(revision 138)
@@ -25,9 +25,21 @@
 // appear within the index directory) and real indexes (indexes as they
 // appear within the collect.cfg file) and mappings between them.
-void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex);
+void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		       const text_tarray &languagemap, const text_t &dirindex,
+		       text_t &index, text_t &subcollection, text_t &language);
+void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+			const text_tarray &languagemap, const text_t &realindex,
+			text_t &index, text_t &subcollection, text_t &language);
+void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart);
+void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
+		      const text_t &languagemap, text_t &realindex, 
+		      text_t &dirindex);
 bool isdirindex (const text_tarray &indexmap, const text_t &dirindex);
-bool isrealindex (const text_tarray &indexmap, const text_t &realindex);
-text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex);
-text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex);
+bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		  const text_tarray &languagemap, const text_t &realindex);
+text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		      const text_tarray &languagemap, const text_t &dirindex);
+text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
+		      const text_tarray &languagemap, const text_t &realindex);
 text_t real2macroindex (const text_t &realindex);
 bool isdoclevelindex (const text_t &realindex);
Index: /trunk/gsdl/src/library/libinterface.cpp
===================================================================
--- /trunk/gsdl/src/library/libinterface.cpp	(revision 137)
+++ /trunk/gsdl/src/library/libinterface.cpp	(revision 138)
@@ -12,4 +12,9 @@
 /*
    $Log$
+   Revision 1.18  1999/02/03 01:13:29  sjboddie
+
+   Got interface to handle subcollections and language subcollections -
+   committed changes made to some of the collections
+
    Revision 1.17  1999/02/02 10:01:11  rjmcnab
 
@@ -255,9 +260,12 @@
 	cfgline.erase(cfgline.begin());
 	if (key == "maintainer")        cfg_info.maintainer = cfgline[0];
-	else if (key == "indexes")      cfg_info.indexes = cfgline;
+	//	else if (key == "indexes")      cfg_info.indexes = cfgline;
 	else if (key == "defaultindex") cfg_info.defaultindex = cfgline[0];
 	else if (key == "macrofiles")   cfg_info.macrofiles = cfgline;
 	else if (key == "builddate")    cfg_info.builddate = cfgline[0];
 	else if (key == "indexmap")     cfg_info.indexmap = cfgline;
+	else if (key == "subcollectionmap")
+	                                cfg_info.subcollectionmap = cfgline;
+	else if (key == "languagemap")  cfg_info.languagemap = cfgline;
 	else if (key == "numbytes")     cfg_info.numbytes = (double)cfgline[0].getint();
 	else if (key == "numdocs")      cfg_info.numdocs = (double)cfgline[0].getint();
@@ -318,9 +326,17 @@
     default_index.clear();
   } else if (cfg_info.defaultindex.empty() || 
-	     !isrealindex (cfg_info.indexmap, cfg_info.defaultindex)) {
+	     !isrealindex (cfg_info.indexmap, cfg_info.subcollectionmap,
+			   cfg_info.languagemap, cfg_info.defaultindex)) {
     logout << "warning: the default index has been reset to the first index\n";
-    getrealdirindex (cfg_info.indexmap[0], cfg_info.defaultindex, default_index);
+    text_t subcollection, language;
+    if (!cfg_info.subcollectionmap.empty()) 
+      subcollection = cfg_info.subcollectionmap[0];
+    if (!cfg_info.languagemap.empty()) 
+      language = cfg_info.languagemap[0];
+    getrealdirindex (cfg_info.indexmap[0], subcollection,
+		     language, cfg_info.defaultindex, default_index);
   } else {
-    default_index = real2dirindex (cfg_info.indexmap, cfg_info.defaultindex);
+    default_index = real2dirindex (cfg_info.indexmap, cfg_info.subcollectionmap, 
+				   cfg_info.languagemap, cfg_info.defaultindex);
   }
 
@@ -328,8 +344,8 @@
   // retrieving documents).
   text_default_index = default_index;
-  if (!isdoclevelindex (cfg_info.defaultindex)) {
-    text_default_index = real2dirindex (cfg_info.indexmap, 
-					getdoclevelindex (cfg_info.indexmap));
-  }
+  //if (!isdoclevelindex (cfg_info.defaultindex)) {
+  //  text_default_index = real2dirindex (cfg_info.indexmap, cfg_info.subcollectionmap,
+  //					cfg_info.languagemap, getdoclevelindex (cfg_info.indexmap));
+  //}
 
   // load up the default macro files, the collection directory
@@ -371,4 +387,5 @@
 
   parse_cgi_args (argstr, args);
+
   expand_compressed_args (args);
   add_default_args (args);
@@ -574,5 +591,45 @@
   if (args["p"].empty()) args.setarg("p", cfg_info.defaultpage);
   if (args["w"].empty()) args.setarg("w", cfg_info.defaultencoding);
-  if (args["i"].empty()) args.setarg("i", default_index);
+
+  // override those parts of the index that need it
+  int indexsize = args["i"].size();
+  if ((indexsize < 3) || (indexsize > 7)) {
+    args["i"] = args["h"] + args["i"] + args["n"];
+  } else {
+    if (args["h"].size() == 3) {
+      args["i"][0] = args["h"][0];
+      args["i"][1] = args["h"][1];
+      args["i"][2] = args["h"][2];
+    }
+
+    if (args["j"].size() == 2) {
+      if (indexsize >= 5) {
+	args["i"][3] = args["j"][0];
+	args["i"][4] = args["j"][1];
+      } else {
+	args["i"] += args["j"];
+      }
+    }
+    if (args["n"].size() == 2) {
+      if (cfg_info.subcollectionmap.empty()) {
+	if (args["i"].size() >= 5) {
+	  args["i"][3] = args["n"][0];
+	  args["i"][4] = args["n"][1];
+	} else {
+	  args["i"] += args["n"];
+	}
+      } else {
+	if (args["i"].size() == 7) {
+	  args["i"][5] = args["n"][0];
+	  args["i"][6] = args["n"][1];
+	} else {
+	  args["i"] += args["n"];
+	}
+      }
+    }
+  }      
+  if ((args["i"].size() < 3) || (args["i"].size() > 7)) 
+    args.setarg("i", default_index);
+
 }
 
@@ -627,38 +684,22 @@
   disp.setmacro("g", "Global", args["g"]);
 
- // set the selection macros
-
-  text_t indexselect;
-  text_t maprealindex, mapdirindex;
-  if (cfg_info.indexmap.size() == 1) {
-    getrealdirindex (cfg_info.indexmap[0], maprealindex, mapdirindex);
-    indexselect += "<input type=hidden name=\"i\" value=\"";
-    indexselect += mapdirindex;
-    indexselect += "\">_query:";
-    indexselect += real2macroindex (maprealindex);
-    indexselect += "_\n";
-
-  } else {
-    text_t &arg_i = args["i"];
-    text_tarray::const_iterator maphere = cfg_info.indexmap.begin();
-    text_tarray::const_iterator mapend = cfg_info.indexmap.end();
-    
-    indexselect += "<select name=\"i\">\n";
-    while (maphere != mapend) {
-      getrealdirindex (*maphere, maprealindex, mapdirindex);
-      indexselect += "<option value=\"";
-      indexselect += mapdirindex;
-      indexselect += "\"";
-      if (arg_i == mapdirindex) indexselect += " selected";
-      indexselect += ">_query:";
-      indexselect += real2macroindex (maprealindex);
-      indexselect += "_\n";
-      
-      maphere++;
-    }
-    indexselect += "</select>\n";
-  }
-
-  disp.setmacro("indexselection", "query", indexselect);
+  // set the selection macros
+
+  text_t index, subcollection, language;
+  getdirindexparts (cfg_info.indexmap, cfg_info.subcollectionmap,
+		    cfg_info.languagemap, args["i"],  index, 
+		    subcollection, language);
+
+  // main part of index
+  set_selection_macro (cfg_info.indexmap, index, "h");
+  
+  // subcollection part of index
+  if (!cfg_info.subcollectionmap.empty())
+    set_selection_macro (cfg_info.subcollectionmap, subcollection, "j");
+
+  // language part of index
+  if (!cfg_info.languagemap.empty())
+    set_selection_macro (cfg_info.languagemap, language, "n");
+  
 
   text_t qtselect;
@@ -675,4 +716,38 @@
 
   disp.setmacro("querytypeselection", "query", qtselect);
+}
+
+void libinterface::set_selection_macro (const text_tarray &map, const text_t &indexarg,
+					const text_t &index) {
+
+  text_t maprealindex, mapdirindex, indexselect;
+
+  if (map.size() == 1) {
+    getrealdir (map[0], maprealindex, mapdirindex);
+    indexselect += "<input type=hidden name=\"" + index + "\" value=\"";
+    indexselect += mapdirindex + "\">_query:";
+    indexselect += real2macroindex (maprealindex);
+    indexselect += "_\n";
+
+  } else {
+    text_tarray::const_iterator maphere = map.begin();
+    text_tarray::const_iterator mapend = map.end();
+    
+    indexselect += "<select name=\"" + index +"\">\n";
+    while (maphere != mapend) {
+      getrealdir (*maphere, maprealindex, mapdirindex);
+      indexselect += "<option value=\"";
+      indexselect += mapdirindex;
+      indexselect += "\"";
+      if (indexarg == mapdirindex) indexselect += " selected";
+      indexselect += ">_query:";
+      indexselect += real2macroindex (maprealindex);
+      indexselect += "_\n";
+      
+      maphere++;
+    }
+    indexselect += "</select>\n";
+  }
+  disp.setmacro(index + "selection", "query", indexselect);
 }
 
@@ -1216,8 +1291,8 @@
   caseoption += "\n<input type=radio name=k value=1";
   if (arg_k) caseoption += " checked";
-  caseoption += "> ignore case differences<br>\n";
+  caseoption += ">_textignorecase_<br>\n";
   caseoption += "<input type=radio name=k value=0";
   if (!arg_k) caseoption += " checked";
-  caseoption += "> upper/lower case must match\n";
+  caseoption += ">_textmatchcase_\n";
 
   disp.setmacro ("caseoption", "preferences", caseoption);
@@ -1229,8 +1304,8 @@
   stemoption += "\n<input type=radio name=s value=1";
   if (arg_s) stemoption += " checked";
-  stemoption += "> ignore word endings<br>\n";
+  stemoption += ">_textstem_<br>\n";
   stemoption += "<input type=radio name=s value=0";
   if (!arg_s) stemoption += " checked";
-  stemoption += "> whole word must match\n";
+  stemoption += ">_textnostem_\n";
 
   disp.setmacro ("stemoption", "preferences", stemoption);
Index: /trunk/gsdl/src/library/libinterface.h
===================================================================
--- /trunk/gsdl/src/library/libinterface.h	(revision 137)
+++ /trunk/gsdl/src/library/libinterface.h	(revision 138)
@@ -55,9 +55,11 @@
 
   text_t      maintainer;
-  text_tarray indexes;
+//  text_tarray indexes;
   text_t      defaultindex;
   text_tarray macrofiles;
   text_t      builddate;
   text_tarray indexmap;
+  text_tarray subcollectionmap;
+  text_tarray languagemap;
   double      numbytes;
   double      numdocs;
@@ -156,4 +158,8 @@
   virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert, 
 				      ostream &logout);
+
+  virtual void set_selection_macro (const text_tarray &map, const text_t &indexarg,
+				    const text_t &index);
+
   virtual void prepare_page (cgiargsclass &args, outconvertclass &outconvert,
 			     ostream &logout);
