renamed MimeHandler::worker to mkDoc + comments for doxygen
This commit is contained in:
parent
7a190d6f88
commit
baa0ff491b
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.5 2005-04-05 09:35:35 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.6 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -130,7 +130,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath)
|
|||||||
|
|
||||||
// Turn file into a document. The document has fields for title, body
|
// Turn file into a document. The document has fields for title, body
|
||||||
// etc., all text converted to utf8
|
// etc., all text converted to utf8
|
||||||
MimeHandler::Status mhs = handler->worker(config, fn, mime, doc, ipath);
|
MimeHandler::Status mhs = handler->mkDoc(config, fn, mime, doc, ipath);
|
||||||
FileInterner::Status ret = FIError;
|
FileInterner::Status ret = FIError;
|
||||||
switch (mhs) {
|
switch (mhs) {
|
||||||
case MimeHandler::MHError: break;
|
case MimeHandler::MHError: break;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
MimeHandler::Status
|
MimeHandler::Status
|
||||||
MimeHandlerHtml::worker(RclConfig *conf, const string &fn,
|
MimeHandlerHtml::mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string&)
|
const string &mtype, Rcl::Doc &docout, string&)
|
||||||
{
|
{
|
||||||
LOGDEB(("textHtmlToDoc: %s\n", fn.c_str()));
|
LOGDEB(("textHtmlToDoc: %s\n", fn.c_str()));
|
||||||
@ -48,11 +48,11 @@ MimeHandlerHtml::worker(RclConfig *conf, const string &fn,
|
|||||||
LOGINFO(("textHtmlToDoc: cant read: %s\n", fn.c_str()));
|
LOGINFO(("textHtmlToDoc: cant read: %s\n", fn.c_str()));
|
||||||
return MimeHandler::MHError;
|
return MimeHandler::MHError;
|
||||||
}
|
}
|
||||||
return worker1(conf, fn, otext, mtype, docout);
|
return mkDoc(conf, fn, otext, mtype, docout);
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeHandler::Status
|
MimeHandler::Status
|
||||||
MimeHandlerHtml::worker1(RclConfig *conf, const string &,
|
MimeHandlerHtml::mkDoc(RclConfig *conf, const string &,
|
||||||
const string& htext,
|
const string& htext,
|
||||||
const string &mtype, Rcl::Doc &docout)
|
const string &mtype, Rcl::Doc &docout)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,21 +1,24 @@
|
|||||||
#ifndef _HTML_H_INCLUDED_
|
#ifndef _HTML_H_INCLUDED_
|
||||||
#define _HTML_H_INCLUDED_
|
#define _HTML_H_INCLUDED_
|
||||||
/* @(#$Id: mh_html.h,v 1.4 2005-03-31 10:04:07 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: mh_html.h,v 1.5 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Code to turn an html document into an internal one. There are 2
|
/// Translate html document to an internal one.
|
||||||
// interfaces, depending if we're working on a file, or on a
|
///
|
||||||
// string. The string form is with external handlers for foreign
|
/// There are 2 interfaces, depending if we're working on a file, or
|
||||||
// formats: they return a result in html, which has the advantage to
|
/// on a string. The string form is applied to the output of external
|
||||||
// be text (easy to use in shell-scripts), and semi-structured (can
|
/// handlers for foreign formats: they return a result in html, which
|
||||||
// carry titles, abstracts, whatever)
|
/// has the advantage to be text (easy to use in shell-scripts), and
|
||||||
|
/// semi-structured (can carry titles, abstracts, whatever)
|
||||||
class MimeHandlerHtml : public MimeHandler {
|
class MimeHandlerHtml : public MimeHandler {
|
||||||
public:
|
public:
|
||||||
std::string charsethint;
|
std::string charsethint;
|
||||||
virtual MimeHandler::Status worker(RclConfig *conf, const string &fn,
|
/// Create internal document from html file (standard interface)
|
||||||
|
virtual MimeHandler::Status mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string&);
|
const string &mtype, Rcl::Doc &docout, string&);
|
||||||
virtual MimeHandler::Status worker1(RclConfig *conf, const string &fn,
|
/// Create internal doc from html string (postfilter for external ones)
|
||||||
|
virtual MimeHandler::Status mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string& htext,
|
const string& htext,
|
||||||
const string &mtype, Rcl::Doc &docout);
|
const string &mtype, Rcl::Doc &docout);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.8 2005-11-05 14:40:50 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.9 2005-11-08 21:02:55 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -44,17 +44,17 @@ MimeHandlerMail::~MimeHandlerMail()
|
|||||||
// We are called for two different file types: mbox-type folders
|
// We are called for two different file types: mbox-type folders
|
||||||
// holding multiple messages, and maildir-type files with one message
|
// holding multiple messages, and maildir-type files with one message
|
||||||
MimeHandler::Status
|
MimeHandler::Status
|
||||||
MimeHandlerMail::worker(RclConfig *cnf, const string &fn,
|
MimeHandlerMail::mkDoc(RclConfig *cnf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string& ipath)
|
const string &mtype, Rcl::Doc &docout, string& ipath)
|
||||||
{
|
{
|
||||||
LOGDEB2(("MimeHandlerMail::worker: %s [%s]\n", mtype.c_str(), fn.c_str()));
|
LOGDEB2(("MimeHandlerMail::mkDoc: %s [%s]\n", mtype.c_str(), fn.c_str()));
|
||||||
conf = cnf;
|
conf = cnf;
|
||||||
|
|
||||||
if (!stringlowercmp("message/rfc822", mtype)) {
|
if (!stringlowercmp("message/rfc822", mtype)) {
|
||||||
ipath = "";
|
ipath = "";
|
||||||
int fd;
|
int fd;
|
||||||
if ((fd = open(fn.c_str(), 0)) < 0) {
|
if ((fd = open(fn.c_str(), 0)) < 0) {
|
||||||
LOGERR(("MimeHandlerMail::worker: open(%s) errno %d\n",
|
LOGERR(("MimeHandlerMail::mkDoc: open(%s) errno %d\n",
|
||||||
fn.c_str(), errno));
|
fn.c_str(), errno));
|
||||||
return MimeHandler::MHError;
|
return MimeHandler::MHError;
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ static void walkmime(RclConfig *cnf, string &out, Binc::MimePart& doc,
|
|||||||
MimeHandlerHtml mh;
|
MimeHandlerHtml mh;
|
||||||
Rcl::Doc hdoc;
|
Rcl::Doc hdoc;
|
||||||
mh.charsethint = charset;
|
mh.charsethint = charset;
|
||||||
mh.worker1(cnf, "", body, content_type.value, hdoc);
|
mh.mkDoc(cnf, "", body, content_type.value, hdoc);
|
||||||
transcoded = hdoc.text;
|
transcoded = hdoc.text;
|
||||||
} else {
|
} else {
|
||||||
// Transcode to utf-8
|
// Transcode to utf-8
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
#ifndef _MAIL_H_INCLUDED_
|
#ifndef _MAIL_H_INCLUDED_
|
||||||
#define _MAIL_H_INCLUDED_
|
#define _MAIL_H_INCLUDED_
|
||||||
/* @(#$Id: mh_mail.h,v 1.2 2005-03-31 10:04:07 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: mh_mail.h,v 1.3 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
namespace Binc {
|
namespace Binc {
|
||||||
class MimeDocument;
|
class MimeDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code to turn a mail folder file into internal documents
|
/// Translate a mail folder file into internal documents (also works
|
||||||
|
/// for maildir files)
|
||||||
class MimeHandlerMail : public MimeHandler {
|
class MimeHandlerMail : public MimeHandler {
|
||||||
void *vfp;
|
void *vfp;
|
||||||
int msgnum;
|
int msgnum;
|
||||||
@ -19,7 +20,8 @@ class MimeHandlerMail : public MimeHandler {
|
|||||||
MimeHandlerMail() : vfp(0), msgnum(0), conf(0) {}
|
MimeHandlerMail() : vfp(0), msgnum(0), conf(0) {}
|
||||||
virtual ~MimeHandlerMail();
|
virtual ~MimeHandlerMail();
|
||||||
virtual MimeHandler::Status
|
virtual MimeHandler::Status
|
||||||
worker(RclConfig *conf, const string &fn,
|
mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string& ipath);
|
const string &mtype, Rcl::Doc &docout, string& ipath);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _MAIL_H_INCLUDED_ */
|
#endif /* _MAIL_H_INCLUDED_ */
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.9 2005-03-25 09:40:27 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.10 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -19,13 +19,13 @@ using namespace std;
|
|||||||
|
|
||||||
class MimeHandlerText : public MimeHandler {
|
class MimeHandlerText : public MimeHandler {
|
||||||
public:
|
public:
|
||||||
MimeHandler::Status worker(RclConfig *conf, const string &fn,
|
MimeHandler::Status mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string&);
|
const string &mtype, Rcl::Doc &docout, string&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process a plain text file
|
// Process a plain text file
|
||||||
MimeHandler::Status MimeHandlerText::worker(RclConfig *conf, const string &fn,
|
MimeHandler::Status MimeHandlerText::mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string&)
|
const string &mtype, Rcl::Doc &docout, string&)
|
||||||
{
|
{
|
||||||
string otext;
|
string otext;
|
||||||
@ -61,7 +61,7 @@ class MimeHandlerExec : public MimeHandler {
|
|||||||
public:
|
public:
|
||||||
list<string> params;
|
list<string> params;
|
||||||
virtual ~MimeHandlerExec() {}
|
virtual ~MimeHandlerExec() {}
|
||||||
virtual MimeHandler::Status worker(RclConfig *conf, const string &fn,
|
virtual MimeHandler::Status mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout,
|
const string &mtype, Rcl::Doc &docout,
|
||||||
string&);
|
string&);
|
||||||
|
|
||||||
@ -71,12 +71,12 @@ class MimeHandlerExec : public MimeHandler {
|
|||||||
// Execute an external program to translate a file from its native format
|
// Execute an external program to translate a file from its native format
|
||||||
// to html. Then call the html parser to do the actual indexing
|
// to html. Then call the html parser to do the actual indexing
|
||||||
MimeHandler::Status
|
MimeHandler::Status
|
||||||
MimeHandlerExec::worker(RclConfig *conf, const string &fn,
|
MimeHandlerExec::mkDoc(RclConfig *conf, const string &fn,
|
||||||
const string &mtype, Rcl::Doc &docout, string&)
|
const string &mtype, Rcl::Doc &docout, string&)
|
||||||
{
|
{
|
||||||
if (params.empty()) {
|
if (params.empty()) {
|
||||||
// Hu ho
|
// Hu ho
|
||||||
LOGERR(("MimeHandlerExec::worker: empty params for mime %s\n",
|
LOGERR(("MimeHandlerExec::mkDoc: empty params for mime %s\n",
|
||||||
mtype.c_str()));
|
mtype.c_str()));
|
||||||
return MimeHandler::MHError;
|
return MimeHandler::MHError;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ MimeHandlerExec::worker(RclConfig *conf, const string &fn,
|
|||||||
|
|
||||||
// Process/index the html
|
// Process/index the html
|
||||||
MimeHandlerHtml hh;
|
MimeHandlerHtml hh;
|
||||||
return hh.worker1(conf, fn, html, mtype, docout);
|
return hh.mkDoc(conf, fn, html, mtype, docout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MimeHandler *mhfact(const string &mime)
|
static MimeHandler *mhfact(const string &mime)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _MIMEHANDLER_H_INCLUDED_
|
#ifndef _MIMEHANDLER_H_INCLUDED_
|
||||||
#define _MIMEHANDLER_H_INCLUDED_
|
#define _MIMEHANDLER_H_INCLUDED_
|
||||||
/* @(#$Id: mimehandler.h,v 1.6 2005-03-25 09:40:27 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: mimehandler.h,v 1.7 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -16,6 +16,8 @@ class MimeHandler {
|
|||||||
public:
|
public:
|
||||||
virtual ~MimeHandler() {}
|
virtual ~MimeHandler() {}
|
||||||
|
|
||||||
|
/// Status from mkDoc method.
|
||||||
|
enum Status {MHError, MHDone, MHAgain};
|
||||||
/**
|
/**
|
||||||
* Transform external data into internal utf8 document
|
* Transform external data into internal utf8 document
|
||||||
*
|
*
|
||||||
@ -31,17 +33,18 @@ class MimeHandler {
|
|||||||
* If this is empty (during indexation), it will be filled-up
|
* If this is empty (during indexation), it will be filled-up
|
||||||
* by the function, and all the file's documents will be
|
* by the function, and all the file's documents will be
|
||||||
* returned by successive calls.
|
* returned by successive calls.
|
||||||
* @return the return value indicates if there are more documents to be
|
* @return The return value indicates if there are more documents to be
|
||||||
* fetched from the same file.
|
* fetched from the same file.
|
||||||
*/
|
*/
|
||||||
enum Status {MHError, MHDone, MHAgain};
|
virtual MimeHandler::Status mkDoc(RclConfig * conf,
|
||||||
virtual Status worker(RclConfig * conf, const std::string &filename,
|
const std::string &filename,
|
||||||
const std::string &mimetype, Rcl::Doc& outdoc,
|
const std::string &mimetype,
|
||||||
string& ipath) = 0;
|
Rcl::Doc& outdoc,
|
||||||
|
string& ipath) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return indexing handler class for given mime type
|
* Return indexing handler object for the given mime type
|
||||||
* returned pointer should be deleted by caller
|
* returned pointer should be deleted by caller
|
||||||
*/
|
*/
|
||||||
extern MimeHandler *getMimeHandler(const std::string &mtyp, ConfTree *mhdlers);
|
extern MimeHandler *getMimeHandler(const std::string &mtyp, ConfTree *mhdlers);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user