Switch to unified view

a/src/internfile/mimehandler.cpp b/src/internfile/mimehandler.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.9 2005-03-25 09:40:27 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.10 2005-11-08 21:02:55 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
4
5
#include <iostream>
5
#include <iostream>
6
#include <string>
6
#include <string>
7
using namespace std;
7
using namespace std;
...
...
17
#include "execmd.h"
17
#include "execmd.h"
18
#include "pathut.h"
18
#include "pathut.h"
19
19
20
class MimeHandlerText : public MimeHandler {
20
class MimeHandlerText : public MimeHandler {
21
 public:
21
 public:
22
    MimeHandler::Status worker(RclConfig *conf, const string &fn, 
22
    MimeHandler::Status mkDoc(RclConfig *conf, const string &fn, 
23
        const string &mtype, Rcl::Doc &docout, string&);
23
        const string &mtype, Rcl::Doc &docout, string&);
24
    
24
    
25
};
25
};
26
26
27
// Process a plain text file
27
// Process a plain text file
28
MimeHandler::Status MimeHandlerText::worker(RclConfig *conf, const string &fn, 
28
MimeHandler::Status MimeHandlerText::mkDoc(RclConfig *conf, const string &fn, 
29
                 const string &mtype, Rcl::Doc &docout, string&)
29
                 const string &mtype, Rcl::Doc &docout, string&)
30
{
30
{
31
    string otext;
31
    string otext;
32
    if (!file_to_string(fn, otext))
32
    if (!file_to_string(fn, otext))
33
    return MimeHandler::MHError;
33
    return MimeHandler::MHError;
...
...
59
59
60
class MimeHandlerExec : public MimeHandler {
60
class MimeHandlerExec : public MimeHandler {
61
 public:
61
 public:
62
    list<string> params;
62
    list<string> params;
63
    virtual ~MimeHandlerExec() {}
63
    virtual ~MimeHandlerExec() {}
64
    virtual MimeHandler::Status worker(RclConfig *conf, const string &fn, 
64
    virtual MimeHandler::Status mkDoc(RclConfig *conf, const string &fn, 
65
                       const string &mtype, Rcl::Doc &docout, 
65
                       const string &mtype, Rcl::Doc &docout, 
66
                       string&);
66
                       string&);
67
67
68
};
68
};
69
69
70
    
70
    
71
// Execute an external program to translate a file from its native format
71
// Execute an external program to translate a file from its native format
72
// to html. Then call the html parser to do the actual indexing
72
// to html. Then call the html parser to do the actual indexing
73
MimeHandler::Status 
73
MimeHandler::Status 
74
MimeHandlerExec::worker(RclConfig *conf, const string &fn, 
74
MimeHandlerExec::mkDoc(RclConfig *conf, const string &fn, 
75
            const string &mtype, Rcl::Doc &docout, string&)
75
            const string &mtype, Rcl::Doc &docout, string&)
76
{
76
{
77
    if (params.empty()) {
77
    if (params.empty()) {
78
    // Hu ho
78
    // Hu ho
79
    LOGERR(("MimeHandlerExec::worker: empty params for mime %s\n",
79
    LOGERR(("MimeHandlerExec::mkDoc: empty params for mime %s\n",
80
        mtype.c_str()));
80
        mtype.c_str()));
81
    return MimeHandler::MHError;
81
    return MimeHandler::MHError;
82
    }
82
    }
83
    // Command name
83
    // Command name
84
    string cmd = find_filter(conf, params.front());
84
    string cmd = find_filter(conf, params.front());
...
...
98
    return MimeHandler::MHError;
98
    return MimeHandler::MHError;
99
    }
99
    }
100
100
101
    // Process/index  the html
101
    // Process/index  the html
102
    MimeHandlerHtml hh;
102
    MimeHandlerHtml hh;
103
    return hh.worker1(conf, fn, html, mtype, docout);
103
    return hh.mkDoc(conf, fn, html, mtype, docout);
104
}
104
}
105
105
106
static MimeHandler *mhfact(const string &mime)
106
static MimeHandler *mhfact(const string &mime)
107
{
107
{
108
    if (!stringlowercmp("text/plain", mime))
108
    if (!stringlowercmp("text/plain", mime))