Switch to unified view

a/src/internfile/mh_exec.h b/src/internfile/mh_exec.h
...
...
17
#ifndef _MH_EXEC_H_INCLUDED_
17
#ifndef _MH_EXEC_H_INCLUDED_
18
#define _MH_EXEC_H_INCLUDED_
18
#define _MH_EXEC_H_INCLUDED_
19
19
20
#include <string>
20
#include <string>
21
#include <vector>
21
#include <vector>
22
using std::vector;
23
using std::string;
24
22
25
#include "mimehandler.h"
23
#include "mimehandler.h"
24
#include "execmd.h"
26
25
27
/** 
26
/** 
28
 * Turn external document into internal one by executing an external filter.
27
 * Turn external document into internal one by executing an external filter.
29
 *
28
 *
30
 * The command to execute, and its parameters, are stored in the "params" 
29
 * The command to execute, and its parameters, are stored in the "params" 
...
...
43
    // (no use to try and execute over and over something that's not
42
    // (no use to try and execute over and over something that's not
44
    // here).
43
    // here).
45
44
46
    // Parameters: this has been built by our creator, from config file 
45
    // Parameters: this has been built by our creator, from config file 
47
    // data. We always add the file name at the end before actual execution
46
    // data. We always add the file name at the end before actual execution
48
    vector<string> params;
47
    std::vector<std::string> params;
49
    // Filter output type. The default for ext. filters is to output html, 
48
    // Filter output type. The default for ext. filters is to output html, 
50
    // but some don't, in which case the type is defined in the config.
49
    // but some don't, in which case the type is defined in the config.
51
    string cfgFilterOutputMtype;
50
    std::string cfgFilterOutputMtype;
52
    // Output character set if the above type is not text/html. For
51
    // Output character set if the above type is not text/html. For
53
    // those filters, the output charset has to be known: ie set by a command
52
    // those filters, the output charset has to be known: ie set by a command
54
    // line option.
53
    // line option.
55
    string cfgFilterOutputCharset; 
54
    std::string cfgFilterOutputCharset; 
56
    bool missingHelper;
55
    bool missingHelper;
56
    // Resource management values
57
    int m_filtermaxseconds;
58
    int m_filtermaxmbytes;
57
    ////////////////
59
    ////////////////
58
60
59
    MimeHandlerExec(RclConfig *cnf, const string& id) 
61
    MimeHandlerExec(RclConfig *cnf, const std::string& id);
60
  : RecollFilter(cnf, id), missingHelper(false) 
62
61
    {}
62
    virtual bool set_document_file(const string& mt, const string &file_path) {
63
    virtual bool set_document_file(const std::string& mt, 
64
                                   const std::string &file_path) {
63
    RecollFilter::set_document_file(mt, file_path);
65
    RecollFilter::set_document_file(mt, file_path);
64
    m_fn = file_path;
66
    m_fn = file_path;
65
    m_havedoc = true;
67
    m_havedoc = true;
66
    return true;
68
    return true;
67
    }
69
    }
70
68
    virtual bool next_document();
71
    virtual bool next_document();
69
    virtual bool skip_to_document(const string& ipath); 
72
    virtual bool skip_to_document(const std::string& ipath); 
73
70
    virtual void clear() {
74
    virtual void clear() {
71
    m_fn.erase(); 
75
    m_fn.erase(); 
72
    m_ipath.erase();
76
    m_ipath.erase();
73
    RecollFilter::clear(); 
77
    RecollFilter::clear(); 
74
    }
78
    }
75
79
76
protected:
80
protected:
77
    string m_fn;
81
    std::string m_fn;
78
    string m_ipath;
82
    std::string m_ipath;
79
83
80
    // Set up the character set metadata fields and possibly transcode
84
    // Set up the character set metadata fields and possibly transcode
81
    // text/plain output. 
85
    // text/plain output. 
82
    // @param charset when called from mh_execm, a possible explicit
86
    // @param charset when called from mh_execm, a possible explicit
83
    //       value from the filter (else the data will come from the config)
87
    //       value from the filter (else the data will come from the config)
84
    virtual void handle_cs(const string& mt, const string& charset = string());
88
    virtual void handle_cs(const std::string& mt, 
89
                           const std::string& charset = std::string());
85
90
86
private:
91
private:
87
    virtual void finaldetails();
92
    virtual void finaldetails();
88
};
93
};
89
94
95
96
// This is called periodically by ExeCmd when it is waiting for data,
97
// or when it does receive some. We may choose to interrupt the
98
// command.
99
class MEAdv : public ExecCmdAdvise {
100
public:
101
    MEAdv(int maxsecs = 900);
102
    // Reset start time to now
103
    void reset();
104
    void setmaxsecs(int maxsecs) {
105
        m_filtermaxseconds = maxsecs;
106
    }
107
    void newData(int n);
108
private:
109
    time_t m_start;
110
    int m_filtermaxseconds;
111
};
112
90
#endif /* _MH_EXEC_H_INCLUDED_ */
113
#endif /* _MH_EXEC_H_INCLUDED_ */