Switch to unified view

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.7 2006-12-13 09:13:18 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.8 2006-12-15 12:40:02 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
...
...
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 format
39
// to html. Then call the html parser to do the actual indexing
39
// to html. Then call the html parser to do the actual indexing
40
MimeHandler::Status 
40
bool MimeHandlerExec::next_document()
41
MimeHandlerExec::mkDoc(RclConfig *conf, const string &fn, 
42
             const string &mtype, Rcl::Doc &docout, string&)
43
{
41
{
42
    if (m_havedoc == false)
43
  return false;
44
    m_havedoc = false;
44
    if (params.empty()) {
45
    if (params.empty()) {
45
    // Hu ho
46
    // Hu ho
46
    LOGERR(("MimeHandlerExec::mkDoc: empty params for mime %s\n",
47
    LOGERR(("MimeHandlerExec::mkDoc: empty params\n"));
47
      mtype.c_str()));
48
  return false;
48
  return MimeHandler::MHError;
49
    }
49
    }
50
50
51
    // Command name
51
    // Command name
52
    string cmd = params.front();
52
    string cmd = params.front();
53
    
53
    
54
    // Build parameter list: delete cmd name and add the file name
54
    // Build parameter list: delete cmd name and add the file name
55
    list<string>::iterator it = params.begin();
55
    list<string>::iterator it = params.begin();
56
    list<string>myparams(++it, params.end());
56
    list<string>myparams(++it, params.end());
57
    myparams.push_back(fn);
57
    myparams.push_back(m_fn);
58
58
59
    // Execute command and store the result text, which is supposedly html
59
    // Execute command and store the result text, which is supposedly html
60
    string html;
60
    string& html = m_metaData["content"];
61
    ExecCmd mexec;
61
    ExecCmd mexec;
62
    MEAdv adv;
62
    MEAdv adv;
63
    mexec.setAdvise(&adv);
63
    mexec.setAdvise(&adv);
64
    mexec.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
64
    mexec.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
65
        "RECOLL_FILTER_FORPREVIEW=no");
65
        "RECOLL_FILTER_FORPREVIEW=no");
66
    int status = mexec.doexec(cmd, myparams, 0, &html);
66
    int status = mexec.doexec(cmd, myparams, 0, &html);
67
    if (status) {
67
    if (status) {
68
    LOGERR(("MimeHandlerExec: command status 0x%x: %s\n", 
68
    LOGERR(("MimeHandlerExec: command status 0x%x: %s\n", 
69
        status, cmd.c_str()));
69
        status, cmd.c_str()));
70
  return MimeHandler::MHError;
70
  return false;
71
    }
71
    }
72
72
73
    // Process/index  the html
73
    m_metaData["origcharset"] = m_defcharset;
74
    MimeHandlerHtml hh;
74
    // All recoll filters output utf-8
75
    return hh.mkDoc(conf, fn, html, mtype, docout);
75
    m_metaData["charset"] = "utf-8";
76
    m_metaData["mimetype"] = "text/html";
77
    return true;
76
}
78
}