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.3 2005-01-26 13:03:02 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.4 2005-01-29 15:41:11 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;
...
...
9
#include "mimehandler.h"
9
#include "mimehandler.h"
10
#include "readfile.h"
10
#include "readfile.h"
11
#include "csguess.h"
11
#include "csguess.h"
12
#include "transcode.h"
12
#include "transcode.h"
13
#include "debuglog.h"
13
#include "debuglog.h"
14
#include "smallut.h"
14
15
15
bool textPlainToDoc(RclConfig *conf, const string &fn, 
16
bool textPlainToDoc(RclConfig *conf, const string &fn, 
16
             const string &mtype, Rcl::Doc &docout)
17
             const string &mtype, Rcl::Doc &docout)
17
{
18
{
18
    string otext;
19
    string otext;
...
...
64
 */
65
 */
65
MimeHandlerFunc getMimeHandler(const std::string &mtype, ConfTree *mhandlers)
66
MimeHandlerFunc getMimeHandler(const std::string &mtype, ConfTree *mhandlers)
66
{
67
{
67
    // Return handler definition for mime type
68
    // Return handler definition for mime type
68
    string hs;
69
    string hs;
69
    if (!mhandlers->get(mtype, hs, "")) 
70
    if (!mhandlers->get(mtype, hs, "index")) {
71
  LOGDEB(("getMimeHandler: no handler for %s\n", mtype.c_str()));
70
    return 0;
72
    return 0;
73
    }
71
74
72
    // Break definition into type and name 
75
    // Break definition into type and name 
73
    vector<string> toks;
76
    vector<string> toks;
74
    ConfTree::stringToStrings(hs, toks);
77
    ConfTree::stringToStrings(hs, toks);
75
    if (toks.size() < 1) {
78
    if (toks.size() < 1) {
76
    LOGERR(("getMimeHandler: bad mimeconf line for %s\n", mtype.c_str()));
79
    LOGERR(("getMimeHandler: bad mimeconf line for %s\n", mtype.c_str()));
77
    return 0;
80
    return 0;
78
    }
81
    }
79
82
80
    // Retrieve handler function according to type
83
    // Retrieve handler function according to type
81
    if (!strcasecmp(toks[0].c_str(), "internal")) {
84
    if (!stringlowercmp("internal", toks[0])) {
82
    map<string, MimeHandlerFunc>::const_iterator it = 
85
    map<string, MimeHandlerFunc>::const_iterator it = 
83
        ihandlers.find(mtype);
86
        ihandlers.find(mtype);
84
    if (it == ihandlers.end()) {
87
    if (it == ihandlers.end()) {
85
        LOGERR(("getMimeHandler: internal handler not found for %s\n",
88
        LOGERR(("getMimeHandler: internal handler not found for %s\n",
86
            mtype.c_str()));
89
            mtype.c_str()));
87
        return 0;
90
        return 0;
88
    }
91
    }
89
    return it->second;
92
    return it->second;
90
    } else if (!strcasecmp(toks[0].c_str(), "dll")) {
93
    } else if (!stringlowercmp("dll", toks[0])) {
91
    if (toks.size() != 2)
94
    if (toks.size() != 2)
92
        return 0;
95
        return 0;
93
    return 0;
96
    return 0;
94
    } else if (!strcasecmp(toks[0].c_str(), "exec")) {
97
    } else if (!stringlowercmp("exec", toks[0])) {
95
    if (toks.size() != 2)
98
    if (toks.size() != 2)
96
        return 0;
99
        return 0;
97
    return 0;
100
    return 0;
98
    } else {
101
    } else {
99
    return 0;
102
    return 0;
100
    }
103
    }
101
}
104
}
105
106
/**
107
 * Return external viewer exec string for given mime type
108
 */
109
string getMimeViewer(const std::string &mtype, ConfTree *mhandlers)
110
{
111
    string hs;
112
    mhandlers->get(mtype, hs, "view");
113
    return hs;
114
}