cosmetics: list -> vector in more places
This commit is contained in:
parent
5462f639d3
commit
a17b7523e7
44 changed files with 285 additions and 313 deletions
|
@ -70,8 +70,8 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
|
||||||
cf.get(cstr_fmtime, dotdoc.fmtime, cstr_null);
|
cf.get(cstr_fmtime, dotdoc.fmtime, cstr_null);
|
||||||
cf.get(cstr_fbytes, dotdoc.pcbytes, cstr_null);
|
cf.get(cstr_fbytes, dotdoc.pcbytes, cstr_null);
|
||||||
dotdoc.sig.clear();
|
dotdoc.sig.clear();
|
||||||
list<string> names = cf.getNames(cstr_null);
|
vector<string> names = cf.getNames(cstr_null);
|
||||||
for (list<string>::const_iterator it = names.begin();
|
for (vector<string>::const_iterator it = names.begin();
|
||||||
it != names.end(); it++) {
|
it != names.end(); it++) {
|
||||||
cf.get(*it, dotdoc.meta[*it], cstr_null);
|
cf.get(*it, dotdoc.meta[*it], cstr_null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,8 +395,8 @@ bool RclConfig::addLocalFields(map<string, string> *tgt)
|
||||||
sfields[i] = '\n';
|
sfields[i] = '\n';
|
||||||
// Parse the result with a confsimple and add the results to the metadata
|
// Parse the result with a confsimple and add the results to the metadata
|
||||||
ConfSimple conf(sfields, 1, true);
|
ConfSimple conf(sfields, 1, true);
|
||||||
list<string> nmlst = conf.getNames(cstr_null);
|
vector<string> nmlst = conf.getNames(cstr_null);
|
||||||
for (list<string>::const_iterator it = nmlst.begin();
|
for (vector<string>::const_iterator it = nmlst.begin();
|
||||||
it != nmlst.end(); it++) {
|
it != nmlst.end(); it++) {
|
||||||
conf.get(*it, (*tgt)[*it]);
|
conf.get(*it, (*tgt)[*it]);
|
||||||
LOGDEB(("RclConfig::addLocalFields: [%s] => [%s]\n",
|
LOGDEB(("RclConfig::addLocalFields: [%s] => [%s]\n",
|
||||||
|
@ -414,14 +414,12 @@ bool RclConfig::addLocalFields(map<string, string> *tgt)
|
||||||
//
|
//
|
||||||
// This unfortunately means that searches by file names and mime type
|
// This unfortunately means that searches by file names and mime type
|
||||||
// filtering don't work well together.
|
// filtering don't work well together.
|
||||||
list<string> RclConfig::getAllMimeTypes()
|
vector<string> RclConfig::getAllMimeTypes()
|
||||||
{
|
{
|
||||||
list<string> lst;
|
vector<string> lst;
|
||||||
if (mimeconf == 0)
|
if (mimeconf == 0)
|
||||||
return lst;
|
return lst;
|
||||||
lst = mimeconf->getNames("index");
|
lst = mimeconf->getNames("index");
|
||||||
lst.sort();
|
|
||||||
lst.unique();
|
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,9 +509,9 @@ string RclConfig::getMimeTypeFromSuffix(const string& suff)
|
||||||
string RclConfig::getSuffixFromMimeType(const string &mt)
|
string RclConfig::getSuffixFromMimeType(const string &mt)
|
||||||
{
|
{
|
||||||
string suffix;
|
string suffix;
|
||||||
list<string>sfs = mimemap->getNames(cstr_null);
|
vector<string>sfs = mimemap->getNames(cstr_null);
|
||||||
string mt1;
|
string mt1;
|
||||||
for (list<string>::const_iterator it = sfs.begin();
|
for (vector<string>::const_iterator it = sfs.begin();
|
||||||
it != sfs.end(); it++) {
|
it != sfs.end(); it++) {
|
||||||
if (mimemap->get(*it, mt1, cstr_null))
|
if (mimemap->get(*it, mt1, cstr_null))
|
||||||
if (!stringicmp(mt, mt1))
|
if (!stringicmp(mt, mt1))
|
||||||
|
@ -523,7 +521,7 @@ string RclConfig::getSuffixFromMimeType(const string &mt)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of file categories from mimeconf */
|
/** Get list of file categories from mimeconf */
|
||||||
bool RclConfig::getMimeCategories(list<string>& cats)
|
bool RclConfig::getMimeCategories(vector<string>& cats)
|
||||||
{
|
{
|
||||||
if (!mimeconf)
|
if (!mimeconf)
|
||||||
return false;
|
return false;
|
||||||
|
@ -533,9 +531,9 @@ bool RclConfig::getMimeCategories(list<string>& cats)
|
||||||
|
|
||||||
bool RclConfig::isMimeCategory(string& cat)
|
bool RclConfig::isMimeCategory(string& cat)
|
||||||
{
|
{
|
||||||
list<string>cats;
|
vector<string>cats;
|
||||||
getMimeCategories(cats);
|
getMimeCategories(cats);
|
||||||
for (list<string>::iterator it = cats.begin(); it != cats.end(); it++) {
|
for (vector<string>::iterator it = cats.begin(); it != cats.end(); it++) {
|
||||||
if (!stringicmp(*it,cat))
|
if (!stringicmp(*it,cat))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -543,7 +541,7 @@ bool RclConfig::isMimeCategory(string& cat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of mime types for category from mimeconf */
|
/** Get list of mime types for category from mimeconf */
|
||||||
bool RclConfig::getMimeCatTypes(const string& cat, list<string>& tps)
|
bool RclConfig::getMimeCatTypes(const string& cat, vector<string>& tps)
|
||||||
{
|
{
|
||||||
tps.clear();
|
tps.clear();
|
||||||
if (!mimeconf)
|
if (!mimeconf)
|
||||||
|
@ -576,7 +574,7 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes)
|
||||||
return hs;
|
return hs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclConfig::getGuiFilterNames(list<string>& cats)
|
bool RclConfig::getGuiFilterNames(vector<string>& cats)
|
||||||
{
|
{
|
||||||
if (!mimeconf)
|
if (!mimeconf)
|
||||||
return false;
|
return false;
|
||||||
|
@ -652,8 +650,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||||
// Build a direct map avoiding all indirections for field to
|
// Build a direct map avoiding all indirections for field to
|
||||||
// prefix translation
|
// prefix translation
|
||||||
// Add direct prefixes from the [prefixes] section
|
// Add direct prefixes from the [prefixes] section
|
||||||
list<string>tps = m_fields->getNames("prefixes");
|
vector<string>tps = m_fields->getNames("prefixes");
|
||||||
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
|
for (vector<string>::const_iterator it = tps.begin();
|
||||||
|
it != tps.end(); it++) {
|
||||||
string val;
|
string val;
|
||||||
m_fields->get(*it, val, "prefixes");
|
m_fields->get(*it, val, "prefixes");
|
||||||
ConfSimple attrs;
|
ConfSimple attrs;
|
||||||
|
@ -677,7 +676,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||||
// Having the aliases in the prefix map avoids an additional indirection
|
// Having the aliases in the prefix map avoids an additional indirection
|
||||||
// at index time.
|
// at index time.
|
||||||
tps = m_fields->getNames("aliases");
|
tps = m_fields->getNames("aliases");
|
||||||
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
|
for (vector<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
|
||||||
string canonic = stringtolower(*it); // canonic name
|
string canonic = stringtolower(*it); // canonic name
|
||||||
FieldTraits ft;
|
FieldTraits ft;
|
||||||
map<string, FieldTraits>::const_iterator pit =
|
map<string, FieldTraits>::const_iterator pit =
|
||||||
|
@ -687,9 +686,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||||
}
|
}
|
||||||
string aliases;
|
string aliases;
|
||||||
m_fields->get(canonic, aliases, "aliases");
|
m_fields->get(canonic, aliases, "aliases");
|
||||||
list<string> l;
|
vector<string> l;
|
||||||
stringToStrings(aliases, l);
|
stringToStrings(aliases, l);
|
||||||
for (list<string>::const_iterator ait = l.begin();
|
for (vector<string>::const_iterator ait = l.begin();
|
||||||
ait != l.end(); ait++) {
|
ait != l.end(); ait++) {
|
||||||
if (pit != m_fldtotraits.end())
|
if (pit != m_fldtotraits.end())
|
||||||
m_fldtotraits[stringtolower(*ait)] = ft;
|
m_fldtotraits[stringtolower(*ait)] = ft;
|
||||||
|
@ -706,9 +705,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
list<string> sl = m_fields->getNames("stored");
|
vector<string> sl = m_fields->getNames("stored");
|
||||||
if (!sl.empty()) {
|
if (!sl.empty()) {
|
||||||
for (list<string>::const_iterator it = sl.begin();
|
for (vector<string>::const_iterator it = sl.begin();
|
||||||
it != sl.end(); it++) {
|
it != sl.end(); it++) {
|
||||||
string fld = fieldCanon(stringtolower(*it));
|
string fld = fieldCanon(stringtolower(*it));
|
||||||
m_storedFields.insert(fld);
|
m_storedFields.insert(fld);
|
||||||
|
@ -716,8 +715,8 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extended file attribute to field translations
|
// Extended file attribute to field translations
|
||||||
list<string>xattrs = m_fields->getNames("xattrtofields");
|
vector<string>xattrs = m_fields->getNames("xattrtofields");
|
||||||
for (list<string>::const_iterator it = xattrs.begin();
|
for (vector<string>::const_iterator it = xattrs.begin();
|
||||||
it != xattrs.end(); it++) {
|
it != xattrs.end(); it++) {
|
||||||
string val;
|
string val;
|
||||||
m_fields->get(*it, val, "xattrtofields");
|
m_fields->get(*it, val, "xattrtofields");
|
||||||
|
@ -751,7 +750,7 @@ set<string> RclConfig::getIndexedFields()
|
||||||
if (m_fields == 0)
|
if (m_fields == 0)
|
||||||
return flds;
|
return flds;
|
||||||
|
|
||||||
list<string> sl = m_fields->getNames("prefixes");
|
vector<string> sl = m_fields->getNames("prefixes");
|
||||||
flds.insert(sl.begin(), sl.end());
|
flds.insert(sl.begin(), sl.end());
|
||||||
return flds;
|
return flds;
|
||||||
}
|
}
|
||||||
|
@ -769,10 +768,10 @@ string RclConfig::fieldCanon(const string& f)
|
||||||
return fld;
|
return fld;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
|
vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
|
||||||
{
|
{
|
||||||
if (m_fields == 0)
|
if (m_fields == 0)
|
||||||
return list<string>();
|
return vector<string>();
|
||||||
return m_fields->getNames(sk, patrn);
|
return m_fields->getNames(sk, patrn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,8 +801,8 @@ bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs)
|
||||||
{
|
{
|
||||||
if (mimeview == 0)
|
if (mimeview == 0)
|
||||||
return false;
|
return false;
|
||||||
list<string>tps = mimeview->getNames("view");
|
vector<string>tps = mimeview->getNames("view");
|
||||||
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
|
for (vector<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
|
||||||
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "")));
|
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "")));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -823,7 +822,7 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> cdirs;
|
vector<string> cdirs;
|
||||||
cdirs.push_back(m_confdir);
|
cdirs.push_back(m_confdir);
|
||||||
cdirs.push_back(path_cat(m_datadir, "examples"));
|
cdirs.push_back(path_cat(m_datadir, "examples"));
|
||||||
|
|
||||||
|
@ -934,7 +933,7 @@ string RclConfig::getIdxStatusFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string>& RclConfig::getSkippedNames()
|
vector<string>& RclConfig::getSkippedNames()
|
||||||
{
|
{
|
||||||
if (m_skpnstate.needrecompute()) {
|
if (m_skpnstate.needrecompute()) {
|
||||||
stringToStrings(m_skpnstate.savedvalue, m_skpnlist);
|
stringToStrings(m_skpnstate.savedvalue, m_skpnlist);
|
||||||
|
@ -942,9 +941,9 @@ list<string>& RclConfig::getSkippedNames()
|
||||||
return m_skpnlist;
|
return m_skpnlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> RclConfig::getSkippedPaths()
|
vector<string> RclConfig::getSkippedPaths()
|
||||||
{
|
{
|
||||||
list<string> skpl;
|
vector<string> skpl;
|
||||||
getConfParam("skippedPaths", &skpl);
|
getConfParam("skippedPaths", &skpl);
|
||||||
|
|
||||||
// Always add the dbdir and confdir to the skipped paths. This is
|
// Always add the dbdir and confdir to the skipped paths. This is
|
||||||
|
@ -952,30 +951,30 @@ list<string> RclConfig::getSkippedPaths()
|
||||||
// don't do this.
|
// don't do this.
|
||||||
skpl.push_back(getDbDir());
|
skpl.push_back(getDbDir());
|
||||||
skpl.push_back(getConfDir());
|
skpl.push_back(getConfDir());
|
||||||
for (list<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
|
for (vector<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
|
||||||
*it = path_tildexpand(*it);
|
*it = path_tildexpand(*it);
|
||||||
*it = path_canon(*it);
|
*it = path_canon(*it);
|
||||||
}
|
}
|
||||||
skpl.sort();
|
sort(skpl.begin(), skpl.end());
|
||||||
skpl.unique();
|
unique(skpl.begin(), skpl.end());
|
||||||
return skpl;
|
return skpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> RclConfig::getDaemSkippedPaths()
|
vector<string> RclConfig::getDaemSkippedPaths()
|
||||||
{
|
{
|
||||||
list<string> skpl = getSkippedPaths();
|
vector<string> dskpl;
|
||||||
|
|
||||||
list<string> dskpl;
|
|
||||||
getConfParam("daemSkippedPaths", &dskpl);
|
getConfParam("daemSkippedPaths", &dskpl);
|
||||||
|
|
||||||
for (list<string>::iterator it = dskpl.begin(); it != dskpl.end(); it++) {
|
for (vector<string>::iterator it = dskpl.begin(); it != dskpl.end(); it++) {
|
||||||
*it = path_tildexpand(*it);
|
*it = path_tildexpand(*it);
|
||||||
*it = path_canon(*it);
|
*it = path_canon(*it);
|
||||||
}
|
}
|
||||||
dskpl.sort();
|
sort(dskpl.begin(), dskpl.end());
|
||||||
|
|
||||||
skpl.merge(dskpl);
|
vector<string> skpl1 = getSkippedPaths();
|
||||||
skpl.unique();
|
vector<string> skpl;
|
||||||
|
merge(dskpl.begin(), dskpl.end(), skpl1.begin(), skpl1.end(), skpl.begin());
|
||||||
|
unique(skpl.begin(), skpl.end());
|
||||||
return skpl;
|
return skpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,20 +1023,20 @@ string RclConfig::findFilter(const string &icmd)
|
||||||
/**
|
/**
|
||||||
* Return decompression command line for given mime type
|
* Return decompression command line for given mime type
|
||||||
*/
|
*/
|
||||||
bool RclConfig::getUncompressor(const string &mtype, list<string>& cmd)
|
bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd)
|
||||||
{
|
{
|
||||||
string hs;
|
string hs;
|
||||||
|
|
||||||
mimeconf->get(mtype, hs, cstr_null);
|
mimeconf->get(mtype, hs, cstr_null);
|
||||||
if (hs.empty())
|
if (hs.empty())
|
||||||
return false;
|
return false;
|
||||||
list<string> tokens;
|
vector<string> tokens;
|
||||||
stringToStrings(hs, tokens);
|
stringToStrings(hs, tokens);
|
||||||
if (tokens.empty()) {
|
if (tokens.empty()) {
|
||||||
LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
|
LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list<string>::iterator it = tokens.begin();
|
vector<string>::iterator it = tokens.begin();
|
||||||
if (tokens.size() < 2)
|
if (tokens.size() < 2)
|
||||||
return false;
|
return false;
|
||||||
if (stringlowercmp("uncompress", *it++))
|
if (stringlowercmp("uncompress", *it++))
|
||||||
|
@ -1148,7 +1147,7 @@ void RclConfig::initFrom(const RclConfig& r)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -1252,20 +1251,20 @@ int main(int argc, char **argv)
|
||||||
} else if (op_flags & OPT_c) {
|
} else if (op_flags & OPT_c) {
|
||||||
// Check that all known mime types have an icon and belong to
|
// Check that all known mime types have an icon and belong to
|
||||||
// some category
|
// some category
|
||||||
list<string> catnames;
|
vector<string> catnames;
|
||||||
config->getMimeCategories(catnames);
|
config->getMimeCategories(catnames);
|
||||||
cout << "Categories: ";
|
cout << "Categories: ";
|
||||||
set<string> allmtsfromcats;
|
set<string> allmtsfromcats;
|
||||||
for (list<string>::const_iterator it = catnames.begin();
|
for (vector<string>::const_iterator it = catnames.begin();
|
||||||
it != catnames.end(); it++) {
|
it != catnames.end(); it++) {
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
for (list<string>::const_iterator it = catnames.begin();
|
for (vector<string>::const_iterator it = catnames.begin();
|
||||||
it != catnames.end(); it++) {
|
it != catnames.end(); it++) {
|
||||||
list<string> cts;
|
vector<string> cts;
|
||||||
config->getMimeCatTypes(*it, cts);
|
config->getMimeCatTypes(*it, cts);
|
||||||
for (list<string>::const_iterator it1 = cts.begin();
|
for (vector<string>::const_iterator it1 = cts.begin();
|
||||||
it1 != cts.end(); it1++) {
|
it1 != cts.end(); it1++) {
|
||||||
// Already in map -> duplicate
|
// Already in map -> duplicate
|
||||||
if (allmtsfromcats.find(*it1) != allmtsfromcats.end()) {
|
if (allmtsfromcats.find(*it1) != allmtsfromcats.end()) {
|
||||||
|
@ -1275,8 +1274,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> mtypes = config->getAllMimeTypes();
|
vector<string> mtypes = config->getAllMimeTypes();
|
||||||
for (list<string>::const_iterator it = mtypes.begin();
|
for (vector<string>::const_iterator it = mtypes.begin();
|
||||||
it != mtypes.end(); it++) {
|
it != mtypes.end(); it++) {
|
||||||
if (allmtsfromcats.find(*it) == allmtsfromcats.end()) {
|
if (allmtsfromcats.find(*it) == allmtsfromcats.end()) {
|
||||||
cout << "Not found in catgs: [" << *it << "]" << endl;
|
cout << "Not found in catgs: [" << *it << "]" << endl;
|
||||||
|
@ -1284,10 +1283,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config->setKeyDir(cstr_null);
|
config->setKeyDir(cstr_null);
|
||||||
list<string> names = config->getConfNames();
|
vector<string> names = config->getConfNames();
|
||||||
names.sort();
|
for (vector<string>::iterator it = names.begin();
|
||||||
names.unique();
|
|
||||||
for (list<string>::iterator it = names.begin();
|
|
||||||
it != names.end();it++) {
|
it != names.end();it++) {
|
||||||
string value;
|
string value;
|
||||||
config->getConfParam(*it, value);
|
config->getConfParam(*it, value);
|
||||||
|
|
|
@ -121,7 +121,7 @@ class RclConfig {
|
||||||
* Get list of config names under current sk, with possible
|
* Get list of config names under current sk, with possible
|
||||||
* wildcard filtering
|
* wildcard filtering
|
||||||
*/
|
*/
|
||||||
list<string> getConfNames(const char *pattern = 0) {
|
vector<string> getConfNames(const char *pattern = 0) {
|
||||||
return m_conf->getNames(m_keydir, pattern);
|
return m_conf->getNames(m_keydir, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,13 +151,13 @@ class RclConfig {
|
||||||
string getIdxStatusFile();
|
string getIdxStatusFile();
|
||||||
|
|
||||||
/** Get list of skipped file names for current keydir */
|
/** Get list of skipped file names for current keydir */
|
||||||
list<string>& getSkippedNames();
|
vector<string>& getSkippedNames();
|
||||||
|
|
||||||
/** Get list of skipped paths patterns. Doesn't depend on the keydir */
|
/** Get list of skipped paths patterns. Doesn't depend on the keydir */
|
||||||
list<string> getSkippedPaths();
|
vector<string> getSkippedPaths();
|
||||||
/** Get list of skipped paths patterns, daemon version (may add some)
|
/** Get list of skipped paths patterns, daemon version (may add some)
|
||||||
Doesn't depend on the keydir */
|
Doesn't depend on the keydir */
|
||||||
list<string> getDaemSkippedPaths();
|
vector<string> getDaemSkippedPaths();
|
||||||
|
|
||||||
/** conf: Add local fields to target dic */
|
/** conf: Add local fields to target dic */
|
||||||
bool addLocalFields(map<string, string> *tgt);
|
bool addLocalFields(map<string, string> *tgt);
|
||||||
|
@ -177,12 +177,12 @@ class RclConfig {
|
||||||
* The returned command has substitutable places for input file name
|
* The returned command has substitutable places for input file name
|
||||||
* and temp dir name, and will return output name
|
* and temp dir name, and will return output name
|
||||||
*/
|
*/
|
||||||
bool getUncompressor(const string &mtpe, list<string>& cmd);
|
bool getUncompressor(const string &mtpe, vector<string>& cmd);
|
||||||
|
|
||||||
/** mimemap: compute mimetype */
|
/** mimemap: compute mimetype */
|
||||||
string getMimeTypeFromSuffix(const string &suffix);
|
string getMimeTypeFromSuffix(const string &suffix);
|
||||||
/** mimemap: get a list of all indexable mime types defined */
|
/** mimemap: get a list of all indexable mime types defined */
|
||||||
list<string> getAllMimeTypes();
|
vector<string> getAllMimeTypes();
|
||||||
/** mimemap: Get appropriate suffix for mime type. This is inefficient */
|
/** mimemap: Get appropriate suffix for mime type. This is inefficient */
|
||||||
string getSuffixFromMimeType(const string &mt);
|
string getSuffixFromMimeType(const string &mt);
|
||||||
|
|
||||||
|
@ -200,14 +200,14 @@ class RclConfig {
|
||||||
string getMimeIconName(const string &mtype, string *path = 0);
|
string getMimeIconName(const string &mtype, string *path = 0);
|
||||||
|
|
||||||
/** mimeconf: get list of file categories */
|
/** mimeconf: get list of file categories */
|
||||||
bool getMimeCategories(list<string>&);
|
bool getMimeCategories(vector<string>&);
|
||||||
/** mimeconf: is parameter one of the categories ? */
|
/** mimeconf: is parameter one of the categories ? */
|
||||||
bool isMimeCategory(string&);
|
bool isMimeCategory(string&);
|
||||||
/** mimeconf: get list of mime types for category */
|
/** mimeconf: get list of mime types for category */
|
||||||
bool getMimeCatTypes(const string& cat, list<string>&);
|
bool getMimeCatTypes(const string& cat, vector<string>&);
|
||||||
|
|
||||||
/** mimeconf: get list of gui filters (doc cats by default */
|
/** mimeconf: get list of gui filters (doc cats by default */
|
||||||
bool getGuiFilterNames(list<string>&);
|
bool getGuiFilterNames(vector<string>&);
|
||||||
/** mimeconf: get query lang frag for named filter */
|
/** mimeconf: get query lang frag for named filter */
|
||||||
bool getGuiFilter(const string& filtername, string& frag);
|
bool getGuiFilter(const string& filtername, string& frag);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class RclConfig {
|
||||||
/** Get value of a parameter inside the "fields" file. Only some filters
|
/** Get value of a parameter inside the "fields" file. Only some filters
|
||||||
use this (ie: mh_mail). The information specific to a given filter
|
use this (ie: mh_mail). The information specific to a given filter
|
||||||
is typically stored in a separate section(ie: [mail]) */
|
is typically stored in a separate section(ie: [mail]) */
|
||||||
list<string> getFieldSectNames(const string &sk, const char* = 0);
|
vector<string> getFieldSectNames(const string &sk, const char* = 0);
|
||||||
bool getFieldConfParam(const string &name, const string &sk, string &value);
|
bool getFieldConfParam(const string &name, const string &sk, string &value);
|
||||||
|
|
||||||
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
|
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
|
||||||
|
@ -267,7 +267,7 @@ class RclConfig {
|
||||||
string m_keydir; // Current directory used for parameter fetches.
|
string m_keydir; // Current directory used for parameter fetches.
|
||||||
int m_keydirgen; // To help with knowing when to update computed data.
|
int m_keydirgen; // To help with knowing when to update computed data.
|
||||||
|
|
||||||
list<string> m_cdirs; // directory stack for the confstacks
|
vector<string> m_cdirs; // directory stack for the confstacks
|
||||||
|
|
||||||
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
||||||
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
||||||
|
@ -284,7 +284,7 @@ class RclConfig {
|
||||||
ParamStale m_stpsuffstate;
|
ParamStale m_stpsuffstate;
|
||||||
|
|
||||||
ParamStale m_skpnstate;
|
ParamStale m_skpnstate;
|
||||||
list<string> m_skpnlist;
|
vector<string> m_skpnlist;
|
||||||
|
|
||||||
// Parameters auto-fetched on setkeydir
|
// Parameters auto-fetched on setkeydir
|
||||||
string defcharset;
|
string defcharset;
|
||||||
|
|
|
@ -127,8 +127,8 @@ public:
|
||||||
confstr += line + "\n";
|
confstr += line + "\n";
|
||||||
}
|
}
|
||||||
ConfSimple fields(confstr, 1);
|
ConfSimple fields(confstr, 1);
|
||||||
list<string> names = fields.getNames(cstr_null);
|
vector<string> names = fields.getNames(cstr_null);
|
||||||
for (list<string>::iterator it = names.begin();
|
for (vector<string>::iterator it = names.begin();
|
||||||
it != names.end(); it++) {
|
it != names.end(); it++) {
|
||||||
string value;
|
string value;
|
||||||
fields.get(*it, value, cstr_null);
|
fields.get(*it, value, cstr_null);
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
#ifndef _beaglequeue_h_included_
|
#ifndef _beaglequeue_h_included_
|
||||||
#define _beaglequeue_h_included_
|
#define _beaglequeue_h_included_
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
using std::list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the Beagle indexing queue.
|
* Process the Beagle indexing queue.
|
||||||
*
|
*
|
||||||
|
|
|
@ -239,13 +239,13 @@ bool ConfIndexer::createStemmingDatabases()
|
||||||
LOGERR(("ConfIndexer::createStemmingDb: could not open db\n"))
|
LOGERR(("ConfIndexer::createStemmingDb: could not open db\n"))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list<string> langs;
|
vector<string> langs;
|
||||||
stringToStrings(slangs, langs);
|
stringToStrings(slangs, langs);
|
||||||
|
|
||||||
// Get the list of existing stem dbs from the database (some may have
|
// Get the list of existing stem dbs from the database (some may have
|
||||||
// been manually created, we just keep those from the config
|
// been manually created, we just keep those from the config
|
||||||
list<string> dblangs = m_db.getStemLangs();
|
vector<string> dblangs = m_db.getStemLangs();
|
||||||
list<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
for (it = dblangs.begin(); it != dblangs.end(); it++) {
|
for (it = dblangs.begin(); it != dblangs.end(); it++) {
|
||||||
if (find(langs.begin(), langs.end(), *it) == langs.end())
|
if (find(langs.begin(), langs.end(), *it) == langs.end())
|
||||||
m_db.deleteStemDb(*it);
|
m_db.deleteStemDb(*it);
|
||||||
|
|
|
@ -130,7 +130,7 @@ bool FileInterner::getEnclosing(const string &url, const string &ipath,
|
||||||
// Uncompress input file into a temporary one, by executing the appropriate
|
// Uncompress input file into a temporary one, by executing the appropriate
|
||||||
// script.
|
// script.
|
||||||
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
||||||
const list<string>& cmdv, TempDir& tdir,
|
const vector<string>& cmdv, TempDir& tdir,
|
||||||
string& tfile)
|
string& tfile)
|
||||||
{
|
{
|
||||||
// Make sure tmp dir is empty. we guarantee this to filters
|
// Make sure tmp dir is empty. we guarantee this to filters
|
||||||
|
@ -141,7 +141,7 @@ static bool uncompressfile(RclConfig *conf, const string& ifn,
|
||||||
string cmd = cmdv.front();
|
string cmd = cmdv.front();
|
||||||
|
|
||||||
// Substitute file name and temp dir in command elements
|
// Substitute file name and temp dir in command elements
|
||||||
list<string>::const_iterator it = cmdv.begin();
|
vector<string>::const_iterator it = cmdv.begin();
|
||||||
++it;
|
++it;
|
||||||
vector<string> args;
|
vector<string> args;
|
||||||
map<char, string> subs;
|
map<char, string> subs;
|
||||||
|
@ -245,7 +245,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
|
||||||
// Has mime: check for a compressed file. If so, create a
|
// Has mime: check for a compressed file. If so, create a
|
||||||
// temporary uncompressed file, and rerun the mime type
|
// temporary uncompressed file, and rerun the mime type
|
||||||
// identification, then do the rest with the temp file.
|
// identification, then do the rest with the temp file.
|
||||||
list<string>ucmd;
|
vector<string>ucmd;
|
||||||
if (m_cfg->getUncompressor(l_mime, ucmd)) {
|
if (m_cfg->getUncompressor(l_mime, ucmd)) {
|
||||||
// Check for compressed size limit
|
// Check for compressed size limit
|
||||||
int maxkbs = -1;
|
int maxkbs = -1;
|
||||||
|
@ -541,10 +541,10 @@ bool FileInterner::dataToTempFile(const string& dt, const string& mt,
|
||||||
void FileInterner::checkExternalMissing(const string& msg, const string& mt)
|
void FileInterner::checkExternalMissing(const string& msg, const string& mt)
|
||||||
{
|
{
|
||||||
if (m_missingdatap && msg.find("RECFILTERROR") == 0) {
|
if (m_missingdatap && msg.find("RECFILTERROR") == 0) {
|
||||||
list<string> lerr;
|
vector<string> lerr;
|
||||||
stringToStrings(msg, lerr);
|
stringToStrings(msg, lerr);
|
||||||
if (lerr.size() > 2) {
|
if (lerr.size() > 2) {
|
||||||
list<string>::iterator it = lerr.begin();
|
vector<string>::iterator it = lerr.begin();
|
||||||
lerr.erase(it++);
|
lerr.erase(it++);
|
||||||
if (*it == "HELPERNOTFOUND") {
|
if (*it == "HELPERNOTFOUND") {
|
||||||
lerr.erase(it++);
|
lerr.erase(it++);
|
||||||
|
@ -597,8 +597,8 @@ void FileInterner::getMissingFromDescription(FIMissingStore *st, const string& i
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The "missing" file is text. Each line defines a missing filter
|
// The "missing" file is text. Each line defines a missing filter
|
||||||
// and the list of mime types actually encountered that needed it (see method
|
// and the list of mime types actually encountered that needed it
|
||||||
// getMissingDescription())
|
// (see method getMissingDescription())
|
||||||
|
|
||||||
vector<string> lines;
|
vector<string> lines;
|
||||||
stringToTokens(in, lines, "\n");
|
stringToTokens(in, lines, "\n");
|
||||||
|
@ -1125,7 +1125,7 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string>ucmd;
|
vector<string> ucmd;
|
||||||
if (cnf->getUncompressor(l_mime, ucmd)) {
|
if (cnf->getUncompressor(l_mime, ucmd)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1149,7 +1149,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string>ucmd;
|
vector<string>ucmd;
|
||||||
if (!cnf->getUncompressor(l_mime, ucmd)) {
|
if (!cnf->getUncompressor(l_mime, ucmd)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,8 @@ bool MimeHandlerExec::next_document()
|
||||||
// Command name
|
// Command name
|
||||||
string cmd = params.front();
|
string cmd = params.front();
|
||||||
|
|
||||||
// Build parameter list: delete cmd name and add the file name
|
// Build parameter vector: delete cmd name and add the file name
|
||||||
list<string>::iterator it = params.begin();
|
vector<string>::iterator it = params.begin();
|
||||||
vector<string>myparams(++it, params.end());
|
vector<string>myparams(++it, params.end());
|
||||||
myparams.push_back(m_fn);
|
myparams.push_back(m_fn);
|
||||||
if (!m_ipath.empty())
|
if (!m_ipath.empty())
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#define _MH_EXEC_H_INCLUDED_
|
#define _MH_EXEC_H_INCLUDED_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <vector>
|
||||||
using std::list;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
|
@ -43,9 +43,9 @@ class MimeHandlerExec : public RecollFilter {
|
||||||
// (no use to try and execute over and over something that's not
|
// (no use to try and execute over and over something that's not
|
||||||
// here).
|
// here).
|
||||||
|
|
||||||
// Parameter list: this has been built by our creator, from config file
|
// Parameters: this has been built by our creator, from config file
|
||||||
// data. We always add the file name at the end before actual execution
|
// data. We always add the file name at the end before actual execution
|
||||||
list<string> params;
|
vector<string> params;
|
||||||
// Filter output type. The default for ext. filters is to output html,
|
// Filter output type. The default for ext. filters is to output html,
|
||||||
// but some don't, in which case the type is defined in the config.
|
// but some don't, in which case the type is defined in the config.
|
||||||
string cfgFilterOutputMtype;
|
string cfgFilterOutputMtype;
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool MimeHandlerExecMultiple::startCmd()
|
||||||
string cmd = params.front();
|
string cmd = params.front();
|
||||||
|
|
||||||
// Build parameter list: delete cmd name
|
// Build parameter list: delete cmd name
|
||||||
list<string>::iterator it = params.begin();
|
vector<string>::iterator it = params.begin();
|
||||||
vector<string>myparams(++it, params.end());
|
vector<string>myparams(++it, params.end());
|
||||||
|
|
||||||
// Start filter
|
// Start filter
|
||||||
|
|
|
@ -51,11 +51,11 @@ MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &mt)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Look for additional headers to be processed as per config:
|
// Look for additional headers to be processed as per config:
|
||||||
list<string> hdrnames =
|
vector<string> hdrnames =
|
||||||
m_config->getFieldSectNames("mail");
|
m_config->getFieldSectNames("mail");
|
||||||
if (hdrnames.empty())
|
if (hdrnames.empty())
|
||||||
return;
|
return;
|
||||||
for (list<string>::const_iterator it = hdrnames.begin();
|
for (vector<string>::const_iterator it = hdrnames.begin();
|
||||||
it != hdrnames.end(); it++) {
|
it != hdrnames.end(); it++) {
|
||||||
(void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
|
(void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,17 +294,17 @@ void AdvSearch::fillFileTypes()
|
||||||
|
|
||||||
QStringList ql;
|
QStringList ql;
|
||||||
if (m_ignByCats == false) {
|
if (m_ignByCats == false) {
|
||||||
list<string> types = theconfig->getAllMimeTypes();
|
vector<string> types = theconfig->getAllMimeTypes();
|
||||||
for (list<string>::iterator it = types.begin();
|
for (vector<string>::iterator it = types.begin();
|
||||||
it != types.end(); it++) {
|
it != types.end(); it++) {
|
||||||
QString qs = QString::fromUtf8(it->c_str());
|
QString qs = QString::fromUtf8(it->c_str());
|
||||||
if (m_ignTypes.indexOf(qs) < 0)
|
if (m_ignTypes.indexOf(qs) < 0)
|
||||||
ql.append(qs);
|
ql.append(qs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list<string> cats;
|
vector<string> cats;
|
||||||
theconfig->getMimeCategories(cats);
|
theconfig->getMimeCategories(cats);
|
||||||
for (list<string>::const_iterator it = cats.begin();
|
for (vector<string>::const_iterator it = cats.begin();
|
||||||
it != cats.end(); it++) {
|
it != cats.end(); it++) {
|
||||||
map<QString, QString>::const_iterator it1;
|
map<QString, QString>::const_iterator it1;
|
||||||
QString cat;
|
QString cat;
|
||||||
|
@ -321,7 +321,7 @@ void AdvSearch::fillFileTypes()
|
||||||
yesFiltypsLB->insertItems(0, ql);
|
yesFiltypsLB->insertItems(0, ql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save current list of ignored file types to prefs
|
// Save current set of ignored file types to prefs
|
||||||
void AdvSearch::saveFileTypes()
|
void AdvSearch::saveFileTypes()
|
||||||
{
|
{
|
||||||
prefs.asearchIgnFilTyps = m_ignTypes;
|
prefs.asearchIgnFilTyps = m_ignTypes;
|
||||||
|
@ -383,9 +383,9 @@ void AdvSearch::runSearch()
|
||||||
} else {
|
} else {
|
||||||
cat = (const char *)qcat.toUtf8();
|
cat = (const char *)qcat.toUtf8();
|
||||||
}
|
}
|
||||||
list<string> types;
|
vector<string> types;
|
||||||
theconfig->getMimeCatTypes(cat, types);
|
theconfig->getMimeCatTypes(cat, types);
|
||||||
for (list<string>::const_iterator it = types.begin();
|
for (vector<string>::const_iterator it = types.begin();
|
||||||
it != types.end(); it++) {
|
it != types.end(); it++) {
|
||||||
sdata->addFiletype(*it);
|
sdata->addFiletype(*it);
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ void AdvSearch::runSearch()
|
||||||
QString current = subtreeCMB->currentText();
|
QString current = subtreeCMB->currentText();
|
||||||
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8(),
|
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8(),
|
||||||
direxclCB->isChecked());
|
direxclCB->isChecked());
|
||||||
// Keep history list clean and sorted. Maybe there would be a
|
// Keep history clean and sorted. Maybe there would be a
|
||||||
// simpler way to do this
|
// simpler way to do this
|
||||||
list<QString> entries;
|
list<QString> entries;
|
||||||
for (int i = 0; i < subtreeCMB->count(); i++) {
|
for (int i = 0; i < subtreeCMB->count(); i++) {
|
||||||
|
@ -427,7 +427,7 @@ void AdvSearch::runSearch()
|
||||||
}
|
}
|
||||||
entries.push_back(subtreeCMB->currentText());
|
entries.push_back(subtreeCMB->currentText());
|
||||||
entries.sort();
|
entries.sort();
|
||||||
unique(entries.begin(), entries.end());
|
entries.unique();
|
||||||
subtreeCMB->clear();
|
subtreeCMB->clear();
|
||||||
for (list<QString>::iterator it = entries.begin();
|
for (list<QString>::iterator it = entries.begin();
|
||||||
it != entries.end(); it++) {
|
it != entries.end(); it++) {
|
||||||
|
|
|
@ -296,10 +296,10 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
|
||||||
// customized in the system config like .thunderbird or
|
// customized in the system config like .thunderbird or
|
||||||
// .purple. This doesn't prevent them to add and customize them
|
// .purple. This doesn't prevent them to add and customize them
|
||||||
// further.
|
// further.
|
||||||
list<string> allkeydirs = config->getSubKeys(true);
|
vector<string> allkeydirs = config->getSubKeys(true);
|
||||||
|
|
||||||
QStringList qls;
|
QStringList qls;
|
||||||
for (list<string>::const_iterator it = allkeydirs.begin();
|
for (vector<string>::const_iterator it = allkeydirs.begin();
|
||||||
it != allkeydirs.end(); it++) {
|
it != allkeydirs.end(); it++) {
|
||||||
qls.push_back(QString::fromUtf8(it->c_str()));
|
qls.push_back(QString::fromUtf8(it->c_str()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getStemLangs(list<string>& langs)
|
bool getStemLangs(vector<string>& langs)
|
||||||
{
|
{
|
||||||
string reason;
|
string reason;
|
||||||
if (!maybeOpenDb(reason)) {
|
if (!maybeOpenDb(reason)) {
|
||||||
|
|
|
@ -178,12 +178,12 @@ void RclMain::init()
|
||||||
bgrp->addButton(allRDB, bgrpid++);
|
bgrp->addButton(allRDB, bgrpid++);
|
||||||
connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int)));
|
connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int)));
|
||||||
allRDB->setChecked(true);
|
allRDB->setChecked(true);
|
||||||
list<string> cats;
|
vector<string> cats;
|
||||||
theconfig->getGuiFilterNames(cats);
|
theconfig->getGuiFilterNames(cats);
|
||||||
// Text for button 0 is not used. Next statement just avoids unused
|
// Text for button 0 is not used. Next statement just avoids unused
|
||||||
// variable compiler warning for catg_strings
|
// variable compiler warning for catg_strings
|
||||||
m_catgbutvec.push_back(catg_strings[0]);
|
m_catgbutvec.push_back(catg_strings[0]);
|
||||||
for (list<string>::const_iterator it = cats.begin();
|
for (vector<string>::const_iterator it = cats.begin();
|
||||||
it != cats.end(); it++) {
|
it != cats.end(); it++) {
|
||||||
QRadioButton *but = new QRadioButton(catgBGRP);
|
QRadioButton *but = new QRadioButton(catgBGRP);
|
||||||
QString catgnm = QString::fromUtf8(it->c_str(), it->length());
|
QString catgnm = QString::fromUtf8(it->c_str(), it->length());
|
||||||
|
@ -1089,12 +1089,12 @@ void RclMain::showActiveTypes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// All types listed in mimeconf:
|
// All types listed in mimeconf:
|
||||||
list<string> mtypesfromconfig = theconfig->getAllMimeTypes();
|
vector<string> mtypesfromconfig = theconfig->getAllMimeTypes();
|
||||||
|
|
||||||
// Intersect file system types with config types (those not in the
|
// Intersect file system types with config types (those not in the
|
||||||
// config can be indexed by name, not by content)
|
// config can be indexed by name, not by content)
|
||||||
set<string> mtypesfromdbconf;
|
set<string> mtypesfromdbconf;
|
||||||
for (list<string>::const_iterator it = mtypesfromconfig.begin();
|
for (vector<string>::const_iterator it = mtypesfromconfig.begin();
|
||||||
it != mtypesfromconfig.end(); it++) {
|
it != mtypesfromconfig.end(); it++) {
|
||||||
if (mtypesfromdb.find(*it) != mtypesfromdb.end())
|
if (mtypesfromdb.find(*it) != mtypesfromdb.end())
|
||||||
mtypesfromdbconf.insert(*it);
|
mtypesfromdbconf.insert(*it);
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern bool maybeOpenDb(std::string &reason, bool force = true,
|
||||||
bool *maindberror = 0);
|
bool *maindberror = 0);
|
||||||
|
|
||||||
/** Retrieve configured stemming languages */
|
/** Retrieve configured stemming languages */
|
||||||
bool getStemLangs(list<string>& langs);
|
bool getStemLangs(vector<string>& langs);
|
||||||
|
|
||||||
extern RclConfig *theconfig;
|
extern RclConfig *theconfig;
|
||||||
extern RclConfig *thestableconfig;
|
extern RclConfig *thestableconfig;
|
||||||
|
|
|
@ -66,12 +66,12 @@ void SpellW::init()
|
||||||
|
|
||||||
// Stemming language combobox
|
// Stemming language combobox
|
||||||
stemLangCMB->clear();
|
stemLangCMB->clear();
|
||||||
list<string> langs;
|
vector<string> langs;
|
||||||
if (!getStemLangs(langs)) {
|
if (!getStemLangs(langs)) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("error retrieving stemming languages"));
|
tr("error retrieving stemming languages"));
|
||||||
}
|
}
|
||||||
for (list<string>::const_iterator it = langs.begin();
|
for (vector<string>::const_iterator it = langs.begin();
|
||||||
it != langs.end(); it++) {
|
it != langs.end(); it++) {
|
||||||
stemLangCMB->
|
stemLangCMB->
|
||||||
addItem(QString::fromAscii(it->c_str(), it->length()));
|
addItem(QString::fromAscii(it->c_str(), it->length()));
|
||||||
|
|
|
@ -140,13 +140,13 @@ void UIPrefsDialog::setFromPrefs()
|
||||||
stemLangCMB->clear();
|
stemLangCMB->clear();
|
||||||
stemLangCMB->addItem(g_stringNoStem);
|
stemLangCMB->addItem(g_stringNoStem);
|
||||||
stemLangCMB->addItem(g_stringAllStem);
|
stemLangCMB->addItem(g_stringAllStem);
|
||||||
list<string> langs;
|
vector<string> langs;
|
||||||
if (!getStemLangs(langs)) {
|
if (!getStemLangs(langs)) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("error retrieving stemming languages"));
|
tr("error retrieving stemming languages"));
|
||||||
}
|
}
|
||||||
int cur = prefs.queryStemLang == "" ? 0 : 1;
|
int cur = prefs.queryStemLang == "" ? 0 : 1;
|
||||||
for (list<string>::const_iterator it = langs.begin();
|
for (vector<string>::const_iterator it = langs.begin();
|
||||||
it != langs.end(); it++) {
|
it != langs.end(); it++) {
|
||||||
stemLangCMB->
|
stemLangCMB->
|
||||||
addItem(QString::fromAscii(it->c_str(), it->length()));
|
addItem(QString::fromAscii(it->c_str(), it->length()));
|
||||||
|
|
|
@ -98,7 +98,8 @@ bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||||
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
||||||
{
|
{
|
||||||
setQuery();
|
setQuery();
|
||||||
return m_q->expand(doc);
|
vector<string> v = m_q->expand(doc);
|
||||||
|
return list<string>(v.begin(), v.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
string DocSequenceDb::title()
|
string DocSequenceDb::title()
|
||||||
|
|
|
@ -44,10 +44,10 @@ bool RclDHistoryEntry::encode(string& value)
|
||||||
// Current entry format is "U time b64udi"
|
// Current entry format is "U time b64udi"
|
||||||
bool RclDHistoryEntry::decode(const string &value)
|
bool RclDHistoryEntry::decode(const string &value)
|
||||||
{
|
{
|
||||||
list<string> vall;
|
vector<string> vall;
|
||||||
stringToStrings(value, vall);
|
stringToStrings(value, vall);
|
||||||
|
|
||||||
list<string>::const_iterator it = vall.begin();
|
vector<string>::const_iterator it = vall.begin();
|
||||||
udi.erase();
|
udi.erase();
|
||||||
string fn, ipath;
|
string fn, ipath;
|
||||||
switch (vall.size()) {
|
switch (vall.size()) {
|
||||||
|
|
|
@ -43,8 +43,8 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
|
||||||
int maxlen)
|
int maxlen)
|
||||||
{
|
{
|
||||||
// Is this doc already in list ? If it is we remove the old entry
|
// Is this doc already in list ? If it is we remove the old entry
|
||||||
list<string> names = m_data.getNames(sk);
|
vector<string> names = m_data.getNames(sk);
|
||||||
list<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (it = names.begin(); it != names.end(); it++) {
|
for (it = names.begin(); it != names.end(); it++) {
|
||||||
string oval;
|
string oval;
|
||||||
|
@ -61,7 +61,7 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe reget list
|
// Maybe reget things
|
||||||
if (changed)
|
if (changed)
|
||||||
names = m_data.getNames(sk);
|
names = m_data.getNames(sk);
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
|
||||||
|
|
||||||
bool RclDynConf::eraseAll(const string &sk)
|
bool RclDynConf::eraseAll(const string &sk)
|
||||||
{
|
{
|
||||||
list<string> names = m_data.getNames(sk);
|
vector<string> names = m_data.getNames(sk);
|
||||||
list<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
for (it = names.begin(); it != names.end(); it++) {
|
for (it = names.begin(); it != names.end(); it++) {
|
||||||
m_data.erase(*it, sk);
|
m_data.erase(*it, sk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ template<typename Tp> list<Tp> RclDynConf::getList(const string &sk)
|
||||||
{
|
{
|
||||||
list<Tp> mlist;
|
list<Tp> mlist;
|
||||||
Tp entry;
|
Tp entry;
|
||||||
list<string> names = m_data.getNames(sk);
|
vector<string> names = m_data.getNames(sk);
|
||||||
for (list<string>::const_iterator it = names.begin();
|
for (vector<string>::const_iterator it = names.begin();
|
||||||
it != names.end(); it++) {
|
it != names.end(); it++) {
|
||||||
string value;
|
string value;
|
||||||
if (m_data.get(*it, value, sk)) {
|
if (m_data.get(*it, value, sk)) {
|
||||||
|
|
|
@ -70,9 +70,9 @@ bool DocSeqFiltered::setFiltSpec(DocSeqFiltSpec &filtspec)
|
||||||
string val = filtspec.values[i];
|
string val = filtspec.values[i];
|
||||||
if (val.find("rclcat:") == 0) {
|
if (val.find("rclcat:") == 0) {
|
||||||
string catg = val.substr(7);
|
string catg = val.substr(7);
|
||||||
list<string> tps;
|
vector<string> tps;
|
||||||
m_config->getMimeCatTypes(catg, tps);
|
m_config->getMimeCatTypes(catg, tps);
|
||||||
for (list<string>::const_iterator it = tps.begin();
|
for (vector<string>::const_iterator it = tps.begin();
|
||||||
it != tps.end(); it++) {
|
it != tps.end(); it++) {
|
||||||
LOGDEB2(("Adding mime: [%s]\n", it->c_str()));
|
LOGDEB2(("Adding mime: [%s]\n", it->c_str()));
|
||||||
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
|
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
|
||||||
|
|
|
@ -82,10 +82,10 @@ static Rcl::SearchData *wasaQueryToRcl(RclConfig *config, WasaQuery *wasa,
|
||||||
"nor excl??";
|
"nor excl??";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
list<string> mtypes;
|
vector<string> mtypes;
|
||||||
if (config && config->getMimeCatTypes((*it)->m_value, mtypes)
|
if (config && config->getMimeCatTypes((*it)->m_value, mtypes)
|
||||||
&& !mtypes.empty()) {
|
&& !mtypes.empty()) {
|
||||||
for (list<string>::iterator mit = mtypes.begin();
|
for (vector<string>::iterator mit = mtypes.begin();
|
||||||
mit != mtypes.end(); mit++) {
|
mit != mtypes.end(); mit++) {
|
||||||
if ((*it)->m_op == WasaQuery::OP_LEAF)
|
if ((*it)->m_op == WasaQuery::OP_LEAF)
|
||||||
sdata->addFiletype(*mit);
|
sdata->addFiletype(*mit);
|
||||||
|
|
|
@ -217,8 +217,8 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||||
doc.xdocid = docid;
|
doc.xdocid = docid;
|
||||||
|
|
||||||
// Other, not predefined meta fields:
|
// Other, not predefined meta fields:
|
||||||
list<string> keys = parms.getNames(string());
|
vector<string> keys = parms.getNames(string());
|
||||||
for (list<string>::const_iterator it = keys.begin();
|
for (vector<string>::const_iterator it = keys.begin();
|
||||||
it != keys.end(); it++) {
|
it != keys.end(); it++) {
|
||||||
if (doc.meta.find(*it) == doc.meta.end())
|
if (doc.meta.find(*it) == doc.meta.end())
|
||||||
parms.get(*it, doc.meta[*it]);
|
parms.get(*it, doc.meta[*it]);
|
||||||
|
@ -228,9 +228,9 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove prefixes (caps) from a list of terms.
|
// Remove prefixes (caps) from a list of terms.
|
||||||
static void noPrefixList(const list<string>& in, list<string>& out)
|
static void noPrefixList(const vector<string>& in, vector<string>& out)
|
||||||
{
|
{
|
||||||
for (list<string>::const_iterator qit = in.begin();
|
for (vector<string>::const_iterator qit = in.begin();
|
||||||
qit != in.end(); qit++) {
|
qit != in.end(); qit++) {
|
||||||
if ('A' <= qit->at(0) && qit->at(0) <= 'Z') {
|
if ('A' <= qit->at(0) && qit->at(0) <= 'Z') {
|
||||||
string term = *qit;
|
string term = *qit;
|
||||||
|
@ -252,10 +252,10 @@ static void noPrefixList(const list<string>& in, list<string>& out)
|
||||||
#define LOGABS LOGDEB2
|
#define LOGABS LOGDEB2
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
static void listList(const string& what, const list<string>&l)
|
static void listList(const string& what, const vector<string>&l)
|
||||||
{
|
{
|
||||||
string a;
|
string a;
|
||||||
for (list<string>::const_iterator it = l.begin(); it != l.end(); it++) {
|
for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) {
|
||||||
a = a + *it + " ";
|
a = a + *it + " ";
|
||||||
}
|
}
|
||||||
LOGDEB(("%s: %s\n", what.c_str(), a.c_str()));
|
LOGDEB(("%s: %s\n", what.c_str(), a.c_str()));
|
||||||
|
@ -273,10 +273,10 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||||
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d\n", chron.ms(),
|
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d\n", chron.ms(),
|
||||||
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen));
|
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen));
|
||||||
|
|
||||||
list<string> terms;
|
vector<string> terms;
|
||||||
|
|
||||||
{
|
{
|
||||||
list<string> iterms;
|
vector<string> iterms;
|
||||||
query->getMatchTerms(docid, iterms);
|
query->getMatchTerms(docid, iterms);
|
||||||
noPrefixList(iterms, terms);
|
noPrefixList(iterms, terms);
|
||||||
if (terms.empty()) {
|
if (terms.empty()) {
|
||||||
|
@ -289,13 +289,13 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||||
// Retrieve db-wide frequencies for the query terms (we do this once per
|
// Retrieve db-wide frequencies for the query terms (we do this once per
|
||||||
// query, using all the query terms, not only the document match terms)
|
// query, using all the query terms, not only the document match terms)
|
||||||
if (query->m_nq->termfreqs.empty()) {
|
if (query->m_nq->termfreqs.empty()) {
|
||||||
list<string> iqterms, qterms;
|
vector<string> iqterms, qterms;
|
||||||
query->getQueryTerms(iqterms);
|
query->getQueryTerms(iqterms);
|
||||||
noPrefixList(iqterms, qterms);
|
noPrefixList(iqterms, qterms);
|
||||||
// listList("Query terms: ", qterms);
|
// listList("Query terms: ", qterms);
|
||||||
double doccnt = xrdb.get_doccount();
|
double doccnt = xrdb.get_doccount();
|
||||||
if (doccnt == 0) doccnt = 1;
|
if (doccnt == 0) doccnt = 1;
|
||||||
for (list<string>::const_iterator qit = qterms.begin();
|
for (vector<string>::const_iterator qit = qterms.begin();
|
||||||
qit != qterms.end(); qit++) {
|
qit != qterms.end(); qit++) {
|
||||||
query->m_nq->termfreqs[*qit] = xrdb.get_termfreq(*qit) / doccnt;
|
query->m_nq->termfreqs[*qit] = xrdb.get_termfreq(*qit) / doccnt;
|
||||||
LOGABS(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(),
|
LOGABS(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(),
|
||||||
|
@ -312,7 +312,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||||
double totalweight = 0;
|
double totalweight = 0;
|
||||||
double doclen = xrdb.get_doclength(docid);
|
double doclen = xrdb.get_doclength(docid);
|
||||||
if (doclen == 0) doclen = 1;
|
if (doclen == 0) doclen = 1;
|
||||||
for (list<string>::const_iterator qit = terms.begin();
|
for (vector<string>::const_iterator qit = terms.begin();
|
||||||
qit != terms.end(); qit++) {
|
qit != terms.end(); qit++) {
|
||||||
Xapian::TermIterator term = xrdb.termlist_begin(docid);
|
Xapian::TermIterator term = xrdb.termlist_begin(docid);
|
||||||
term.skip_to(*qit);
|
term.skip_to(*qit);
|
||||||
|
@ -338,7 +338,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||||
|
|
||||||
// Build a sorted by quality term list.
|
// Build a sorted by quality term list.
|
||||||
multimap<double, string> byQ;
|
multimap<double, string> byQ;
|
||||||
for (list<string>::const_iterator qit = terms.begin();
|
for (vector<string>::const_iterator qit = terms.begin();
|
||||||
qit != terms.end(); qit++) {
|
qit != terms.end(); qit++) {
|
||||||
if (termQcoefs.find(*qit) != termQcoefs.end())
|
if (termQcoefs.find(*qit) != termQcoefs.end())
|
||||||
byQ.insert(pair<double,string>(termQcoefs[*qit], *qit));
|
byQ.insert(pair<double,string>(termQcoefs[*qit], *qit));
|
||||||
|
@ -1481,10 +1481,10 @@ bool Db::needUpdate(const string &udi, const string& sig)
|
||||||
|
|
||||||
|
|
||||||
// Return list of existing stem db languages
|
// Return list of existing stem db languages
|
||||||
list<string> Db::getStemLangs()
|
vector<string> Db::getStemLangs()
|
||||||
{
|
{
|
||||||
LOGDEB(("Db::getStemLang\n"));
|
LOGDEB(("Db::getStemLang\n"));
|
||||||
list<string> dirs;
|
vector<string> dirs;
|
||||||
if (m_ndb == 0 || m_ndb->m_isopen == false)
|
if (m_ndb == 0 || m_ndb->m_isopen == false)
|
||||||
return dirs;
|
return dirs;
|
||||||
dirs = StemDb::getLangs(m_basedir);
|
dirs = StemDb::getLangs(m_basedir);
|
||||||
|
@ -1724,7 +1724,7 @@ bool Db::stemExpand(const string &lang, const string &term,
|
||||||
list<string> dirs = m_extraDbs;
|
list<string> dirs = m_extraDbs;
|
||||||
dirs.push_front(m_basedir);
|
dirs.push_front(m_basedir);
|
||||||
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
||||||
list<string> more;
|
vector<string> more;
|
||||||
StemDb::stemExpand(*it, lang, term, more);
|
StemDb::stemExpand(*it, lang, term, more);
|
||||||
LOGDEB1(("Db::stemExpand: Got %d from %s\n",
|
LOGDEB1(("Db::stemExpand: Got %d from %s\n",
|
||||||
more.size(), it->c_str()));
|
more.size(), it->c_str()));
|
||||||
|
|
|
@ -140,7 +140,7 @@ class Db {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** List existing stemming databases */
|
/** List existing stemming databases */
|
||||||
std::list<std::string> getStemLangs();
|
std::vector<std::string> getStemLangs();
|
||||||
|
|
||||||
#ifdef TESTING_XAPIAN_SPELL
|
#ifdef TESTING_XAPIAN_SPELL
|
||||||
/** Return spelling suggestion */
|
/** Return spelling suggestion */
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "xapian.h"
|
#include "xapian.h"
|
||||||
|
@ -240,7 +239,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Query::getQueryTerms(list<string>& terms)
|
bool Query::getQueryTerms(vector<string>& terms)
|
||||||
{
|
{
|
||||||
if (ISNULL(m_nq))
|
if (ISNULL(m_nq))
|
||||||
return false;
|
return false;
|
||||||
|
@ -261,11 +260,11 @@ bool Query::getQueryTerms(list<string>& terms)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Query::getMatchTerms(const Doc& doc, list<string>& terms)
|
bool Query::getMatchTerms(const Doc& doc, vector<string>& terms)
|
||||||
{
|
{
|
||||||
return getMatchTerms(doc.xdocid, terms);
|
return getMatchTerms(doc.xdocid, terms);
|
||||||
}
|
}
|
||||||
bool Query::getMatchTerms(unsigned long xdocid, list<string>& terms)
|
bool Query::getMatchTerms(unsigned long xdocid, vector<string>& terms)
|
||||||
{
|
{
|
||||||
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
||||||
LOGERR(("Query::getMatchTerms: no query opened\n"));
|
LOGERR(("Query::getMatchTerms: no query opened\n"));
|
||||||
|
@ -421,10 +420,10 @@ bool Query::getDoc(int xapi, Doc &doc)
|
||||||
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
|
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> Query::expand(const Doc &doc)
|
vector<string> Query::expand(const Doc &doc)
|
||||||
{
|
{
|
||||||
LOGDEB(("Rcl::Query::expand()\n"));
|
LOGDEB(("Rcl::Query::expand()\n"));
|
||||||
list<string> res;
|
vector<string> res;
|
||||||
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
||||||
LOGERR(("Query::expand: no query opened\n"));
|
LOGERR(("Query::expand: no query opened\n"));
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -17,12 +17,10 @@
|
||||||
#ifndef _rclquery_h_included_
|
#ifndef _rclquery_h_included_
|
||||||
#define _rclquery_h_included_
|
#define _rclquery_h_included_
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,14 +70,14 @@ class Query {
|
||||||
bool getDoc(int i, Doc &doc);
|
bool getDoc(int i, Doc &doc);
|
||||||
|
|
||||||
/** Get possibly expanded list of query terms */
|
/** Get possibly expanded list of query terms */
|
||||||
bool getQueryTerms(list<string>& terms);
|
bool getQueryTerms(vector<string>& terms);
|
||||||
|
|
||||||
/** Return a list of terms which matched for a specific result document */
|
/** Return a list of terms which matched for a specific result document */
|
||||||
bool getMatchTerms(const Doc& doc, list<string>& terms);
|
bool getMatchTerms(const Doc& doc, vector<string>& terms);
|
||||||
bool getMatchTerms(unsigned long xdocid, list<string>& terms);
|
bool getMatchTerms(unsigned long xdocid, vector<string>& terms);
|
||||||
|
|
||||||
/** Expand query to look for documents like the one passed in */
|
/** Expand query to look for documents like the one passed in */
|
||||||
list<string> expand(const Doc &doc);
|
vector<string> expand(const Doc &doc);
|
||||||
|
|
||||||
/** Return the Db we're set for */
|
/** Return the Db we're set for */
|
||||||
Db *whatDb();
|
Db *whatDb();
|
||||||
|
|
|
@ -151,15 +151,15 @@ bool SearchData::expandFileTypes(RclConfig *cfg, vector<string>& tps)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vector<string> exptps;
|
vector<string> exptps;
|
||||||
list<string> alltypes = cfg->getAllMimeTypes();
|
vector<string> alltypes = cfg->getAllMimeTypes();
|
||||||
|
|
||||||
for (vector<string>::iterator it = tps.begin(); it != tps.end(); it++) {
|
for (vector<string>::iterator it = tps.begin(); it != tps.end(); it++) {
|
||||||
if (cfg->isMimeCategory(*it)) {
|
if (cfg->isMimeCategory(*it)) {
|
||||||
list<string>tps;
|
vector<string>tps;
|
||||||
cfg->getMimeCatTypes(*it, tps);
|
cfg->getMimeCatTypes(*it, tps);
|
||||||
exptps.insert(exptps.end(), tps.begin(), tps.end());
|
exptps.insert(exptps.end(), tps.begin(), tps.end());
|
||||||
} else {
|
} else {
|
||||||
for (list<string>::const_iterator ait = alltypes.begin();
|
for (vector<string>::const_iterator ait = alltypes.begin();
|
||||||
ait != alltypes.end(); ait++) {
|
ait != alltypes.end(); ait++) {
|
||||||
if (fnmatch(it->c_str(), ait->c_str(), FNM_CASEFOLD)
|
if (fnmatch(it->c_str(), ait->c_str(), FNM_CASEFOLD)
|
||||||
!= FNM_NOMATCH) {
|
!= FNM_NOMATCH) {
|
||||||
|
|
|
@ -48,11 +48,11 @@ static string stemdbname(const string& dbdir, const string& lang)
|
||||||
return path_cat(dbdir, cstr_stemdirstem + lang);
|
return path_cat(dbdir, cstr_stemdirstem + lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> getLangs(const string& dbdir)
|
vector<string> getLangs(const string& dbdir)
|
||||||
{
|
{
|
||||||
string pattern = cstr_stemdirstem + "*";
|
string pattern = cstr_stemdirstem + "*";
|
||||||
list<string> dirs = path_dirglob(dbdir, pattern);
|
vector<string> dirs = path_dirglob(dbdir, pattern);
|
||||||
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
for (vector<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
||||||
*it = path_basename(*it);
|
*it = path_basename(*it);
|
||||||
*it = it->substr(cstr_stemdirstem.length(), string::npos);
|
*it = it->substr(cstr_stemdirstem.length(), string::npos);
|
||||||
}
|
}
|
||||||
|
@ -262,10 +262,10 @@ bool createDb(Xapian::Database& xdb, const string& dbdir, const string& lang)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string stringlistdisp(const list<string>& sl)
|
static string stringlistdisp(const vector<string>& sl)
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
for (list<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
|
for (vector<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
|
||||||
s += "[" + *it + "] ";
|
s += "[" + *it + "] ";
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
s.erase(s.length()-1);
|
s.erase(s.length()-1);
|
||||||
|
@ -279,7 +279,7 @@ static string stringlistdisp(const list<string>& sl)
|
||||||
static bool stemExpandOne(const std::string& dbdir,
|
static bool stemExpandOne(const std::string& dbdir,
|
||||||
const std::string& lang,
|
const std::string& lang,
|
||||||
const std::string& term,
|
const std::string& term,
|
||||||
list<string>& result)
|
vector<string>& result)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Xapian::Stem stemmer(lang);
|
Xapian::Stem stemmer(lang);
|
||||||
|
@ -347,19 +347,19 @@ static bool stemExpandOne(const std::string& dbdir,
|
||||||
bool stemExpand(const std::string& dbdir,
|
bool stemExpand(const std::string& dbdir,
|
||||||
const std::string& langs,
|
const std::string& langs,
|
||||||
const std::string& term,
|
const std::string& term,
|
||||||
list<string>& result)
|
vector<string>& result)
|
||||||
{
|
{
|
||||||
|
|
||||||
list<string> llangs;
|
list<string> llangs;
|
||||||
stringToStrings(langs, llangs);
|
stringToStrings(langs, llangs);
|
||||||
for (list<string>::const_iterator it = llangs.begin();
|
for (list<string>::const_iterator it = llangs.begin();
|
||||||
it != llangs.end(); it++) {
|
it != llangs.end(); it++) {
|
||||||
list<string> oneexp;
|
vector<string> oneexp;
|
||||||
stemExpandOne(dbdir, *it, term, oneexp);
|
stemExpandOne(dbdir, *it, term, oneexp);
|
||||||
result.insert(result.end(), oneexp.begin(), oneexp.end());
|
result.insert(result.end(), oneexp.begin(), oneexp.end());
|
||||||
}
|
}
|
||||||
result.sort();
|
sort(result.begin(), result.end());
|
||||||
result.unique();
|
unique(result.begin(), result.end());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,16 @@
|
||||||
/// Stem databases are stored as separate xapian databases (used as an
|
/// Stem databases are stored as separate xapian databases (used as an
|
||||||
/// Isam method), in subdirectories of the index.
|
/// Isam method), in subdirectories of the index.
|
||||||
|
|
||||||
#include <list>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <xapian.h>
|
#include <xapian.h>
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
|
||||||
using std::string;
|
|
||||||
using std::list;
|
|
||||||
namespace Rcl {
|
namespace Rcl {
|
||||||
namespace StemDb {
|
namespace StemDb {
|
||||||
#endif // NO_NAMESPACES
|
|
||||||
|
|
||||||
/// Get languages of existing stem databases
|
/// Get languages of existing stem databases
|
||||||
extern std::list<std::string> getLangs(const std::string& dbdir);
|
extern std::vector<std::string> getLangs(const std::string& dbdir);
|
||||||
/// Delete stem database for given language
|
/// Delete stem database for given language
|
||||||
extern bool deleteDb(const std::string& dbdir, const std::string& lang);
|
extern bool deleteDb(const std::string& dbdir, const std::string& lang);
|
||||||
/// Create stem database for given language
|
/// Create stem database for given language
|
||||||
|
@ -47,10 +43,8 @@ extern bool createDb(Xapian::Database& xdb,
|
||||||
extern bool stemExpand(const std::string& dbdir,
|
extern bool stemExpand(const std::string& dbdir,
|
||||||
const std::string& langs,
|
const std::string& langs,
|
||||||
const std::string& term,
|
const std::string& term,
|
||||||
list<string>& result);
|
std::vector<std::string>& result);
|
||||||
#ifndef NO_NAMESPACES
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // NO_NAMESPACES
|
|
||||||
|
|
||||||
#endif /* _STEMDB_H_INCLUDED_ */
|
#endif /* _STEMDB_H_INCLUDED_ */
|
||||||
|
|
|
@ -217,7 +217,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return list of candidate offsets for udi (possibly several
|
// Return vector of candidate offsets for udi (possibly several
|
||||||
// because there may be hash collisions, and also multiple
|
// because there may be hash collisions, and also multiple
|
||||||
// instances).
|
// instances).
|
||||||
bool khFind(const string& udi, vector<off_t>& ofss)
|
bool khFind(const string& udi, vector<off_t>& ofss)
|
||||||
|
@ -262,10 +262,10 @@ public:
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Clear entries for list of udi/offs
|
// Clear entries for vector of udi/offs
|
||||||
bool khClear(const list<pair<string, off_t> >& udis)
|
bool khClear(const vector<pair<string, off_t> >& udis)
|
||||||
{
|
{
|
||||||
for (list<pair<string, off_t> >::const_iterator it = udis.begin();
|
for (vector<pair<string, off_t> >::const_iterator it = udis.begin();
|
||||||
it != udis.end(); it++)
|
it != udis.end(); it++)
|
||||||
khClear(*it);
|
khClear(*it);
|
||||||
return true;
|
return true;
|
||||||
|
@ -754,7 +754,7 @@ bool CirCache::get(const string& udi, string& dic, string& data, int instance)
|
||||||
if (!fudi.compare(udi)) {
|
if (!fudi.compare(udi)) {
|
||||||
// Found one, memorize offset. Done if instance
|
// Found one, memorize offset. Done if instance
|
||||||
// matches, else go on. If instance is -1 need to
|
// matches, else go on. If instance is -1 need to
|
||||||
// go to the end of the list anyway
|
// go to the end anyway
|
||||||
d_good = d;
|
d_good = d;
|
||||||
o_good = *it;
|
o_good = *it;
|
||||||
if (finst == instance) {
|
if (finst == instance) {
|
||||||
|
@ -849,7 +849,7 @@ class CCScanHookSpacer : public CCScanHook {
|
||||||
public:
|
public:
|
||||||
UINT sizewanted;
|
UINT sizewanted;
|
||||||
UINT sizeseen;
|
UINT sizeseen;
|
||||||
list<pair<string, off_t> > squashed_udis;
|
vector<pair<string, off_t> > squashed_udis;
|
||||||
CCScanHookSpacer(int sz)
|
CCScanHookSpacer(int sz)
|
||||||
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
|
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* an exec (security, pipe control, the possibility that a bug will trigger
|
* an exec (security, pipe control, the possibility that a bug will trigger
|
||||||
* an unwanted write, etc.)
|
* an unwanted write, etc.)
|
||||||
*
|
*
|
||||||
* A process has currently no POSIX way to determine the list of open file
|
* A process has currently no POSIX way to determine the set of open file
|
||||||
* descriptors or at least the highest value. Closing all files (except a few),
|
* descriptors or at least the highest value. Closing all files (except a few),
|
||||||
* thus implies performing a close() system call on each entry up to the
|
* thus implies performing a close() system call on each entry up to the
|
||||||
* maximum, which can be both relatively difficult to determine, and quite
|
* maximum, which can be both relatively difficult to determine, and quite
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
* System interfaces:
|
* System interfaces:
|
||||||
* FreeBSD:
|
* FreeBSD:
|
||||||
* - Has a closefrom() system call as of release 7.x around Sep 2009
|
* - Has a closefrom() system call as of release 7.x around Sep 2009
|
||||||
* - Has a /dev/fd, directory which lists the current process' open
|
* - Has a /dev/fd, directory which shows the current process' open
|
||||||
* descriptors. Only descriptors 0, 1, 2 are shown except if
|
* descriptors. Only descriptors 0, 1, 2 are shown except if
|
||||||
* fdescfs is mounted which it is not by default
|
* fdescfs is mounted which it is not by default
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using std::list;
|
|
||||||
#endif // NO_NAMESPACES
|
#endif // NO_NAMESPACES
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
|
@ -346,7 +345,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
|
||||||
// at begin() for a null subkey, or just behind the subkey
|
// at begin() for a null subkey, or just behind the subkey
|
||||||
// entry. End is either the next subkey entry, or the end of
|
// entry. End is either the next subkey entry, or the end of
|
||||||
// list. We insert the new entry just before end.
|
// list. We insert the new entry just before end.
|
||||||
list<ConfLine>::iterator start, fin;
|
vector<ConfLine>::iterator start, fin;
|
||||||
if (sk.empty()) {
|
if (sk.empty()) {
|
||||||
start = m_order.begin();
|
start = m_order.begin();
|
||||||
LOGDEB((stderr,"ConfSimple::i_set: null sk, start at top of order\n"));
|
LOGDEB((stderr,"ConfSimple::i_set: null sk, start at top of order\n"));
|
||||||
|
@ -367,7 +366,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
|
||||||
// The null subkey has no entry (maybe it should)
|
// The null subkey has no entry (maybe it should)
|
||||||
if (!sk.empty())
|
if (!sk.empty())
|
||||||
start++;
|
start++;
|
||||||
for (list<ConfLine>::iterator it = start; it != m_order.end(); it++) {
|
for (vector<ConfLine>::iterator it = start; it != m_order.end(); it++) {
|
||||||
if (it->m_kind == ConfLine::CFL_SK) {
|
if (it->m_kind == ConfLine::CFL_SK) {
|
||||||
fin = it;
|
fin = it;
|
||||||
break;
|
break;
|
||||||
|
@ -402,8 +401,8 @@ int ConfSimple::erase(const string &nm, const string &sk)
|
||||||
|
|
||||||
int ConfSimple::eraseKey(const string &sk)
|
int ConfSimple::eraseKey(const string &sk)
|
||||||
{
|
{
|
||||||
list<string>nms = getNames(sk);
|
vector<string> nms = getNames(sk);
|
||||||
for (list<string>::iterator it = nms.begin(); it != nms.end(); it++) {
|
for (vector<string>::iterator it = nms.begin(); it != nms.end(); it++) {
|
||||||
erase(*it, sk);
|
erase(*it, sk);
|
||||||
}
|
}
|
||||||
return write();
|
return write();
|
||||||
|
@ -460,13 +459,13 @@ bool ConfSimple::write()
|
||||||
|
|
||||||
// Write out the tree in configuration file format:
|
// Write out the tree in configuration file format:
|
||||||
// This does not check holdWrites, this is done by write(void), which
|
// This does not check holdWrites, this is done by write(void), which
|
||||||
// lets ie: listall work even when holdWrites is set
|
// lets ie: showall work even when holdWrites is set
|
||||||
bool ConfSimple::write(ostream& out) const
|
bool ConfSimple::write(ostream& out) const
|
||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
string sk;
|
string sk;
|
||||||
for (list<ConfLine>::const_iterator it = m_order.begin();
|
for (vector<ConfLine>::const_iterator it = m_order.begin();
|
||||||
it != m_order.end(); it++) {
|
it != m_order.end(); it++) {
|
||||||
switch(it->m_kind) {
|
switch(it->m_kind) {
|
||||||
case ConfLine::CFL_COMMENT:
|
case ConfLine::CFL_COMMENT:
|
||||||
|
@ -509,38 +508,38 @@ bool ConfSimple::write(ostream& out) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfSimple::listall()
|
void ConfSimple::showall()
|
||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return;
|
return;
|
||||||
write(std::cout);
|
write(std::cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> ConfSimple::getNames(const string &sk, const char *pattern)
|
vector<string> ConfSimple::getNames(const string &sk, const char *pattern)
|
||||||
{
|
{
|
||||||
std::list<string> mylist;
|
vector<string> mylist;
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return mylist;
|
return mylist;
|
||||||
map<string, map<string, string> >::iterator ss;
|
map<string, map<string, string> >::iterator ss;
|
||||||
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
|
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
|
||||||
return mylist;
|
return mylist;
|
||||||
}
|
}
|
||||||
|
mylist.reserve(ss->second.size());
|
||||||
map<string, string>::const_iterator it;
|
map<string, string>::const_iterator it;
|
||||||
for (it = ss->second.begin();it != ss->second.end();it++) {
|
for (it = ss->second.begin(); it != ss->second.end(); it++) {
|
||||||
if (pattern && FNM_NOMATCH == fnmatch(pattern, it->first.c_str(), 0))
|
if (pattern && FNM_NOMATCH == fnmatch(pattern, it->first.c_str(), 0))
|
||||||
continue;
|
continue;
|
||||||
mylist.push_back(it->first);
|
mylist.push_back(it->first);
|
||||||
}
|
}
|
||||||
mylist.sort();
|
|
||||||
mylist.unique();
|
|
||||||
return mylist;
|
return mylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> ConfSimple::getSubKeys()
|
vector<string> ConfSimple::getSubKeys()
|
||||||
{
|
{
|
||||||
std::list<string> mylist;
|
vector<string> mylist;
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return mylist;
|
return mylist;
|
||||||
|
mylist.reserve(m_submaps.size());
|
||||||
map<string, map<string, string> >::iterator ss;
|
map<string, map<string, string> >::iterator ss;
|
||||||
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
|
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
|
||||||
mylist.push_back(ss->first);
|
mylist.push_back(ss->first);
|
||||||
|
@ -550,8 +549,8 @@ list<string> ConfSimple::getSubKeys()
|
||||||
|
|
||||||
bool ConfSimple::hasNameAnywhere(const string& nm)
|
bool ConfSimple::hasNameAnywhere(const string& nm)
|
||||||
{
|
{
|
||||||
list<string>keys = getSubKeys();
|
vector<string>keys = getSubKeys();
|
||||||
for (list<string>::const_iterator it = keys.begin();
|
for (vector<string>::const_iterator it = keys.begin();
|
||||||
it != keys.end(); it++) {
|
it != keys.end(); it++) {
|
||||||
string val;
|
string val;
|
||||||
if (get(nm, val, *it))
|
if (get(nm, val, *it))
|
||||||
|
@ -603,7 +602,7 @@ int ConfTree::get(const std::string &name, string &value, const string &sk)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
#include "conftree.h"
|
#include "conftree.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
|
@ -700,7 +699,7 @@ const char *longvalue =
|
||||||
void memtest(ConfSimple &c)
|
void memtest(ConfSimple &c)
|
||||||
{
|
{
|
||||||
cout << "Initial:" << endl;
|
cout << "Initial:" << endl;
|
||||||
c.listall();
|
c.showall();
|
||||||
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
||||||
fprintf(stderr, "set with embedded nl succeeded !\n");
|
fprintf(stderr, "set with embedded nl succeeded !\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -719,7 +718,7 @@ void memtest(ConfSimple &c)
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Final:" << endl;
|
cout << "Final:" << endl;
|
||||||
c.listall();
|
c.showall();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readwrite(ConfNull *conf)
|
bool readwrite(ConfNull *conf)
|
||||||
|
@ -924,7 +923,7 @@ int main(int argc, char **argv)
|
||||||
if (op_flags & OPT_U) {
|
if (op_flags & OPT_U) {
|
||||||
exit(!complex_updates(argv[0]));
|
exit(!complex_updates(argv[0]));
|
||||||
}
|
}
|
||||||
list<string> flist;
|
vector<string> flist;
|
||||||
while (argc--) {
|
while (argc--) {
|
||||||
flist.push_back(*argv++);
|
flist.push_back(*argv++);
|
||||||
}
|
}
|
||||||
|
@ -951,8 +950,8 @@ int main(int argc, char **argv)
|
||||||
cerr << "conf init error" << endl;
|
cerr << "conf init error" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
list<string>lst = conf->getSubKeys();
|
vector<string>lst = conf->getSubKeys();
|
||||||
for (list<string>::const_iterator it = lst.begin();
|
for (vector<string>::const_iterator it = lst.begin();
|
||||||
it != lst.end(); it++) {
|
it != lst.end(); it++) {
|
||||||
cout << *it << endl;
|
cout << *it << endl;
|
||||||
}
|
}
|
||||||
|
@ -975,13 +974,13 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
cout << "source: [" << source << "]" << endl;
|
cout << "source: [" << source << "]" << endl;
|
||||||
list<string> strings;
|
vector<string> strings;
|
||||||
if (!stringToStrings(source, strings)) {
|
if (!stringToStrings(source, strings)) {
|
||||||
cerr << "parse failed" << endl;
|
cerr << "parse failed" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (list<string>::iterator it = strings.begin();
|
for (vector<string>::iterator it = strings.begin();
|
||||||
it != strings.end(); it++) {
|
it != strings.end(); it++) {
|
||||||
cout << "[" << *it << "]" << endl;
|
cout << "[" << *it << "]" << endl;
|
||||||
}
|
}
|
||||||
|
@ -992,17 +991,17 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("LIST\n");
|
printf("LIST\n");
|
||||||
conf->listall();
|
conf->showall();
|
||||||
//printf("WALK\n");conf->sortwalk(mywalker, 0);
|
//printf("WALK\n");conf->sortwalk(mywalker, 0);
|
||||||
printf("\nNAMES in global space:\n");
|
printf("\nNAMES in global space:\n");
|
||||||
list<string> names = conf->getNames("");
|
vector<string> names = conf->getNames("");
|
||||||
for (list<string>::iterator it = names.begin();
|
for (vector<string>::iterator it = names.begin();
|
||||||
it!=names.end(); it++)
|
it!=names.end(); it++)
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
printf("\nNAMES in global space matching t* \n");
|
printf("\nNAMES in global space matching t* \n");
|
||||||
names = conf->getNames("", "t*");
|
names = conf->getNames("", "t*");
|
||||||
for (list<string>::iterator it = names.begin();
|
for (vector<string>::iterator it = names.begin();
|
||||||
it!=names.end(); it++)
|
it!=names.end(); it++)
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
// rh7.3 likes iostream better...
|
// rh7.3 likes iostream better...
|
||||||
#if defined(__GNUC__) && __GNUC__ < 3
|
#if defined(__GNUC__) && __GNUC__ < 3
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::istream;
|
using std::istream;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
@ -100,12 +100,12 @@ public:
|
||||||
virtual int set(const string &nm, const string &val,
|
virtual int set(const string &nm, const string &val,
|
||||||
const string &sk = string()) = 0;
|
const string &sk = string()) = 0;
|
||||||
virtual bool ok() const = 0;
|
virtual bool ok() const = 0;
|
||||||
virtual list<string> getNames(const string &sk, const char* = 0) = 0;
|
virtual vector<string> getNames(const string &sk, const char* = 0) = 0;
|
||||||
virtual int erase(const string &, const string &) = 0;
|
virtual int erase(const string &, const string &) = 0;
|
||||||
virtual int eraseKey(const string &) = 0;
|
virtual int eraseKey(const string &) = 0;
|
||||||
virtual void listall() {};
|
virtual void showall() {};
|
||||||
virtual list<string> getSubKeys() = 0;
|
virtual vector<string> getSubKeys() = 0;
|
||||||
virtual list<string> getSubKeys(bool) = 0;
|
virtual vector<string> getSubKeys(bool) = 0;
|
||||||
virtual bool holdWrites(bool) = 0;
|
virtual bool holdWrites(bool) = 0;
|
||||||
virtual bool sourceChanged() = 0;
|
virtual bool sourceChanged() = 0;
|
||||||
};
|
};
|
||||||
|
@ -198,11 +198,11 @@ public:
|
||||||
const string &val),
|
const string &val),
|
||||||
void *clidata);
|
void *clidata);
|
||||||
|
|
||||||
/** List all values to stdout */
|
/** Print all values to stdout */
|
||||||
virtual void listall();
|
virtual void showall();
|
||||||
|
|
||||||
/** Return all names in given submap. */
|
/** Return all names in given submap. */
|
||||||
virtual list<string> getNames(const string &sk, const char *pattern = 0);
|
virtual vector<string> getNames(const string &sk, const char *pattern = 0);
|
||||||
|
|
||||||
/** Check if name is present in any submap. This is relatively expensive
|
/** Check if name is present in any submap. This is relatively expensive
|
||||||
* but useful for saving further processing sometimes */
|
* but useful for saving further processing sometimes */
|
||||||
|
@ -211,8 +211,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Return all subkeys
|
* Return all subkeys
|
||||||
*/
|
*/
|
||||||
virtual list<string> getSubKeys(bool) {return getSubKeys();}
|
virtual vector<string> getSubKeys(bool) {return getSubKeys();}
|
||||||
virtual list<string> getSubKeys();
|
virtual vector<string> getSubKeys();
|
||||||
/** Test for subkey existence */
|
/** Test for subkey existence */
|
||||||
virtual bool hasSubKey(const string& sk)
|
virtual bool hasSubKey(const string& sk)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +263,7 @@ private:
|
||||||
// Presentation data. We keep the comments, empty lines and
|
// Presentation data. We keep the comments, empty lines and
|
||||||
// variable and subkey ordering information in there (for
|
// variable and subkey ordering information in there (for
|
||||||
// rewriting the file while keeping hand-edited information)
|
// rewriting the file while keeping hand-edited information)
|
||||||
list<ConfLine> m_order;
|
vector<ConfLine> m_order;
|
||||||
// Control if we're writing to the backing store
|
// Control if we're writing to the backing store
|
||||||
bool m_holdWrites;
|
bool m_holdWrites;
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ public:
|
||||||
* have a central config, with possible overrides from more specific
|
* have a central config, with possible overrides from more specific
|
||||||
* (ie personal) ones.
|
* (ie personal) ones.
|
||||||
*
|
*
|
||||||
* Notes: it's ok for some of the files in the list to not exist, but the last
|
* Notes: it's ok for some of the files not to exist, but the last
|
||||||
* one must or we generate an error. We open all trees readonly, except the
|
* one must or we generate an error. We open all trees readonly, except the
|
||||||
* topmost one if requested. All writes go to the topmost file. Note that
|
* topmost one if requested. All writes go to the topmost file. Note that
|
||||||
* erase() won't work except for parameters only defined in the topmost
|
* erase() won't work except for parameters only defined in the topmost
|
||||||
|
@ -331,18 +331,18 @@ public:
|
||||||
*/
|
*/
|
||||||
template <class T> class ConfStack : public ConfNull {
|
template <class T> class ConfStack : public ConfNull {
|
||||||
public:
|
public:
|
||||||
/// Construct from list of configuration file names. The earler
|
/// Construct from configuration file names. The earler
|
||||||
/// files in have priority when fetching values. Only the first
|
/// files in have priority when fetching values. Only the first
|
||||||
/// file will be updated if ro is false and set() is used.
|
/// file will be updated if ro is false and set() is used.
|
||||||
ConfStack(const list<string> &fns, bool ro = true)
|
ConfStack(const vector<string> &fns, bool ro = true)
|
||||||
{
|
{
|
||||||
construct(fns, ro);
|
construct(fns, ro);
|
||||||
}
|
}
|
||||||
/// Construct out of single file name and list of directories
|
/// Construct out of single file name and multiple directories
|
||||||
ConfStack(const string& nm, const list<string>& dirs, bool ro = true)
|
ConfStack(const string& nm, const vector<string>& dirs, bool ro = true)
|
||||||
{
|
{
|
||||||
list<string> fns;
|
vector<string> fns;
|
||||||
for (list<string>::const_iterator it = dirs.begin();
|
for (vector<string>::const_iterator it = dirs.begin();
|
||||||
it != dirs.end(); it++){
|
it != dirs.end(); it++){
|
||||||
fns.push_back(path_cat(*it, nm));
|
fns.push_back(path_cat(*it, nm));
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ public:
|
||||||
|
|
||||||
virtual bool sourceChanged()
|
virtual bool sourceChanged()
|
||||||
{
|
{
|
||||||
typename list<T*>::const_iterator it;
|
typename vector<T*>::const_iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
if ((*it)->sourceChanged())
|
if ((*it)->sourceChanged())
|
||||||
return true;
|
return true;
|
||||||
|
@ -384,7 +384,7 @@ public:
|
||||||
|
|
||||||
virtual int get(const string &name, string &value, const string &sk) const
|
virtual int get(const string &name, string &value, const string &sk) const
|
||||||
{
|
{
|
||||||
typename list<T*>::const_iterator it;
|
typename vector<T*>::const_iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
if ((*it)->get(name, value, sk))
|
if ((*it)->get(name, value, sk))
|
||||||
return true;
|
return true;
|
||||||
|
@ -394,7 +394,7 @@ public:
|
||||||
|
|
||||||
virtual bool hasNameAnywhere(const string& nm)
|
virtual bool hasNameAnywhere(const string& nm)
|
||||||
{
|
{
|
||||||
typename list<T*>::iterator it;
|
typename vector<T*>::iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
if ((*it)->hasNameAnywhere(nm))
|
if ((*it)->hasNameAnywhere(nm))
|
||||||
return true;
|
return true;
|
||||||
|
@ -411,7 +411,7 @@ public:
|
||||||
// Avoid adding unneeded entries: if the new value matches the
|
// Avoid adding unneeded entries: if the new value matches the
|
||||||
// one out from the deeper configs, erase or dont add it
|
// one out from the deeper configs, erase or dont add it
|
||||||
// from/to the topmost file
|
// from/to the topmost file
|
||||||
typename list<T*>::iterator it = m_confs.begin();
|
typename vector<T*>::iterator it = m_confs.begin();
|
||||||
it++;
|
it++;
|
||||||
while (it != m_confs.end()) {
|
while (it != m_confs.end()) {
|
||||||
string value;
|
string value;
|
||||||
|
@ -445,49 +445,49 @@ public:
|
||||||
return m_confs.front()->holdWrites(on);
|
return m_confs.front()->holdWrites(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual list<string> getNames(const string &sk, const char *pattern = 0)
|
virtual vector<string> getNames(const string &sk, const char *pattern = 0)
|
||||||
{
|
{
|
||||||
return getNames1(sk, pattern, false);
|
return getNames1(sk, pattern, false);
|
||||||
}
|
}
|
||||||
virtual list<string> getNamesShallow(const string &sk, const char *patt = 0)
|
virtual vector<string> getNamesShallow(const string &sk, const char *patt = 0)
|
||||||
{
|
{
|
||||||
return getNames1(sk, patt, true);
|
return getNames1(sk, patt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual list<string> getNames1(const string &sk, const char *pattern,
|
virtual vector<string> getNames1(const string &sk, const char *pattern,
|
||||||
bool shallow)
|
bool shallow)
|
||||||
{
|
{
|
||||||
list<string> nms;
|
vector<string> nms;
|
||||||
typename list<T*>::iterator it;
|
typename vector<T*>::iterator it;
|
||||||
bool skfound = false;
|
bool skfound = false;
|
||||||
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
||||||
if ((*it)->hasSubKey(sk)) {
|
if ((*it)->hasSubKey(sk)) {
|
||||||
skfound = true;
|
skfound = true;
|
||||||
list<string> lst = (*it)->getNames(sk, pattern);
|
vector<string> lst = (*it)->getNames(sk, pattern);
|
||||||
nms.insert(nms.end(), lst.begin(), lst.end());
|
nms.insert(nms.end(), lst.begin(), lst.end());
|
||||||
}
|
}
|
||||||
if (shallow && skfound)
|
if (shallow && skfound)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nms.sort();
|
sort(nms.begin(), nms.end());
|
||||||
nms.unique();
|
unique(nms.begin(), nms.end());
|
||||||
return nms;
|
return nms;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual list<string> getSubKeys(){return getSubKeys(false);}
|
virtual vector<string> getSubKeys(){return getSubKeys(false);}
|
||||||
virtual list<string> getSubKeys(bool shallow)
|
virtual vector<string> getSubKeys(bool shallow)
|
||||||
{
|
{
|
||||||
list<string> sks;
|
vector<string> sks;
|
||||||
typename list<T*>::iterator it;
|
typename vector<T*>::iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
||||||
list<string> lst;
|
vector<string> lst;
|
||||||
lst = (*it)->getSubKeys();
|
lst = (*it)->getSubKeys();
|
||||||
sks.insert(sks.end(), lst.begin(), lst.end());
|
sks.insert(sks.end(), lst.begin(), lst.end());
|
||||||
if (shallow)
|
if (shallow)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sks.sort();
|
sort(sks.begin(), sks.end());
|
||||||
sks.unique();
|
unique(sks.begin(), sks.end());
|
||||||
return sks;
|
return sks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,11 +495,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_ok;
|
bool m_ok;
|
||||||
list<T*> m_confs;
|
vector<T*> m_confs;
|
||||||
|
|
||||||
/// Reset to pristine
|
/// Reset to pristine
|
||||||
void clear() {
|
void clear() {
|
||||||
typename list<T*>::iterator it;
|
typename vector<T*>::iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
@ -509,16 +509,16 @@ private:
|
||||||
/// Common code to initialize from existing object
|
/// Common code to initialize from existing object
|
||||||
void init_from(const ConfStack &rhs) {
|
void init_from(const ConfStack &rhs) {
|
||||||
if ((m_ok = rhs.m_ok)) {
|
if ((m_ok = rhs.m_ok)) {
|
||||||
typename list<T*>::const_iterator it;
|
typename vector<T*>::const_iterator it;
|
||||||
for (it = rhs.m_confs.begin();it != rhs.m_confs.end();it++) {
|
for (it = rhs.m_confs.begin();it != rhs.m_confs.end();it++) {
|
||||||
m_confs.push_back(new T(**it));
|
m_confs.push_back(new T(**it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Common construct from file list code
|
/// Common construct from file names code
|
||||||
void construct(const list<string> &fns, bool ro) {
|
void construct(const vector<string> &fns, bool ro) {
|
||||||
list<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
bool lastok = false;
|
bool lastok = false;
|
||||||
for (it = fns.begin(); it != fns.end(); it++) {
|
for (it = fns.begin(); it != fns.end(); it++) {
|
||||||
T* p = new T(it->c_str(), ro);
|
T* p = new T(it->c_str(), ro);
|
||||||
|
|
|
@ -28,10 +28,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <list>
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
|
||||||
|
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "cstr.h"
|
#include "cstr.h"
|
||||||
|
@ -60,11 +61,11 @@ class FsTreeWalker::Internal {
|
||||||
int options;
|
int options;
|
||||||
int depthswitch;
|
int depthswitch;
|
||||||
stringstream reason;
|
stringstream reason;
|
||||||
list<string> skippedNames;
|
vector<string> skippedNames;
|
||||||
list<string> skippedPaths;
|
vector<string> skippedPaths;
|
||||||
// When doing Breadth or FilesThenDirs traversal, we keep a list
|
// When doing Breadth or FilesThenDirs traversal, we keep a list
|
||||||
// of directory paths to be processed, and we do not recurse.
|
// of directory paths to be processed, and we do not recurse.
|
||||||
list<string> dirs;
|
deque<string> dirs;
|
||||||
int errors;
|
int errors;
|
||||||
set<DirId> donedirs;
|
set<DirId> donedirs;
|
||||||
void logsyserr(const char *call, const string ¶m)
|
void logsyserr(const char *call, const string ¶m)
|
||||||
|
@ -119,15 +120,14 @@ bool FsTreeWalker::addSkippedName(const string& pattern)
|
||||||
data->skippedNames.push_back(pattern);
|
data->skippedNames.push_back(pattern);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
|
bool FsTreeWalker::setSkippedNames(const vector<string> &patterns)
|
||||||
{
|
{
|
||||||
data->skippedNames = patterns;
|
data->skippedNames = patterns;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool FsTreeWalker::inSkippedNames(const string& name)
|
bool FsTreeWalker::inSkippedNames(const string& name)
|
||||||
{
|
{
|
||||||
list<string>::const_iterator it;
|
for (vector<string>::const_iterator it = data->skippedNames.begin();
|
||||||
for (it = data->skippedNames.begin();
|
|
||||||
it != data->skippedNames.end(); it++) {
|
it != data->skippedNames.end(); it++) {
|
||||||
if (fnmatch(it->c_str(), name.c_str(), 0) == 0) {
|
if (fnmatch(it->c_str(), name.c_str(), 0) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -144,10 +144,10 @@ bool FsTreeWalker::addSkippedPath(const string& ipath)
|
||||||
data->skippedPaths.push_back(path);
|
data->skippedPaths.push_back(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
|
bool FsTreeWalker::setSkippedPaths(const vector<string> &paths)
|
||||||
{
|
{
|
||||||
data->skippedPaths = paths;
|
data->skippedPaths = paths;
|
||||||
for (list<string>::iterator it = data->skippedPaths.begin();
|
for (vector<string>::iterator it = data->skippedPaths.begin();
|
||||||
it != data->skippedPaths.end(); it++)
|
it != data->skippedPaths.end(); it++)
|
||||||
if (!(data->options & FtwNoCanon))
|
if (!(data->options & FtwNoCanon))
|
||||||
*it = path_canon(*it);
|
*it = path_canon(*it);
|
||||||
|
@ -160,8 +160,8 @@ bool FsTreeWalker::inSkippedPaths(const string& path, bool ckparents)
|
||||||
if (ckparents)
|
if (ckparents)
|
||||||
fnmflags |= FNM_LEADING_DIR;
|
fnmflags |= FNM_LEADING_DIR;
|
||||||
#endif
|
#endif
|
||||||
list<string>::const_iterator it;
|
|
||||||
for (it = data->skippedPaths.begin();
|
for (vector<string>::const_iterator it = data->skippedPaths.begin();
|
||||||
it != data->skippedPaths.end(); it++) {
|
it != data->skippedPaths.end(); it++) {
|
||||||
#ifndef FNM_LEADING_DIR
|
#ifndef FNM_LEADING_DIR
|
||||||
if (ckparents) {
|
if (ckparents) {
|
||||||
|
@ -217,8 +217,8 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Breadth first of filesThenDirs semi-depth first order
|
// Breadth first of filesThenDirs semi-depth first order
|
||||||
// Managing lists of directories to be visited later, in breadth or
|
// Managing queues of directories to be visited later, in breadth or
|
||||||
// depth order. Null marker are inserted in the list to indicate
|
// depth order. Null marker are inserted in the queue to indicate
|
||||||
// father directory changes (avoids computing parents all the time).
|
// father directory changes (avoids computing parents all the time).
|
||||||
data->dirs.push_back(top);
|
data->dirs.push_back(top);
|
||||||
Status status;
|
Status status;
|
||||||
|
@ -226,7 +226,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||||
string dir, nfather;
|
string dir, nfather;
|
||||||
if (data->options & (FtwTravBreadth|FtwTravBreadthThenDepth)) {
|
if (data->options & (FtwTravBreadth|FtwTravBreadthThenDepth)) {
|
||||||
// Breadth first, pop and process an older dir at the
|
// Breadth first, pop and process an older dir at the
|
||||||
// front of the list. This will add any child dirs at the
|
// front of the queue. This will add any child dirs at the
|
||||||
// back
|
// back
|
||||||
dir = data->dirs.front();
|
dir = data->dirs.front();
|
||||||
data->dirs.pop_front();
|
data->dirs.pop_front();
|
||||||
|
@ -279,7 +279,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||||
return errno == ENOENT ? FtwOk : FtwError;
|
return errno == ENOENT ? FtwOk : FtwError;
|
||||||
}
|
}
|
||||||
// iwalk will not recurse in this case, just process file entries
|
// iwalk will not recurse in this case, just process file entries
|
||||||
// and append subdir entries to the list.
|
// and append subdir entries to the queue.
|
||||||
status = iwalk(dir, &st, cb);
|
status = iwalk(dir, &st, cb);
|
||||||
if (status != FtwOk)
|
if (status != FtwOk)
|
||||||
return status;
|
return status;
|
||||||
|
@ -497,8 +497,8 @@ Usage(void)
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
list<string> patterns;
|
vector<string> patterns;
|
||||||
list<string> paths;
|
vector<string> paths;
|
||||||
thisprog = argv[0];
|
thisprog = argv[0];
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
#define _FSTREEWALK_H_INCLUDED_
|
#define _FSTREEWALK_H_INCLUDED_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
using std::vector;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class FsTreeWalkerCB;
|
class FsTreeWalkerCB;
|
||||||
|
@ -92,18 +91,17 @@ class FsTreeWalker {
|
||||||
int getErrCnt();
|
int getErrCnt();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a pattern to the list of things (file or dir) to be ignored
|
* Add a pattern (file or dir) to be ignored (ie: #* , *~)
|
||||||
* (ie: #* , *~)
|
|
||||||
*/
|
*/
|
||||||
bool addSkippedName(const string &pattern);
|
bool addSkippedName(const string &pattern);
|
||||||
/** Set the ignored patterns list */
|
/** Set the ignored patterns set */
|
||||||
bool setSkippedNames(const list<string> &patlist);
|
bool setSkippedNames(const vector<string> &patterns);
|
||||||
|
|
||||||
/** Same for skipped paths: this are paths, not names, under which we
|
/** Same for skipped paths: this are paths, not names, under which we
|
||||||
do not descend (ie: /home/me/.recoll) */
|
do not descend (ie: /home/me/.recoll) */
|
||||||
bool addSkippedPath(const string &path);
|
bool addSkippedPath(const string &path);
|
||||||
/** Set the ignored paths list */
|
/** Set the ignored paths list */
|
||||||
bool setSkippedPaths(const list<string> &pathlist);
|
bool setSkippedPaths(const vector<string> &patterns);
|
||||||
|
|
||||||
/** Test if path/name should be skipped. This can be used independantly of
|
/** Test if path/name should be skipped. This can be used independantly of
|
||||||
* an actual tree walk */
|
* an actual tree walk */
|
||||||
|
|
|
@ -37,14 +37,6 @@ using namespace std;
|
||||||
* to separate messages, that we don't recognize currently
|
* to separate messages, that we don't recognize currently
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::list<string> idFileAllTypes()
|
|
||||||
{
|
|
||||||
std::list<string> lst;
|
|
||||||
lst.push_back("text/x-mail");
|
|
||||||
lst.push_back("message/rfc822");
|
|
||||||
return lst;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mail headers we compare to:
|
// Mail headers we compare to:
|
||||||
static const char *mailhs[] = {"From: ", "Received: ", "Message-Id: ", "To: ",
|
static const char *mailhs[] = {"From: ", "Received: ", "Message-Id: ", "To: ",
|
||||||
"Date: ", "Subject: ", "Status: ",
|
"Date: ", "Subject: ", "Status: ",
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#define _IDFILE_H_INCLUDED_
|
#define _IDFILE_H_INCLUDED_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
// Look at data inside file or string, and return mime type or empty string.
|
// Look at data inside file or string, and return mime type or empty string.
|
||||||
//
|
//
|
||||||
|
@ -28,7 +27,4 @@
|
||||||
extern std::string idFile(const char *fn);
|
extern std::string idFile(const char *fn);
|
||||||
extern std::string idFileMem(const std::string& data);
|
extern std::string idFileMem(const std::string& data);
|
||||||
|
|
||||||
// Return all types known to us
|
|
||||||
extern std::list<std::string> idFileAllTypes();
|
|
||||||
|
|
||||||
#endif /* _IDFILE_H_INCLUDED_ */
|
#endif /* _IDFILE_H_INCLUDED_ */
|
||||||
|
|
|
@ -47,11 +47,9 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
|
||||||
using std::stack;
|
using std::stack;
|
||||||
#endif /* NO_NAMESPACES */
|
#endif /* NO_NAMESPACES */
|
||||||
|
|
||||||
|
@ -363,10 +361,10 @@ extern string path_canon(const string &is)
|
||||||
|
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
list<string> path_dirglob(const string &dir,
|
vector<string> path_dirglob(const string &dir,
|
||||||
const string pattern)
|
const string pattern)
|
||||||
{
|
{
|
||||||
list<string> res;
|
vector<string> res;
|
||||||
glob_t mglob;
|
glob_t mglob;
|
||||||
string mypat=path_cat(dir, pattern);
|
string mypat=path_cat(dir, pattern);
|
||||||
if (glob(mypat.c_str(), 0, 0, &mglob)) {
|
if (glob(mypat.c_str(), 0, 0, &mglob)) {
|
||||||
|
@ -673,7 +671,7 @@ int main(int argc, const char **argv)
|
||||||
thisprog = *argv++;argc--;
|
thisprog = *argv++;argc--;
|
||||||
|
|
||||||
string s;
|
string s;
|
||||||
list<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
#if 0
|
#if 0
|
||||||
for (unsigned int i = 0;i < sizeof(tstvec) / sizeof(char *); i++) {
|
for (unsigned int i = 0;i < sizeof(tstvec) / sizeof(char *); i++) {
|
||||||
cout << tstvec[i] << " Father " << path_getfather(tstvec[i]) << endl;
|
cout << tstvec[i] << " Father " << path_getfather(tstvec[i]) << endl;
|
||||||
|
@ -713,7 +711,7 @@ int main(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
string dir = *argv++;argc--;
|
string dir = *argv++;argc--;
|
||||||
string pattern = *argv++;argc--;
|
string pattern = *argv++;argc--;
|
||||||
list<string> matched = path_dirglob(dir, pattern);
|
vector<string> matched = path_dirglob(dir, pattern);
|
||||||
for (it = matched.begin(); it != matched.end();it++) {
|
for (it = matched.begin(); it != matched.end();it++) {
|
||||||
cout << *it << endl;
|
cout << *it << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <vector>
|
||||||
#include "refcntr.h"
|
#include "refcntr.h"
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
using std::vector;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Add a / at the end if none there yet.
|
/// Add a / at the end if none there yet.
|
||||||
|
@ -46,9 +46,9 @@ extern string path_tildexpand(const string &s);
|
||||||
extern string path_absolute(const string &s);
|
extern string path_absolute(const string &s);
|
||||||
/// Clean up path by removing duplicated / and resolving ../ + make it absolute
|
/// Clean up path by removing duplicated / and resolving ../ + make it absolute
|
||||||
extern string path_canon(const string &s);
|
extern string path_canon(const string &s);
|
||||||
/// Use glob(3) to return a list of file names matching pattern inside dir
|
/// Use glob(3) to return the file names matching pattern inside dir
|
||||||
extern list<string> path_dirglob(const string &dir,
|
extern vector<string> path_dirglob(const string &dir,
|
||||||
const string pattern);
|
const string pattern);
|
||||||
/// Encode according to rfc 1738
|
/// Encode according to rfc 1738
|
||||||
extern string url_encode(const string& url,
|
extern string url_encode(const string& url,
|
||||||
string::size_type offs = 0);
|
string::size_type offs = 0);
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "utf8iter.h"
|
#include "utf8iter.h"
|
||||||
|
|
|
@ -20,14 +20,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::list;
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue