Switch to unified view

a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.13 2005-11-24 07:16:15 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.14 2005-11-25 09:13:06 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
#include <unistd.h>
4
#include <unistd.h>
5
#include <errno.h>
5
#include <errno.h>
6
6
7
#include <iostream>
7
#include <iostream>
...
...
99
    return true;
99
    return true;
100
}
100
}
101
101
102
bool RclConfig::getConfParam(const std::string &name, bool *bvp)
102
bool RclConfig::getConfParam(const std::string &name, bool *bvp)
103
{
103
{
104
    if (!bvp) 
105
  return false;
106
104
    *bvp = false;
107
    *bvp = false;
105
    string s;
108
    string s;
106
    if (!getConfParam(name, s))
109
    if (!getConfParam(name, s))
107
    return false;
110
    return false;
108
    if (s.empty())
111
    *bvp = stringToBool(s);
109
  return true;
110
    if (isdigit(s[0])) {
111
  int val = atoi(s.c_str());
112
  *bvp = val ? true : false;
113
    } else if (strchr("yYoOtT", s[0])) {
114
  *bvp = true;
115
    }
116
    return true;
112
    return true;
117
}
113
}
118
114
119
static ConfSimple::WalkerCode mtypesWalker(void *l, 
115
// Get all known document mime values. We get them from the mimeconf
120
                     const char *nm, const char *value)
116
// 'index' submap: values not in there (ie from mimemap or idfile) can't
121
{
117
// possibly belong to documents in the database.
122
    std::list<string> *lst = (std::list<string> *)l;
123
    if (nm && nm[0] == '.')
124
  lst->push_back(value);
125
    return ConfSimple::WALK_CONTINUE;
126
}
127
128
#include "idfile.h"
129
std::list<string> RclConfig::getAllMimeTypes()
118
std::list<string> RclConfig::getAllMimeTypes()
130
{
119
{
131
    std::list<string> lst;
120
    std::list<string> lst;
132
    if (mimemap == 0)
121
    if (mimeconf == 0)
133
    return lst;
122
    return lst;
134
    mimemap->sortwalk(mtypesWalker, &lst);
123
    //    mimeconf->sortwalk(mtypesWalker, &lst);
135
    std::list<string> l1 = idFileAllTypes(); 
124
    lst = mimeconf->getNames("index");
136
    lst.insert(lst.end(), l1.begin(), l1.end());
137
    lst.sort();
125
    lst.sort();
138
    lst.unique();
126
    lst.unique();
139
    return lst;
127
    return lst;
140
}
128
}
141
129
142
bool RclConfig::getStopSuffixes(list<string>& sufflist)
130
bool RclConfig::getStopSuffixes(list<string>& sufflist)
143
{
131
{
144
    if (stopsuffixes == 0 && (stopsuffixes = new list<string>) != 0) {
132
    if (stopsuffixes == 0 && (stopsuffixes = new list<string>) != 0) {
145
    string stp;
133
    string stp;
146
    if (mimemap->get("recoll_noindex", stp, keydir)) {
134
    if (mimemap->get("recoll_noindex", stp, keydir)) {
147
        ConfTree::stringToStrings(stp, *stopsuffixes);
135
        stringToStrings(stp, *stopsuffixes);
148
    }
136
    }
149
    }
137
    }
150
138
151
    if (stopsuffixes) {
139
    if (stopsuffixes) {
152
    sufflist = *stopsuffixes;
140
    sufflist = *stopsuffixes;
...
...
222
210
223
    mimeconf->get(mtype, hs, "");
211
    mimeconf->get(mtype, hs, "");
224
    if (hs.empty())
212
    if (hs.empty())
225
    return false;
213
    return false;
226
    list<string> tokens;
214
    list<string> tokens;
227
    ConfTree::stringToStrings(hs, tokens);
215
    stringToStrings(hs, tokens);
228
    if (tokens.empty()) {
216
    if (tokens.empty()) {
229
    LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
217
    LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
230
    return false;
218
    return false;
231
    }
219
    }
232
    if (stringlowercmp("uncompress", tokens.front())) 
220
    if (stringlowercmp("uncompress", tokens.front()))