gui connected to rcldb (init)

This commit is contained in:
dockes
2005-01-25 14:37:35 +00:00
parent 5210139b85
commit 15855b018f
17 changed files with 621 additions and 265 deletions
+5 -49
View File
@@ -1,67 +1,23 @@
CXXFLAGS = -Wall -g -I. -I../utils -I../common -I/usr/local/include
BIGLIB = ../lib/librcl.a
PROGS = transcode textsplit idxdriver csguess
PROGS = idxdriver csguess
all: $(PROGS)
IDXDRIVER_OBJS= idxdriver.o pathut.o conftree.o rclconfig.o fstreewalk.o \
mimetype.o rcldb.o readfile.o transcode.o csguess.o \
textsplit.o unac.o unacpp.o
IDXDRIVER_OBJS= idxdriver.o $(BIGLIB)
idxdriver : $(IDXDRIVER_OBJS)
$(CXX) $(CXXFLAGS) -o idxdriver $(IDXDRIVER_OBJS) \
-L/usr/local/lib -lxapian -liconv
TEXTSPLIT_OBJS= trtextsplit.o textsplit.o readfile.o
textsplit : $(TEXTSPLIT_OBJS)
$(CXX) $(CXXFLAGS) -o textsplit $(TEXTSPLIT_OBJS)
trtextsplit.o : ../common/textsplit.cpp ../common/textsplit.h
$(CXX) $(CXXFLAGS) -DTEST_TEXTSPLIT -c -o trtextsplit.o \
../common/textsplit.cpp
pathut.o : ../utils/pathut.cpp ../utils/pathut.h
$(CXX) $(CXXFLAGS) -c -o pathut.o ../utils/pathut.cpp
conftree.o : ../utils/conftree.cpp ../utils/conftree.h
$(CXX) $(CXXFLAGS) -c -o conftree.o ../utils/conftree.cpp
rclconfig.o : ../common/rclconfig.cpp ../common/rclconfig.h
$(CXX) $(CXXFLAGS) -c -o rclconfig.o ../common/rclconfig.cpp
fstreewalk.o : ../utils/fstreewalk.cpp ../utils/fstreewalk.h
$(CXX) $(CXXFLAGS) -c -o fstreewalk.o ../utils/fstreewalk.cpp
readfile.o : ../utils/readfile.cpp ../utils/readfile.h
$(CXX) $(CXXFLAGS) -c -o readfile.o ../utils/readfile.cpp
unacpp.o : ../common/unacpp.cpp ../common/unacpp.h
$(CXX) $(CXXFLAGS) -I../unac -c -o unacpp.o ../common/unacpp.cpp
rcldb.o : ../common/rcldb.cpp ../common/rcldb.h
$(CXX) $(CXXFLAGS) -c -o rcldb.o ../common/rcldb.cpp
textsplit.o : ../common/textsplit.cpp ../common/textsplit.h
$(CXX) $(CXXFLAGS) -c -o textsplit.o ../common/textsplit.cpp
CSGUESS_OBJS= trcsguess.o csguess.o readfile.o
CSGUESS_OBJS= trcsguess.o $(BIGLIB)
csguess : $(CSGUESS_OBJS)
$(CXX) $(CXXFLAGS) -o csguess $(CSGUESS_OBJS) \
-L/usr/local/lib -liconv
trcsguess.o : csguess.cpp csguess.h
trcsguess.o : csguess.cpp
$(CXX) $(CXXFLAGS) -DTEST_CSGUESS -c -o trcsguess.o \
csguess.cpp
TRANSCODE_OBJS= trtranscode.o transcode.o readfile.o
transcode : $(TRANSCODE_OBJS)
$(CXX) $(CXXFLAGS) -o transcode $(TRANSCODE_OBJS) \
-L/usr/local/lib -liconv
trtranscode.o : transcode.cpp transcode.h
$(CXX) $(CXXFLAGS) -DTEST_TRANSCODE -c -o trtranscode.o \
transcode.cpp
CFLAGS = -g -I. -I../unac -I/usr/local/include -DUNAC_VERSION=\"1.0.7\"
unac.o : ../unac/unac.c ../unac/unac.h
$(CC) $(CFLAGS) -c -o unac.o ../unac/unac.c
clean:
rm -f *.o $(PROGS)
+1 -6
View File
@@ -1,14 +1,9 @@
#ifndef _INDEXER_H_INCLUDED_
#define _INDEXER_H_INCLUDED_
/* @(#$Id: indexer.h,v 1.2 2004-12-15 15:00:37 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: indexer.h,v 1.3 2005-01-25 14:37:21 dockes Exp $ (C) 2004 J.F.Dockes */
#include "rclconfig.h"
/* Definition for document interner functions */
typedef bool (*MimeHandlerFunc)(RclConfig *, const string &,
const string &, Rcl::Doc&);
#if 0
class FsIndexer {
const ConfTree &conf;
+7 -94
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.4 2004-12-17 13:01:01 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.5 2005-01-25 14:37:21 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
#include <sys/stat.h>
@@ -18,101 +18,11 @@ static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.4 2004-12-17 13:01:01 dockes
#include "indexer.h"
#include "csguess.h"
#include "transcode.h"
#include "mimehandler.h"
using namespace std;
bool textPlainToDoc(RclConfig *conf, const string &fn,
const string &mtype, Rcl::Doc &docout)
{
string otext;
if (!file_to_string(fn, otext))
return false;
// Try to guess charset, then convert to utf-8, and fill document
// fields The charset guesser really doesnt work well in general
// and should be avoided (especially for short documents)
string charset;
if (conf->guesscharset) {
charset = csguess(otext, conf->defcharset);
} else
charset = conf->defcharset;
string utf8;
cerr << "textPlainToDoc: transcod from " << charset << " to UTF-8"
<< endl;
if (!transcode(otext, utf8, charset, "UTF-8")) {
cerr << "textPlainToDoc: transcode failed: charset '" << charset
<< "' to UTF-8: "<< utf8 << endl;
otext.erase();
return 0;
}
Rcl::Doc out;
out.origcharset = charset;
out.text = utf8;
//out.text = otext;
docout = out;
cerr << utf8 << endl;
return true;
}
// Map of mime types to internal interner functions. This could just as well
// be an if else if suite inside getMimeHandler(), but this is prettier ?
static map<string, MimeHandlerFunc> ihandlers;
// Static object to get the map to be initialized at program start.
class IHandler_Init {
public:
IHandler_Init() {
ihandlers["text/plain"] = textPlainToDoc;
// Add new associations here when needed
}
};
static IHandler_Init ihandleriniter;
/**
* Return handler function for given mime type
*/
MimeHandlerFunc getMimeHandler(const std::string &mtype, ConfTree *mhandlers)
{
// Return handler definition for mime type
string hs;
if (!mhandlers->get(mtype, hs, ""))
return 0;
// Break definition into type and name
vector<string> toks;
ConfTree::stringToStrings(hs, toks);
if (toks.size() < 1) {
cerr << "Bad mimeconf line for " << mtype << endl;
return 0;
}
// Retrieve handler function according to type
if (!strcasecmp(toks[0].c_str(), "internal")) {
cerr << "Internal Handler" << endl;
map<string, MimeHandlerFunc>::const_iterator it =
ihandlers.find(mtype);
if (it == ihandlers.end()) {
cerr << "Internal handler not found for " << mtype << endl;
return 0;
}
cerr << "Got handler" << endl;
return it->second;
} else if (!strcasecmp(toks[0].c_str(), "dll")) {
if (toks.size() != 2)
return 0;
return 0;
} else if (!strcasecmp(toks[0].c_str(), "exec")) {
if (toks.size() != 2)
return 0;
return 0;
} else {
return 0;
}
}
/**
* Bunch holder for data used while indexing a directory tree
*/
@@ -151,7 +61,11 @@ void DirIndexer::index()
/**
* This function gets called for every file and directory found by the
* tree walker. Adjust parameters and index files if/when needed.
* tree walker. It checks with the db is the file has changed and needs to
* be reindexed. If so, it calls an appropriate handler depending on the mime
* type, which is responsible for populating an Rcl::Doc.
* Accent and majuscule handling are performed by the db module when doing
* the actual indexing work.
*/
FsTreeWalker::Status
indexfile(void *cdata, const std::string &fn, const struct stat *stp,
@@ -209,7 +123,6 @@ indexfile(void *cdata, const std::string &fn, const struct stat *stp,
}
int main(int argc, const char **argv)
{
RclConfig *config = new RclConfig;