indents + use range-base for loops in extrameta.cpp
This commit is contained in:
parent
9e0018034c
commit
20c3a7ed12
@ -33,8 +33,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
|
|||||||
const string &value, Rcl::Doc& doc)
|
const string &value, Rcl::Doc& doc)
|
||||||
{
|
{
|
||||||
string fieldname = cfg->fieldCanon(name);
|
string fieldname = cfg->fieldCanon(name);
|
||||||
LOGDEB0("Internfile:: setting [" << fieldname <<
|
LOGDEB0("Internfile:: setting [" << fieldname << "] from cmd/xattr value [" << value << "]\n");
|
||||||
"] from cmd/xattr value [" << value << "]\n");
|
|
||||||
if (fieldname == cstr_dj_keymd) {
|
if (fieldname == cstr_dj_keymd) {
|
||||||
doc.dmtime = value;
|
doc.dmtime = value;
|
||||||
} else {
|
} else {
|
||||||
@ -42,8 +41,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reapXAttrs(const RclConfig* cfg, const string& path,
|
void reapXAttrs(const RclConfig* cfg, const string& path, map<string, string>& xfields)
|
||||||
map<string, string>& xfields)
|
|
||||||
{
|
{
|
||||||
LOGDEB2("reapXAttrs: [" << path << "]\n");
|
LOGDEB2("reapXAttrs: [" << path << "]\n");
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -51,11 +49,9 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
|||||||
vector<string> xnames;
|
vector<string> xnames;
|
||||||
if (!pxattr::list(path, &xnames)) {
|
if (!pxattr::list(path, &xnames)) {
|
||||||
if (errno == ENOTSUP) {
|
if (errno == ENOTSUP) {
|
||||||
LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " <<
|
LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " << errno << "\n");
|
||||||
errno << "\n");
|
|
||||||
} else {
|
} else {
|
||||||
LOGERR("FileInterner::reapXattrs: pxattr::list: errno " <<
|
LOGSYSERR("FileInterner::reapXattrs", "pxattr::list", path);
|
||||||
errno << "\n");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,10 +60,9 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
|||||||
// Record the xattrs: names found in the config are either skipped
|
// Record the xattrs: names found in the config are either skipped
|
||||||
// or mapped depending if the translation is empty. Other names
|
// or mapped depending if the translation is empty. Other names
|
||||||
// are recorded as-is
|
// are recorded as-is
|
||||||
for (vector<string>::const_iterator it = xnames.begin();
|
for (const auto& xkey : xnames) {
|
||||||
it != xnames.end(); it++) {
|
string key = xkey;
|
||||||
string key = *it;
|
auto mit = xtof.find(xkey);
|
||||||
map<string, string>::const_iterator mit = xtof.find(*it);
|
|
||||||
if (mit != xtof.end()) {
|
if (mit != xtof.end()) {
|
||||||
if (mit->second.empty()) {
|
if (mit->second.empty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -76,9 +71,8 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
string value;
|
string value;
|
||||||
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
|
if (!pxattr::get(path, xkey, &value, pxattr::PXATTR_NOFOLLOW)) {
|
||||||
LOGERR("FileInterner::reapXattrs: pxattr::get failed for " << *it
|
LOGSYSERR("FileInterner::reapXattrs", "pxattr::get", path + " : " + xkey);
|
||||||
<< ", errno " << errno << "\n");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Encode should we ?
|
// Encode should we ?
|
||||||
@ -92,34 +86,29 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void docFieldsFromXattrs(RclConfig *cfg, const map<string, string>& xfields,
|
void docFieldsFromXattrs(RclConfig *cfg, const map<string, string>& xfields, Rcl::Doc& doc)
|
||||||
Rcl::Doc& doc)
|
|
||||||
{
|
{
|
||||||
for (map<string,string>::const_iterator it = xfields.begin();
|
for (const auto& fld : xfields) {
|
||||||
it != xfields.end(); it++) {
|
docfieldfrommeta(cfg, fld.first, fld.second, doc);
|
||||||
docfieldfrommeta(cfg, it->first, it->second, doc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reapMetaCmds(RclConfig* cfg, const string& path,
|
void reapMetaCmds(RclConfig* cfg, const string& path, map<string, string>& cfields)
|
||||||
map<string, string>& cfields)
|
|
||||||
{
|
{
|
||||||
const vector<MDReaper>& reapers = cfg->getMDReapers();
|
const auto& reapers = cfg->getMDReapers();
|
||||||
if (reapers.empty())
|
if (reapers.empty())
|
||||||
return;
|
return;
|
||||||
map<char,string> smap = {{'f', path}};
|
map<char,string> smap = {{'f', path}};
|
||||||
for (vector<MDReaper>::const_iterator rp = reapers.begin();
|
for (const auto& reaper : reapers) {
|
||||||
rp != reapers.end(); rp++) {
|
|
||||||
vector<string> cmd;
|
vector<string> cmd;
|
||||||
for (vector<string>::const_iterator it = rp->cmdv.begin();
|
for (const auto& arg : reaper.cmdv) {
|
||||||
it != rp->cmdv.end(); it++) {
|
|
||||||
string s;
|
string s;
|
||||||
pcSubst(*it, s, smap);
|
pcSubst(arg, s, smap);
|
||||||
cmd.push_back(s);
|
cmd.push_back(s);
|
||||||
}
|
}
|
||||||
string output;
|
string output;
|
||||||
if (ExecCmd::backtick(cmd, output)) {
|
if (ExecCmd::backtick(cmd, output)) {
|
||||||
cfields[rp->fieldname] = output;
|
cfields[reaper.fieldname] = output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,25 +121,22 @@ void reapMetaCmds(RclConfig* cfg, const string& path,
|
|||||||
// "modificationdate" will set mtime instead of an ordinary field,
|
// "modificationdate" will set mtime instead of an ordinary field,
|
||||||
// and the output from anything beginning with "rclmulti" will be
|
// and the output from anything beginning with "rclmulti" will be
|
||||||
// interpreted as multiple fields in configuration file format...
|
// interpreted as multiple fields in configuration file format...
|
||||||
void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields,
|
void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields, Rcl::Doc& doc)
|
||||||
Rcl::Doc& doc)
|
|
||||||
{
|
{
|
||||||
for (map<string,string>::const_iterator it = cfields.begin();
|
for (const auto& cfld : cfields) {
|
||||||
it != cfields.end(); it++) {
|
if (!cfld.first.compare(0, 8, "rclmulti")) {
|
||||||
if (!it->first.compare(0, 8, "rclmulti")) {
|
ConfSimple simple(cfld.second);
|
||||||
ConfSimple simple(it->second);
|
|
||||||
if (simple.ok()) {
|
if (simple.ok()) {
|
||||||
vector<string> names = simple.getNames("");
|
auto names = simple.getNames("");
|
||||||
for (vector<string>::const_iterator nm = names.begin();
|
for (const auto& nm : names) {
|
||||||
nm != names.end(); nm++) {
|
|
||||||
string value;
|
string value;
|
||||||
if (simple.get(*nm, value)) {
|
if (simple.get(nm, value)) {
|
||||||
docfieldfrommeta(cfg, *nm, value, doc);
|
docfieldfrommeta(cfg, nm, value, doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
docfieldfrommeta(cfg, it->first, it->second, doc);
|
docfieldfrommeta(cfg, cfld.first, cfld.second, doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,14 +32,14 @@ using std::map;
|
|||||||
|
|
||||||
class HtmlParser {
|
class HtmlParser {
|
||||||
map<string, string> parameters;
|
map<string, string> parameters;
|
||||||
protected:
|
protected:
|
||||||
virtual void decode_entities(string &s);
|
virtual void decode_entities(string &s);
|
||||||
bool in_script;
|
bool in_script;
|
||||||
string charset;
|
string charset;
|
||||||
static map<string, unsigned int> named_ents;
|
static map<string, unsigned int> named_ents;
|
||||||
|
|
||||||
bool get_parameter(const string & param, string & value) const;
|
bool get_parameter(const string & param, string & value) const;
|
||||||
public:
|
public:
|
||||||
virtual void process_text(const string &/*text*/) { }
|
virtual void process_text(const string &/*text*/) { }
|
||||||
virtual bool opening_tag(const string &/*tag*/) { return true; }
|
virtual bool opening_tag(const string &/*tag*/) { return true; }
|
||||||
virtual bool closing_tag(const string &/*tag*/) { return true; }
|
virtual bool closing_tag(const string &/*tag*/) { return true; }
|
||||||
|
|||||||
@ -39,8 +39,7 @@ public:
|
|||||||
virtual void clear_impl() override;
|
virtual void clear_impl() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool set_document_file_impl(const std::string&,
|
virtual bool set_document_file_impl(const std::string&, const std::string&) override;
|
||||||
const std::string&) override;
|
|
||||||
|
|
||||||
class Internal;
|
class Internal;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -33,11 +33,10 @@
|
|||||||
/// Associated to application/x-zerosize, so use the following in mimeconf:
|
/// Associated to application/x-zerosize, so use the following in mimeconf:
|
||||||
/// <mimetype> = internal application/x-zerosize
|
/// <mimetype> = internal application/x-zerosize
|
||||||
class MimeHandlerNull : public RecollFilter {
|
class MimeHandlerNull : public RecollFilter {
|
||||||
public:
|
public:
|
||||||
MimeHandlerNull(RclConfig *cnf, const std::string& id)
|
MimeHandlerNull(RclConfig *cnf, const std::string& id)
|
||||||
: RecollFilter(cnf, id) {
|
: RecollFilter(cnf, id) {}
|
||||||
}
|
virtual ~MimeHandlerNull() = default;
|
||||||
virtual ~MimeHandlerNull() {}
|
|
||||||
MimeHandlerNull(const MimeHandlerNull&) = delete;
|
MimeHandlerNull(const MimeHandlerNull&) = delete;
|
||||||
MimeHandlerNull& operator=(const MimeHandlerNull&) = delete;
|
MimeHandlerNull& operator=(const MimeHandlerNull&) = delete;
|
||||||
|
|
||||||
@ -45,8 +44,7 @@ class MimeHandlerNull : public RecollFilter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool next_document()
|
virtual bool next_document() {
|
||||||
{
|
|
||||||
if (m_havedoc == false)
|
if (m_havedoc == false)
|
||||||
return false;
|
return false;
|
||||||
m_havedoc = false;
|
m_havedoc = false;
|
||||||
|
|||||||
@ -36,9 +36,8 @@
|
|||||||
class MimeHandlerSymlink : public RecollFilter {
|
class MimeHandlerSymlink : public RecollFilter {
|
||||||
public:
|
public:
|
||||||
MimeHandlerSymlink(RclConfig *cnf, const std::string& id)
|
MimeHandlerSymlink(RclConfig *cnf, const std::string& id)
|
||||||
: RecollFilter(cnf, id) {
|
: RecollFilter(cnf, id) {}
|
||||||
}
|
virtual ~MimeHandlerSymlink() = default;
|
||||||
virtual ~MimeHandlerSymlink() {}
|
|
||||||
MimeHandlerSymlink(const MimeHandlerSymlink&) = delete;
|
MimeHandlerSymlink(const MimeHandlerSymlink&) = delete;
|
||||||
MimeHandlerSymlink& operator=(const MimeHandlerSymlink&) = delete;
|
MimeHandlerSymlink& operator=(const MimeHandlerSymlink&) = delete;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user