Switch to unified view

a/src/internfile/mimehandler.cpp b/src/internfile/mimehandler.cpp
...
...
138
138
139
/* Get handler/filter object for given mime type: */
139
/* Get handler/filter object for given mime type: */
140
Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg, 
140
Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg, 
141
                  bool filtertypes)
141
                  bool filtertypes)
142
{
142
{
143
    if (mtype.empty())
143
    LOGDEB2(("getMimeHandler: mtype [%s] filtertypes %d\n", 
144
  return false;
144
             mtype.c_str(), filtertypes));
145
145
146
    // Do we already have one ?
147
    map<string, Dijon::Filter *>::iterator it = o_handlers.find(mtype);
148
    if (it != o_handlers.end()) {
149
  Dijon::Filter *h = it->second;
150
  o_handlers.erase(it);
151
  LOGDEB2(("getMimeHandler: found in cache\n"));
152
  return h;
153
    }
154
    
155
    // Get handler definition for mime type
146
    // Get handler definition for mime type. We do this even if an
147
    // appropriate handler object may be in the cache (indexed by mime
148
    // type). This is fast, and necessary to conform to the
149
    // configuration, (ie: text/html might be filtered out by
150
    // indexedmimetypes but an html handler could still be in the
151
    // cache because it was needed by some other interning stack).
156
    string hs;
152
    string hs;
157
    hs = cfg->getMimeHandlerDef(mtype, filtertypes);
153
    hs = cfg->getMimeHandlerDef(mtype, filtertypes);
158
154
159
    if (!hs.empty()) {
155
    if (!hs.empty()) { // Got a handler definition line
156
157
        // Do we already have a handler object in the cache ?
158
        map<string, Dijon::Filter *>::iterator it = o_handlers.find(mtype);
159
        if (it != o_handlers.end()) {
160
            Dijon::Filter *h = it->second;
161
            o_handlers.erase(it);
162
            LOGDEB2(("getMimeHandler: found in cache\n"));
163
            return h;
164
        }
165
160
    // Break definition into type and name/command string
166
    // Not in cache. Break definition into type and name/command
167
        // string and instanciate handler object
161
        string::size_type b1 = hs.find_first_of(" \t");
168
        string::size_type b1 = hs.find_first_of(" \t");
162
        string handlertype = hs.substr(0, b1);
169
        string handlertype = hs.substr(0, b1);
163
    if (!stringlowercmp("internal", handlertype)) {
170
    if (!stringlowercmp("internal", handlertype)) {
164
        return mhFactory(mtype);
171
        return mhFactory(mtype);
165
    } else if (!stringlowercmp("dll", handlertype)) {
172
    } else if (!stringlowercmp("dll", handlertype)) {
...
...
192
    if (mtype.find("text/") == 0) {
199
    if (mtype.find("text/") == 0) {
193
        return mhFactory("text/plain");
200
        return mhFactory("text/plain");
194
    }
201
    }
195
#endif
202
#endif
196
203
197
    // Finally, unhandled files are either ignored or their name is
204
    // Finally, unhandled files are either ignored or their name and
198
    // indexed, depending on configuration
205
    // generic metadata is indexed, depending on configuration
199
    bool indexunknown = false;
206
    bool indexunknown = false;
200
    cfg->getConfParam("indexallfilenames", &indexunknown);
207
    cfg->getConfParam("indexallfilenames", &indexunknown);
201
    if (indexunknown) {
208
    if (indexunknown) {
202
    LOGDEB(("getMimeHandler: returning MimeHandlerUnknown\n"));
209
    LOGDEB(("getMimeHandler: returning MimeHandlerUnknown\n"));
203
    return new MimeHandlerUnknown("application/octet-stream");
210
    return new MimeHandlerUnknown("application/octet-stream");