--- a/src/index/indexer.cpp
+++ b/src/index/indexer.cpp
@@ -1,5 +1,5 @@
 #ifndef lint
-static char rcsid[] = "@(#$Id: indexer.cpp,v 1.5 2005-02-09 12:07:30 dockes Exp $ (C) 2004 J.F.Dockes";
+static char rcsid[] = "@(#$Id: indexer.cpp,v 1.6 2005-02-10 15:21:12 dockes Exp $ (C) 2004 J.F.Dockes";
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
@@ -34,7 +34,7 @@
 /**
  * Bunch holder for data used while indexing a directory tree
  */
-class DbIndexer {
+class DbIndexer : public FsTreeWalkerCB {
     FsTreeWalker walker;
     RclConfig *config;
     string dbdir;
@@ -46,7 +46,7 @@
 	: config(cnf), dbdir(dbd), topdirs(top)
     { }
 
-    ~DbIndexer() {
+    virtual ~DbIndexer() {
 	if (tmpdir.length()) {
 	    wipedir(tmpdir);
 	    if (rmdir(tmpdir.c_str()) < 0) {
@@ -55,9 +55,9 @@
 	    }
 	}
     }
-    friend FsTreeWalker::Status 
-      indexfile(void *, const std::string &, const struct stat *, 
-		FsTreeWalker::CbFlag);
+
+    FsTreeWalker::Status 
+    processone(const std::string &, const struct stat *, FsTreeWalker::CbFlag);
 
     bool index();
 };
@@ -79,7 +79,7 @@
 	 it != topdirs->end(); it++) {
 	LOGDEB(("DbIndexer::index: Indexing %s into %s\n", it->c_str(), 
 		dbdir.c_str()));
-	if (walker.walk(*it, indexfile, this) != FsTreeWalker::FtwOk) {
+	if (walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
 	    LOGERR(("DbIndexer::index: error while indexing %s\n", 
 		    it->c_str()));
 	    db.close();
@@ -87,6 +87,18 @@
 	}
     }
     db.purge();
+
+    // Create stemming databases
+    string slangs;
+    if (config->getConfParam("indexstemminglanguages", slangs)) {
+	list<string> langs;
+	ConfTree::stringToStrings(slangs, langs);
+	for (list<string>::const_iterator it = langs.begin(); 
+	     it != langs.end(); it++) {
+	    db.createStemDb(*it);
+	}
+    }
+
     if (!db.close()) {
 	LOGERR(("DbIndexer::index: error closing database in %s\n", 
 		dbdir.c_str()));
@@ -105,26 +117,24 @@
  * the actual indexing work.
  */
 FsTreeWalker::Status 
-indexfile(void *cdata, const std::string &fn, const struct stat *stp, 
-	  FsTreeWalker::CbFlag flg)
-{
-    DbIndexer *me = (DbIndexer *)cdata;
-
+DbIndexer::processone(const std::string &fn, const struct stat *stp, 
+		   FsTreeWalker::CbFlag flg)
+{
     // If we're changing directories, possibly adjust parameters.
     if (flg == FsTreeWalker::FtwDirEnter || 
 	flg == FsTreeWalker::FtwDirReturn) {
-	me->config->setKeyDir(fn);
+	config->setKeyDir(fn);
 	return FsTreeWalker::FtwOk;
     }
 
     // Check db up to date ?
-    if (!me->db.needUpdate(fn, stp)) {
+    if (!db.needUpdate(fn, stp)) {
 	LOGDEB(("indexfile: up to date: %s\n", fn.c_str()));
 	return FsTreeWalker::FtwOk;
     }
 
     Rcl::Doc doc;
-    if (!internfile(fn, me->config, doc, me->tmpdir))
+    if (!internfile(fn, config, doc, tmpdir))
 	return FsTreeWalker::FtwOk;
 
     // Set up common fields:
@@ -133,7 +143,7 @@
     doc.mtime = ascdate;
 
     // Do database-specific work to update document data
-    if (!me->db.add(fn, doc)) 
+    if (!db.add(fn, doc)) 
 	return FsTreeWalker::FtwError;
 
     return FsTreeWalker::FtwOk;