mail ckpt

This commit is contained in:
dockes
2005-03-25 09:40:28 +00:00
parent 63a29c7ced
commit d392d317bb
25 changed files with 872 additions and 145 deletions
+2 -1
View File
@@ -1,11 +1,12 @@
include ../mk/sysconf
BIGLIB = ../lib/librcl.a
MIMELIB = ../bincimapmime/libmime.a
PROGS = recollindex csguess
all: $(PROGS)
RECOLLINDEX_OBJS= recollindex.o $(BIGLIB)
RECOLLINDEX_OBJS= recollindex.o $(BIGLIB) $(MIMELIB)
recollindex : $(RECOLLINDEX_OBJS)
$(CXX) $(CXXFLAGS) -o recollindex $(RECOLLINDEX_OBJS) \
$(LIBXAPIAN) $(LIBICONV) $(LIBSYS)
+18 -11
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.8 2005-03-17 15:35:49 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.9 2005-03-25 09:40:27 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
#include <stdio.h>
#include <sys/stat.h>
@@ -146,18 +146,25 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
return FsTreeWalker::FtwOk;
}
Rcl::Doc doc;
if (!internfile(fn, config, doc, tmpdir))
return FsTreeWalker::FtwOk;
FileInterner interner(fn, config, tmpdir);
FileInterner::Status fis = FileInterner::FIAgain;
while (fis == FileInterner::FIAgain) {
Rcl::Doc doc;
string ipath;
fis = interner.internfile(doc, ipath);
if (fis == FileInterner::FIError)
break;
// Set up common fields:
char ascdate[20];
sprintf(ascdate, "%ld", long(stp->st_ctime));
doc.mtime = ascdate;
// Set up common fields:
char ascdate[20];
sprintf(ascdate, "%ld", long(stp->st_ctime));
doc.mtime = ascdate;
doc.ipath = ipath;
// Do database-specific work to update document data
if (!db.add(fn, doc))
return FsTreeWalker::FtwError;
// Do database-specific work to update document data
if (!db.add(fn, doc))
return FsTreeWalker::FtwError;
}
return FsTreeWalker::FtwOk;
}
+39 -3
View File
@@ -1,14 +1,47 @@
#ifndef lint
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.5 2005-02-09 13:34:08 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.6 2005-03-25 09:40:27 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
#include <ctype.h>
#include <string>
using std::string;
#include <list>
using std::list;
#include "mimetype.h"
#include "debuglog.h"
#include "execmd.h"
#include "conftree.h"
static string mimetypefromdata(const string &fn)
{
list<string> args;
args.push_back("-i");
args.push_back(fn);
ExecCmd ex;
string result;
string cmd = "file";
int status = ex.doexec(cmd, args, 0, &result);
if (status) {
LOGERR(("mimetypefromdata: doexec: status 0x%x\n", status));
return "";
}
// LOGDEB(("mimetypefromdata: %s [%s]\n", result.c_str(), fn.c_str()));
list<string> res;
ConfTree::stringToStrings(result, res);
if (res.size() <= 1)
return "";
list<string>::iterator it = res.begin();
it++;
string mime = *it;
if (mime.length() > 0 && !isalpha(mime[mime.length() - 1]))
mime.erase(mime.length() -1);
return mime;
}
string mimetype(const string &fn, ConfTree *mtypes)
{
@@ -38,8 +71,9 @@ string mimetype(const string &fn, ConfTree *mtypes)
// If the file name has a suffix and we find it in the map, we're done
string::size_type dot = fn.find_last_of(".");
string suff;
if (dot != string::npos) {
string suff = fn.substr(dot);
suff = fn.substr(dot);
for (unsigned int i = 0; i < suff.length(); i++)
suff[i] = tolower(suff[i]);
@@ -48,7 +82,9 @@ string mimetype(const string &fn, ConfTree *mtypes)
return mtype;
}
// Look at file data ? One day maybe
// Look at file data ? Only when no suffix
if (suff.empty())
return mimetypefromdata(fn);
return "";
}