logging now uses c++ streams

This commit is contained in:
Jean-Francois Dockes
2016-07-12 09:41:04 +02:00
parent 7c4223088b
commit f6a999de84
123 changed files with 1974 additions and 2760 deletions
+8 -11
View File
@@ -21,7 +21,7 @@
#include "rclconfig.h"
#include "pxattr.h"
#include "debuglog.h"
#include "log.h"
#include "cstr.h"
#include "rcldoc.h"
#include "execmd.h"
@@ -33,8 +33,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
const string &value, Rcl::Doc& doc)
{
string fieldname = cfg->fieldCanon(name);
LOGDEB0(("Internfile:: setting [%s] from cmd/xattr value [%s]\n",
fieldname.c_str(), value.c_str()));
LOGDEB0("Internfile:: setting [" << (fieldname) << "] from cmd/xattr value [" << (value) << "]\n" );
if (fieldname == cstr_dj_keymd) {
doc.dmtime = value;
} else {
@@ -45,17 +44,15 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
void reapXAttrs(const RclConfig* cfg, const string& path,
map<string, string>& xfields)
{
LOGDEB2(("reapXAttrs: [%s]\n", path.c_str()));
LOGDEB2("reapXAttrs: [" << (path) << "]\n" );
#ifndef _WIN32
// Retrieve xattrs names from files and mapping table from config
vector<string> xnames;
if (!pxattr::list(path, &xnames)) {
if (errno == ENOTSUP) {
LOGDEB(("FileInterner::reapXattrs: pxattr::list: errno %d\n",
errno));
LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" );
} else {
LOGERR(("FileInterner::reapXattrs: pxattr::list: errno %d\n",
errno));
LOGERR("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" );
}
return;
}
@@ -77,13 +74,12 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
}
string value;
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
LOGERR(("FileInterner::reapXattrs: pxattr::get failed"
"for %s, errno %d\n", (*it).c_str(), errno));
LOGERR("FileInterner::reapXattrs: pxattr::get failedfor " << ((*it)) << ", errno " << (errno) << "\n" );
continue;
}
// Encode should we ?
xfields[key] = value;
LOGDEB2(("reapXAttrs: [%s] -> [%s]\n", key.c_str(), value.c_str()));
LOGDEB2("reapXAttrs: [" << (key) << "] -> [" << (value) << "]\n" );
}
#endif
}
@@ -150,3 +146,4 @@ void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields,
}
}
}
-3
View File
@@ -18,9 +18,6 @@
#define _INDEXTEXT_H_INCLUDED_
/* Note: this only exists to help with using myhtmlparse.cc */
// Minimize changes to myhtmlparse.cpp
#include "debuglog.h"
#include <string>
// lets hope that the charset includes ascii values...
+74 -93
View File
@@ -35,7 +35,7 @@ using namespace std;
#include "internfile.h"
#include "rcldoc.h"
#include "mimetype.h"
#include "debuglog.h"
#include "log.h"
#include "mimehandler.h"
#include "execmd.h"
#include "pathut.h"
@@ -76,8 +76,7 @@ static string colon_restore(const string& in)
// (ie message having a given attachment)
bool FileInterner::getEnclosingUDI(const Rcl::Doc &doc, string& udi)
{
LOGDEB(("FileInterner::getEnclosingUDI(): url [%s] ipath [%s]\n",
doc.url.c_str(), doc.ipath.c_str()));
LOGDEB("FileInterner::getEnclosingUDI(): url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" );
string eipath = doc.ipath;
string::size_type colon;
if (eipath.empty())
@@ -119,9 +118,9 @@ FileInterner::FileInterner(const string &fn, const struct stat *stp,
RclConfig *cnf, int flags, const string *imime)
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
{
LOGDEB0(("FileInterner::FileInterner(fn=%s)\n", fn.c_str()));
LOGDEB0("FileInterner::FileInterner(fn=" << (fn) << ")\n" );
if (fn.empty()) {
LOGERR(("FileInterner::FileInterner: empty file name!\n"));
LOGERR("FileInterner::FileInterner: empty file name!\n" );
return;
}
initcommon(cnf, flags);
@@ -132,7 +131,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
int flags, const string *imime)
{
if (f.empty()) {
LOGERR(("FileInterner::init: empty file name!\n"));
LOGERR("FileInterner::init: empty file name!\n" );
return;
}
m_fn = f;
@@ -157,13 +156,14 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
// (e.g. the beagle indexer sets it).
if (flags & FIF_doUseInputMimetype) {
if (!imime) {
LOGERR(("FileInterner:: told to use null imime\n"));
LOGERR("FileInterner:: told to use null imime\n" );
return;
}
l_mime = *imime;
} else {
LOGDEB(("FileInterner::init fn [%s] mime [%s] preview %d\n",
f.c_str(), imime?imime->c_str() : "(null)", m_forPreview));
LOGDEB("FileInterner::init fn [" << f << "] mime [" <<
(imime?imime->c_str() : "(null)") << "] preview " << m_forPreview
<< "\n" );
// Run mime type identification in any case (see comment above).
l_mime = mimetype(m_fn, stp, m_cfg, usfci);
@@ -190,14 +190,12 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (!m_uncomp.uncompressfile(m_fn, ucmd, m_tfile)) {
return;
}
LOGDEB1(("FileInterner:: after ucomp: tfile %s\n",
m_tfile.c_str()));
LOGDEB1("FileInterner:: after ucomp: tfile " << (m_tfile) << "\n" );
m_fn = m_tfile;
// Stat the uncompressed file, mainly to get the size
struct stat ucstat;
if (path_fileprops(m_fn, &ucstat) != 0) {
LOGERR(("FileInterner: can't stat the uncompressed file"
"[%s] errno %d\n", m_fn.c_str(), errno));
LOGERR("FileInterner: can't stat the uncompressed file[" << (m_fn) << "] errno " << (errno) << "\n" );
return;
} else {
docsize = ucstat.st_size;
@@ -206,8 +204,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (l_mime.empty() && imime)
l_mime = *imime;
} else {
LOGINFO(("FileInterner:: %s over size limit %d kbs\n",
m_fn.c_str(), maxkbs));
LOGINFO("FileInterner:: " << (m_fn) << " over size limit " << (maxkbs) << " kbs\n" );
}
}
}
@@ -215,7 +212,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (l_mime.empty()) {
// No mime type. We let it through as config may warrant that
// we index all file names
LOGDEB0(("FileInterner:: no mime: [%s]\n", m_fn.c_str()));
LOGDEB0("FileInterner:: no mime: [" << (m_fn) << "]\n" );
}
// Look for appropriate handler (might still return empty)
@@ -224,8 +221,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (!df || df->is_unknown()) {
// No real handler for this type, for now :(
LOGDEB(("FileInterner:: unprocessed mime: [%s] [%s]\n",
l_mime.c_str(), f.c_str()));
LOGDEB("FileInterner:: unprocessed mime: [" << (l_mime) << "] [" << (f) << "]\n" );
if (!df)
return;
}
@@ -245,12 +241,12 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
df->set_docsize(docsize);
if (!df->set_document_file(l_mime, m_fn)) {
delete df;
LOGERR(("FileInterner:: error converting %s\n", m_fn.c_str()));
LOGERR("FileInterner:: error converting " << (m_fn) << "\n" );
return;
}
m_handlers.push_back(df);
LOGDEB(("FileInterner:: init ok %s [%s]\n", l_mime.c_str(), m_fn.c_str()));
LOGDEB("FileInterner:: init ok " << (l_mime) << " [" << (m_fn) << "]\n" );
m_ok = true;
}
@@ -259,7 +255,7 @@ FileInterner::FileInterner(const string &data, RclConfig *cnf,
int flags, const string& imime)
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
{
LOGDEB0(("FileInterner::FileInterner(data)\n"));
LOGDEB0("FileInterner::FileInterner(data)\n" );
initcommon(cnf, flags);
init(data, cnf, flags, imime);
}
@@ -268,7 +264,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
int flags, const string& imime)
{
if (imime.empty()) {
LOGERR(("FileInterner: inmemory constructor needs input mime type\n"));
LOGERR("FileInterner: inmemory constructor needs input mime type\n" );
return;
}
m_mimetype = imime;
@@ -279,7 +275,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
if (!df) {
// No handler for this type, for now :( if indexallfilenames
// is set in the config, this normally wont happen (we get mh_unknown)
LOGDEB(("FileInterner:: unprocessed mime [%s]\n", m_mimetype.c_str()));
LOGDEB("FileInterner:: unprocessed mime [" << (m_mimetype) << "]\n" );
return;
}
df->set_property(Dijon::Filter::OPERATING_MODE,
@@ -300,8 +296,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
}
}
if (!result) {
LOGINFO(("FileInterner:: set_doc failed inside for mtype %s\n",
m_mimetype.c_str()));
LOGINFO("FileInterner:: set_doc failed inside for mtype " << (m_mimetype) << "\n" );
delete df;
return;
}
@@ -325,17 +320,17 @@ void FileInterner::initcommon(RclConfig *cnf, int flags)
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
: m_ok(false), m_missingdatap(0), m_uncomp(((flags & FIF_forPreview) != 0))
{
LOGDEB0(("FileInterner::FileInterner(idoc)\n"));
LOGDEB0("FileInterner::FileInterner(idoc)\n" );
initcommon(cnf, flags);
DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) {
LOGERR(("FileInterner:: no backend\n"));
LOGERR("FileInterner:: no backend\n" );
return;
}
DocFetcher::RawDoc rawdoc;
if (!fetcher->fetch(cnf, idoc, rawdoc)) {
LOGERR(("FileInterner:: fetcher failed\n"));
LOGERR("FileInterner:: fetcher failed\n" );
return;
}
switch (rawdoc.kind) {
@@ -350,7 +345,7 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
m_direct = true;
break;
default:
LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n"));
LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" );
}
return;
}
@@ -359,7 +354,7 @@ bool FileInterner::makesig(RclConfig *cnf, const Rcl::Doc& idoc, string& sig)
{
DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) {
LOGERR(("FileInterner::makesig no backend for doc\n"));
LOGERR("FileInterner::makesig no backend for doc\n" );
return false;
}
@@ -386,14 +381,12 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt)
// Create temp file with appropriate suffix for mime type
TempFile temp(new TempFileInternal(m_cfg->getSuffixFromMimeType(mt)));
if (!temp->ok()) {
LOGERR(("FileInterner::dataToTempFile: cant create tempfile: %s\n",
temp->getreason().c_str()));
LOGERR("FileInterner::dataToTempFile: cant create tempfile: " << (temp->getreason()) << "\n" );
return TempFile();
}
string reason;
if (!stringtofile(dt, temp->filename(), reason)) {
LOGERR(("FileInterner::dataToTempFile: stringtofile: %s\n",
reason.c_str()));
LOGERR("FileInterner::dataToTempFile: stringtofile: " << (reason) << "\n" );
return TempFile();
}
return temp;
@@ -404,7 +397,7 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt)
// RECFILTERROR HELPERNOTFOUND program1 [program2 ...]
void FileInterner::checkExternalMissing(const string& msg, const string& mt)
{
LOGDEB2(("checkExternalMissing: [%s]\n", msg.c_str()));
LOGDEB2("checkExternalMissing: [" << (msg) << "]\n" );
if (m_missingdatap && msg.find("RECFILTERROR") == 0) {
vector<string> verr;
stringToStrings(msg, verr);
@@ -496,10 +489,10 @@ static inline bool getKeyValue(const map<string, string>& docdata,
it = docdata.find(key);
if (it != docdata.end()) {
value = it->second;
LOGDEB2(("getKeyValue: [%s]->[%s]\n", key.c_str(), value.c_str()));
LOGDEB2("getKeyValue: [" << (key) << "]->[" << (value) << "]\n" );
return true;
}
LOGDEB2(("getKeyValue: no value for [%s]\n", key.c_str()));
LOGDEB2("getKeyValue: no value for [" << (key) << "]\n" );
return false;
}
@@ -508,7 +501,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
RecollFilter *df = m_handlers.back();
if (df == 0) {
//??
LOGERR(("FileInterner::dijontorcl: null top handler ??\n"));
LOGERR("FileInterner::dijontorcl: null top handler ??\n" );
return false;
}
const map<string, string>& docdata = df->get_meta_data();
@@ -575,7 +568,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
// actually complicated.
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
{
LOGDEB2(("FileInterner::collectIpathAndMT\n"));
LOGDEB2("FileInterner::collectIpathAndMT\n" );
bool hasipath = false;
if (!m_noxattrs) {
@@ -624,7 +617,7 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
// Trim empty tail elements in ipath.
if (hasipath) {
LOGDEB2(("IPATH [%s]\n", doc.ipath.c_str()));
LOGDEB2("IPATH [" << (doc.ipath) << "]\n" );
string::size_type sit = doc.ipath.find_last_not_of(cstr_isep);
if (sit == string::npos)
doc.ipath.erase();
@@ -660,8 +653,7 @@ int FileInterner::addHandler()
getKeyValue(docdata, cstr_dj_keycharset, charset);
getKeyValue(docdata, cstr_dj_keymt, mimetype);
LOGDEB(("FileInterner::addHandler: next_doc is %s target [%s]\n",
mimetype.c_str(), m_targetMType.c_str()));
LOGDEB("FileInterner::addHandler: next_doc is " << (mimetype) << " target [" << (m_targetMType) << "]\n" );
// If we find a document of the target type (text/plain in
// general), we're done decoding. If we hit text/plain, we're done
@@ -669,7 +661,7 @@ int FileInterner::addHandler()
if (!stringicmp(mimetype, m_targetMType) ||
!stringicmp(mimetype, cstr_textplain)) {
m_reachedMType = mimetype;
LOGDEB1(("FileInterner::addHandler: target reached\n"));
LOGDEB1("FileInterner::addHandler: target reached\n" );
return ADD_BREAK;
}
@@ -677,7 +669,7 @@ int FileInterner::addHandler()
if (m_handlers.size() >= MAXHANDLERS) {
// Stack too big. Skip this and go on to check if there is
// something else in the current back()
LOGERR(("FileInterner::addHandler: stack too high\n"));
LOGERR("FileInterner::addHandler: stack too high\n" );
return ADD_CONTINUE;
}
@@ -685,8 +677,7 @@ int FileInterner::addHandler()
if (!newflt) {
// If we can't find a handler, this doc can't be handled
// but there can be other ones so we go on
LOGINFO(("FileInterner::addHandler: no filter for [%s]\n",
mimetype.c_str()));
LOGINFO("FileInterner::addHandler: no filter for [" << (mimetype) << "]\n" );
return ADD_CONTINUE;
}
newflt->set_property(Dijon::Filter::OPERATING_MODE,
@@ -725,8 +716,7 @@ int FileInterner::addHandler()
}
}
if (!setres) {
LOGINFO(("FileInterner::addHandler: set_doc failed inside %s "
" for mtype %s\n", m_fn.c_str(), mimetype.c_str()));
LOGINFO("FileInterner::addHandler: set_doc failed inside " << (m_fn) << " for mtype " << (mimetype) << "\n" );
delete newflt;
if (m_forPreview)
return ADD_ERROR;
@@ -734,7 +724,7 @@ int FileInterner::addHandler()
}
// add handler and go on, maybe this one will give us text...
m_handlers.push_back(newflt);
LOGDEB1(("FileInterner::addHandler: added\n"));
LOGDEB1("FileInterner::addHandler: added\n" );
return ADD_OK;
}
@@ -744,21 +734,19 @@ void FileInterner::processNextDocError(Rcl::Doc &doc)
collectIpathAndMT(doc);
m_reason = m_handlers.back()->get_error();
checkExternalMissing(m_reason, doc.mimetype);
LOGERR(("FileInterner::internfile: next_document error "
"[%s%s%s] %s %s\n", m_fn.c_str(), doc.ipath.empty() ? "" : "|",
doc.ipath.c_str(), doc.mimetype.c_str(), m_reason.c_str()));
LOGERR("FileInterner::internfile: next_document error [" << (m_fn) << "" << (doc.ipath.empty() ? "" : "|") << "" << (doc.ipath) << "] " << (doc.mimetype) << " " << (m_reason) << "\n" );
}
FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath)
{
LOGDEB(("FileInterner::internfile. ipath [%s]\n", ipath.c_str()));
LOGDEB("FileInterner::internfile. ipath [" << (ipath) << "]\n" );
// Get rid of possible image tempfile from older call
m_imgtmp.reset();
if (m_handlers.size() < 1) {
// Just means the constructor failed
LOGDEB(("FileInterner::internfile: no handler: constructor failed\n"));
LOGDEB("FileInterner::internfile: no handler: constructor failed\n" );
return FIError;
}
@@ -777,7 +765,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
}
vipath.insert(vipath.begin(), lipath.begin(), lipath.end());
if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){
LOGERR(("FileInterner::internfile: can't skip\n"));
LOGERR("FileInterner::internfile: can't skip\n" );
return FIError;
}
}
@@ -793,7 +781,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
while (!m_handlers.empty()) {
CancelCheck::instance().checkCancel();
if (loop++ > 1000) {
LOGERR(("FileInterner:: looping!\n"));
LOGERR("FileInterner:: looping!\n" );
return FIError;
}
// If there are no more docs at the current top level we pop and
@@ -805,7 +793,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (m_forPreview) {
m_reason += "Requested document does not exist. ";
m_reason += m_handlers.back()->get_error();
LOGERR(("FileInterner: requested document does not exist\n"));
LOGERR("FileInterner: requested document does not exist\n" );
return FIError;
}
popHandler();
@@ -820,7 +808,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (m_forPreview) {
m_reason += "Requested document does not exist. ";
m_reason += m_handlers.back()->get_error();
LOGERR(("FileInterner: requested document does not exist\n"));
LOGERR("FileInterner: requested document does not exist\n" );
return FIError;
}
popHandler();
@@ -831,20 +819,20 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
// handler to stack.
switch (addHandler()) {
case ADD_OK: // Just go through: handler has been stacked, use it
LOGDEB2(("addHandler returned OK\n"));
LOGDEB2("addHandler returned OK\n" );
break;
case ADD_CONTINUE:
// forget this doc and retrieve next from current handler
// (ipath stays same)
LOGDEB2(("addHandler returned CONTINUE\n"));
LOGDEB2("addHandler returned CONTINUE\n" );
continue;
case ADD_BREAK:
// Stop looping: doc type ok, need complete its processing
// and return it
LOGDEB2(("addHandler returned BREAK\n"));
LOGDEB2("addHandler returned BREAK\n" );
goto breakloop; // when you have to you have to
case ADD_ERROR:
LOGDEB2(("addHandler returned ERROR\n"));
LOGDEB2("addHandler returned ERROR\n" );
return FIError;
}
@@ -858,14 +846,14 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (!ipath.empty()) {
if (m_handlers.size() <= vipath.size() &&
!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])) {
LOGERR(("FileInterner::internfile: can't skip\n"));
LOGERR("FileInterner::internfile: can't skip\n" );
return FIError;
}
}
}
breakloop:
if (m_handlers.empty()) {
LOGDEB(("FileInterner::internfile: conversion ended with no doc\n"));
LOGDEB("FileInterner::internfile: conversion ended with no doc\n" );
return FIError;
}
@@ -908,7 +896,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf,
TempFile temp(new TempFileInternal(
cnf->getSuffixFromMimeType(mimetype)));
if (!temp->ok()) {
LOGERR(("FileInterner::interntofile: can't create temp file\n"));
LOGERR("FileInterner::interntofile: can't create temp file\n" );
return false;
}
otemp = temp;
@@ -934,7 +922,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf,
bool FileInterner::idocToFile(TempFile& otemp, const string& tofile,
RclConfig *cnf, const Rcl::Doc& idoc)
{
LOGDEB(("FileInterner::idocToFile\n"));
LOGDEB("FileInterner::idocToFile\n" );
if (idoc.ipath.empty()) {
return topdocToFile(otemp, tofile, cnf, idoc);
@@ -953,12 +941,12 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile,
{
DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) {
LOGERR(("FileInterner::idocToFile no backend\n"));
LOGERR("FileInterner::idocToFile no backend\n" );
return false;
}
DocFetcher::RawDoc rawdoc;
if (!fetcher->fetch(cnf, idoc, rawdoc)) {
LOGERR(("FileInterner::idocToFile fetcher failed\n"));
LOGERR("FileInterner::idocToFile fetcher failed\n" );
return false;
}
const char *filename = "";
@@ -975,20 +963,18 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile,
switch (rawdoc.kind) {
case DocFetcher::RawDoc::RDK_FILENAME:
if (!copyfile(rawdoc.data.c_str(), filename, reason)) {
LOGERR(("FileInterner::idocToFile: copyfile: %s\n",
reason.c_str()));
LOGERR("FileInterner::idocToFile: copyfile: " << (reason) << "\n" );
return false;
}
break;
case DocFetcher::RawDoc::RDK_DATA:
if (!stringtofile(rawdoc.data, filename, reason)) {
LOGERR(("FileInterner::idocToFile: stringtofile: %s\n",
reason.c_str()));
LOGERR("FileInterner::idocToFile: stringtofile: " << (reason) << "\n" );
return false;
}
break;
default:
LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n"));
LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" );
}
if (tofile.empty())
@@ -1000,13 +986,13 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
const string& ipath, const string& mimetype)
{
if (!ok()) {
LOGERR(("FileInterner::interntofile: constructor failed\n"));
LOGERR("FileInterner::interntofile: constructor failed\n" );
return false;
}
Rcl::Doc doc;
Status ret = internfile(doc, ipath);
if (ret == FileInterner::FIError) {
LOGERR(("FileInterner::interntofile: internfile() failed\n"));
LOGERR("FileInterner::interntofile: internfile() failed\n" );
return false;
}
@@ -1033,8 +1019,7 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
}
string reason;
if (!stringtofile(doc.text, filename, reason)) {
LOGERR(("FileInterner::interntofile: stringtofile : %s\n",
reason.c_str()));
LOGERR("FileInterner::interntofile: stringtofile : " << (reason) << "\n" );
return false;
}
@@ -1045,16 +1030,15 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
{
LOGDEB(("FileInterner::isCompressed: [%s]\n", fn.c_str()));
LOGDEB("FileInterner::isCompressed: [" << (fn) << "]\n" );
struct stat st;
if (path_fileprops(fn, &st) < 0) {
LOGERR(("FileInterner::isCompressed: can't stat [%s]\n", fn.c_str()));
LOGERR("FileInterner::isCompressed: can't stat [" << (fn) << "]\n" );
return false;
}
string l_mime = mimetype(fn, &st, cnf, true);
if (l_mime.empty()) {
LOGERR(("FileInterner::isUncompressed: can't get mime for [%s]\n",
fn.c_str()));
LOGERR("FileInterner::isUncompressed: can't get mime for [" << (fn) << "]\n" );
return false;
}
@@ -1069,17 +1053,15 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
RclConfig *cnf, const Rcl::Doc& doc)
{
LOGDEB(("FileInterner::maybeUncompressToTemp: [%s]\n", fn.c_str()));
LOGDEB("FileInterner::maybeUncompressToTemp: [" << (fn) << "]\n" );
struct stat st;
if (path_fileprops(fn.c_str(), &st) < 0) {
LOGERR(("FileInterner::maybeUncompressToTemp: can't stat [%s]\n",
fn.c_str()));
LOGERR("FileInterner::maybeUncompressToTemp: can't stat [" << (fn) << "]\n" );
return false;
}
string l_mime = mimetype(fn, &st, cnf, true);
if (l_mime.empty()) {
LOGERR(("FileInterner::maybeUncompress.: can't id. mime for [%s]\n",
fn.c_str()));
LOGERR("FileInterner::maybeUncompress.: can't id. mime for [" << (fn) << "]\n" );
return false;
}
@@ -1091,14 +1073,13 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
int maxkbs = -1;
if (cnf->getConfParam("compressedfilemaxkbs", &maxkbs) &&
maxkbs >= 0 && int(st.st_size / 1024) > maxkbs) {
LOGINFO(("FileInterner:: %s over size limit %d kbs\n",
fn.c_str(), maxkbs));
LOGINFO("FileInterner:: " << (fn) << " over size limit " << (maxkbs) << " kbs\n" );
return false;
}
temp =
TempFile(new TempFileInternal(cnf->getSuffixFromMimeType(doc.mimetype)));
if (!temp->ok()) {
LOGERR(("FileInterner: cant create temporary file"));
LOGERR("FileInterner: cant create temporary file" );
return false;
}
@@ -1113,9 +1094,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
// uncompressed file, hopefully staying on the same dev.
string reason;
if (!renameormove(uncomped.c_str(), temp->filename(), reason)) {
LOGERR(("FileInterner::maybeUncompress: move [%s] -> [%s] "
"failed: %s\n",
uncomped.c_str(), temp->filename(), reason.c_str()));
LOGERR("FileInterner::maybeUncompress: move [" << (uncomped) << "] -> [" << (temp->filename()) << "] failed: " << (reason) << "\n" );
return false;
}
return true;
@@ -1131,7 +1110,8 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
using namespace std;
#include "debuglog.h"
#include "log.h"
#include "rclinit.h"
#include "internfile.h"
#include "rclconfig.h"
@@ -1232,3 +1212,4 @@ int main(int argc, char **argv)
}
#endif // TEST_INTERNFILE
+11 -13
View File
@@ -26,7 +26,7 @@
#include "execmd.h"
#include "mh_exec.h"
#include "mh_html.h"
#include "debuglog.h"
#include "log.h"
#include "cancelcheck.h"
#include "smallut.h"
#include "md5ut.h"
@@ -55,11 +55,10 @@ void MEAdv::reset()
void MEAdv::newData(int n)
{
LOGDEB2(("MHExec:newData(%d)\n", n));
LOGDEB2("MHExec:newData(" << (n) << ")\n" );
if (m_filtermaxseconds > 0 &&
time(0L) - m_start > m_filtermaxseconds) {
LOGERR(("MimeHandlerExec: filter timeout (%d S)\n",
m_filtermaxseconds));
LOGERR("MimeHandlerExec: filter timeout (" << (m_filtermaxseconds) << " S)\n" );
throw HandlerTimeout();
}
// If a cancel request was set by the signal handler (or by us
@@ -70,7 +69,7 @@ void MEAdv::newData(int n)
bool MimeHandlerExec::skip_to_document(const string& ipath)
{
LOGDEB(("MimeHandlerExec:skip_to_document: [%s]\n", ipath.c_str()));
LOGDEB("MimeHandlerExec:skip_to_document: [" << (ipath) << "]\n" );
m_ipath = ipath;
return true;
}
@@ -83,13 +82,13 @@ bool MimeHandlerExec::next_document()
return false;
m_havedoc = false;
if (missingHelper) {
LOGDEB(("MimeHandlerExec::next_document(): helper known missing\n"));
LOGDEB("MimeHandlerExec::next_document(): helper known missing\n" );
return false;
}
if (params.empty()) {
// Hu ho
LOGERR(("MimeHandlerExec::mkDoc: empty params\n"));
LOGERR("MimeHandlerExec::mkDoc: empty params\n" );
m_reason = "RECFILTERROR BADCONFIG";
return false;
}
@@ -118,16 +117,15 @@ bool MimeHandlerExec::next_document()
try {
status = mexec.doexec(cmd, myparams, 0, &output);
} catch (HandlerTimeout) {
LOGERR(("MimeHandlerExec: handler timeout\n"));
LOGERR("MimeHandlerExec: handler timeout\n" );
status = 0x110f;
} catch (CancelExcept) {
LOGERR(("MimeHandlerExec: cancelled\n"));
LOGERR("MimeHandlerExec: cancelled\n" );
status = 0x110f;
}
if (status) {
LOGERR(("MimeHandlerExec: command status 0x%x for %s\n",
status, cmd.c_str()));
LOGERR("MimeHandlerExec: command status 0x" << (status) << " for " << (cmd) << "\n" );
if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
// That's how execmd signals a failed exec (most probably
// a missing command). Let'hope no filter uses the same value as
@@ -195,10 +193,10 @@ void MimeHandlerExec::finaldetails()
if (MD5File(m_fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else {
LOGERR(("MimeHandlerExec: cant compute md5 for [%s]: %s\n",
m_fn.c_str(), reason.c_str()));
LOGERR("MimeHandlerExec: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" );
}
}
handle_cs(m_metaData[cstr_dj_keymt]);
}
+35 -46
View File
@@ -23,7 +23,7 @@ using namespace std;
#include "cstr.h"
#include "mh_execm.h"
#include "mh_html.h"
#include "debuglog.h"
#include "log.h"
#include "cancelcheck.h"
#include "smallut.h"
#include "md5ut.h"
@@ -36,10 +36,10 @@ using namespace std;
bool MimeHandlerExecMultiple::startCmd()
{
LOGDEB(("MimeHandlerExecMultiple::startCmd\n"));
LOGDEB("MimeHandlerExecMultiple::startCmd\n" );
if (params.empty()) {
// Hu ho
LOGERR(("MHExecMultiple::startCmd: empty params\n"));
LOGERR("MHExecMultiple::startCmd: empty params\n" );
m_reason = "RECFILTERROR BADCONFIG";
return false;
}
@@ -86,15 +86,15 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
// Read name and length
if (m_cmd.getline(ibuf) <= 0) {
LOGERR(("MHExecMultiple: getline error\n"));
LOGERR("MHExecMultiple: getline error\n" );
return false;
}
LOGDEB1(("MHEM:rde: line [%s]\n", ibuf.c_str()));
LOGDEB1("MHEM:rde: line [" << (ibuf) << "]\n" );
// Empty line (end of message) ?
if (!ibuf.compare("\n")) {
LOGDEB(("MHExecMultiple: Got empty line\n"));
LOGDEB("MHExecMultiple: Got empty line\n" );
name.clear();
return true;
}
@@ -112,8 +112,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
vector<string> tokens;
stringToTokens(ibuf, tokens);
if (tokens.size() != 2) {
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n",
ibuf.c_str()));
LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" );
return false;
}
vector<string>::iterator it = tokens.begin();
@@ -121,13 +120,12 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
string& slen = *it;
int len;
if (sscanf(slen.c_str(), "%d", &len) != 1) {
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n",
ibuf.c_str()));
LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" );
return false;
}
if (len / 1024 > m_maxmemberkb) {
LOGERR(("MHExecMultiple: data len > maxmemberkb\n"));
LOGERR("MHExecMultiple: data len > maxmemberkb\n" );
return false;
}
@@ -144,24 +142,23 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
// Read element data
datap->erase();
if (len > 0 && m_cmd.receive(*datap, len) != len) {
LOGERR(("MHExecMultiple: expected %d bytes of data, got %d\n",
len, datap->length()));
LOGERR("MHExecMultiple: expected " << (len) << " bytes of data, got " << (datap->length()) << "\n" );
return false;
}
LOGDEB1(("MHExecMe:rdDtElt got: name [%s] len %d value [%s]\n",
name.c_str(), len, datap->size() > 100 ?
(datap->substr(0, 100) + " ...").c_str() : datap->c_str()));
LOGDEB1("MHExecMe:rdDtElt got: name [" << name << "] len " << len <<
"value [" << (datap->size() > 100 ?
(datap->substr(0, 100) + " ...") : datap) << endl);
return true;
}
bool MimeHandlerExecMultiple::next_document()
{
LOGDEB(("MimeHandlerExecMultiple::next_document(): [%s]\n", m_fn.c_str()));
LOGDEB("MimeHandlerExecMultiple::next_document(): [" << (m_fn) << "]\n" );
if (m_havedoc == false)
return false;
if (missingHelper) {
LOGDEB(("MHExecMultiple::next_document(): helper known missing\n"));
LOGDEB("MHExecMultiple::next_document(): helper known missing\n" );
return false;
}
@@ -185,8 +182,7 @@ bool MimeHandlerExecMultiple::next_document()
if (MD5File(m_fn, md5, &reason)) {
file_md5 = MD5HexPrint(md5, xmd5);
} else {
LOGERR(("MimeHandlerExecM: cant compute md5 for [%s]: %s\n",
m_fn.c_str(), reason.c_str()));
LOGERR("MimeHandlerExecM: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" );
}
}
obuf << "FileName: " << m_fn.length() << "\n" << m_fn;
@@ -196,8 +192,7 @@ bool MimeHandlerExecMultiple::next_document()
obuf << "Filename: " << 0 << "\n";
}
if (!m_ipath.empty()) {
LOGDEB(("next_doc: sending len %d val [%s]\n", m_ipath.length(),
m_ipath.c_str()));
LOGDEB("next_doc: sending len " << (m_ipath.length()) << " val [" << (m_ipath) << "]\n" );
obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath;
}
if (!m_dfltInputCharset.empty()) {
@@ -208,14 +203,14 @@ bool MimeHandlerExecMultiple::next_document()
obuf << "\n";
if (m_cmd.send(obuf.str()) < 0) {
m_cmd.zapChild();
LOGERR(("MHExecMultiple: send error\n"));
LOGERR("MHExecMultiple: send error\n" );
return false;
}
m_adv.reset();
// Read answer (multiple elements)
LOGDEB1(("MHExecMultiple: reading answer\n"));
LOGDEB1("MHExecMultiple: reading answer\n" );
bool eofnext_received = false;
bool eofnow_received = false;
bool fileerror_received = false;
@@ -231,47 +226,46 @@ bool MimeHandlerExecMultiple::next_document()
return false;
}
} catch (HandlerTimeout) {
LOGINFO(("MHExecMultiple: timeout\n"));
LOGINFO("MHExecMultiple: timeout\n" );
m_cmd.zapChild();
return false;
} catch (CancelExcept) {
LOGINFO(("MHExecMultiple: interrupt\n"));
LOGINFO("MHExecMultiple: interrupt\n" );
m_cmd.zapChild();
return false;
}
if (name.empty())
break;
if (!stringlowercmp("eofnext:", name)) {
LOGDEB(("MHExecMultiple: got EOFNEXT\n"));
LOGDEB("MHExecMultiple: got EOFNEXT\n" );
eofnext_received = true;
} else if (!stringlowercmp("eofnow:", name)) {
LOGDEB(("MHExecMultiple: got EOFNOW\n"));
LOGDEB("MHExecMultiple: got EOFNOW\n" );
eofnow_received = true;
} else if (!stringlowercmp("fileerror:", name)) {
LOGDEB(("MHExecMultiple: got FILEERROR\n"));
LOGDEB("MHExecMultiple: got FILEERROR\n" );
fileerror_received = true;
} else if (!stringlowercmp("subdocerror:", name)) {
LOGDEB(("MHExecMultiple: got SUBDOCERROR\n"));
LOGDEB("MHExecMultiple: got SUBDOCERROR\n" );
subdocerror_received = true;
} else if (!stringlowercmp("ipath:", name)) {
ipath = data;
LOGDEB(("MHExecMultiple: got ipath [%s]\n", data.c_str()));
LOGDEB("MHExecMultiple: got ipath [" << (data) << "]\n" );
} else if (!stringlowercmp("charset:", name)) {
charset = data;
LOGDEB(("MHExecMultiple: got charset [%s]\n", data.c_str()));
LOGDEB("MHExecMultiple: got charset [" << (data) << "]\n" );
} else if (!stringlowercmp("mimetype:", name)) {
mtype = data;
LOGDEB(("MHExecMultiple: got mimetype [%s]\n", data.c_str()));
LOGDEB("MHExecMultiple: got mimetype [" << (data) << "]\n" );
} else {
string nm = stringtolower((const string&)name);
trimstring(nm, ":");
LOGDEB(("MHExecMultiple: got [%s] -> [%s]\n", nm.c_str(),
data.c_str()));
LOGDEB("MHExecMultiple: got [" << (nm) << "] -> [" << (data) << "]\n" );
m_metaData[nm] += data;
}
if (loop == 20) {
// ??
LOGERR(("MHExecMultiple: filter sent too many parameters\n"));
LOGERR("MHExecMultiple: filter sent too many parameters\n" );
return false;
}
}
@@ -289,8 +283,7 @@ bool MimeHandlerExecMultiple::next_document()
// this was wrong. Empty documents can be found ie in zip files and should
// not be interpreted as eof.
if (m_metaData[cstr_dj_keycontent].empty()) {
LOGDEB0(("MHExecMultiple: got empty document inside [%s]: [%s]\n",
m_fn.c_str(), ipath.c_str()));
LOGDEB0("MHExecMultiple: got empty document inside [" << (m_fn) << "]: [" << (ipath) << "]\n" );
}
if (!ipath.empty()) {
@@ -300,8 +293,7 @@ bool MimeHandlerExecMultiple::next_document()
// string which we can use to compute a mime type
m_metaData[cstr_dj_keyipath] = ipath;
if (mtype.empty()) {
LOGDEB0(("MHExecMultiple: no mime type from filter, "
"using ipath for a guess\n"));
LOGDEB0("MHExecMultiple: no mime type from filter, using ipath for a guess\n" );
mtype = mimetype(ipath, 0, m_config, false);
if (mtype.empty()) {
// mimetype() won't call idFile when there is no file. Do it
@@ -310,7 +302,7 @@ bool MimeHandlerExecMultiple::next_document()
// Note this happens for example for directory zip members
// We could recognize them by the end /, but wouldn't know
// what to do with them anyway.
LOGINFO(("MHExecMultiple: cant guess mime type\n"));
LOGINFO("MHExecMultiple: cant guess mime type\n" );
mtype = "application/octet-stream";
}
}
@@ -335,10 +327,7 @@ bool MimeHandlerExecMultiple::next_document()
if (eofnext_received)
m_havedoc = false;
LOGDEB0(("MHExecMultiple: returning %d bytes of content,"
" mtype [%s] charset [%s]\n",
m_metaData[cstr_dj_keycontent].size(),
m_metaData[cstr_dj_keymt].c_str(),
m_metaData[cstr_dj_keycharset].c_str()));
LOGDEB0("MHExecMultiple: returning " << (m_metaData[cstr_dj_keycontent].size()) << " bytes of content, mtype [" << (m_metaData[cstr_dj_keymt]) << "] charset [" << (m_metaData[cstr_dj_keycharset]) << "]\n" );
return true;
}
+13 -18
View File
@@ -17,7 +17,7 @@
#include "cstr.h"
#include "mimehandler.h"
#include "debuglog.h"
#include "log.h"
#include "readfile.h"
#include "transcode.h"
#include "mimeparse.h"
@@ -36,11 +36,11 @@ using namespace std;
bool MimeHandlerHtml::set_document_file(const string& mt, const string &fn)
{
LOGDEB0(("textHtmlToDoc: %s\n", fn.c_str()));
LOGDEB0("textHtmlToDoc: " << (fn) << "\n" );
RecollFilter::set_document_file(mt, fn);
string otext;
if (!file_to_string(fn, otext)) {
LOGINFO(("textHtmlToDoc: cant read: %s\n", fn.c_str()));
LOGINFO("textHtmlToDoc: cant read: " << (fn) << "\n" );
return false;
}
m_filename = fn;
@@ -73,14 +73,12 @@ bool MimeHandlerHtml::next_document()
m_filename.erase();
string charset = m_dfltInputCharset;
LOGDEB(("MHHtml::next_doc.: default supposed input charset: [%s]\n",
charset.c_str()));
LOGDEB("MHHtml::next_doc.: default supposed input charset: [" << (charset) << "]\n" );
// Override default input charset if someone took care to set one:
map<string,string>::const_iterator it = m_metaData.find(cstr_dj_keycharset);
if (it != m_metaData.end() && !it->second.empty()) {
charset = it->second;
LOGDEB(("MHHtml: next_doc.: input charset from ext. metadata: [%s]\n",
charset.c_str()));
LOGDEB("MHHtml: next_doc.: input charset from ext. metadata: [" << (charset) << "]\n" );
}
// - We first try to convert from the supposed charset
@@ -93,14 +91,13 @@ bool MimeHandlerHtml::next_document()
MyHtmlParser result;
for (int pass = 0; pass < 2; pass++) {
string transcoded;
LOGDEB(("Html::mkDoc: pass %d\n", pass));
LOGDEB("Html::mkDoc: pass " << (pass) << "\n" );
MyHtmlParser p;
// Try transcoding. If it fails, use original text.
int ecnt;
if (!transcode(m_html, transcoded, charset, "UTF-8", &ecnt)) {
LOGDEB(("textHtmlToDoc: transcode failed from cs '%s' to UTF-8 for"
"[%s]", charset.c_str(), fn.empty()?"unknown":fn.c_str()));
LOGDEB("textHtmlToDoc: transcode failed from cs '" << (charset) << "' to UTF-8 for[" << (fn.empty()?"unknown":fn) << "]" );
transcoded = m_html;
// We don't know the charset, at all
p.reset_charsets();
@@ -108,11 +105,9 @@ bool MimeHandlerHtml::next_document()
} else {
if (ecnt) {
if (pass == 0) {
LOGDEB(("textHtmlToDoc: init transcode had %d errors for "
"[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str()));
LOGDEB("textHtmlToDoc: init transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" );
} else {
LOGERR(("textHtmlToDoc: final transcode had %d errors for "
"[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str()));
LOGERR("textHtmlToDoc: final transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" );
}
}
// charset has the putative source charset, transcoded is now
@@ -150,16 +145,15 @@ bool MimeHandlerHtml::next_document()
break;
}
LOGDEB(("textHtmlToDoc: charset [%s] doc charset [%s]\n",
charset.c_str(), result.get_charset().c_str()));
LOGDEB("textHtmlToDoc: charset [" << (charset) << "] doc charset [" << (result.get_charset()) << "]\n" );
if (!result.get_charset().empty() &&
!samecharset(result.get_charset(), result.fromcharset)) {
LOGDEB(("textHtmlToDoc: reparse for charsets\n"));
LOGDEB("textHtmlToDoc: reparse for charsets\n" );
// Set the origin charset as specified in document before
// transcoding again
charset = result.get_charset();
} else {
LOGERR(("textHtmlToDoc:: error: non charset exception\n"));
LOGERR("textHtmlToDoc:: error: non charset exception\n" );
return false;
}
}
@@ -181,3 +175,4 @@ bool MimeHandlerHtml::next_document()
}
return true;
}
+44 -63
View File
@@ -33,7 +33,7 @@
#include "transcode.h"
#include "mimeparse.h"
#include "mh_mail.h"
#include "debuglog.h"
#include "log.h"
#include "smallut.h"
#include "mh_html.h"
#include "rclconfig.h"
@@ -89,7 +89,7 @@ void MimeHandlerMail::clear()
bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
{
LOGDEB(("MimeHandlerMail::set_document_file(%s)\n", fn.c_str()));
LOGDEB("MimeHandlerMail::set_document_file(" << (fn) << ")\n" );
RecollFilter::set_document_file(mt, fn);
if (m_fd >= 0) {
close(m_fd);
@@ -103,14 +103,12 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
if (MD5File(fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else {
LOGERR(("MimeHandlerMail: cant md5 [%s]: %s\n", fn.c_str(),
reason.c_str()));
LOGERR("MimeHandlerMail: cant md5 [" << (fn) << "]: " << (reason) << "\n" );
}
}
m_fd = open(fn.c_str(), 0);
if (m_fd < 0) {
LOGERR(("MimeHandlerMail::set_document_file: open(%s) errno %d\n",
fn.c_str(), errno));
LOGERR("MimeHandlerMail::set_document_file: open(" << (fn) << ") errno " << (errno) << "\n" );
return false;
}
#if defined O_NOATIME && O_NOATIME != 0
@@ -122,8 +120,7 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
m_bincdoc = new Binc::MimeDocument;
m_bincdoc->parseFull(m_fd);
if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) {
LOGERR(("MimeHandlerMail::mkDoc: mime parse error for %s\n",
fn.c_str()));
LOGERR("MimeHandlerMail::mkDoc: mime parse error for " << (fn) << "\n" );
return false;
}
m_havedoc = true;
@@ -133,8 +130,8 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
bool MimeHandlerMail::set_document_string(const string& mt,
const string &msgtxt)
{
LOGDEB1(("MimeHandlerMail::set_document_string\n"));
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str()));
LOGDEB1("MimeHandlerMail::set_document_string\n" );
LOGDEB2("Message text: [" << (msgtxt) << "]\n" );
RecollFilter::set_document_string(mt, msgtxt);
delete m_stream;
@@ -145,19 +142,17 @@ bool MimeHandlerMail::set_document_string(const string& mt,
}
if ((m_stream = new stringstream(msgtxt)) == 0 || !m_stream->good()) {
LOGERR(("MimeHandlerMail::set_document_string: stream create error."
"msgtxt.size() %d\n", int(msgtxt.size())));
LOGERR("MimeHandlerMail::set_document_string: stream create error.msgtxt.size() " << (int(msgtxt.size())) << "\n" );
return false;
}
delete m_bincdoc;
if ((m_bincdoc = new Binc::MimeDocument) == 0) {
LOGERR(("MimeHandlerMail::set_doc._string: new Binc:Document failed."
" Out of memory?"));
LOGERR("MimeHandlerMail::set_doc._string: new Binc:Document failed. Out of memory?" );
return false;
}
m_bincdoc->parseFull(*m_stream);
if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) {
LOGERR(("MimeHandlerMail::set_document_string: mime parse error\n"));
LOGERR("MimeHandlerMail::set_document_string: mime parse error\n" );
return false;
}
m_havedoc = true;
@@ -166,14 +161,14 @@ bool MimeHandlerMail::set_document_string(const string& mt,
bool MimeHandlerMail::skip_to_document(const string& ipath)
{
LOGDEB(("MimeHandlerMail::skip_to_document(%s)\n", ipath.c_str()));
LOGDEB("MimeHandlerMail::skip_to_document(" << (ipath) << ")\n" );
if (m_idx == -1) {
// No decoding done yet. If ipath is null need do nothing
if (ipath.empty() || ipath == "-1")
return true;
// ipath points to attachment: need to decode message
if (!next_document()) {
LOGERR(("MimeHandlerMail::skip_to_doc: next_document failed\n"));
LOGERR("MimeHandlerMail::skip_to_doc: next_document failed\n" );
return false;
}
}
@@ -183,8 +178,7 @@ bool MimeHandlerMail::skip_to_document(const string& ipath)
bool MimeHandlerMail::next_document()
{
LOGDEB(("MimeHandlerMail::next_document m_idx %d m_havedoc %d\n",
m_idx, m_havedoc));
LOGDEB("MimeHandlerMail::next_document m_idx " << (m_idx) << " m_havedoc " << (m_havedoc) << "\n" );
if (!m_havedoc)
return false;
bool res = false;
@@ -192,8 +186,7 @@ bool MimeHandlerMail::next_document()
if (m_idx == -1) {
m_metaData[cstr_dj_keymt] = cstr_textplain;
res = processMsg(m_bincdoc, 0);
LOGDEB1(("MimeHandlerMail::next_document: mt %s, att cnt %d\n",
m_metaData[cstr_dj_keymt].c_str(), m_attachments.size()));
LOGDEB1("MimeHandlerMail::next_document: mt " << (m_metaData[cstr_dj_keymt]) << ", att cnt " << (m_attachments.size()) << "\n" );
const string& txt = m_metaData[cstr_dj_keycontent];
if (m_startoftext < txt.size())
m_metaData[cstr_dj_keyabstract] =
@@ -228,16 +221,16 @@ static bool decodeBody(const string& cte, // Content transfer encoding
if (!stringlowercmp("quoted-printable", cte)) {
if (!qp_decode(body, decoded)) {
LOGERR(("decodeBody: quoted-printable decoding failed !\n"));
LOGDEB((" Body: \n%s\n", body.c_str()));
LOGERR("decodeBody: quoted-printable decoding failed !\n" );
LOGDEB(" Body: \n" << (body) << "\n" );
return false;
}
*respp = &decoded;
} else if (!stringlowercmp("base64", cte)) {
if (!base64_decode(body, decoded)) {
// base64 encoding errors are actually relatively common
LOGERR(("decodeBody: base64 decoding failed !\n"));
LOGDEB((" Body: \n%s\n", body.c_str()));
LOGERR("decodeBody: base64 decoding failed !\n" );
LOGDEB(" Body: \n" << (body) << "\n" );
return false;
}
*respp = &decoded;
@@ -247,7 +240,7 @@ static bool decodeBody(const string& cte, // Content transfer encoding
bool MimeHandlerMail::processAttach()
{
LOGDEB(("MimeHandlerMail::processAttach() m_idx %d\n", m_idx));
LOGDEB("MimeHandlerMail::processAttach() m_idx " << (m_idx) << "\n" );
if (!m_havedoc)
return false;
if (m_idx >= (int)m_attachments.size()) {
@@ -261,10 +254,7 @@ bool MimeHandlerMail::processAttach()
m_metaData[cstr_dj_keycharset] = att->m_charset;
m_metaData[cstr_dj_keyfn] = att->m_filename;
m_metaData[cstr_dj_keytitle] = att->m_filename + " (" + m_subject + ")";
LOGDEB1((" processAttach:ct [%s] cs [%s] fn [%s]\n",
att->m_contentType.c_str(),
att->m_charset.c_str(),
att->m_filename.c_str()));
LOGDEB1(" processAttach:ct [" << (att->m_contentType) << "] cs [" << (att->m_charset) << "] fn [" << (att->m_filename) << "]\n" );
// Erase current content and replace
m_metaData[cstr_dj_keycontent] = string();
@@ -315,11 +305,10 @@ bool MimeHandlerMail::processAttach()
// text
bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
{
LOGDEB2(("MimeHandlerMail::processMsg: depth %d\n", depth));
LOGDEB2("MimeHandlerMail::processMsg: depth " << (depth) << "\n" );
if (depth++ >= maxdepth) {
// Have to stop somewhere
LOGINFO(("MimeHandlerMail::processMsg: maxdepth %d exceeded\n",
maxdepth));
LOGINFO("MimeHandlerMail::processMsg: maxdepth " << (maxdepth) << " exceeded\n" );
// Return true anyway, better to index partially than not at all
return true;
}
@@ -371,7 +360,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
m_metaData[cstr_dj_keymd] = ascuxtime;
} else {
// Leave mtime field alone, ftime will be used instead.
LOGDEB(("rfc2822Date...: failed: [%s]\n", decoded.c_str()));
LOGDEB("rfc2822Date...: failed: [" << (decoded) << "]\n" );
}
}
if (preview())
@@ -405,12 +394,10 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
text += '\n';
m_startoftext = text.size();
LOGDEB2(("MimeHandlerMail::processMsg:ismultipart %d mime subtype '%s'\n",
doc->isMultipart(), doc->getSubType().c_str()));
LOGDEB2("MimeHandlerMail::processMsg:ismultipart " << (doc->isMultipart()) << " mime subtype '" << (doc->getSubType()) << "'\n" );
walkmime(doc, depth);
LOGDEB2(("MimeHandlerMail::processMsg:text:[%s]\n",
m_metaData[cstr_dj_keycontent].c_str()));
LOGDEB2("MimeHandlerMail::processMsg:text:[" << (m_metaData[cstr_dj_keycontent]) << "]\n" );
return true;
}
@@ -426,17 +413,16 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
// message/rfc822 may also be of interest.
void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
{
LOGDEB2(("MimeHandlerMail::walkmime: depth %d\n", depth));
LOGDEB2("MimeHandlerMail::walkmime: depth " << (depth) << "\n" );
if (depth++ >= maxdepth) {
LOGINFO(("walkmime: max depth (%d) exceeded\n", maxdepth));
LOGINFO("walkmime: max depth (" << (maxdepth) << ") exceeded\n" );
return;
}
string& out = m_metaData[cstr_dj_keycontent];
if (doc->isMultipart()) {
LOGDEB2(("walkmime: ismultipart %d subtype '%s'\n",
doc->isMultipart(), doc->getSubType().c_str()));
LOGDEB2("walkmime: ismultipart " << (doc->isMultipart()) << " subtype '" << (doc->getSubType()) << "'\n" );
// We only handle alternative, related and mixed (no digests).
std::vector<Binc::MimePart>::iterator it;
@@ -459,22 +445,22 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
// Get and parse content-type header
Binc::HeaderItem hi;
if (!it->h.getFirstHeader("Content-Type", hi)) {
LOGDEB(("walkmime:no ctent-type header for part %d\n", i));
LOGDEB("walkmime:no ctent-type header for part " << (i) << "\n" );
continue;
}
MimeHeaderValue content_type;
parseMimeHeaderValue(hi.getValue(), content_type);
LOGDEB2(("walkmime: C-type: %s\n",content_type.value.c_str()));
LOGDEB2("walkmime: C-type: " << (content_type.value) << "\n" );
if (!stringlowercmp(cstr_textplain, content_type.value))
ittxt = it;
else if (!stringlowercmp("text/html", content_type.value))
ithtml = it;
}
if (ittxt != doc->members.end()) {
LOGDEB2(("walkmime: alternative: chose text/plain part\n"))
LOGDEB2("walkmime: alternative: chose text/plain part\n" );
walkmime(&(*ittxt), depth);
} else if (ithtml != doc->members.end()) {
LOGDEB2(("walkmime: alternative: chose text/html part\n"))
LOGDEB2("walkmime: alternative: chose text/html part\n" );
walkmime(&(*ithtml), depth);
}
}
@@ -490,7 +476,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
if (doc->h.getFirstHeader("Content-Type", hi)) {
ctt = hi.getValue();
}
LOGDEB2(("walkmime:content-type: %s\n", ctt.c_str()));
LOGDEB2("walkmime:content-type: " << (ctt) << "\n" );
MimeHeaderValue content_type;
parseMimeHeaderValue(ctt, content_type);
@@ -501,7 +487,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
}
MimeHeaderValue content_disposition;
parseMimeHeaderValue(ctd, content_disposition);
LOGDEB2(("Content_disposition:[%s]\n", content_disposition.value.c_str()));
LOGDEB2("Content_disposition:[" << (content_disposition.value) << "]\n" );
string dispindic;
if (stringlowercmp("inline", content_disposition.value))
dispindic = "Attachment";
@@ -521,7 +507,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
}
if (doc->isMessageRFC822()) {
LOGDEB2(("walkmime: message/RFC822 part\n"));
LOGDEB2("walkmime: message/RFC822 part\n" );
// The first part is the already parsed message. Call
// processMsg instead of walkmime so that mail headers get
@@ -542,7 +528,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
}
// "Simple" part.
LOGDEB2(("walkmime: simple part\n"));
LOGDEB2("walkmime: simple part\n" );
// Normally the default charset is us-ascii. But it happens that 8
// bit chars exist in a message that is stated as us-ascii. Ie the
// mailer used by yahoo support ('KANA') does this. We could
@@ -589,7 +575,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
}
MHMailAttach *att = new MHMailAttach;
if (att == 0) {
LOGERR(("Out of memory\n"));
LOGERR("Out of memory\n" );
return;
}
att->m_contentType = content_type.value;
@@ -598,11 +584,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
att->m_charset = charset;
att->m_contentTransferEncoding = cte;
att->m_part = doc;
LOGDEB(("walkmime: attachmnt: ct [%s] cte [%s] cs [%s] fn [%s]\n",
att->m_contentType.c_str(),
att->m_contentTransferEncoding.c_str(),
att->m_charset.c_str(),
filename.c_str()));
LOGDEB("walkmime: attachmnt: ct [" << (att->m_contentType) << "] cte [" << (att->m_contentTransferEncoding) << "] cs [" << (att->m_charset) << "] fn [" << (filename) << "]\n" );
m_attachments.push_back(att);
return;
}
@@ -612,15 +594,14 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
// filter stack work: this would create another subdocument, but
// we want instead to decode a body part of this message document.
LOGDEB2(("walkmime: final: body start offset %d, length %d\n",
doc->getBodyStartOffset(), doc->getBodyLength()));
LOGDEB2("walkmime: final: body start offset " << (doc->getBodyStartOffset()) << ", length " << (doc->getBodyLength()) << "\n" );
string body;
doc->getBody(body, 0, doc->bodylength);
{
string decoded;
const string *bdp;
if (!decodeBody(cte, body, decoded, &bdp)) {
LOGERR(("MimeHandlerMail::walkmime: failed decoding body\n"));
LOGERR("MimeHandlerMail::walkmime: failed decoding body\n" );
}
if (bdp != &body)
body.swap(decoded);
@@ -641,10 +622,9 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} else {
string utf8;
// Transcode to utf-8
LOGDEB1(("walkmime: transcoding from %s to UTF-8\n", charset.c_str()));
LOGDEB1("walkmime: transcoding from " << (charset) << " to UTF-8\n" );
if (!transcode(body, utf8, charset, cstr_utf8)) {
LOGERR(("walkmime: transcode failed from cs '%s' to UTF-8\n",
charset.c_str()));
LOGERR("walkmime: transcode failed from cs '" << (charset) << "' to UTF-8\n" );
out += body;
} else {
out += utf8;
@@ -654,5 +634,6 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
if (out.length() && out[out.length()-1] != '\n')
out += '\n';
LOGDEB2(("walkmime: out now: [%s]\n", out.c_str()));
LOGDEB2("walkmime: out now: [" << (out) << "]\n" );
}
+30 -42
View File
@@ -38,7 +38,7 @@
#include "cstr.h"
#include "mimehandler.h"
#include "debuglog.h"
#include "log.h"
#include "readfile.h"
#include "mh_mbox.h"
#include "smallut.h"
@@ -100,47 +100,43 @@ public:
~MboxCache() {}
mbhoff_type get_offset(RclConfig *config, const string& udi, int msgnum)
{
LOGDEB0(("MboxCache::get_offsets: udi [%s] msgnum %d\n", udi.c_str(),
msgnum));
LOGDEB0("MboxCache::get_offsets: udi [" << (udi) << "] msgnum " << (msgnum) << "\n" );
if (!ok(config)) {
LOGDEB0(("MboxCache::get_offsets: init failed\n"));
LOGDEB0("MboxCache::get_offsets: init failed\n" );
return -1;
}
PTMutexLocker locker(o_mcache_mutex);
string fn = makefilename(udi);
FILE *fp = 0;
if ((fp = fopen(fn.c_str(), "r")) == 0) {
LOGDEB(("MboxCache::get_offsets: open failed, errno %d\n", errno));
LOGDEB("MboxCache::get_offsets: open failed, errno " << (errno) << "\n" );
return -1;
}
FpKeeper keeper(&fp);
char blk1[M_o_b1size];
if (fread(blk1, 1, o_b1size, fp) != o_b1size) {
LOGDEB0(("MboxCache::get_offsets: read blk1 errno %d\n", errno));
LOGDEB0("MboxCache::get_offsets: read blk1 errno " << (errno) << "\n" );
return -1;
}
ConfSimple cf(string(blk1, o_b1size));
string fudi;
if (!cf.get("udi", fudi) || fudi.compare(udi)) {
LOGINFO(("MboxCache::get_offset:badudi fn %s udi [%s], fudi [%s]\n",
fn.c_str(), udi.c_str(), fudi.c_str()));
LOGINFO("MboxCache::get_offset:badudi fn " << (fn) << " udi [" << (udi) << "], fudi [" << (fudi) << "]\n" );
return -1;
}
if (fseeko(fp, cacheoffset(msgnum), SEEK_SET) != 0) {
LOGDEB0(("MboxCache::get_offsets: seek %s errno %d\n",
lltodecstr(cacheoffset(msgnum)).c_str(), errno));
LOGDEB0("MboxCache::get_offsets: seek " << (lltodecstr(cacheoffset(msgnum))) << " errno " << (errno) << "\n" );
return -1;
}
mbhoff_type offset = -1;
size_t ret;
if ((ret = fread(&offset, 1, sizeof(mbhoff_type), fp))
!= sizeof(mbhoff_type)) {
LOGDEB0(("MboxCache::get_offsets: read ret %d errno %d\n",
ret, errno));
LOGDEB0("MboxCache::get_offsets: read ret " << (ret) << " errno " << (errno) << "\n" );
return -1;
}
LOGDEB0(("MboxCache::get_offsets: ret %s\n", lltodecstr(offset).c_str()));
LOGDEB0("MboxCache::get_offsets: ret " << (lltodecstr(offset)) << "\n" );
return offset;
}
@@ -148,7 +144,7 @@ public:
void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize,
vector<mbhoff_type>& offs)
{
LOGDEB0(("MboxCache::put_offsets: %u offsets\n", offs.size()));
LOGDEB0("MboxCache::put_offsets: " << (offs.size()) << " offsets\n" );
if (!ok(config) || !maybemakedir())
return;
if (fsize < m_minfsize)
@@ -157,7 +153,7 @@ public:
string fn = makefilename(udi);
FILE *fp;
if ((fp = fopen(fn.c_str(), "w")) == 0) {
LOGDEB(("MboxCache::put_offsets: fopen errno %d\n", errno));
LOGDEB("MboxCache::put_offsets: fopen errno " << (errno) << "\n" );
return;
}
FpKeeper keeper(&fp);
@@ -167,7 +163,7 @@ public:
blk1.append(cstr_newline);
blk1.resize(o_b1size, 0);
if (fwrite(blk1.c_str(), 1, o_b1size, fp) != o_b1size) {
LOGDEB(("MboxCache::put_offsets: fwrite errno %d\n", errno));
LOGDEB("MboxCache::put_offsets: fwrite errno " << (errno) << "\n" );
return;
}
@@ -261,7 +257,7 @@ void MimeHandlerMbox::clear()
bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
{
LOGDEB(("MimeHandlerMbox::set_document_file(%s)\n", fn.c_str()));
LOGDEB("MimeHandlerMbox::set_document_file(" << (fn) << ")\n" );
RecollFilter::set_document_file(mt, fn);
m_fn = fn;
if (m_vfp) {
@@ -271,8 +267,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
m_vfp = fopen(fn.c_str(), "r");
if (m_vfp == 0) {
LOGERR(("MimeHandlerMail::set_document_file: error opening %s\n",
fn.c_str()));
LOGERR("MimeHandlerMail::set_document_file: error opening " << (fn) << "\n" );
return false;
}
#if defined O_NOATIME && O_NOATIME != 0
@@ -283,8 +278,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
// Used to use ftell() here: no good beyond 2GB
{struct stat st;
if (fstat(fileno((FILE*)m_vfp), &st) < 0) {
LOGERR(("MimeHandlerMbox:setdocfile: fstat(%s) failed errno %d\n",
fn.c_str(), errno));
LOGERR("MimeHandlerMbox:setdocfile: fstat(" << (fn) << ") failed errno " << (errno) << "\n" );
return false;
}
m_fsize = st.st_size;
@@ -297,7 +291,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
string quirks;
if (m_config && m_config->getConfParam(cstr_keyquirks, quirks)) {
if (quirks == "tbird") {
LOGDEB(("MimeHandlerMbox: setting quirks TBIRD\n"));
LOGDEB("MimeHandlerMbox: setting quirks TBIRD\n" );
m_quirks |= MBOXQUIRK_TBIRD;
}
}
@@ -305,8 +299,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
// And double check for thunderbird
string tbirdmsf = fn + ".msf";
if ((m_quirks&MBOXQUIRK_TBIRD) == 0 && path_exists(tbirdmsf)) {
LOGDEB(("MimeHandlerMbox: detected unconfigured tbird mbox in %s\n",
fn.c_str()));
LOGDEB("MimeHandlerMbox: detected unconfigured tbird mbox in " << (fn) << "\n" );
m_quirks |= MBOXQUIRK_TBIRD;
}
@@ -423,7 +416,7 @@ static void compileregexes()
bool MimeHandlerMbox::next_document()
{
if (m_vfp == 0) {
LOGERR(("MimeHandlerMbox::next_document: not open\n"));
LOGERR("MimeHandlerMbox::next_document: not open\n" );
return false;
}
if (!m_havedoc) {
@@ -435,11 +428,10 @@ bool MimeHandlerMbox::next_document()
sscanf(m_ipath.c_str(), "%d", &mtarg);
} else if (m_forPreview) {
// Can't preview an mbox.
LOGDEB(("MimeHandlerMbox::next_document: can't preview folders!\n"));
LOGDEB("MimeHandlerMbox::next_document: can't preview folders!\n" );
return false;
}
LOGDEB0(("MimeHandlerMbox::next_document: fn %s, msgnum %d mtarg %d \n",
m_fn.c_str(), m_msgnum, mtarg));
LOGDEB0("MimeHandlerMbox::next_document: fn " << (m_fn) << ", msgnum " << (m_msgnum) << " mtarg " << (mtarg) << " \n" );
if (mtarg == 0)
mtarg = -1;
@@ -459,8 +451,7 @@ bool MimeHandlerMbox::next_document()
if (mtarg > 0) {
mbhoff_type off;
line_type line;
LOGDEB0(("MimeHandlerMbox::next_doc: mtarg %d m_udi[%s]\n",
mtarg, m_udi.c_str()));
LOGDEB0("MimeHandlerMbox::next_doc: mtarg " << (mtarg) << " m_udi[" << (m_udi) << "]\n" );
if (!m_udi.empty() &&
(off = o_mcache.get_offset(m_config, m_udi, mtarg)) >= 0 &&
fseeko(fp, (off_t)off, SEEK_SET) >= 0 &&
@@ -468,7 +459,7 @@ bool MimeHandlerMbox::next_document()
(!M_regexec(fromregex, line, 0, 0, 0) ||
((m_quirks & MBOXQUIRK_TBIRD) &&
!M_regexec(minifromregex, line, 0, 0, 0))) ) {
LOGDEB0(("MimeHandlerMbox: Cache: From_ Ok\n"));
LOGDEB0("MimeHandlerMbox: Cache: From_ Ok\n" );
fseeko(fp, (off_t)off, SEEK_SET);
m_msgnum = mtarg -1;
storeoffsets = false;
@@ -487,7 +478,7 @@ bool MimeHandlerMbox::next_document()
for (;;) {
message_end = ftello(fp);
if (!fgets(line, LL, fp)) {
LOGDEB2(("MimeHandlerMbox:next: eof\n"));
LOGDEB2("MimeHandlerMbox:next: eof\n" );
iseof = true;
m_msgnum++;
break;
@@ -495,8 +486,7 @@ bool MimeHandlerMbox::next_document()
m_lineno++;
int ll;
stripendnl(line, ll);
LOGDEB2(("mhmbox:next: hadempty %d lineno %d ll %d Line: [%s]\n",
hademptyline, m_lineno, ll, line));
LOGDEB2("mhmbox:next: hadempty " << (hademptyline) << " lineno " << (m_lineno) << " ll " << (ll) << " Line: [" << (line) << "]\n" );
if (hademptyline) {
if (ll > 0) {
// Non-empty line with empty line flag set, reset flag
@@ -514,8 +504,7 @@ bool MimeHandlerMbox::next_document()
((m_quirks & MBOXQUIRK_TBIRD) &&
!M_regexec(minifromregex, line, 0, 0, 0)))
) {
LOGDEB0(("MimeHandlerMbox: msgnum %d, "
"From_ at line %d: [%s]\n", m_msgnum, m_lineno, line));
LOGDEB0("MimeHandlerMbox: msgnum " << (m_msgnum) << ", From_ at line " << (m_lineno) << ": [" << (line) << "]\n" );
if (storeoffsets)
m_offsets.push_back(message_end);
m_msgnum++;
@@ -538,15 +527,13 @@ bool MimeHandlerMbox::next_document()
line[ll+1] = 0;
msgtxt += line;
if (msgtxt.size() > max_mbox_member_size) {
LOGERR(("mh_mbox: huge message (more than %u MB) inside %s,"
" giving up\n", max_mbox_member_size/(1024*1024),
m_fn.c_str()));
LOGERR("mh_mbox: huge message (more than " << (max_mbox_member_size/(1024*1024)) << " MB) inside " << (m_fn) << ", giving up\n" );
return false;
}
}
}
LOGDEB2(("Message text length %d\n", msgtxt.size()));
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str()));
LOGDEB2("Message text length " << (msgtxt.size()) << "\n" );
LOGDEB2("Message text: [" << (msgtxt) << "]\n" );
char buf[20];
// m_msgnum was incremented when hitting the next From_ or eof, so the data
// is for m_msgnum - 1
@@ -554,7 +541,7 @@ bool MimeHandlerMbox::next_document()
m_metaData[cstr_dj_keyipath] = buf;
m_metaData[cstr_dj_keymt] = "message/rfc822";
if (iseof) {
LOGDEB2(("MimeHandlerMbox::next: eof hit\n"));
LOGDEB2("MimeHandlerMbox::next: eof hit\n" );
m_havedoc = false;
if (!m_udi.empty() && storeoffsets) {
o_mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets);
@@ -679,3 +666,4 @@ int main(int argc, char **argv)
#endif // TEST_MH_MBOX
+3 -3
View File
@@ -25,7 +25,7 @@
#include "mimehandler.h"
#include "transcode.h"
#include "pathut.h"
#include "debuglog.h"
#include "log.h"
/** Index symlink target
*
@@ -61,8 +61,7 @@ class MimeHandlerSymlink : public RecollFilter {
transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent],
m_config->getDefCharset(true), "UTF-8");
} else {
LOGDEB(("Symlink: readlink [%s] failed, errno %d\n", m_fn.c_str(),
errno));
LOGDEB("Symlink: readlink [" << (m_fn) << "] failed, errno " << (errno) << "\n" );
}
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
@@ -72,3 +71,4 @@ private:
};
#endif /* _MH_SYMLINK_H_INCLUDED_ */
+7 -9
View File
@@ -27,7 +27,7 @@
#include "cstr.h"
#include "mh_text.h"
#include "debuglog.h"
#include "log.h"
#include "readfile.h"
#include "md5ut.h"
#include "rclconfig.h"
@@ -42,8 +42,7 @@ const int KB = 1024;
// Process a plain text file
bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
{
LOGDEB(("MimeHandlerText::set_document_file: [%s] offs %s\n",
fn.c_str(), lltodecstr(m_offs).c_str()));
LOGDEB("MimeHandlerText::set_document_file: [" << (fn) << "] offs " << (lltodecstr(m_offs)) << "\n" );
RecollFilter::set_document_file(mt, fn);
@@ -55,8 +54,7 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
// file size for oversize check
long long fsize = path_filesize(m_fn);
if (fsize < 0) {
LOGERR(("MimeHandlerText::set_document_file: stat %s errno %d\n",
m_fn.c_str(), errno));
LOGERR("MimeHandlerText::set_document_file: stat " << (m_fn) << " errno " << (errno) << "\n" );
return false;
}
@@ -111,8 +109,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
char *endptr;
long long t = strtoll(ipath.c_str(), &endptr, 10);
if (endptr == ipath.c_str()) {
LOGERR(("MimeHandlerText::skip_to_document: bad ipath offs [%s]\n",
ipath.c_str()));
LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" << (ipath) << "]\n" );
return false;
}
m_offs = (off_t)t;
@@ -122,7 +119,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
bool MimeHandlerText::next_document()
{
LOGDEB(("MimeHandlerText::next_document: m_havedoc %d\n", int(m_havedoc)));
LOGDEB("MimeHandlerText::next_document: m_havedoc " << (int(m_havedoc)) << "\n" );
if (m_havedoc == false)
return false;
@@ -175,7 +172,7 @@ bool MimeHandlerText::readnext()
string reason;
m_text.clear();
if (!file_to_string(m_fn, m_text, m_offs, m_pagesz, &reason)) {
LOGERR(("MimeHandlerText: can't read file: %s\n", reason.c_str()));
LOGERR("MimeHandlerText: can't read file: " << (reason) << "\n" );
m_havedoc = false;
return false;
}
@@ -197,3 +194,4 @@ bool MimeHandlerText::readnext()
m_offs += m_text.length();
return true;
}
+29 -46
View File
@@ -27,7 +27,7 @@ using namespace std;
#include "cstr.h"
#include "mimehandler.h"
#include "debuglog.h"
#include "log.h"
#include "rclconfig.h"
#include "smallut.h"
#include "md5ut.h"
@@ -60,8 +60,7 @@ static RecollFilter *getMimeHandlerFromCache(const string& key)
PTMutexLocker locker(o_handlers_mutex);
string xdigest;
MD5HexPrint(key, xdigest);
LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n",
xdigest.c_str(), o_handlers.size()));
LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " cache size " << (o_handlers.size()) << "\n" );
multimap<string, RecollFilter *>::iterator it = o_handlers.find(key);
if (it != o_handlers.end()) {
@@ -70,14 +69,13 @@ static RecollFilter *getMimeHandlerFromCache(const string& key)
if (it1 != o_hlru.end()) {
o_hlru.erase(it1);
} else {
LOGERR(("getMimeHandlerFromCache: lru position not found\n"));
LOGERR("getMimeHandlerFromCache: lru position not found\n" );
}
o_handlers.erase(it);
LOGDEB(("getMimeHandlerFromCache: %s found size %u\n",
xdigest.c_str(), o_handlers.size()));
LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " found size " << (o_handlers.size()) << "\n" );
return h;
}
LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str()));
LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " not found\n" );
return 0;
}
@@ -87,15 +85,14 @@ void returnMimeHandler(RecollFilter *handler)
typedef multimap<string, RecollFilter*>::value_type value_type;
if (handler == 0) {
LOGERR(("returnMimeHandler: bad parameter\n"));
LOGERR("returnMimeHandler: bad parameter\n" );
return;
}
handler->clear();
PTMutexLocker locker(o_handlers_mutex);
LOGDEB(("returnMimeHandler: returning filter for %s cache size %d\n",
handler->get_mime_type().c_str(), o_handlers.size()));
LOGDEB("returnMimeHandler: returning filter for " << (handler->get_mime_type()) << " cache size " << (o_handlers.size()) << "\n" );
// Limit pool size. The pool can grow quite big because there are
// many filter types, each of which can be used in several copies
@@ -108,9 +105,9 @@ void returnMimeHandler(RecollFilter *handler)
if (once) {
once = 0;
for (it = o_handlers.begin(); it != o_handlers.end(); it++) {
LOGDEB1(("Cache full. key: %s\n", it->first.c_str()));
LOGDEB1("Cache full. key: " << (it->first) << "\n" );
}
LOGDEB1(("Cache LRU size: %u\n", o_hlru.size()));
LOGDEB1("Cache LRU size: " << (o_hlru.size()) << "\n" );
}
if (o_hlru.size() > 0) {
it = o_hlru.back();
@@ -125,7 +122,7 @@ void returnMimeHandler(RecollFilter *handler)
void clearMimeHandlerCache()
{
LOGDEB(("clearMimeHandlerCache()\n"));
LOGDEB("clearMimeHandlerCache()\n" );
multimap<string, RecollFilter *>::iterator it;
PTMutexLocker locker(o_handlers_mutex);
for (it = o_handlers.begin(); it != o_handlers.end(); it++) {
@@ -139,31 +136,31 @@ void clearMimeHandlerCache()
static RecollFilter *mhFactory(RclConfig *config, const string &mime,
bool nobuild, string& id)
{
LOGDEB2(("mhFactory(%s)\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << ")\n" );
string lmime(mime);
stringtolower(lmime);
if (cstr_textplain == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerText\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerText\n" );
MD5String("MimeHandlerText", id);
return nobuild ? 0 : new MimeHandlerText(config, id);
} else if ("text/html" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerHtml\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerHtml\n" );
MD5String("MimeHandlerHtml", id);
return nobuild ? 0 : new MimeHandlerHtml(config, id);
} else if ("text/x-mail" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerMbox\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMbox\n" );
MD5String("MimeHandlerMbox", id);
return nobuild ? 0 : new MimeHandlerMbox(config, id);
} else if ("message/rfc822" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerMail\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMail\n" );
MD5String("MimeHandlerMail", id);
return nobuild ? 0 : new MimeHandlerMail(config, id);
} else if ("inode/symlink" == lmime) {
LOGDEB2(("mhFactory(%s): ret MimeHandlerSymlink\n", mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): ret MimeHandlerSymlink\n" );
MD5String("MimeHandlerSymlink", id);
return nobuild ? 0 : new MimeHandlerSymlink(config, id);
} else if ("application/x-zerosize" == lmime) {
LOGDEB(("mhFactory(%s): ret MimeHandlerNull\n", mime.c_str()));
LOGDEB("mhFactory(" << (mime) << "): ret MimeHandlerNull\n" );
MD5String("MimeHandlerNull", id);
return nobuild ? 0 : new MimeHandlerNull(config, id);
} else if (lmime.find("text/") == 0) {
@@ -172,15 +169,14 @@ static RecollFilter *mhFactory(RclConfig *config, const string &mime,
// mimeconf, not at random. For programs, for example this
// allows indexing and previewing as text/plain (no filter
// exec) but still opening with a specific editor.
LOGDEB2(("mhFactory(%s): returning MimeHandlerText(x)\n",mime.c_str()));
LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerText(x)\n" );
MD5String("MimeHandlerText", id);
return nobuild ? 0 : new MimeHandlerText(config, id);
} else {
// We should not get there. It means that "internal" was set
// as a handler in mimeconf for a mime type we actually can't
// handle.
LOGERR(("mhFactory: mime type [%s] set as internal but unknown\n",
lmime.c_str()));
LOGERR("mhFactory: mime type [" << (lmime) << "] set as internal but unknown\n" );
MD5String("MimeHandlerUnknown", id);
return nobuild ? 0 : new MimeHandlerUnknown(config, id);
}
@@ -203,8 +199,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
string cmdstr;
if (!cfg->valueSplitAttributes(hs, cmdstr, attrs)) {
LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n",
mtype.c_str(), hs.c_str()));
LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" );
return 0;
}
@@ -212,8 +207,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
vector<string> cmdtoks;
stringToStrings(cmdstr, cmdtoks);
if (cmdtoks.empty()) {
LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n",
mtype.c_str(), hs.c_str()));
LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" );
return 0;
}
MimeHandlerExec *h = multiple ?
@@ -227,8 +221,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
// the same change if we ever want to use the same cmdling as windows
if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) {
if (cmdtoks.size() < 2) {
LOGERR(("mhExecFactory: python/perl cmd: no script?. [%s]: [%s]\n",
mtype.c_str(), hs.c_str()));
LOGERR("mhExecFactory: python/perl cmd: no script?. [" << (mtype) << "]: [" << (hs) << "]\n" );
}
vector<string>::iterator it1(it);
it1++;
@@ -251,9 +244,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
for (it = h->params.begin(); it != h->params.end(); it++) {
scmd += string("[") + *it + "] ";
}
LOGDEB(("mhExecFactory:mt [%s] cfgmt [%s] cfgcs [%s] cmd: [%s]\n",
mtype.c_str(), h->cfgFilterOutputMtype.c_str(), h->cfgFilterOutputCharset.c_str(),
scmd.c_str()));
LOGDEB("mhExecFactory:mt [" << (mtype) << "] cfgmt [" << (h->cfgFilterOutputMtype) << "] cfgcs [" << (h->cfgFilterOutputCharset) << "] cmd: [" << (scmd) << "]\n" );
#endif
return h;
@@ -263,8 +254,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
bool filtertypes)
{
LOGDEB(("getMimeHandler: mtype [%s] filtertypes %d\n",
mtype.c_str(), filtertypes));
LOGDEB("getMimeHandler: mtype [" << (mtype) << "] filtertypes " << (filtertypes) << "\n" );
RecollFilter *h = 0;
// Get handler definition for mime type. We do this even if an
@@ -297,18 +287,12 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
MD5String(hs, id);
}
#if 0
{ // string xdigest; LOGDEB2(("getMimeHandler: [%s] hs [%s] id [%s]\n",
//mtype.c_str(), hs.c_str(), MD5HexPrint(id, xdigest).c_str()));
}
#endif
// Do we already have a handler object in the cache ?
h = getMimeHandlerFromCache(id);
if (h != 0)
goto out;
LOGDEB2(("getMimeHandler: %s not in cache\n", mtype.c_str()));
LOGDEB2("getMimeHandler: " << (mtype) << " not in cache\n" );
// Not in cache.
if (internal) {
@@ -319,14 +303,13 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
// partly redundant with the localfields/rclaptg, but
// better and the latter will probably go away at some
// point in the future.
LOGDEB2(("handlertype internal, cmdstr [%s]\n", cmdstr.c_str()));
LOGDEB2("handlertype internal, cmdstr [" << (cmdstr) << "]\n" );
h = mhFactory(cfg, cmdstr.empty() ? mtype : cmdstr, false, id);
goto out;
} else if (!stringlowercmp("dll", handlertype)) {
} else {
if (cmdstr.empty()) {
LOGERR(("getMimeHandler: bad line for %s: %s\n",
mtype.c_str(), hs.c_str()));
LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" );
goto out;
}
if (!stringlowercmp("exec", handlertype)) {
@@ -336,8 +319,7 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
h = mhExecFactory(cfg, mtype, cmdstr, true, id);
goto out;
} else {
LOGERR(("getMimeHandler: bad line for %s: %s\n",
mtype.c_str(), hs.c_str()));
LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" );
goto out;
}
}
@@ -380,3 +362,4 @@ bool canIntern(const std::string mtype, RclConfig *cfg)
return false;
return true;
}
+8 -20
View File
@@ -37,7 +37,7 @@
#include "mimeparse.h"
#include "smallut.h"
#include "cancelcheck.h"
#include "debuglog.h"
#include "log.h"
#include "transcode.h"
static const string cstr_html_charset("charset");
@@ -193,7 +193,7 @@ MyHtmlParser::MyHtmlParser()
void MyHtmlParser::decode_entities(string &s)
{
LOGDEB2(("MyHtmlParser::decode_entities\n"));
LOGDEB2("MyHtmlParser::decode_entities\n" );
// This has no meaning whatsoever if the character encoding is unknown,
// so don't do it. If charset known, caller has converted text to utf-8,
// and this is also how we translate entities
@@ -261,14 +261,7 @@ void MyHtmlParser::decode_entities(string &s)
void
MyHtmlParser::process_text(const string &text)
{
LOGDEB2(("process_text: title %d script %d style %d pre %d "
"pending_space %d txt [%s]\n",
in_title_tag,
in_script_tag,
in_style_tag,
in_pre_tag,
pending_space,
text.c_str()));
LOGDEB2("process_text: title " << (in_title_tag) << " script " << (in_script_tag) << " style " << (in_style_tag) << " pre " << (in_pre_tag) << " pending_space " << (pending_space) << " txt [" << (text) << "]\n" );
CancelCheck::instance().checkCancel();
if (!in_script_tag && !in_style_tag) {
@@ -307,7 +300,7 @@ MyHtmlParser::process_text(const string &text)
bool
MyHtmlParser::opening_tag(const string &tag)
{
LOGDEB2(("opening_tag: [%s]\n", tag.c_str()));
LOGDEB2("opening_tag: [" << (tag) << "]\n" );
#if 0
cout << "TAG: " << tag << ": " << endl;
map<string, string>::const_iterator x;
@@ -419,10 +412,7 @@ MyHtmlParser::opening_tag(const string &tag)
charset = k->second;
if (!charset.empty() &&
!samecharset(charset, fromcharset)) {
LOGDEB1(("Doc http-equiv charset '%s' "
"differs from dir deflt '%s'\n",
charset.c_str(),
fromcharset.c_str()));
LOGDEB1("Doc http-equiv charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" );
throw false;
}
}
@@ -436,10 +426,7 @@ MyHtmlParser::opening_tag(const string &tag)
charset = newcharset;
if (!charset.empty() &&
!samecharset(charset, fromcharset)) {
LOGDEB1(("Doc html5 charset '%s' "
"differs from dir deflt '%s'\n",
charset.c_str(),
fromcharset.c_str()));
LOGDEB1("Doc html5 charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" );
throw false;
}
}
@@ -494,7 +481,7 @@ MyHtmlParser::opening_tag(const string &tag)
bool
MyHtmlParser::closing_tag(const string &tag)
{
LOGDEB2(("closing_tag: [%s]\n", tag.c_str()));
LOGDEB2("closing_tag: [" << (tag) << "]\n" );
if (tag.empty()) return true;
switch (tag[0]) {
case 'a':
@@ -592,3 +579,4 @@ void
MyHtmlParser::do_eof()
{
}
+7 -11
View File
@@ -18,7 +18,7 @@
#include "cstr.h"
#include "transcode.h"
#include "mimehandler.h"
#include "debuglog.h"
#include "log.h"
#include "smallut.h"
@@ -33,8 +33,7 @@ static bool alternate_decode(const string& in, string& out)
{
string lang = localelang();
string code = langtocode(lang);
LOGDEB(("RecollFilter::txtdcode: trying alternate decode from %s\n",
code.c_str()));
LOGDEB("RecollFilter::txtdcode: trying alternate decode from " << (code) << "\n" );
int ecnt;
bool ret = transcode(in, out, code, cstr_utf8, &ecnt);
return ecnt > 5 ? false : ret;
@@ -43,22 +42,18 @@ static bool alternate_decode(const string& in, string& out)
bool RecollFilter::txtdcode(const string& who)
{
if (m_metaData[cstr_dj_keymt].compare(cstr_textplain)) {
LOGERR(("%s::txtdcode: called on non txt/plain: %s\n", who.c_str(),
m_metaData[cstr_dj_keymt].c_str()));
LOGERR("" << (who) << "::txtdcode: called on non txt/plain: " << (m_metaData[cstr_dj_keymt]) << "\n" );
return false;
}
string& ocs = m_metaData[cstr_dj_keyorigcharset];
string& itext = m_metaData[cstr_dj_keycontent];
LOGDEB1(("%s::txtdcode: %d bytes from [%s] to UTF-8\n",
who.c_str(), itext.size(), ocs.c_str()));
LOGDEB1("" << (who) << "::txtdcode: " << (itext.size()) << " bytes from [" << (ocs) << "] to UTF-8\n" );
int ecnt;
string otext;
bool ret = transcode(itext, otext, ocs, cstr_utf8, &ecnt);
if (!ret || ecnt > int(itext.size() / 100)) {
LOGERR(("%s::txtdcode: transcode %d bytes to UTF-8 failed "
"for input charset [%s] ret %d ecnt %d\n",
who.c_str(), itext.size(), ocs.c_str(), ret, ecnt));
LOGERR("" << (who) << "::txtdcode: transcode " << (itext.size()) << " bytes to UTF-8 failed for input charset [" << (ocs) << "] ret " << (ret) << " ecnt " << (ecnt) << "\n" );
if (samecharset(ocs, cstr_utf8)) {
ret = alternate_decode(itext, otext);
@@ -66,7 +61,7 @@ bool RecollFilter::txtdcode(const string& who)
ret = false;
}
if (!ret) {
LOGDEB(("txtdcode: failed. Doc is not text?\n"));
LOGDEB("txtdcode: failed. Doc is not text?\n" );
itext.erase();
return false;
}
@@ -77,3 +72,4 @@ bool RecollFilter::txtdcode(const string& who)
return true;
}
+8 -13
View File
@@ -24,7 +24,7 @@
#include <map>
#include "uncomp.h"
#include "debuglog.h"
#include "log.h"
#include "smallut.h"
#include "execmd.h"
#include "pathut.h"
@@ -57,7 +57,7 @@ bool Uncomp::uncompressfile(const string& ifn,
}
// Make sure tmp dir is empty. we guarantee this to filters
if (!m_dir || !m_dir->ok() || !m_dir->wipe()) {
LOGERR(("uncompressfile: can't clear temp dir %s\n", m_dir->dirname()));
LOGERR("uncompressfile: can't clear temp dir " << (m_dir->dirname()) << "\n" );
return false;
}
@@ -66,14 +66,12 @@ bool Uncomp::uncompressfile(const string& ifn,
int pc;
long long availmbs;
if (!fsocc(m_dir->dirname(), &pc, &availmbs)) {
LOGERR(("uncompressfile: can't retrieve avail space for %s\n",
m_dir->dirname()));
LOGERR("uncompressfile: can't retrieve avail space for " << (m_dir->dirname()) << "\n" );
// Hope for the best
} else {
long long fsize = path_filesize(ifn);
if (fsize < 0) {
LOGERR(("uncompressfile: stat input file %s errno %d\n",
ifn.c_str(), errno));
LOGERR("uncompressfile: stat input file " << (ifn) << " errno " << (errno) << "\n" );
return false;
}
// We need at least twice the file size for the uncompressed
@@ -85,10 +83,7 @@ bool Uncomp::uncompressfile(const string& ifn,
long long filembs = fsize / (1024 * 1024);
if (availmbs < 2 * filembs + 1) {
LOGERR(("uncompressfile. %s MBs available in %s not enough "
"to uncompress %s of size %s mbs\n",
lltodecstr(availmbs).c_str(), m_dir->dirname(),
ifn.c_str(), lltodecstr(filembs).c_str()));
LOGERR("uncompressfile. " << (lltodecstr(availmbs)) << " MBs available in " << (m_dir->dirname()) << " not enough to uncompress " << (ifn) << " of size " << (lltodecstr(filembs)) << " mbs\n" );
return false;
}
}
@@ -112,10 +107,9 @@ bool Uncomp::uncompressfile(const string& ifn,
ExecCmd ex;
int status = ex.doexec(cmd, args, 0, &tfile);
if (status || tfile.empty()) {
LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n",
ifn.c_str(), status));
LOGERR("uncompressfile: doexec: failed for [" << (ifn) << "] status 0x" << (status) << "\n" );
if (!m_dir->wipe()) {
LOGERR(("uncompressfile: wipedir failed\n"));
LOGERR("uncompressfile: wipedir failed\n" );
}
return false;
}
@@ -139,3 +133,4 @@ Uncomp::~Uncomp()
}
}