|
a/src/internfile/mh_exec.cpp |
|
b/src/internfile/mh_exec.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.11 2008-10-02 13:30:32 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.12 2008-10-04 14:26:59 dockes Exp $ (C) 2005 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
33 |
void newData(int) {
|
33 |
void newData(int) {
|
34 |
CancelCheck::instance().checkCancel();
|
34 |
CancelCheck::instance().checkCancel();
|
35 |
}
|
35 |
}
|
36 |
};
|
36 |
};
|
37 |
|
37 |
|
38 |
// Execute an external program to translate a file from its native format
|
38 |
// Execute an external program to translate a file from its native
|
39 |
// to html. Then call the html parser to do the actual indexing
|
39 |
// format to text or html.
|
40 |
bool MimeHandlerExec::next_document()
|
40 |
bool MimeHandlerExec::next_document()
|
41 |
{
|
41 |
{
|
42 |
if (m_havedoc == false)
|
42 |
if (m_havedoc == false)
|
43 |
return false;
|
43 |
return false;
|
44 |
m_havedoc = false;
|
44 |
m_havedoc = false;
|
|
... |
|
... |
57 |
list<string>myparams(++it, params.end());
|
57 |
list<string>myparams(++it, params.end());
|
58 |
myparams.push_back(m_fn);
|
58 |
myparams.push_back(m_fn);
|
59 |
if (!m_ipath.empty())
|
59 |
if (!m_ipath.empty())
|
60 |
myparams.push_back(m_ipath);
|
60 |
myparams.push_back(m_ipath);
|
61 |
|
61 |
|
62 |
// Execute command and store the result text, which is supposedly html
|
62 |
// Execute command and store the result text
|
63 |
string& html = m_metaData["content"];
|
63 |
string& output = m_metaData["content"];
|
64 |
html.erase();
|
64 |
output.erase();
|
65 |
ExecCmd mexec;
|
65 |
ExecCmd mexec;
|
66 |
MEAdv adv;
|
66 |
MEAdv adv;
|
67 |
mexec.setAdvise(&adv);
|
67 |
mexec.setAdvise(&adv);
|
68 |
mexec.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
|
68 |
mexec.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
|
69 |
"RECOLL_FILTER_FORPREVIEW=no");
|
69 |
"RECOLL_FILTER_FORPREVIEW=no");
|
70 |
int status = mexec.doexec(cmd, myparams, 0, &html);
|
70 |
int status = mexec.doexec(cmd, myparams, 0, &output);
|
71 |
if (status) {
|
71 |
if (status) {
|
72 |
LOGERR(("MimeHandlerExec: command status 0x%x: %s\n",
|
72 |
LOGERR(("MimeHandlerExec: command status 0x%x: %s\n",
|
73 |
status, cmd.c_str()));
|
73 |
status, cmd.c_str()));
|
74 |
// If the output string begins with RECFILTERROR, then it's
|
74 |
// If the output string begins with RECFILTERROR, then it's
|
75 |
// interpretable error information
|
75 |
// interpretable error information
|
76 |
if (html.find("RECFILTERROR") == 0)
|
76 |
if (output.find("RECFILTERROR") == 0)
|
77 |
m_reason = html;
|
77 |
m_reason = output;
|
78 |
return false;
|
78 |
return false;
|
79 |
}
|
79 |
}
|
80 |
|
|
|
81 |
m_metaData["origcharset"] = m_defcharset;
|
80 |
m_metaData["origcharset"] = m_defcharset;
|
82 |
// Default charset: all recoll filters output utf-8, but this
|
81 |
// Default charset: all recoll filters output utf-8, but this
|
83 |
// could still be overridden by the content-type meta tag.
|
82 |
// could still be overridden by the content-type meta tag.
|
84 |
m_metaData["charset"] = "utf-8";
|
83 |
m_metaData["charset"] = cfgCharset.empty() ? "utf-8" : cfgCharset;
|
85 |
m_metaData["mimetype"] = "text/html";
|
84 |
m_metaData["mimetype"] = cfgMtype.empty() ? "text/html" : cfgMtype;
|
86 |
return true;
|
85 |
return true;
|
87 |
}
|
86 |
}
|