cleared out errant tabs

This commit is contained in:
Jean-Francois Dockes 2020-05-30 15:54:49 +02:00
parent 796db76fc6
commit 560041cab9
167 changed files with 18868 additions and 18868 deletions

View File

@ -64,7 +64,7 @@ class Aspell {
/** Return a list of possible expansions for a given word */
bool suggest(Rcl::Db &db, const std::string& term,
std::list<std::string> &suggestions, std::string &reason);
std::list<std::string> &suggestions, std::string &reason);
private:
std::string dicPath();

View File

@ -93,25 +93,25 @@ namespace Binc {
const char hexchars[] = "0123456789abcdef";
std::string tmp;
for (std::string::const_iterator i = s.begin();
i != s.end() && i + 1 != s.end(); i += 2) {
i != s.end() && i + 1 != s.end(); i += 2) {
ptrdiff_t n;
unsigned char c = *i;
unsigned char d = *(i + 1);
const char *t;
if ((t = strchr(hexchars, c)) == 0)
return "out of range";
return "out of range";
n = (t - hexchars) << 4;
if ((t = strchr(hexchars, d)) == 0)
return "out of range";
return "out of range";
n += (t - hexchars);
if (n >= 0 && n <= 255)
tmp += (char) n;
tmp += (char) n;
else
return "out of range";
return "out of range";
}
return tmp;
@ -123,7 +123,7 @@ namespace Binc {
for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) {
unsigned char c = (unsigned char)*i;
if (c <= 31 || c >= 127 || c == '\"' || c == '\\')
return "{" + toString((unsigned long)s_in.length()) + "}\r\n" + s_in;
return "{" + toString((unsigned long)s_in.length()) + "}\r\n" + s_in;
}
return "\"" + s_in + "\"";
@ -161,7 +161,7 @@ namespace Binc {
//----------------------------------------------------------------------
inline const std::string unfold(const std::string &a,
bool removecomment = true)
bool removecomment = true)
{
std::string tmp;
bool incomment = false;
@ -169,16 +169,16 @@ namespace Binc {
for (std::string::const_iterator i = a.begin(); i != a.end(); ++i) {
unsigned char c = (unsigned char)*i;
if (!inquotes && removecomment) {
if (c == '(') {
incomment = true;
tmp += " ";
} else if (c == ')') {
incomment = false;
} else if (c != 0x0a && c != 0x0d) {
tmp += *i;
if (c == '(') {
incomment = true;
tmp += " ";
} else if (c == ')') {
incomment = false;
} else if (c != 0x0a && c != 0x0d) {
tmp += *i;
}
} else if (c != 0x0a && c != 0x0d) {
tmp += *i;
tmp += *i;
}
if (!incomment) {
@ -193,16 +193,16 @@ namespace Binc {
//----------------------------------------------------------------------
inline void split(const std::string &s_in, const std::string &delim,
std::vector<std::string> &dest, bool skipempty = true)
std::vector<std::string> &dest, bool skipempty = true)
{
std::string token;
for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) {
if (delim.find(*i) != std::string::npos) {
if (!skipempty || token != "")
dest.push_back(token);
token.clear();
if (!skipempty || token != "")
dest.push_back(token);
token.clear();
} else
token += *i;
token += *i;
}
if (token != "")
@ -211,7 +211,7 @@ namespace Binc {
//----------------------------------------------------------------------
inline void splitAddr(const std::string &s_in,
std::vector<std::string> &dest, bool skipempty = true)
std::vector<std::string> &dest, bool skipempty = true)
{
static const std::string delim = ",";
std::string token;
@ -221,11 +221,11 @@ namespace Binc {
else if (!inquote && *i == '\"') inquote = true;
if (!inquote && delim.find(*i) != std::string::npos) {
if (!skipempty || token != "")
dest.push_back(token);
token.clear();
if (!skipempty || token != "")
dest.push_back(token);
token.clear();
} else
token += *i;
token += *i;
}
if (token != "")
dest.push_back(token);
@ -240,7 +240,7 @@ namespace Binc {
std::string a = s_in.substr(0, 5);
uppercase(a);
return a == "INBOX" ?
a + (s_in.length() > 5 ? s_in.substr(5) : std::string()) : s_in;
a + (s_in.length() > 5 ? s_in.substr(5) : std::string()) : s_in;
}
return s_in;
@ -252,19 +252,19 @@ namespace Binc {
std::string regex = "^";
for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) {
if (*i == '.' || *i == '[' || *i == ']' || *i == '{' || *i == '}' ||
*i == '(' || *i == ')' || *i == '^' || *i == '$' || *i == '?' ||
*i == '+' || *i == '\\') {
regex += "\\";
regex += *i;
*i == '(' || *i == ')' || *i == '^' || *i == '$' || *i == '?' ||
*i == '+' || *i == '\\') {
regex += "\\";
regex += *i;
} else if (*i == '*')
regex += ".*?";
regex += ".*?";
else if (*i == '%') {
regex += "(\\";
regex += delimiter;
regex += "){0,1}";
regex += "[^\\";
regex += delimiter;
regex += "]*?";
regex += "[^\\";
regex += delimiter;
regex += "]*?";
} else regex += *i;
}

View File

@ -112,7 +112,7 @@ void Binc::MimeDocument::parseFull(istream& s)
//------------------------------------------------------------------------
bool Binc::MimePart::parseOneHeaderLine(Binc::Header *header,
unsigned int *nlines)
unsigned int *nlines)
{
using namespace ::Binc;
char c;
@ -127,7 +127,7 @@ bool Binc::MimePart::parseOneHeaderLine(Binc::Header *header,
// start of the body.
if (c == '\r') {
for (int i = 0; i < (int) name.length() + 1; ++i)
mimeSource->ungetChar();
mimeSource->ungetChar();
return false;
}
@ -167,15 +167,15 @@ bool Binc::MimePart::parseOneHeaderLine(Binc::Header *header,
// key,value pair.
if (cqueue[2] == '\n' && c != ' ' && c != '\t') {
if (content.length() > 2)
content.resize(content.length() - 2);
content.resize(content.length() - 2);
trim(content);
header->add(name, content);
if (c != '\r') {
mimeSource->ungetChar();
if (c == '\n') --*nlines;
return true;
mimeSource->ungetChar();
if (c == '\n') --*nlines;
return true;
}
mimeSource->getChar(&c);
@ -203,8 +203,8 @@ void Binc::MimePart::parseHeader(Binc::Header *header, unsigned int *nlines)
//------------------------------------------------------------------------
void Binc::MimePart::analyzeHeader(Binc::Header *header, bool *multipart,
bool *messagerfc822, string *subtype,
string *boundary)
bool *messagerfc822, string *subtype,
string *boundary)
{
using namespace ::Binc;
@ -228,43 +228,43 @@ void Binc::MimePart::analyzeHeader(Binc::Header *header, bool *multipart,
lowercase(key);
if (key == "multipart") {
*multipart = true;
lowercase(value);
*subtype = value;
*multipart = true;
lowercase(value);
*subtype = value;
} else if (key == "message") {
lowercase(value);
if (value == "rfc822")
*messagerfc822 = true;
lowercase(value);
if (value == "rfc822")
*messagerfc822 = true;
}
}
for (vector<string>::const_iterator i = types.begin();
i != types.end(); ++i) {
i != types.end(); ++i) {
string element = *i;
trim(element);
if (element.find("=") != string::npos) {
string::size_type pos = element.find('=');
string key = element.substr(0, pos);
string value = element.substr(pos + 1);
string::size_type pos = element.find('=');
string key = element.substr(0, pos);
string value = element.substr(pos + 1);
lowercase(key);
trim(key);
lowercase(key);
trim(key);
if (key == "boundary") {
trim(value, " \"");
*boundary = value;
}
if (key == "boundary") {
trim(value, " \"");
*boundary = value;
}
}
}
}
}
void Binc::MimePart::parseMessageRFC822(vector<Binc::MimePart> *members,
bool *foundendofpart,
unsigned int *bodylength,
unsigned int *nbodylines,
const string &toboundary)
bool *foundendofpart,
unsigned int *bodylength,
unsigned int *nbodylines,
const string &toboundary)
{
using namespace ::Binc;
@ -301,7 +301,7 @@ void Binc::MimePart::parseMessageRFC822(vector<Binc::MimePart> *members,
}
bool Binc::MimePart::skipUntilBoundary(const string &delimiter,
unsigned int *nlines, bool *eof)
unsigned int *nlines, bool *eof)
{
string::size_type endpos = delimiter.length();
char *delimiterqueue = 0;
@ -337,7 +337,7 @@ bool Binc::MimePart::skipUntilBoundary(const string &delimiter,
delimiterpos = 0;
if (compareStringToQueue(delimiterStr, delimiterqueue,
delimiterpos, int(endpos))) {
delimiterpos, int(endpos))) {
foundBoundary = true;
break;
}
@ -354,9 +354,9 @@ bool Binc::MimePart::skipUntilBoundary(const string &delimiter,
// and need to check if it is immediately followed by another boundary
// (in this case, we give up our final CRLF in its favour)
inline void Binc::MimePart::postBoundaryProcessing(bool *eof,
unsigned int *nlines,
int *boundarysize,
bool *foundendofpart)
unsigned int *nlines,
int *boundarysize,
bool *foundendofpart)
{
// Read two more characters. This may be CRLF, it may be "--" and
// it may be any other two characters.
@ -383,14 +383,14 @@ inline void Binc::MimePart::postBoundaryProcessing(bool *eof,
*boundarysize += 2;
if (!mimeSource->getChar(&a))
*eof = true;
*eof = true;
if (a == '\n')
++*nlines;
++*nlines;
if (!mimeSource->getChar(&b))
*eof = true;
*eof = true;
if (b == '\n')
++*nlines;
++*nlines;
}
// If the boundary is followed by CRLF, we need to handle the
@ -400,19 +400,19 @@ inline void Binc::MimePart::postBoundaryProcessing(bool *eof,
if (a == '\r' && b == '\n') {
// Get 2 more
if (!mimeSource->getChar(&a) || !mimeSource->getChar(&b)) {
*eof = true;
*eof = true;
} else if (a == '-' && b == '-') {
MPFDEB((stderr, "BINC: consecutive delimiters, giving up CRLF\n"));
mimeSource->ungetChar();
mimeSource->ungetChar();
mimeSource->ungetChar();
mimeSource->ungetChar();
MPFDEB((stderr, "BINC: consecutive delimiters, giving up CRLF\n"));
mimeSource->ungetChar();
mimeSource->ungetChar();
mimeSource->ungetChar();
mimeSource->ungetChar();
} else {
// We unget the 2 chars, and keep our crlf (increasing our own size)
MPFDEB((stderr, "BINC: keeping my CRLF\n"));
mimeSource->ungetChar();
mimeSource->ungetChar();
*boundarysize += 2;
// We unget the 2 chars, and keep our crlf (increasing our own size)
MPFDEB((stderr, "BINC: keeping my CRLF\n"));
mimeSource->ungetChar();
mimeSource->ungetChar();
*boundarysize += 2;
}
} else {
@ -424,17 +424,17 @@ inline void Binc::MimePart::postBoundaryProcessing(bool *eof,
}
void Binc::MimePart::parseMultipart(const string &boundary,
const string &toboundary,
bool *eof,
unsigned int *nlines,
int *boundarysize,
bool *foundendofpart,
unsigned int *bodylength,
vector<Binc::MimePart> *members)
const string &toboundary,
bool *eof,
unsigned int *nlines,
int *boundarysize,
bool *foundendofpart,
unsigned int *bodylength,
vector<Binc::MimePart> *members)
{
MPFDEB((stderr, "BINC: ParseMultipart: boundary [%s], toboundary[%s]\n",
boundary.c_str(),
toboundary.c_str()));
boundary.c_str(),
toboundary.c_str()));
using namespace ::Binc;
unsigned int bodystartoffsetcrlf = mimeSource->getOffset();
@ -462,8 +462,8 @@ void Binc::MimePart::parseMultipart(const string &boundary,
// final boundary.
int bsize = 0;
if (m.doParseFull(mimeSource, boundary, bsize)) {
quit = true;
*boundarysize = bsize;
quit = true;
*boundarysize = bsize;
}
members->push_back(m);
@ -502,14 +502,14 @@ void Binc::MimePart::parseMultipart(const string &boundary,
}
void Binc::MimePart::parseSinglePart(const string &toboundary,
int *boundarysize,
unsigned int *nbodylines,
unsigned int *nlines,
bool *eof, bool *foundendofpart,
unsigned int *bodylength)
int *boundarysize,
unsigned int *nbodylines,
unsigned int *nlines,
bool *eof, bool *foundendofpart,
unsigned int *bodylength)
{
MPFDEB((stderr, "BINC: parseSinglePart, boundary [%s]\n",
toboundary.c_str()));
toboundary.c_str()));
using namespace ::Binc;
unsigned int bodystartoffsetcrlf = mimeSource->getOffset();
@ -550,7 +550,7 @@ void Binc::MimePart::parseSinglePart(const string &toboundary,
boundarypos = 0;
if (compareStringToQueue(_toboundaryStr, boundaryqueue,
boundarypos, int(endpos))) {
boundarypos, int(endpos))) {
*boundarysize = static_cast<int>(_toboundary.length());
break;
}
@ -580,12 +580,12 @@ void Binc::MimePart::parseSinglePart(const string &toboundary,
*bodylength = 0;
}
MPFDEB((stderr, "BINC: parseSimple ret: bodylength %d, boundarysize %d\n",
*bodylength, *boundarysize));
*bodylength, *boundarysize));
}
//------------------------------------------------------------------------
int Binc::MimePart::doParseFull(MimeInputSource *ms, const string &toboundary,
int &boundarysize)
int &boundarysize)
{
MPFDEB((stderr, "BINC: doParsefull, toboundary[%s]\n", toboundary.c_str()));
mimeSource = ms;
@ -610,15 +610,15 @@ int Binc::MimePart::doParseFull(MimeInputSource *ms, const string &toboundary,
if (messagerfc822) {
parseMessageRFC822(&members, &foundendofpart, &bodylength,
&nbodylines, toboundary);
&nbodylines, toboundary);
} else if (multipart) {
parseMultipart(boundary, toboundary, &eof, &nlines, &boundarysize,
&foundendofpart, &bodylength,
&members);
&foundendofpart, &bodylength,
&members);
} else {
parseSinglePart(toboundary, &boundarysize, &nbodylines, &nlines,
&eof, &foundendofpart, &bodylength);
&eof, &foundendofpart, &bodylength);
}
MPFDEB((stderr, "BINC: doParsefull ret, toboundary[%s]\n", toboundary.c_str()));

View File

@ -107,27 +107,27 @@ int Binc::MimePart::doParseOnlyHeader(MimeInputSource *ms)
// read name
while (1) {
if (!mimeSource->getChar(&c)) {
quit = true;
break;
quit = true;
break;
}
if (c == '\n') ++nlines;
if (c == ':') break;
if (c == '\n') {
for (int i = int(name.length()) - 1; i >= 0; --i)
mimeSource->ungetChar();
mimeSource->ungetChar();
quit = true;
name.clear();
break;
quit = true;
name.clear();
break;
}
name += c;
if (name.length() == 2 && name.substr(0, 2) == "\r\n") {
name.clear();
quit = true;
break;
name.clear();
quit = true;
break;
}
}
@ -140,36 +140,36 @@ int Binc::MimePart::doParseOnlyHeader(MimeInputSource *ms)
while (!quit) {
if (!mimeSource->getChar(&c)) {
quit = true;
break;
quit = true;
break;
}
if (c == '\n') ++nlines;
for (int i = 0; i < 3; ++i)
cqueue[i] = cqueue[i + 1];
cqueue[i] = cqueue[i + 1];
cqueue[3] = c;
if (strncmp(cqueue, "\r\n\r\n", 4) == 0) {
quit = true;
break;
quit = true;
break;
}
if (cqueue[2] == '\n') {
// guess the mime rfc says what can not appear on the beginning
// of a line.
if (!isspace(cqueue[3])) {
if (content.length() > 2)
content.resize(content.length() - 2);
// guess the mime rfc says what can not appear on the beginning
// of a line.
if (!isspace(cqueue[3])) {
if (content.length() > 2)
content.resize(content.length() - 2);
trim(content);
h.add(name, content);
trim(content);
h.add(name, content);
name = c;
content.clear();
break;
}
name = c;
content.clear();
break;
}
}
content += c;

View File

@ -34,8 +34,8 @@
using namespace ::std;
void Binc::MimePart::getBody(string &s,
unsigned int startoffset,
unsigned int length) const
unsigned int startoffset,
unsigned int length) const
{
mimeSource->reset();
mimeSource->seek(bodystartoffsetcrlf + startoffset);

View File

@ -35,7 +35,7 @@ using namespace ::std;
#endif /* NO_NAMESPACES */
inline bool compareStringToQueue(const char *s_in, char *bqueue,
int pos, int size)
int pos, int size)
{
for (int i = 0; i < size; ++i) {
if (s_in[i] != bqueue[pos])

View File

@ -44,8 +44,8 @@ Usage(void)
static int op_flags;
#define OPT_MOINS 0x1
#define OPT_s 0x2
#define OPT_b 0x4
#define OPT_s 0x2
#define OPT_b 0x4
#define DEFCOUNT 10
@ -60,31 +60,31 @@ int main(int argc, char **argv)
argc--; argv++;
while (argc > 0 && **argv == '-') {
(*argv)++;
if (!(**argv))
/* Cas du "adb - core" */
Usage();
while (**argv)
switch (*(*argv)++) {
case 's': op_flags |= OPT_s; break;
case 'b': op_flags |= OPT_b; if (argc < 2) Usage();
if ((sscanf(*(++argv), "%d", &count)) != 1)
Usage();
argc--;
goto b1;
default: Usage(); break;
}
(*argv)++;
if (!(**argv))
/* Cas du "adb - core" */
Usage();
while (**argv)
switch (*(*argv)++) {
case 's': op_flags |= OPT_s; break;
case 'b': op_flags |= OPT_b; if (argc < 2) Usage();
if ((sscanf(*(++argv), "%d", &count)) != 1)
Usage();
argc--;
goto b1;
default: Usage(); break;
}
b1: argc--; argv++;
}
if (argc != 1)
Usage();
Usage();
char *mfile = *argv++;argc--;
int fd;
if ((fd = open(mfile, 0)) < 0) {
perror("Opening");
exit(1);
perror("Opening");
exit(1);
}
Binc::MimeDocument doc;
@ -97,30 +97,30 @@ int main(int argc, char **argv)
fprintf(stderr, "Size: %d\n", size);
cp = (char *)malloc(size);
if (cp==0) {
fprintf(stderr, "Malloc %d failed\n", size);
exit(1);
fprintf(stderr, "Malloc %d failed\n", size);
exit(1);
}
int n;
if ((n=read(fd, cp, size)) != size) {
fprintf(stderr, "Read failed: requested %d, got %d\n", size, n);
exit(1);
fprintf(stderr, "Read failed: requested %d, got %d\n", size, n);
exit(1);
}
std::stringstream s(string(cp, size), ios::in);
doc.parseFull(s);
#endif
if (!doc.isHeaderParsed() && !doc.isAllParsed()) {
fprintf(stderr, "Parse error\n");
exit(1);
fprintf(stderr, "Parse error\n");
exit(1);
}
close(fd);
Binc::HeaderItem hi;
for (int i = 0; i < nh ; i++) {
if (!doc.h.getFirstHeader(hnames[i], hi)) {
fprintf(stderr, "No %s\n", hnames[i]);
exit(1);
}
printf("%s: %s\n", hnames[i], hi.getValue().c_str());
if (!doc.h.getFirstHeader(hnames[i], hi)) {
fprintf(stderr, "No %s\n", hnames[i]);
exit(1);
}
printf("%s: %s\n", hnames[i], hi.getValue().c_str());
}
exit(0);
}

View File

@ -1571,7 +1571,7 @@ vector<string> RclConfig::getSkippedPaths() const
skpl.push_back(getDbDir());
skpl.push_back(getConfDir());
#ifdef _WIN32
skpl.push_back(TempFile::rcltmpdir());
skpl.push_back(TempFile::rcltmpdir());
#endif
if (getCacheDir().compare(getConfDir())) {
skpl.push_back(getCacheDir());

View File

@ -100,7 +100,7 @@ class RclConfig {
RclConfig(const RclConfig &r);
~RclConfig() {
freeAll();
freeAll();
}
// Return a writable clone of the main config. This belongs to the
@ -136,9 +136,9 @@ class RclConfig {
bool getConfParam(const string &name, string &value,
bool shallow=false) const
{
if (m_conf == 0)
return false;
return m_conf->get(name, value, m_keydir, shallow);
if (m_conf == 0)
return false;
return m_conf->get(name, value, m_keydir, shallow);
}
/** Variant with autoconversion to int */
bool getConfParam(const string &name, int *value, bool shallow=false) const;
@ -166,7 +166,7 @@ class RclConfig {
*/
vector<string> getConfNames(const char *pattern = 0) const
{
return m_conf->getNames(m_keydir, pattern);
return m_conf->getNames(m_keydir, pattern);
}
/** Check if name exists anywhere in config */
@ -207,7 +207,7 @@ class RclConfig {
/** Do path translation according to the ptrans table */
void urlrewrite(const string& dbdir, string& url) const;
ConfSimple *getPTrans() {
return m_ptrans;
return m_ptrans;
}
/** Get Web Queue directory name */
string getWebQueueDir() const;
@ -221,7 +221,7 @@ class RclConfig {
/** Get list of skipped paths patterns. Doesn't depend on the keydir */
vector<string> getSkippedPaths() const;
/** Get list of skipped paths patterns, daemon version (may add some)
Doesn't depend on the keydir */
Doesn't depend on the keydir */
vector<string> getDaemSkippedPaths() const;
/** Return list of no content suffixes. Used by confgui, indexing uses
@ -260,7 +260,7 @@ class RclConfig {
* @param whole the raw value. No way to escape a semi-colon in there.
*/
static bool valueSplitAttributes(const string& whole, string& value,
ConfSimple& attrs) ;
ConfSimple& attrs) ;
/** Compute difference between 'base' and 'changed', as elements to be
* added and substracted from base. Input and output strings are in
@ -315,7 +315,7 @@ class RclConfig {
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
string getMimeViewerDef(const string &mimetype, const string& apptag,
bool useall) const;
bool useall) const;
set<string> getMimeViewerAllEx() const;
bool setMimeViewerAllEx(const set<string>& allex);
bool getMimeViewerDefs(vector<pair<string, string> >&) const;
@ -348,21 +348,21 @@ class RclConfig {
string findFilter(const string& cmd) const;
/** Thread config init is not done automatically because not all
programs need it and it uses the debug log so that it's better to
call it after primary init */
programs need it and it uses the debug log so that it's better to
call it after primary init */
void initThrConf();
const string& getOrigCwd()
{
return o_origcwd;
return o_origcwd;
}
RclConfig& operator=(const RclConfig &r) {
if (this != &r) {
freeAll();
initFrom(r);
}
return *this;
if (this != &r) {
freeAll();
initFrom(r);
}
return *this;
}
friend class ParamStale;

View File

@ -77,29 +77,29 @@ void initAsyncSigs(void (*sigcleanup)(int))
// Install app signal handler
if (sigcleanup) {
struct sigaction action;
action.sa_handler = sigcleanup;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
for (unsigned int i = 0; i < sizeof(catchedSigs) / sizeof(int); i++)
if (signal(catchedSigs[i], SIG_IGN) != SIG_IGN) {
if (sigaction(catchedSigs[i], &action, 0) < 0) {
perror("Sigaction failed");
}
}
struct sigaction action;
action.sa_handler = sigcleanup;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
for (unsigned int i = 0; i < sizeof(catchedSigs) / sizeof(int); i++)
if (signal(catchedSigs[i], SIG_IGN) != SIG_IGN) {
if (sigaction(catchedSigs[i], &action, 0) < 0) {
perror("Sigaction failed");
}
}
}
// Install log rotate sig handler
{
struct sigaction action;
action.sa_handler = siglogreopen;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
if (sigaction(SIGHUP, &action, 0) < 0) {
perror("Sigaction failed");
}
}
struct sigaction action;
action.sa_handler = siglogreopen;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
if (sigaction(SIGHUP, &action, 0) < 0) {
perror("Sigaction failed");
}
}
}
}
void recoll_exitready()
@ -150,10 +150,10 @@ static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
{
l_sigcleanup(SIGINT);
LOGDEB0("CtrlHandler: waiting for exit ready\n" );
DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
if (res != WAIT_OBJECT_0) {
DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
if (res != WAIT_OBJECT_0) {
LOGERR("CtrlHandler: exit ack wait failed\n" );
}
}
LOGDEB0("CtrlHandler: got exit ready event, exiting\n" );
return TRUE;
}
@ -242,14 +242,14 @@ void initAsyncSigs(void (*sigcleanup)(int))
// Install app signal handler
if (sigcleanup) {
l_sigcleanup = sigcleanup;
for (unsigned int i = 0; i < sizeof(catchedSigs) / sizeof(int); i++) {
if (signal(catchedSigs[i], SIG_IGN) != SIG_IGN) {
signal(catchedSigs[i], sigcleanup);
}
for (unsigned int i = 0; i < sizeof(catchedSigs) / sizeof(int); i++) {
if (signal(catchedSigs[i], SIG_IGN) != SIG_IGN) {
signal(catchedSigs[i], sigcleanup);
}
}
}
CreateThread(NULL, 0, RunInvisibleWindowThread, NULL, 0, &tid);
CreateThread(NULL, 0, RunInvisibleWindowThread, NULL, 0, &tid);
SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
eWorkFinished = CreateEvent(NULL, TRUE, FALSE, NULL);
if (eWorkFinished == INVALID_HANDLE_VALUE) {
@ -267,11 +267,11 @@ void recoll_exitready()
#endif
RclConfig *recollinit(int flags,
void (*cleanup)(void), void (*sigcleanup)(int),
string &reason, const string *argcnf)
void (*cleanup)(void), void (*sigcleanup)(int),
string &reason, const string *argcnf)
{
if (cleanup)
atexit(cleanup);
atexit(cleanup);
#if defined(MACPORTS) || defined(HOMEBREW)
// The MACPORTS and HOMEBREW flags are set by the resp. portfile
@ -303,12 +303,12 @@ RclConfig *recollinit(int flags,
RclConfig *config = new RclConfig(argcnf);
if (!config || !config->ok()) {
reason = "Configuration could not be built:\n";
if (config)
reason += config->getReason();
else
reason += "Out of memory ?";
return 0;
reason = "Configuration could not be built:\n";
if (config)
reason += config->getReason();
else
reason += "Out of memory ?";
return 0;
}
TextSplit::staticConfInit(config);
@ -318,8 +318,8 @@ RclConfig *recollinit(int flags,
// ones.
string logfilename, loglevel;
if (flags & RCLINIT_DAEMON) {
config->getConfParam(string("daemlogfilename"), logfilename);
config->getConfParam(string("daemloglevel"), loglevel);
config->getConfParam(string("daemlogfilename"), logfilename);
config->getConfParam(string("daemloglevel"), loglevel);
}
if (flags & RCLINIT_IDX) {
if (logfilename.empty()) {
@ -339,22 +339,22 @@ RclConfig *recollinit(int flags,
}
if (logfilename.empty())
config->getConfParam(string("logfilename"), logfilename);
config->getConfParam(string("logfilename"), logfilename);
if (loglevel.empty())
config->getConfParam(string("loglevel"), loglevel);
config->getConfParam(string("loglevel"), loglevel);
// Initialize logging
if (!logfilename.empty()) {
logfilename = path_tildexpand(logfilename);
// If not an absolute path or stderr, compute relative to config dir.
if (!path_isabsolute(logfilename) &&
logfilename = path_tildexpand(logfilename);
// If not an absolute path or stderr, compute relative to config dir.
if (!path_isabsolute(logfilename) &&
logfilename.compare("stderr")) {
logfilename = path_cat(config->getConfDir(), logfilename);
}
logfilename = path_cat(config->getConfDir(), logfilename);
}
Logger::getTheLog("")->reopen(logfilename);
}
if (!loglevel.empty()) {
int lev = atoi(loglevel.c_str());
int lev = atoi(loglevel.c_str());
Logger::getTheLog("")->setLogLevel(Logger::LogLevel(lev));
}
LOGINF(Rcl::version_string() << " [" << config->getConfDir() << "]\n");
@ -378,7 +378,7 @@ RclConfig *recollinit(int flags,
// Init Unac translation exceptions
string unacex;
if (config->getConfParam("unac_except_trans", unacex) && !unacex.empty())
unac_set_except_translations(unacex.c_str());
unac_set_except_translations(unacex.c_str());
#ifndef IDX_THREADS
ExecCmd::useVfork(true);
@ -393,23 +393,23 @@ RclConfig *recollinit(int flags,
bool novfork;
config->getConfParam("novfork", &novfork);
if (novfork) {
LOGDEB0("rclinit: will use fork() for starting commands\n" );
LOGDEB0("rclinit: will use fork() for starting commands\n" );
ExecCmd::useVfork(false);
} else {
LOGDEB0("rclinit: will use vfork() for starting commands\n" );
ExecCmd::useVfork(true);
LOGDEB0("rclinit: will use vfork() for starting commands\n" );
ExecCmd::useVfork(true);
}
#endif
int flushmb;
if (config->getConfParam("idxflushmb", &flushmb) && flushmb > 0) {
LOGDEB1("rclinit: idxflushmb=" << flushmb <<
LOGDEB1("rclinit: idxflushmb=" << flushmb <<
", set XAPIAN_FLUSH_THRESHOLD to 10E6\n");
static const char *cp = "XAPIAN_FLUSH_THRESHOLD=1000000";
static const char *cp = "XAPIAN_FLUSH_THRESHOLD=1000000";
#ifdef PUTENV_ARG_CONST
::putenv(cp);
::putenv(cp);
#else
::putenv(strdup(cp));
::putenv(strdup(cp));
#endif
}
@ -425,7 +425,7 @@ void recoll_threadinit()
sigemptyset(&sset);
for (unsigned int i = 0; i < sizeof(catchedSigs) / sizeof(int); i++)
sigaddset(&sset, catchedSigs[i]);
sigaddset(&sset, catchedSigs[i]);
sigaddset(&sset, SIGHUP);
pthread_sigmask(SIG_BLOCK, &sset, 0);
#else

View File

@ -99,7 +99,7 @@ bool SynGroups::setfile(const string& fn)
if (fn.empty()) {
delete m;
m = 0;
return true;
return true;
}
if (m->samefile(fn)) {
@ -111,8 +111,8 @@ bool SynGroups::setfile(const string& fn)
ifstream input;
input.open(fn.c_str(), ios::in);
if (!input.is_open()) {
LOGSYSERR("SynGroups:setfile", "open", fn);
return false;
LOGSYSERR("SynGroups:setfile", "open", fn);
return false;
}
string cline;
@ -123,18 +123,18 @@ bool SynGroups::setfile(const string& fn)
for (;;) {
cline.clear();
getline(input, cline);
if (!input.good()) {
if (input.bad()) {
getline(input, cline);
if (!input.good()) {
if (input.bad()) {
LOGERR("Syngroup::setfile(" << fn << "):Parse: input.bad()\n");
return false;
}
// Must be eof ? But maybe we have a partial line which
// must be processed. This happens if the last line before
// eof ends with a backslash, or there is no final \n
return false;
}
// Must be eof ? But maybe we have a partial line which
// must be processed. This happens if the last line before
// eof ends with a backslash, or there is no final \n
eof = true;
}
lnum++;
}
lnum++;
{
string::size_type pos = cline.find_last_not_of("\n\r");
@ -145,46 +145,46 @@ bool SynGroups::setfile(const string& fn)
}
}
if (appending)
line += cline;
else
line = cline;
if (appending)
line += cline;
else
line = cline;
// Note that we trim whitespace before checking for backslash-eol
// This avoids invisible whitespace problems.
trimstring(line);
if (line.empty() || line.at(0) == '#') {
// Note that we trim whitespace before checking for backslash-eol
// This avoids invisible whitespace problems.
trimstring(line);
if (line.empty() || line.at(0) == '#') {
if (eof)
break;
continue;
}
if (line[line.length() - 1] == '\\') {
line.erase(line.length() - 1);
appending = true;
continue;
}
appending = false;
continue;
}
if (line[line.length() - 1] == '\\') {
line.erase(line.length() - 1);
appending = true;
continue;
}
appending = false;
vector<string> words;
if (!stringToStrings(line, words)) {
LOGERR("SynGroups:setfile: " << fn << ": bad line " << lnum <<
vector<string> words;
if (!stringToStrings(line, words)) {
LOGERR("SynGroups:setfile: " << fn << ": bad line " << lnum <<
": " << line << "\n");
continue;
}
continue;
}
if (words.empty())
continue;
if (words.size() == 1) {
LOGERR("Syngroup::setfile(" << fn << "):single term group at line "
if (words.empty())
continue;
if (words.size() == 1) {
LOGERR("Syngroup::setfile(" << fn << "):single term group at line "
<< lnum << " ??\n");
continue;
}
continue;
}
m->groups.push_back(words);
for (const auto& word : words) {
m->terms[word] = m->groups.size()-1;
}
LOGDEB1("SynGroups::setfile: group: [" <<
m->groups.push_back(words);
for (const auto& word : words) {
m->terms[word] = m->groups.size()-1;
}
LOGDEB1("SynGroups::setfile: group: [" <<
stringsToString(m->groups.back()) << "]\n");
}
LOGDEB("SynGroups::setfile: got " << m->groups.size() <<
@ -198,12 +198,12 @@ vector<string> SynGroups::getgroup(const string& term)
{
vector<string> ret;
if (!ok())
return ret;
return ret;
const auto it1 = m->terms.find(term);
if (it1 == m->terms.end()) {
LOGDEB0("SynGroups::getgroup: [" << term << "] not found in map\n");
return ret;
LOGDEB0("SynGroups::getgroup: [" << term << "] not found in map\n");
return ret;
}
unsigned int idx = it1->second;

View File

@ -113,9 +113,9 @@ static bool initCmd()
#define STRSZT std::string::size_type
#define ISASCIIPUNCTORCTL(c) (c <= 0x7f && \
!((c >= 'A' && c <= 'Z') || \
(c >= 'a' && c <= 'z') || \
(c >= '0' && c <= '9')))
!((c >= 'A' && c <= 'Z') || \
(c >= 'a' && c <= 'z') || \
(c >= '0' && c <= '9')))
bool TextSplit::ko_to_words(Utf8Iter *itp, unsigned int *cp)
{
@ -153,10 +153,10 @@ bool TextSplit::ko_to_words(Utf8Iter *itp, unsigned int *cp)
for (; !it.eof() && !it.error(); it++) {
c = *it;
if (!isHANGUL(c) && !ISASCIIPUNCTORCTL(c)) {
// Non-Korean: we keep on if encountering space and other
// ASCII punctuation. Allows sending longer pieces of text
// to the splitter (perf). Else break, process this piece,
// and return to the main splitter
// Non-Korean: we keep on if encountering space and other
// ASCII punctuation. Allows sending longer pieces of text
// to the splitter (perf). Else break, process this piece,
// and return to the main splitter
LOGKO("ko_to_words: broke on " << (std::string)it << endl);
break;
} else {
@ -194,7 +194,7 @@ bool TextSplit::ko_to_words(Utf8Iter *itp, unsigned int *cp)
}
LOGKO("TextSplit::k_to_words: sending out " << inputdata.size() <<
" bytes " << inputdata << endl);
" bytes " << inputdata << endl);
// Overall data counter for slave restarts
restartcount += inputdata.size();

View File

@ -29,7 +29,7 @@
using namespace std;
bool unacmaybefold(const string &in, string &out,
const char *encoding, UnacOp what)
const char *encoding, UnacOp what)
{
char *cout = 0;
size_t out_len;

View File

@ -22,7 +22,7 @@
// A small stringified wrapper for unac.c
enum UnacOp {UNACOP_UNAC = 1, UNACOP_FOLD = 2, UNACOP_UNACFOLD = 3};
extern bool unacmaybefold(const std::string& in, std::string& out,
const char *encoding, UnacOp what);
const char *encoding, UnacOp what);
// Utility function to determine if string begins with capital
extern bool unaciscapital(const std::string& in);

View File

@ -170,7 +170,7 @@ static const unsigned int uniskip[] = {
0x200C, /* ZERO WIDTH NON-JOINER */
0x200D, /* ZERO WIDTH JOINER */
0x2060, /* WORD JOINER . Actually this should not be ignored but used to
* prevent a word break... */
* prevent a word break... */
};
/* Things that would visibly break a block of text, rendering obvious the need

View File

@ -37,10 +37,10 @@ string compute_utf8fn(const RclConfig *config, const string& ifn, bool simple)
string utf8fn;
int ercnt;
if (!transcode(lfn, utf8fn, charset, "UTF-8", &ercnt)) {
LOGERR("compute_utf8fn: fn transcode failure from [" << charset <<
LOGERR("compute_utf8fn: fn transcode failure from [" << charset <<
"] to UTF-8 for: [" << lfn << "]\n");
} else if (ercnt) {
LOGDEB("compute_utf8fn: " << ercnt << " transcode errors from [" <<
LOGDEB("compute_utf8fn: " << ercnt << " transcode errors from [" <<
charset << "] to UTF-8 for: [" << lfn << "]\n");
}
LOGDEB1("compute_utf8fn: transcoded from [" << lfn << "] to [" <<

View File

@ -37,15 +37,15 @@ WebStore::WebStore(RclConfig *cnf)
int maxmbs = 40;
cnf->getConfParam("webcachemaxmbs", &maxmbs);
if ((m_cache = new CirCache(ccdir)) == 0) {
LOGERR("WebStore: cant create CirCache object\n" );
return;
LOGERR("WebStore: cant create CirCache object\n" );
return;
}
if (!m_cache->create(int64_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) {
LOGERR("WebStore: cache file creation failed: " <<
LOGERR("WebStore: cache file creation failed: " <<
m_cache->getReason() << "\n");
delete m_cache;
m_cache = 0;
return;
delete m_cache;
m_cache = 0;
return;
}
}
@ -57,17 +57,17 @@ WebStore::~WebStore()
// Read document from cache. Return the metadata as an Rcl::Doc
// @param htt Web Hit Type
bool WebStore::getFromCache(const string& udi, Rcl::Doc &dotdoc,
string& data, string *htt)
string& data, string *htt)
{
string dict;
if (m_cache == 0) {
LOGERR("WebStore::getFromCache: cache is null\n");
return false;
LOGERR("WebStore::getFromCache: cache is null\n");
return false;
}
if (!m_cache->get(udi, dict, &data)) {
LOGDEB("WebStore::getFromCache: get failed\n");
return false;
LOGDEB("WebStore::getFromCache: get failed\n");
return false;
}
ConfSimple cf(dict, 1);

View File

@ -35,17 +35,17 @@ std::unique_ptr<DocFetcher> docFetcherMake(RclConfig *config,
string backend;
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
if (backend.empty() || !backend.compare("FS")) {
return std::unique_ptr<DocFetcher>(new FSDocFetcher);
return std::unique_ptr<DocFetcher>(new FSDocFetcher);
#ifndef DISABLE_WEB_INDEXER
} else if (!backend.compare("BGL")) {
return std::unique_ptr<DocFetcher>(new WQDocFetcher);
return std::unique_ptr<DocFetcher>(new WQDocFetcher);
#endif
} else {
std::unique_ptr<DocFetcher> f(exeDocFetcherMake(config, backend));
if (!f) {
LOGERR("DocFetcherFactory: unknown backend [" << backend << "]\n");
}
return f;
return f;
}
}

View File

@ -25,9 +25,9 @@
class DbIxStatus {
public:
enum Phase {DBIXS_NONE,
DBIXS_FILES, DBIXS_PURGE, DBIXS_STEMDB, DBIXS_CLOSING,
DBIXS_MONITOR,
DBIXS_DONE};
DBIXS_FILES, DBIXS_PURGE, DBIXS_STEMDB, DBIXS_CLOSING,
DBIXS_MONITOR,
DBIXS_DONE};
Phase phase;
std::string fn; // Last file processed
int docsdone; // Documents actually updated
@ -43,9 +43,9 @@ class DbIxStatus {
bool hasmonitor{false};
void reset() {
phase = DBIXS_FILES;
fn.erase();
docsdone = filesdone = fileerrors = dbtotdocs = totfiles = 0;
phase = DBIXS_FILES;
fn.erase();
docsdone = filesdone = fileerrors = dbtotdocs = totfiles = 0;
}
DbIxStatus() {reset();}
};

View File

@ -132,14 +132,14 @@ bool ConfIndexer::runFirstIndexing()
{
// Indexing status file existing and not empty ?
if (path_filesize(m_config->getIdxStatusFile()) > 0) {
LOGDEB0("ConfIndexer::runFirstIndexing: no: status file not empty\n");
return false;
LOGDEB0("ConfIndexer::runFirstIndexing: no: status file not empty\n");
return false;
}
// And only do this if the user has kept the default topdirs (~).
vector<string> tdl = m_config->getTopdirs();
if (tdl.size() != 1 || tdl[0].compare(path_canon(path_tildexpand("~")))) {
LOGDEB0("ConfIndexer::runFirstIndexing: no: not home only\n");
return false;
LOGDEB0("ConfIndexer::runFirstIndexing: no: not home only\n");
return false;
}
return true;
}
@ -150,7 +150,7 @@ bool ConfIndexer::firstFsIndexingSequence()
deleteZ(m_fsindexer);
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (!m_fsindexer) {
return false;
return false;
}
int flushmb = m_db.getFlushMb();
m_db.setFlushMb(2);
@ -164,17 +164,17 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
{
Rcl::Db::OpenMode mode = resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd;
if (!m_db.open(mode)) {
LOGERR("ConfIndexer: error opening database " << m_config->getDbDir() <<
LOGERR("ConfIndexer: error opening database " << m_config->getDbDir() <<
" : " << m_db.getReason() << "\n");
addIdxReason("indexer", m_db.getReason());
return false;
return false;
}
m_config->setKeyDir(cstr_null);
if (typestorun & IxTFs) {
if (runFirstIndexing()) {
firstFsIndexingSequence();
}
if (runFirstIndexing()) {
firstFsIndexingSequence();
}
deleteZ(m_fsindexer);
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (!m_fsindexer || !m_fsindexer->index(flags)) {
@ -183,7 +183,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
} else {
addIdxReason("indexer", "Index creation failed. See log.");
}
m_db.close();
m_db.close();
return false;
}
}
@ -193,7 +193,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
deleteZ(m_webindexer);
m_webindexer = new WebQueueIndexer(m_config, &m_db, m_updater);
if (!m_webindexer || !m_webindexer->index()) {
m_db.close();
m_db.close();
addIdxReason("indexer", "Web index creation failed. See log");
return false;
}
@ -203,10 +203,10 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
// Get rid of all database entries that don't exist in the
// filesystem anymore. Only if all *configured* indexers ran.
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_PURGE, "")) {
m_db.close();
m_db.close();
addIdxReason("indexer", "Index purge failed. See log");
return false;
}
return false;
}
m_db.purge();
}
@ -214,22 +214,22 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
// here. Makes no sense to check for cancel, we'll have to close
// anyway
if (m_updater)
m_updater->update(DbIxStatus::DBIXS_CLOSING, string());
m_updater->update(DbIxStatus::DBIXS_CLOSING, string());
if (!m_db.close()) {
LOGERR("ConfIndexer::index: error closing database in " <<
LOGERR("ConfIndexer::index: error closing database in " <<
m_config->getDbDir() << "\n");
addIdxReason("indexer", "Index close/flush failed. See log");
return false;
return false;
}
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
return false;
return false;
bool ret = true;
if (!createStemmingDatabases()) {
ret = false;
ret = false;
}
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
return false;
return false;
// Don't fail indexing because of an aspell issue: we ignore the status.
// Messages were written to the reasons output
@ -237,7 +237,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
clearMimeHandlerCache();
if (m_updater)
m_updater->update(DbIxStatus::DBIXS_DONE, string());
m_updater->update(DbIxStatus::DBIXS_DONE, string());
return ret;
}
@ -246,14 +246,14 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
list<string> myfiles;
string origcwd = m_config->getOrigCwd();
for (const auto& entry : ifiles) {
myfiles.push_back(path_canon(entry, &origcwd));
myfiles.push_back(path_canon(entry, &origcwd));
}
myfiles.sort();
if (!m_db.open(Rcl::Db::DbUpd)) {
LOGERR("ConfIndexer: indexFiles error opening database " <<
LOGERR("ConfIndexer: indexFiles error opening database " <<
m_config->getDbDir() << "\n");
return false;
return false;
}
m_config->setKeyDir(cstr_null);
bool ret = false;
@ -280,9 +280,9 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
}
// The close would be done in our destructor, but we want status here
if (!m_db.close()) {
LOGERR("ConfIndexer::index: error closing database in " <<
LOGERR("ConfIndexer::index: error closing database in " <<
m_config->getDbDir() << "\n");
return false;
return false;
}
ifiles = myfiles;
clearMimeHandlerCache();
@ -297,7 +297,7 @@ bool ConfIndexer::updateDocs(vector<Rcl::Doc> &docs, IxFlag flag)
docsToPaths(docs, paths);
list<string> files(paths.begin(), paths.end());
if (!files.empty()) {
return indexFiles(files, flag);
return indexFiles(files, flag);
}
return true;
}
@ -307,14 +307,14 @@ bool ConfIndexer::purgeFiles(list<string> &files, int flag)
list<string> myfiles;
string origcwd = m_config->getOrigCwd();
for (const auto& entry : files) {
myfiles.push_back(path_canon(entry, &origcwd));
myfiles.push_back(path_canon(entry, &origcwd));
}
myfiles.sort();
if (!m_db.open(Rcl::Db::DbUpd)) {
LOGERR("ConfIndexer: purgeFiles error opening database " <<
LOGERR("ConfIndexer: purgeFiles error opening database " <<
m_config->getDbDir() << "\n");
return false;
return false;
}
bool ret = false;
m_config->setKeyDir(cstr_null);
@ -337,9 +337,9 @@ bool ConfIndexer::purgeFiles(list<string> &files, int flag)
// The close would be done in our destructor, but we want status here
if (!m_db.close()) {
LOGERR("ConfIndexer::purgefiles: error closing database in " <<
LOGERR("ConfIndexer::purgefiles: error closing database in " <<
m_config->getDbDir() << "\n");
return false;
return false;
}
return ret;
}
@ -356,18 +356,18 @@ bool ConfIndexer::createStemmingDatabases()
addIdxReason("stemming", "could not open db");
return false;
}
vector<string> langs;
stringToStrings(slangs, langs);
vector<string> langs;
stringToStrings(slangs, langs);
// Get the list of existing stem dbs from the database (some may have
// been manually created, we just keep those from the config
vector<string> dblangs = m_db.getStemLangs();
vector<string>::const_iterator it;
for (it = dblangs.begin(); it != dblangs.end(); it++) {
if (find(langs.begin(), langs.end(), *it) == langs.end())
m_db.deleteStemDb(*it);
}
ret = ret && m_db.createStemDbs(langs);
// Get the list of existing stem dbs from the database (some may have
// been manually created, we just keep those from the config
vector<string> dblangs = m_db.getStemLangs();
vector<string>::const_iterator it;
for (it = dblangs.begin(); it != dblangs.end(); it++) {
if (find(langs.begin(), langs.end(), *it) == langs.end())
m_db.deleteStemDb(*it);
}
ret = ret && m_db.createStemDbs(langs);
if (!ret) {
addIdxReason("stemming", "stem db creation failed");
}
@ -379,7 +379,7 @@ bool ConfIndexer::createStemmingDatabases()
bool ConfIndexer::createStemDb(const string &lang)
{
if (!m_db.open(Rcl::Db::DbUpd))
return false;
return false;
vector<string> langs;
stringToStrings(lang, langs);
return m_db.createStemDbs(langs);
@ -397,32 +397,32 @@ bool ConfIndexer::createAspellDict()
// it forever.
static int noaspell = -12345;
if (noaspell == -12345) {
noaspell = false;
m_config->getConfParam("noaspell", &noaspell);
noaspell = false;
m_config->getConfParam("noaspell", &noaspell);
}
if (noaspell)
return true;
return true;
if (!m_db.open(Rcl::Db::DbRO)) {
LOGERR("ConfIndexer::createAspellDict: could not open db\n");
return false;
return false;
}
Aspell aspell(m_config);
string reason;
if (!aspell.init(reason)) {
LOGERR("ConfIndexer::createAspellDict: aspell init failed: " <<
LOGERR("ConfIndexer::createAspellDict: aspell init failed: " <<
reason << "\n");
noaspell = true;
return false;
noaspell = true;
return false;
}
LOGDEB("ConfIndexer::createAspellDict: creating dictionary\n");
if (!aspell.buildDict(m_db, reason)) {
LOGERR("ConfIndexer::createAspellDict: aspell buildDict failed: " <<
LOGERR("ConfIndexer::createAspellDict: aspell buildDict failed: " <<
reason << "\n");
addIdxReason("aspell", reason);
noaspell = true;
return false;
noaspell = true;
return false;
}
#endif
return true;

View File

@ -45,7 +45,7 @@ class DbIxStatusUpdater {
virtual bool update(DbIxStatus::Phase phase, const string& fn)
{
#ifdef IDX_THREADS
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
#endif
status.phase = phase;
status.fn = fn;

View File

@ -55,11 +55,11 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
#ifdef USE_SYSTEM_FILE_COMMAND
if (usfc && mime.empty()) {
// Last resort: use "file -i", or its configured replacement.
// Last resort: use "file -i", or its configured replacement.
// 'file' fallback if the configured command (default:
// xdg-mime) is not found
static const vector<string> tradfilecmd = {{FILE_PROG}, {"-i"}};
static const vector<string> tradfilecmd = {{FILE_PROG}, {"-i"}};
vector<string> cmd;
string scommand;
@ -81,55 +81,55 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
cmd = tradfilecmd;
}
string result;
string result;
LOGDEB2("mimetype: executing: [" << stringsToString(cmd) << "]\n");
if (!ExecCmd::backtick(cmd, result)) {
LOGERR("mimetypefromdata: exec " <<
if (!ExecCmd::backtick(cmd, result)) {
LOGERR("mimetypefromdata: exec " <<
stringsToString(cmd) << " failed\n");
return string();
}
trimstring(result, " \t\n\r");
LOGDEB2("mimetype: systemfilecommand output [" << result << "]\n");
return string();
}
trimstring(result, " \t\n\r");
LOGDEB2("mimetype: systemfilecommand output [" << result << "]\n");
// The normal output from "file -i" looks like the following:
// thefilename.xxx: text/plain; charset=us-ascii
// Sometimes the semi-colon is missing like in:
// mimetype.cpp: text/x-c charset=us-ascii
// And sometimes we only get the mime type. This apparently happens
// when 'file' believes that the file name is binary
// The normal output from "file -i" looks like the following:
// thefilename.xxx: text/plain; charset=us-ascii
// Sometimes the semi-colon is missing like in:
// mimetype.cpp: text/x-c charset=us-ascii
// And sometimes we only get the mime type. This apparently happens
// when 'file' believes that the file name is binary
// xdg-mime only outputs the MIME type.
// If there is no colon and there is a slash, this is hopefuly
// the mime type
if (result.find_first_of(":") == string::npos &&
result.find_first_of("/") != string::npos) {
return result;
}
// If there is no colon and there is a slash, this is hopefuly
// the mime type
if (result.find_first_of(":") == string::npos &&
result.find_first_of("/") != string::npos) {
return result;
}
// Else the result should begin with the file name. Get rid of it:
if (result.find(fn) != 0) {
// Garbage "file" output. Maybe the result of a charset
// conversion attempt?
LOGERR("mimetype: can't interpret output from [" <<
// Else the result should begin with the file name. Get rid of it:
if (result.find(fn) != 0) {
// Garbage "file" output. Maybe the result of a charset
// conversion attempt?
LOGERR("mimetype: can't interpret output from [" <<
stringsToString(cmd) << "] : [" << result << "]\n");
return string();
}
result = result.substr(fn.size());
return string();
}
result = result.substr(fn.size());
// Now should look like ": text/plain; charset=us-ascii"
// Split it, and take second field
list<string> res;
stringToStrings(result, res);
if (res.size() <= 1)
return string();
list<string>::iterator it = res.begin();
mime = *++it;
// Remove possible semi-colon at the end
trimstring(mime, " \t;");
// Now should look like ": text/plain; charset=us-ascii"
// Split it, and take second field
list<string> res;
stringToStrings(result, res);
if (res.size() <= 1)
return string();
list<string>::iterator it = res.begin();
mime = *++it;
// Remove possible semi-colon at the end
trimstring(mime, " \t;");
// File -i will sometimes return strange stuff (ie: "very small file")
if(mime.find("/") == string::npos)
mime.clear();
// File -i will sometimes return strange stuff (ie: "very small file")
if(mime.find("/") == string::npos)
mime.clear();
}
#endif //USE_SYSTEM_FILE_COMMAND
@ -139,24 +139,24 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
/// Guess mime type, first from suffix, then from file data. We also
/// have a list of suffixes that we don't touch at all.
string mimetype(const string &fn, const struct PathStat *stp,
RclConfig *cfg, bool usfc)
RclConfig *cfg, bool usfc)
{
// Use stat data if available to check for non regular files
if (stp) {
// Note: the value used for directories is different from what
// file -i would print on Linux (inode/directory). Probably
// comes from bsd. Thos may surprise a user trying to use a
// 'mime:' filter with the query language, but it's not work
// changing (would force a reindex).
if (stp->pst_type == PathStat::PST_DIR)
return "inode/directory";
if (stp->pst_type == PathStat::PST_SYMLINK)
return "inode/symlink";
if (stp->pst_type != PathStat::PST_REGULAR)
return "inode/x-fsspecial";
// Empty files are just this: avoid further errors with actual filters.
if (stp->pst_size == 0)
return "inode/x-empty";
// Note: the value used for directories is different from what
// file -i would print on Linux (inode/directory). Probably
// comes from bsd. Thos may surprise a user trying to use a
// 'mime:' filter with the query language, but it's not work
// changing (would force a reindex).
if (stp->pst_type == PathStat::PST_DIR)
return "inode/directory";
if (stp->pst_type == PathStat::PST_SYMLINK)
return "inode/symlink";
if (stp->pst_type != PathStat::PST_REGULAR)
return "inode/x-fsspecial";
// Empty files are just this: avoid further errors with actual filters.
if (stp->pst_size == 0)
return "inode/x-empty";
}
string mtype;
@ -165,40 +165,40 @@ string mimetype(const string &fn, const struct PathStat *stp,
// Extended attribute has priority on everything, as per:
// http://freedesktop.org/wiki/CommonExtendedAttributes
if (pxattr::get(fn, "mime_type", &mtype)) {
LOGDEB0("Mimetype: 'mime_type' xattr : [" << mtype << "]\n");
if (mtype.empty()) {
LOGDEB0("Mimetype: getxattr() returned empty mime type !\n");
} else {
return mtype;
}
LOGDEB0("Mimetype: 'mime_type' xattr : [" << mtype << "]\n");
if (mtype.empty()) {
LOGDEB0("Mimetype: getxattr() returned empty mime type !\n");
} else {
return mtype;
}
}
#endif
if (cfg == 0) {
LOGERR("Mimetype: null config ??\n");
return mtype;
LOGERR("Mimetype: null config ??\n");
return mtype;
}
if (cfg->inStopSuffixes(fn)) {
LOGDEB("mimetype: fn [" << fn << "] in stopsuffixes\n");
return mtype;
LOGDEB("mimetype: fn [" << fn << "] in stopsuffixes\n");
return mtype;
}
// Compute file name suffix and search the mimetype map
string::size_type dot = fn.find_first_of(".");
while (dot != string::npos) {
string suff = stringtolower(fn.substr(dot));
mtype = cfg->getMimeTypeFromSuffix(suff);
if (!mtype.empty() || dot >= fn.size() - 1)
break;
dot = fn.find_first_of(".", dot + 1);
string suff = stringtolower(fn.substr(dot));
mtype = cfg->getMimeTypeFromSuffix(suff);
if (!mtype.empty() || dot >= fn.size() - 1)
break;
dot = fn.find_first_of(".", dot + 1);
}
// If type was not determined from suffix, examine file data. Can
// only do this if we have an actual file (as opposed to a pure
// name).
if (mtype.empty() && stp)
mtype = mimetypefromdata(cfg, fn, usfc);
mtype = mimetypefromdata(cfg, fn, usfc);
return mtype;
}

View File

@ -47,7 +47,7 @@ using std::multimap;
class RclMonEvent {
public:
enum EvType {RCLEVT_NONE= 0, RCLEVT_MODIFY=1, RCLEVT_DELETE=2,
RCLEVT_DIRCREATE=3, RCLEVT_ISDIR=0x10};
RCLEVT_DIRCREATE=3, RCLEVT_ISDIR=0x10};
string m_path;
// Type and flags
int m_etyp;
@ -61,13 +61,13 @@ class RclMonEvent {
bool m_needidx;
RclMonEvent() : m_etyp(RCLEVT_NONE),
m_itvsecs(0), m_minclock(0), m_needidx(false) {}
m_itvsecs(0), m_minclock(0), m_needidx(false) {}
EvType evtype() {return EvType(m_etyp & 0xf);}
int evflags() {return m_etyp & 0xf0;}
};
enum RclMonitorOption {RCLMON_NONE=0, RCLMON_NOFORK=1, RCLMON_NOX11=2,
RCLMON_NOCONFCHECK=4};
RCLMON_NOCONFCHECK=4};
/**
* Monitoring event queue. This is the shared object between the main thread

View File

@ -142,19 +142,19 @@ public:
std::condition_variable m_cond;
RclEQData()
: m_config(0), m_ok(true)
: m_config(0), m_ok(true)
{
}
void readDelayPats(int dfltsecs);
DelayPat searchDelayPats(const string& path)
{
for (vector<DelayPat>::iterator it = m_delaypats.begin();
it != m_delaypats.end(); it++) {
if (fnmatch(it->pattern.c_str(), path.c_str(), 0) == 0) {
return *it;
}
}
return DelayPat();
for (vector<DelayPat>::iterator it = m_delaypats.begin();
it != m_delaypats.end(); it++) {
if (fnmatch(it->pattern.c_str(), path.c_str(), 0) == 0) {
return *it;
}
}
return DelayPat();
}
void delayInsert(const queue_type::iterator &qit);
};
@ -162,30 +162,30 @@ public:
void RclEQData::readDelayPats(int dfltsecs)
{
if (m_config == 0)
return;
return;
string patstring;
if (!m_config->getConfParam("mondelaypatterns", patstring) ||
patstring.empty())
return;
patstring.empty())
return;
vector<string> dplist;
if (!stringToStrings(patstring, dplist)) {
LOGERR("rclEQData: bad pattern list: [" << (patstring) << "]\n" );
return;
LOGERR("rclEQData: bad pattern list: [" << (patstring) << "]\n" );
return;
}
for (vector<string>::iterator it = dplist.begin();
it != dplist.end(); it++) {
string::size_type pos = it->find_last_of(":");
DelayPat dp;
dp.pattern = it->substr(0, pos);
if (pos != string::npos && pos != it->size()-1) {
dp.seconds = atoi(it->substr(pos+1).c_str());
} else {
dp.seconds = dfltsecs;
}
m_delaypats.push_back(dp);
LOGDEB2("rclmon::readDelayPats: add [" << (dp.pattern) << "] " << (dp.seconds) << "\n" );
it != dplist.end(); it++) {
string::size_type pos = it->find_last_of(":");
DelayPat dp;
dp.pattern = it->substr(0, pos);
if (pos != string::npos && pos != it->size()-1) {
dp.seconds = atoi(it->substr(pos+1).c_str());
} else {
dp.seconds = dfltsecs;
}
m_delaypats.push_back(dp);
LOGDEB2("rclmon::readDelayPats: add [" << (dp.pattern) << "] " << (dp.seconds) << "\n" );
}
}
@ -197,12 +197,12 @@ void RclEQData::delayInsert(const queue_type::iterator &qit)
MONDEB("RclEQData::delayInsert: minclock " << qit->second.m_minclock <<
std::endl);
for (delays_type::iterator dit = m_delays.begin();
dit != m_delays.end(); dit++) {
queue_type::iterator qit1 = *dit;
if ((*qit1).second.m_minclock > qit->second.m_minclock) {
m_delays.insert(dit, qit);
return;
}
dit != m_delays.end(); dit++) {
queue_type::iterator qit1 = *dit;
if ((*qit1).second.m_minclock > qit->second.m_minclock) {
m_delays.insert(dit, qit);
return;
}
}
m_delays.push_back(qit);
}
@ -220,7 +220,7 @@ RclMonEventQueue::~RclMonEventQueue()
void RclMonEventQueue::setopts(int opts)
{
if (m_data)
m_data->m_opts = opts;
m_data->m_opts = opts;
}
/** Wait until there is something to process on the queue, or timeout.
@ -232,22 +232,22 @@ std::unique_lock<std::mutex> RclMonEventQueue::wait(int seconds, bool *top)
MONDEB("RclMonEventQueue::wait, seconds: " << seconds << std::endl);
if (!empty()) {
MONDEB("RclMonEventQueue:: immediate return\n");
return lock;
MONDEB("RclMonEventQueue:: immediate return\n");
return lock;
}
int err;
if (seconds > 0) {
if (top)
*top = false;
if (m_data->m_cond.wait_for(lock, std::chrono::seconds(seconds)) ==
if (top)
*top = false;
if (m_data->m_cond.wait_for(lock, std::chrono::seconds(seconds)) ==
std::cv_status::timeout) {
*top = true;
MONDEB("RclMonEventQueue:: timeout\n");
return lock;
}
} else {
m_data->m_cond.wait(lock);
m_data->m_cond.wait(lock);
}
MONDEB("RclMonEventQueue:: non-timeout return\n");
return lock;
@ -269,16 +269,16 @@ RclConfig *RclMonEventQueue::getConfig()
bool RclMonEventQueue::ok()
{
if (m_data == 0) {
LOGINFO("RclMonEventQueue: not ok: bad state\n" );
return false;
LOGINFO("RclMonEventQueue: not ok: bad state\n" );
return false;
}
if (stopindexing) {
LOGINFO("RclMonEventQueue: not ok: stop request\n" );
return false;
LOGINFO("RclMonEventQueue: not ok: stop request\n" );
return false;
}
if (!m_data->m_ok) {
LOGINFO("RclMonEventQueue: not ok: queue terminated\n" );
return false;
LOGINFO("RclMonEventQueue: not ok: queue terminated\n" );
return false;
}
return true;
}
@ -295,24 +295,24 @@ void RclMonEventQueue::setTerminate()
bool RclMonEventQueue::empty()
{
if (m_data == 0) {
MONDEB("RclMonEventQueue::empty(): true (m_data==0)\n");
return true;
MONDEB("RclMonEventQueue::empty(): true (m_data==0)\n");
return true;
}
if (!m_data->m_iqueue.empty()) {
MONDEB("RclMonEventQueue::empty(): false (m_iqueue not empty)\n");
return true;
MONDEB("RclMonEventQueue::empty(): false (m_iqueue not empty)\n");
return true;
}
if (m_data->m_dqueue.empty()) {
MONDEB("RclMonEventQueue::empty(): true (m_Xqueue both empty)\n");
return true;
MONDEB("RclMonEventQueue::empty(): true (m_Xqueue both empty)\n");
return true;
}
// Only dqueue has events. Have to check the delays (only the
// first, earliest one):
queue_type::iterator qit = *(m_data->m_delays.begin());
if (qit->second.m_minclock > time(0)) {
MONDEB("RclMonEventQueue::empty(): true (no delay ready " <<
MONDEB("RclMonEventQueue::empty(): true (no delay ready " <<
qit->second.m_minclock << ")\n");
return true;
return true;
}
MONDEB("RclMonEventQueue::empty(): returning false (delay expired)\n");
return false;
@ -329,36 +329,36 @@ RclMonEvent RclMonEventQueue::pop()
// Look at the delayed events, get rid of the expired/unactive
// ones, possibly return an expired/needidx one.
while (!m_data->m_delays.empty()) {
delays_type::iterator dit = m_data->m_delays.begin();
queue_type::iterator qit = *dit;
MONDEB("RclMonEventQueue::pop(): in delays: evt minclock " <<
qit->second.m_minclock << std::endl);
if (qit->second.m_minclock <= now) {
if (qit->second.m_needidx) {
RclMonEvent ev = qit->second;
qit->second.m_minclock = time(0) + qit->second.m_itvsecs;
qit->second.m_needidx = false;
m_data->m_delays.erase(dit);
m_data->delayInsert(qit);
return ev;
} else {
// Delay elapsed without new update, get rid of event.
m_data->m_dqueue.erase(qit);
m_data->m_delays.erase(dit);
}
} else {
// This and following events are for later processing, we
// are done with the delayed event list.
break;
}
delays_type::iterator dit = m_data->m_delays.begin();
queue_type::iterator qit = *dit;
MONDEB("RclMonEventQueue::pop(): in delays: evt minclock " <<
qit->second.m_minclock << std::endl);
if (qit->second.m_minclock <= now) {
if (qit->second.m_needidx) {
RclMonEvent ev = qit->second;
qit->second.m_minclock = time(0) + qit->second.m_itvsecs;
qit->second.m_needidx = false;
m_data->m_delays.erase(dit);
m_data->delayInsert(qit);
return ev;
} else {
// Delay elapsed without new update, get rid of event.
m_data->m_dqueue.erase(qit);
m_data->m_delays.erase(dit);
}
} else {
// This and following events are for later processing, we
// are done with the delayed event list.
break;
}
}
// Look for non-delayed event
if (!m_data->m_iqueue.empty()) {
queue_type::iterator qit = m_data->m_iqueue.begin();
RclMonEvent ev = qit->second;
m_data->m_iqueue.erase(qit);
return ev;
queue_type::iterator qit = m_data->m_iqueue.begin();
RclMonEvent ev = qit->second;
m_data->m_iqueue.erase(qit);
return ev;
}
return RclMonEvent();
@ -376,32 +376,32 @@ bool RclMonEventQueue::pushEvent(const RclMonEvent &ev)
DelayPat pat = m_data->searchDelayPats(ev.m_path);
if (pat.seconds != 0) {
// Using delayed reindex queue. Need to take care of minclock and also
// insert into the in-minclock-order list
queue_type::iterator qit = m_data->m_dqueue.find(ev.m_path);
if (qit == m_data->m_dqueue.end()) {
// Not there yet, insert new
qit =
m_data->m_dqueue.insert(queue_type::value_type(ev.m_path, ev)).first;
// Set the time to next index to "now" as it has not been
// indexed recently (otherwise it would still be in the
// queue), and add the iterator to the delay queue.
qit->second.m_minclock = time(0);
qit->second.m_needidx = true;
qit->second.m_itvsecs = pat.seconds;
m_data->delayInsert(qit);
} else {
// Already in queue. Possibly update type but save minclock
// (so no need to touch m_delays). Flag as needing indexing
time_t saved_clock = qit->second.m_minclock;
qit->second = ev;
qit->second.m_minclock = saved_clock;
qit->second.m_needidx = true;
}
// Using delayed reindex queue. Need to take care of minclock and also
// insert into the in-minclock-order list
queue_type::iterator qit = m_data->m_dqueue.find(ev.m_path);
if (qit == m_data->m_dqueue.end()) {
// Not there yet, insert new
qit =
m_data->m_dqueue.insert(queue_type::value_type(ev.m_path, ev)).first;
// Set the time to next index to "now" as it has not been
// indexed recently (otherwise it would still be in the
// queue), and add the iterator to the delay queue.
qit->second.m_minclock = time(0);
qit->second.m_needidx = true;
qit->second.m_itvsecs = pat.seconds;
m_data->delayInsert(qit);
} else {
// Immediate event: just insert it, erasing any previously
// existing entry
m_data->m_iqueue[ev.m_path] = ev;
// Already in queue. Possibly update type but save minclock
// (so no need to touch m_delays). Flag as needing indexing
time_t saved_clock = qit->second.m_minclock;
qit->second = ev;
qit->second.m_minclock = saved_clock;
qit->second.m_needidx = true;
}
} else {
// Immediate event: just insert it, erasing any previously
// existing entry
m_data->m_iqueue[ev.m_path] = ev;
}
m_data->m_cond.notify_all();
@ -429,19 +429,19 @@ static bool expeditedIndexingRequested(RclConfig *conf)
{
static vector<string> rqfiles;
if (rqfiles.empty()) {
rqfiles.push_back(path_cat(conf->getConfDir(), "rclmonixnow"));
const char *cp;
if ((cp = getenv("RECOLL_CONFTOP"))) {
rqfiles.push_back(path_cat(cp, "rclmonixnow"));
}
if ((cp = getenv("RECOLL_CONFMID"))) {
rqfiles.push_back(path_cat(cp, "rclmonixnow"));
}
rqfiles.push_back(path_cat(conf->getConfDir(), "rclmonixnow"));
const char *cp;
if ((cp = getenv("RECOLL_CONFTOP"))) {
rqfiles.push_back(path_cat(cp, "rclmonixnow"));
}
if ((cp = getenv("RECOLL_CONFMID"))) {
rqfiles.push_back(path_cat(cp, "rclmonixnow"));
}
}
bool found = false;
for (vector<string>::const_iterator it = rqfiles.begin();
it != rqfiles.end(); it++) {
found = found || checkfileanddelete(*it);
it != rqfiles.end(); it++) {
found = found || checkfileanddelete(*it);
}
return found;
}
@ -449,9 +449,9 @@ static bool expeditedIndexingRequested(RclConfig *conf)
bool startMonitor(RclConfig *conf, int opts)
{
if (!conf->getConfParam("monauxinterval", &auxinterval))
auxinterval = dfltauxinterval;
auxinterval = dfltauxinterval;
if (!conf->getConfParam("monixinterval", &ixinterval))
ixinterval = dfltixinterval;
ixinterval = dfltixinterval;
rclEQ.setConfig(conf);
rclEQ.setopts(opts);
@ -533,14 +533,14 @@ bool startMonitor(RclConfig *conf, int opts)
}
now = time(0);
// Process. We don't do this every time but let the lists accumulate
// Process. We don't do this every time but let the lists accumulate
// a little, this saves processing. Start at once if list is big.
if (expeditedIndexingRequested(conf) ||
(now - lastixtime > ixinterval) ||
(deleted.size() + modified.size() > 20)) {
(now - lastixtime > ixinterval) ||
(deleted.size() + modified.size() > 20)) {
lastixtime = now;
// Used to do the modified list first, but it does seem
// smarter to make room first...
// Used to do the modified list first, but it does seem
// smarter to make room first...
if (!deleted.empty()) {
deleted.sort();
deleted.unique();
@ -559,28 +559,28 @@ bool startMonitor(RclConfig *conf, int opts)
}
}
// Recreate the auxiliary dbs every hour at most.
// Recreate the auxiliary dbs every hour at most.
now = time(0);
if (didsomething && now - lastauxtime > auxinterval) {
lastauxtime = now;
didsomething = false;
if (!createAuxDbs(conf)) {
// We used to bail out on error here. Not anymore,
// because this is most of the time due to a failure
// of aspell dictionary generation, which is not
// critical.
}
}
if (didsomething && now - lastauxtime > auxinterval) {
lastauxtime = now;
didsomething = false;
if (!createAuxDbs(conf)) {
// We used to bail out on error here. Not anymore,
// because this is most of the time due to a failure
// of aspell dictionary generation, which is not
// critical.
}
}
// Check for a config change
if (!(opts & RCLMON_NOCONFCHECK) && o_reexec && conf->sourceChanged()) {
LOGDEB("Rclmonprc: config changed, reexecuting myself\n" );
// We never want to have a -n option after a config
// change. -n was added by the reexec after the initial
// pass even if it was not given on the command line
o_reexec->removeArg("-n");
o_reexec->reexec();
}
// Check for a config change
if (!(opts & RCLMON_NOCONFCHECK) && o_reexec && conf->sourceChanged()) {
LOGDEB("Rclmonprc: config changed, reexecuting myself\n" );
// We never want to have a -n option after a config
// change. -n was added by the reexec after the initial
// pass even if it was not given on the command line
o_reexec->removeArg("-n");
o_reexec->reexec();
}
}
LOGDEB("Rclmonprc: calling queue setTerminate\n" );
rclEQ.setTerminate();

View File

@ -550,22 +550,22 @@ static void flushIdxReasons()
static vector<string> argstovector(int argc, char **argv)
{
vector<string> args;
for (int i = 0; i < argc; i++) {
args.push_back(argv[i]);
}
return args;
vector<string> args;
for (int i = 0; i < argc; i++) {
args.push_back(argv[i]);
}
return args;
}
static vector<string> fileToArgs(const string& fn)
{
string reason, data;
if (!file_to_string(fn, data, &reason)) {
cerr << "Failed reading args file " << fn << " errno " << errno << "\n";
exit(1);
}
vector<string> args;
stringToStrings(data, args);
return args;
string reason, data;
if (!file_to_string(fn, data, &reason)) {
cerr << "Failed reading args file " << fn << " errno " << errno << "\n";
exit(1);
}
vector<string> args;
stringToStrings(data, args);
return args;
}
int main(int argc, char **argv)
@ -585,23 +585,23 @@ int main(int argc, char **argv)
thisprog = path_absolute(argv[0]);
argc--; argv++;
vector<string> args = argstovector(argc, argv);
vector<string> args = argstovector(argc, argv);
// Passing args through a temp file: this is used on Windows to
// avoid issues with charsets in args (avoid using wmain)
if (args.size() == 1 && args[0][0] != '-') {
args = fileToArgs(args[0]);
}
// Passing args through a temp file: this is used on Windows to
// avoid issues with charsets in args (avoid using wmain)
if (args.size() == 1 && args[0][0] != '-') {
args = fileToArgs(args[0]);
}
unsigned int aremain = args.size();
unsigned int argidx = 0;
for (; argidx < args.size(); argidx++) {
const string& arg{args[argidx]};
aremain = args.size() - argidx;
if (arg[0] != '-') {
break;
}
for (unsigned int cidx = 1; cidx < arg.size(); cidx++) {
unsigned int aremain = args.size();
unsigned int argidx = 0;
for (; argidx < args.size(); argidx++) {
const string& arg{args[argidx]};
aremain = args.size() - argidx;
if (arg[0] != '-') {
break;
}
for (unsigned int cidx = 1; cidx < arg.size(); cidx++) {
switch (arg[cidx]) {
case 'b': op_flags |= OPT_b; break;
case 'c': op_flags |= OPT_c; if (aremain < 2) Usage();
@ -639,10 +639,10 @@ int main(int argc, char **argv)
case 'z': op_flags |= OPT_z; break;
default: Usage(); break;
}
}
b1:
;
}
}
b1:
;
}
aremain = args.size() - argidx;
if (op_flags & OPT_h)

View File

@ -28,13 +28,13 @@
#include "log.h"
bool subtreelist(RclConfig *config, const string& top,
vector<string>& paths)
vector<string>& paths)
{
LOGDEB("subtreelist: top: [" << (top) << "]\n" );
Rcl::Db rcldb(config);
if (!rcldb.open(Rcl::Db::DbRO)) {
LOGERR("subtreelist: can't open database in [" << (config->getDbDir()) << "]: " << (rcldb.getReason()) << "\n" );
return false;
LOGERR("subtreelist: can't open database in [" << (config->getDbDir()) << "]: " << (rcldb.getReason()) << "\n" );
return false;
}
Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_OR, cstr_null);
@ -47,12 +47,12 @@ bool subtreelist(RclConfig *config, const string& top,
int cnt = query.getResCnt();
for (int i = 0; i < cnt; i++) {
Rcl::Doc doc;
if (!query.getDoc(i, doc))
break;
string path = fileurltolocalpath(doc.url);
if (!path.empty())
paths.push_back(path);
Rcl::Doc doc;
if (!query.getDoc(i, doc))
break;
string path = fileurltolocalpath(doc.url);
if (!path.empty())
paths.push_back(path);
}
return true;
}
@ -104,26 +104,26 @@ int main(int argc, char **argv)
switch (*(*argv)++) {
default: Usage(); break;
}
argc--; argv++;
argc--; argv++;
}
if (argc < 1)
Usage();
Usage();
top = *argv++;argc--;
string reason;
RclConfig *config = recollinit(0, 0, 0, reason, 0);
if (!config || !config->ok()) {
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
exit(1);
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
exit(1);
}
vector<string> paths;
if (!subtreelist(config, top, paths)) {
cerr << "subtreelist failed" << endl;
exit(1);
cerr << "subtreelist failed" << endl;
exit(1);
}
for (vector<string>::const_iterator it = paths.begin();
it != paths.end(); it++) {
cout << *it << endl;
it != paths.end(); it++) {
cout << *it << endl;
}
exit(0);
}

View File

@ -28,6 +28,6 @@ class RclConfig;
// the real time indexer to purge entries when a top directory is
// renamed. This is really convoluted, I'd like a better way.
extern bool subtreelist(RclConfig *config, const string& top,
std::vector<std::string>& paths);
std::vector<std::string>& paths);
#endif /* _SUBTREELIST_H_INCLUDED_ */

View File

@ -35,23 +35,23 @@ bool WQDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
{
string udi;
if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
LOGERR("WQDocFetcher:: no udi in idoc\n" );
return false;
LOGERR("WQDocFetcher:: no udi in idoc\n" );
return false;
}
Rcl::Doc dotdoc;
{
std::unique_lock<std::mutex> locker(o_beagler_mutex);
// Retrieve from our webcache (beagle data). The beagler
// object is created at the first call of this routine and
// deleted when the program exits.
static WebStore o_beagler(cnf);
if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {
LOGINFO("WQDocFetcher::fetch: failed for [" << udi << "]\n");
return false;
}
// Retrieve from our webcache (beagle data). The beagler
// object is created at the first call of this routine and
// deleted when the program exits.
static WebStore o_beagler(cnf);
if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {
LOGINFO("WQDocFetcher::fetch: failed for [" << udi << "]\n");
return false;
}
}
if (dotdoc.mimetype.compare(idoc.mimetype)) {
LOGINFO("WQDocFetcher:: udi [" << udi << "], mimetp mismatch: in: [" <<
LOGINFO("WQDocFetcher:: udi [" << udi << "], mimetp mismatch: in: [" <<
idoc.mimetype << "], bgl [" << dotdoc.mimetype << "]\n");
}
out.kind = RawDoc::RDK_DATA;

View File

@ -30,20 +30,20 @@ using std::string;
using std::map;
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);
LOGDEB0("Internfile:: setting [" << fieldname <<
"] from cmd/xattr value [" << value << "]\n");
if (fieldname == cstr_dj_keymd) {
doc.dmtime = value;
doc.dmtime = value;
} else {
doc.meta[fieldname] = value;
doc.meta[fieldname] = value;
}
}
void reapXAttrs(const RclConfig* cfg, const string& path,
map<string, string>& xfields)
map<string, string>& xfields)
{
LOGDEB2("reapXAttrs: [" << path << "]\n");
#ifndef _WIN32
@ -57,7 +57,7 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
LOGERR("FileInterner::reapXattrs: pxattr::list: errno " <<
errno << "\n");
}
return;
return;
}
const map<string, string>& xtof = cfg->getXattrToField();
@ -65,25 +65,25 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
// or mapped depending if the translation is empty. Other names
// are recorded as-is
for (vector<string>::const_iterator it = xnames.begin();
it != xnames.end(); it++) {
string key = *it;
map<string, string>::const_iterator mit = xtof.find(*it);
if (mit != xtof.end()) {
if (mit->second.empty()) {
continue;
} else {
key = mit->second;
}
}
string value;
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
LOGERR("FileInterner::reapXattrs: pxattr::get failed for " << *it
it != xnames.end(); it++) {
string key = *it;
map<string, string>::const_iterator mit = xtof.find(*it);
if (mit != xtof.end()) {
if (mit->second.empty()) {
continue;
} else {
key = mit->second;
}
}
string value;
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
LOGERR("FileInterner::reapXattrs: pxattr::get failed for " << *it
<< ", errno " << errno << "\n");
continue;
}
// Encode should we ?
xfields[key] = value;
LOGDEB2("reapXAttrs: [" << key << "] -> [" << value << "]\n");
continue;
}
// Encode should we ?
xfields[key] = value;
LOGDEB2("reapXAttrs: [" << key << "] -> [" << value << "]\n");
}
#else
PRETEND_USE(cfg);
@ -93,34 +93,34 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
}
void docFieldsFromXattrs(RclConfig *cfg, const map<string, string>& xfields,
Rcl::Doc& doc)
Rcl::Doc& doc)
{
for (map<string,string>::const_iterator it = xfields.begin();
it != xfields.end(); it++) {
docfieldfrommeta(cfg, it->first, it->second, doc);
it != xfields.end(); it++) {
docfieldfrommeta(cfg, it->first, it->second, doc);
}
}
void reapMetaCmds(RclConfig* cfg, const string& path,
map<string, string>& cfields)
map<string, string>& cfields)
{
const vector<MDReaper>& reapers = cfg->getMDReapers();
if (reapers.empty())
return;
return;
map<char,string> smap = {{'f', path}};
for (vector<MDReaper>::const_iterator rp = reapers.begin();
rp != reapers.end(); rp++) {
vector<string> cmd;
for (vector<string>::const_iterator it = rp->cmdv.begin();
it != rp->cmdv.end(); it++) {
string s;
pcSubst(*it, s, smap);
cmd.push_back(s);
}
string output;
if (ExecCmd::backtick(cmd, output)) {
cfields[rp->fieldname] = output;
}
rp != reapers.end(); rp++) {
vector<string> cmd;
for (vector<string>::const_iterator it = rp->cmdv.begin();
it != rp->cmdv.end(); it++) {
string s;
pcSubst(*it, s, smap);
cmd.push_back(s);
}
string output;
if (ExecCmd::backtick(cmd, output)) {
cfields[rp->fieldname] = output;
}
}
}
@ -133,25 +133,25 @@ void reapMetaCmds(RclConfig* cfg, const string& path,
// and the output from anything beginning with "rclmulti" will be
// interpreted as multiple fields in configuration file format...
void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields,
Rcl::Doc& doc)
Rcl::Doc& doc)
{
for (map<string,string>::const_iterator it = cfields.begin();
it != cfields.end(); it++) {
if (!it->first.compare(0, 8, "rclmulti")) {
ConfSimple simple(it->second);
if (simple.ok()) {
vector<string> names = simple.getNames("");
for (vector<string>::const_iterator nm = names.begin();
nm != names.end(); nm++) {
string value;
if (simple.get(*nm, value)) {
docfieldfrommeta(cfg, *nm, value, doc);
}
}
}
} else {
docfieldfrommeta(cfg, it->first, it->second, doc);
}
it != cfields.end(); it++) {
if (!it->first.compare(0, 8, "rclmulti")) {
ConfSimple simple(it->second);
if (simple.ok()) {
vector<string> names = simple.getNames("");
for (vector<string>::const_iterator nm = names.begin();
nm != names.end(); nm++) {
string value;
if (simple.get(*nm, value)) {
docfieldfrommeta(cfg, *nm, value, doc);
}
}
}
} else {
docfieldfrommeta(cfg, it->first, it->second, doc);
}
}
}

View File

@ -30,7 +30,7 @@ namespace Rcl {class Doc;};
/** Read external attributes, possibly ignore some or change the names
according to the fields configuration */
extern void reapXAttrs(const RclConfig* config, const std::string& path,
std::map<std::string, std::string>& xfields);
std::map<std::string, std::string>& xfields);
/** Turn the pre-processed extended file attributes into doc fields */
extern void docFieldsFromXattrs(
@ -39,7 +39,7 @@ extern void docFieldsFromXattrs(
/** Get metadata by executing commands */
extern void reapMetaCmds(RclConfig* config, const std::string& path,
std::map<std::string, std::string>& xfields);
std::map<std::string, std::string>& xfields);
/** Turn the pre-processed ext cmd metadata into doc fields */
extern void docFieldsFromMetaCmds(

View File

@ -34,7 +34,7 @@ inline void
lowercase_string(string &str)
{
for (string::iterator i = str.begin(); i != str.end(); ++i) {
*i = tolower(static_cast<unsigned char>(*i));
*i = tolower(static_cast<unsigned char>(*i));
}
}
@ -68,7 +68,7 @@ inline static bool
p_nottag(char c)
{
return !isalnum(static_cast<unsigned char>(c)) &&
c != '.' && c != '-' && c != ':'; // ':' for XML namespaces.
c != '.' && c != '-' && c != ':'; // ':' for XML namespaces.
}
inline static bool
@ -99,14 +99,14 @@ HtmlParser::HtmlParser()
#if 0
static const struct ent { const char *n; unsigned int v; } ents[] = {
#include "namedentities.h"
{ NULL, 0 }
{ NULL, 0 }
};
if (named_ents.empty()) {
const struct ent *i = ents;
while (i->n) {
named_ents[string(i->n)] = i->v;
++i;
}
const struct ent *i = ents;
while (i->n) {
named_ents[string(i->n)] = i->v;
++i;
}
}
#endif
}
@ -123,45 +123,45 @@ HtmlParser::decode_entities(string &)
// find() and find_if() templates don't work...
string::const_iterator amp = s.begin(), s_end = s.end();
while ((amp = find(amp, s_end, '&')) != s_end) {
unsigned int val = 0;
string::const_iterator end, p = amp + 1;
if (p != s_end && *p == '#') {
p++;
if (p != s_end && (*p == 'x' || *p == 'X')) {
// hex
p++;
end = find_if(p, s_end, p_notxdigit);
sscanf(s.substr(p - s.begin(), end - p).c_str(), "%x", &val);
} else {
// number
end = find_if(p, s_end, p_notdigit);
val = atoi(s.substr(p - s.begin(), end - p).c_str());
}
} else {
end = find_if(p, s_end, p_notalnum);
string code = s.substr(p - s.begin(), end - p);
map<string, unsigned int>::const_iterator i;
i = named_ents.find(code);
if (i != named_ents.end()) val = i->second;
}
if (end < s_end && *end == ';') end++;
if (val) {
string::size_type amp_pos = amp - s.begin();
if (val < 0x80) {
s.replace(amp_pos, end - amp, 1u, char(val));
} else {
// Convert unicode value val to UTF-8.
char seq[4];
unsigned len = Xapian::Unicode::nonascii_to_utf8(val, seq);
s.replace(amp_pos, end - amp, seq, len);
}
s_end = s.end();
// We've modified the string, so the iterators are no longer
// valid...
amp = s.begin() + amp_pos + 1;
} else {
amp = end;
}
unsigned int val = 0;
string::const_iterator end, p = amp + 1;
if (p != s_end && *p == '#') {
p++;
if (p != s_end && (*p == 'x' || *p == 'X')) {
// hex
p++;
end = find_if(p, s_end, p_notxdigit);
sscanf(s.substr(p - s.begin(), end - p).c_str(), "%x", &val);
} else {
// number
end = find_if(p, s_end, p_notdigit);
val = atoi(s.substr(p - s.begin(), end - p).c_str());
}
} else {
end = find_if(p, s_end, p_notalnum);
string code = s.substr(p - s.begin(), end - p);
map<string, unsigned int>::const_iterator i;
i = named_ents.find(code);
if (i != named_ents.end()) val = i->second;
}
if (end < s_end && *end == ';') end++;
if (val) {
string::size_type amp_pos = amp - s.begin();
if (val < 0x80) {
s.replace(amp_pos, end - amp, 1u, char(val));
} else {
// Convert unicode value val to UTF-8.
char seq[4];
unsigned len = Xapian::Unicode::nonascii_to_utf8(val, seq);
s.replace(amp_pos, end - amp, seq, len);
}
s_end = s.end();
// We've modified the string, so the iterators are no longer
// valid...
amp = s.begin() + amp_pos + 1;
} else {
amp = end;
}
}
#endif
}
@ -175,222 +175,222 @@ HtmlParser::parse_html(const string &body)
string::const_iterator start = body.begin();
while (true) {
// Skip through until we find an HTML tag, a comment, or the end of
// document. Ignore isolated occurrences of `<' which don't start
// a tag or comment.
string::const_iterator p = start;
while (true) {
p = find(p, body.end(), '<');
if (p == body.end()) break;
unsigned char ch = *(p + 1);
// Skip through until we find an HTML tag, a comment, or the end of
// document. Ignore isolated occurrences of `<' which don't start
// a tag or comment.
string::const_iterator p = start;
while (true) {
p = find(p, body.end(), '<');
if (p == body.end()) break;
unsigned char ch = *(p + 1);
// Tag, closing tag, or comment (or SGML declaration).
if ((!in_script && isalpha(ch)) || ch == '/' || ch == '!') break;
// Tag, closing tag, or comment (or SGML declaration).
if ((!in_script && isalpha(ch)) || ch == '/' || ch == '!') break;
if (ch == '?') {
// PHP code or XML declaration.
// XML declaration is only valid at the start of the first line.
// FIXME: need to deal with BOMs...
if (p != body.begin() || body.size() < 20) break;
if (ch == '?') {
// PHP code or XML declaration.
// XML declaration is only valid at the start of the first line.
// FIXME: need to deal with BOMs...
if (p != body.begin() || body.size() < 20) break;
// XML declaration looks something like this:
// <?xml version="1.0" encoding="UTF-8"?>
if (p[2] != 'x' || p[3] != 'm' || p[4] != 'l') break;
if (strchr(" \t\r\n", p[5]) == NULL) break;
// XML declaration looks something like this:
// <?xml version="1.0" encoding="UTF-8"?>
if (p[2] != 'x' || p[3] != 'm' || p[4] != 'l') break;
if (strchr(" \t\r\n", p[5]) == NULL) break;
string::const_iterator decl_end = find(p + 6, body.end(), '?');
if (decl_end == body.end()) break;
string::const_iterator decl_end = find(p + 6, body.end(), '?');
if (decl_end == body.end()) break;
// Default charset for XML is UTF-8.
charset = "utf-8";
// Default charset for XML is UTF-8.
charset = "utf-8";
string decl(p + 6, decl_end);
size_t enc = decl.find("encoding");
if (enc == string::npos) break;
string decl(p + 6, decl_end);
size_t enc = decl.find("encoding");
if (enc == string::npos) break;
enc = decl.find_first_not_of(" \t\r\n", enc + 8);
if (enc == string::npos || enc == decl.size()) break;
enc = decl.find_first_not_of(" \t\r\n", enc + 8);
if (enc == string::npos || enc == decl.size()) break;
if (decl[enc] != '=') break;
if (decl[enc] != '=') break;
enc = decl.find_first_not_of(" \t\r\n", enc + 1);
if (enc == string::npos || enc == decl.size()) break;
enc = decl.find_first_not_of(" \t\r\n", enc + 1);
if (enc == string::npos || enc == decl.size()) break;
if (decl[enc] != '"' && decl[enc] != '\'') break;
if (decl[enc] != '"' && decl[enc] != '\'') break;
char quote = decl[enc++];
size_t enc_end = decl.find(quote, enc);
char quote = decl[enc++];
size_t enc_end = decl.find(quote, enc);
if (enc != string::npos)
charset = decl.substr(enc, enc_end - enc);
if (enc != string::npos)
charset = decl.substr(enc, enc_end - enc);
break;
}
p++;
}
break;
}
p++;
}
// Process text up to start of tag.
if (p > start || p == body.end()) {
string text = body.substr(start - body.begin(), p - start);
decode_entities(text);
process_text(text);
}
// Process text up to start of tag.
if (p > start || p == body.end()) {
string text = body.substr(start - body.begin(), p - start);
decode_entities(text);
process_text(text);
}
if (p == body.end()) {
do_eof();
break;
}
if (p == body.end()) {
do_eof();
break;
}
start = p + 1;
start = p + 1;
if (start == body.end()) break;
if (start == body.end()) break;
if (*start == '!') {
if (++start == body.end()) break;
if (++start == body.end()) break;
// comment or SGML declaration
if (*(start - 1) == '-' && *start == '-') {
++start;
string::const_iterator close = find(start, body.end(), '>');
// An unterminated comment swallows rest of document
// (like Netscape, but unlike MSIE IIRC)
if (close == body.end()) break;
if (*start == '!') {
if (++start == body.end()) break;
if (++start == body.end()) break;
// comment or SGML declaration
if (*(start - 1) == '-' && *start == '-') {
++start;
string::const_iterator close = find(start, body.end(), '>');
// An unterminated comment swallows rest of document
// (like Netscape, but unlike MSIE IIRC)
if (close == body.end()) break;
p = close;
// look for -->
while (p != body.end() && (*(p - 1) != '-' || *(p - 2) != '-'))
p = find(p + 1, body.end(), '>');
p = close;
// look for -->
while (p != body.end() && (*(p - 1) != '-' || *(p - 2) != '-'))
p = find(p + 1, body.end(), '>');
if (p != body.end()) {
// Check for htdig's "ignore this bit" comments.
if (p - start == 15 && string(start, p - 2) == "htdig_noindex") {
string::size_type i;
i = body.find("<!--/htdig_noindex-->", p + 1 - body.begin());
if (i == string::npos) break;
start = body.begin() + i + 21;
continue;
}
// If we found --> skip to there.
start = p;
} else {
// Otherwise skip to the first > we found (as Netscape does).
start = close;
}
} else {
// just an SGML declaration, perhaps giving the DTD - ignore it
start = find(start - 1, body.end(), '>');
if (start == body.end()) break;
}
++start;
} else if (*start == '?') {
if (++start == body.end()) break;
// PHP - swallow until ?> or EOF
start = find(start + 1, body.end(), '>');
if (p != body.end()) {
// Check for htdig's "ignore this bit" comments.
if (p - start == 15 && string(start, p - 2) == "htdig_noindex") {
string::size_type i;
i = body.find("<!--/htdig_noindex-->", p + 1 - body.begin());
if (i == string::npos) break;
start = body.begin() + i + 21;
continue;
}
// If we found --> skip to there.
start = p;
} else {
// Otherwise skip to the first > we found (as Netscape does).
start = close;
}
} else {
// just an SGML declaration, perhaps giving the DTD - ignore it
start = find(start - 1, body.end(), '>');
if (start == body.end()) break;
}
++start;
} else if (*start == '?') {
if (++start == body.end()) break;
// PHP - swallow until ?> or EOF
start = find(start + 1, body.end(), '>');
// look for ?>
while (start != body.end() && *(start - 1) != '?')
start = find(start + 1, body.end(), '>');
// look for ?>
while (start != body.end() && *(start - 1) != '?')
start = find(start + 1, body.end(), '>');
// unterminated PHP swallows rest of document (rather arbitrarily
// but it avoids polluting the database when things go wrong)
if (start != body.end()) ++start;
} else {
// opening or closing tag
int closing = 0;
// unterminated PHP swallows rest of document (rather arbitrarily
// but it avoids polluting the database when things go wrong)
if (start != body.end()) ++start;
} else {
// opening or closing tag
int closing = 0;
if (*start == '/') {
closing = 1;
start = find_if(start + 1, body.end(), p_notwhitespace);
}
if (*start == '/') {
closing = 1;
start = find_if(start + 1, body.end(), p_notwhitespace);
}
p = start;
start = find_if(start, body.end(), p_nottag);
string tag = body.substr(p - body.begin(), start - p);
// convert tagname to lowercase
lowercase_string(tag);
p = start;
start = find_if(start, body.end(), p_nottag);
string tag = body.substr(p - body.begin(), start - p);
// convert tagname to lowercase
lowercase_string(tag);
if (closing) {
if (!closing_tag(tag))
return;
if (in_script && tag == "script") in_script = false;
if (closing) {
if (!closing_tag(tag))
return;
if (in_script && tag == "script") in_script = false;
/* ignore any bogus parameters on closing tags */
p = find(start, body.end(), '>');
if (p == body.end()) break;
start = p + 1;
} else {
bool empty_element = false;
// FIXME: parse parameters lazily.
while (start < body.end() && *start != '>') {
string name, value;
/* ignore any bogus parameters on closing tags */
p = find(start, body.end(), '>');
if (p == body.end()) break;
start = p + 1;
} else {
bool empty_element = false;
// FIXME: parse parameters lazily.
while (start < body.end() && *start != '>') {
string name, value;
p = find_if(start, body.end(), p_whitespaceeqgt);
p = find_if(start, body.end(), p_whitespaceeqgt);
size_t name_len = p - start;
if (name_len == 1) {
if (*start == '/' && p < body.end() && *p == '>') {
// E.g. <tag foo="bar" />
start = p;
empty_element = true;
break;
}
}
size_t name_len = p - start;
if (name_len == 1) {
if (*start == '/' && p < body.end() && *p == '>') {
// E.g. <tag foo="bar" />
start = p;
empty_element = true;
break;
}
}
name.assign(body, start - body.begin(), name_len);
name.assign(body, start - body.begin(), name_len);
p = find_if(p, body.end(), p_notwhitespace);
p = find_if(p, body.end(), p_notwhitespace);
start = p;
if (start != body.end() && *start == '=') {
start = find_if(start + 1, body.end(), p_notwhitespace);
start = p;
if (start != body.end() && *start == '=') {
start = find_if(start + 1, body.end(), p_notwhitespace);
p = body.end();
p = body.end();
int quote = *start;
if (quote == '"' || quote == '\'') {
start++;
p = find(start, body.end(), quote);
}
int quote = *start;
if (quote == '"' || quote == '\'') {
start++;
p = find(start, body.end(), quote);
}
if (p == body.end()) {
// unquoted or no closing quote
p = find_if(start, body.end(), p_whitespacegt);
}
value.assign(body, start - body.begin(), p - start);
start = find_if(p, body.end(), p_notwhitespace);
if (p == body.end()) {
// unquoted or no closing quote
p = find_if(start, body.end(), p_whitespacegt);
}
value.assign(body, start - body.begin(), p - start);
start = find_if(p, body.end(), p_notwhitespace);
if (!name.empty()) {
// convert parameter name to lowercase
lowercase_string(name);
// in case of multiple entries, use the first
// (as Netscape does)
parameters.insert(make_pair(name, value));
}
}
}
if (!name.empty()) {
// convert parameter name to lowercase
lowercase_string(name);
// in case of multiple entries, use the first
// (as Netscape does)
parameters.insert(make_pair(name, value));
}
}
}
#if 0
cout << "<" << tag;
map<string, string>::const_iterator x;
for (x = parameters.begin(); x != parameters.end(); x++) {
cout << " " << x->first << "=\"" << x->second << "\"";
}
cout << ">\n";
cout << "<" << tag;
map<string, string>::const_iterator x;
for (x = parameters.begin(); x != parameters.end(); x++) {
cout << " " << x->first << "=\"" << x->second << "\"";
}
cout << ">\n";
#endif
if (!opening_tag(tag))
return;
parameters.clear();
if (!opening_tag(tag))
return;
parameters.clear();
if (empty_element) {
if (!closing_tag(tag))
return;
}
if (empty_element) {
if (!closing_tag(tag))
return;
}
// In <script> tags we ignore opening tags to avoid problems
// with "a<b".
if (tag == "script") in_script = true;
// In <script> tags we ignore opening tags to avoid problems
// with "a<b".
if (tag == "script") in_script = true;
if (start != body.end() && *start == '>') ++start;
}
}
if (start != body.end() && *start == '>') ++start;
}
}
}
}

View File

@ -31,22 +31,22 @@ using std::string;
using std::map;
class HtmlParser {
map<string, string> parameters;
map<string, string> parameters;
protected:
virtual void decode_entities(string &s);
bool in_script;
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:
virtual void process_text(const string &/*text*/) { }
virtual bool opening_tag(const string &/*tag*/) { return true; }
virtual void process_text(const string &/*text*/) { }
virtual bool opening_tag(const string &/*tag*/) { return true; }
virtual bool closing_tag(const string &/*tag*/) { return true; }
virtual void parse_html(const string &text);
virtual void do_eof() {}
HtmlParser();
virtual ~HtmlParser() { }
virtual void parse_html(const string &text);
virtual void do_eof() {}
HtmlParser();
virtual ~HtmlParser() { }
};
#endif

View File

@ -26,8 +26,8 @@ lowercase_term(std::string &term)
{
std::string::iterator i = term.begin();
while (i != term.end()) {
if (*i >= 'A' && *i <= 'Z')
*i = *i + 'a' - 'A';
if (*i >= 'A' && *i <= 'Z')
*i = *i + 'a' - 'A';
i++;
}
}

View File

@ -129,18 +129,18 @@ bool MimeHandlerExec::skip_to_document(const string& ipath)
bool MimeHandlerExec::next_document()
{
if (m_havedoc == false)
return false;
return false;
m_havedoc = false;
if (missingHelper) {
LOGDEB("MimeHandlerExec::next_document(): helper known missing\n");
return false;
LOGDEB("MimeHandlerExec::next_document(): helper known missing\n");
return false;
}
if (params.empty()) {
// Hu ho
LOGERR("MimeHandlerExec::next_document: empty params\n");
m_reason = "RECFILTERROR BADCONFIG";
return false;
// Hu ho
LOGERR("MimeHandlerExec::next_document: empty params\n");
m_reason = "RECFILTERROR BADCONFIG";
return false;
}
// Command name
@ -150,7 +150,7 @@ bool MimeHandlerExec::next_document()
vector<string>myparams(params.begin() + 1, params.end());
myparams.push_back(m_fn);
if (!m_ipath.empty())
myparams.push_back(m_ipath);
myparams.push_back(m_ipath);
// Execute command, store the output
string& output = m_metaData[cstr_dj_keycontent];
@ -167,40 +167,40 @@ bool MimeHandlerExec::next_document()
try {
status = mexec.doexec(cmd, myparams, 0, &output);
} catch (HandlerTimeout) {
LOGERR("MimeHandlerExec: handler timeout\n" );
LOGERR("MimeHandlerExec: handler timeout\n" );
status = 0x110f;
} catch (CancelExcept) {
LOGERR("MimeHandlerExec: cancelled\n" );
LOGERR("MimeHandlerExec: cancelled\n" );
status = 0x110f;
}
if (status) {
LOGERR("MimeHandlerExec: command status 0x" <<
LOGERR("MimeHandlerExec: command status 0x" <<
std::hex << status << std::dec << " for " << cmd << "\n");
if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
// That's how execmd signals a failed exec (most probably
// a missing command). Let'hope no filter uses the same value as
// an exit status... Disable myself permanently and signal the
// missing cmd.
missingHelper = true;
m_reason = string("RECFILTERROR HELPERNOTFOUND ") + cmd;
} else if (output.find("RECFILTERROR") == 0) {
// If the output string begins with RECFILTERROR, then it's
// interpretable error information out from a recoll script
m_reason = output;
list<string> lerr;
stringToStrings(output, lerr);
if (lerr.size() > 2) {
list<string>::iterator it = lerr.begin();
it++;
if (*it == "HELPERNOTFOUND") {
// No use trying again and again to execute this filter,
// it won't work.
missingHelper = true;
}
}
}
return false;
if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
// That's how execmd signals a failed exec (most probably
// a missing command). Let'hope no filter uses the same value as
// an exit status... Disable myself permanently and signal the
// missing cmd.
missingHelper = true;
m_reason = string("RECFILTERROR HELPERNOTFOUND ") + cmd;
} else if (output.find("RECFILTERROR") == 0) {
// If the output string begins with RECFILTERROR, then it's
// interpretable error information out from a recoll script
m_reason = output;
list<string> lerr;
stringToStrings(output, lerr);
if (lerr.size() > 2) {
list<string>::iterator it = lerr.begin();
it++;
if (*it == "HELPERNOTFOUND") {
// No use trying again and again to execute this filter,
// it won't work.
missingHelper = true;
}
}
}
return false;
}
finaldetails();
@ -216,19 +216,19 @@ void MimeHandlerExec::handle_cs(const string& mt, const string& icharset)
// "default", we use the default input charset value defined in
// recoll.conf (which may vary depending on directory)
if (charset.empty()) {
charset = cfgFilterOutputCharset.empty() ? cstr_utf8 :
cfgFilterOutputCharset;
if (!stringlowercmp("default", charset)) {
charset = m_dfltInputCharset;
}
charset = cfgFilterOutputCharset.empty() ? cstr_utf8 :
cfgFilterOutputCharset;
if (!stringlowercmp("default", charset)) {
charset = m_dfltInputCharset;
}
}
m_metaData[cstr_dj_keyorigcharset] = charset;
// If this is text/plain transcode_to/check utf-8
if (!mt.compare(cstr_textplain)) {
(void)txtdcode("mh_exec/m");
(void)txtdcode("mh_exec/m");
} else {
m_metaData[cstr_dj_keycharset] = charset;
m_metaData[cstr_dj_keycharset] = charset;
}
}
@ -237,16 +237,16 @@ void MimeHandlerExec::finaldetails()
// The default output mime type is html, but it may be defined
// otherwise in the filter definition.
m_metaData[cstr_dj_keymt] = cfgFilterOutputMtype.empty() ? cstr_texthtml :
cfgFilterOutputMtype;
cfgFilterOutputMtype;
if (!m_forPreview && !m_nomd5) {
string md5, xmd5, reason;
if (MD5File(m_fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else {
LOGERR("MimeHandlerExec: cant compute md5 for [" << m_fn << "]: " <<
string md5, xmd5, reason;
if (MD5File(m_fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else {
LOGERR("MimeHandlerExec: cant compute md5 for [" << m_fn << "]: " <<
reason << "\n");
}
}
}
handle_cs(m_metaData[cstr_dj_keymt]);

View File

@ -74,8 +74,8 @@ class MimeHandlerExec : public RecollFilter {
virtual bool skip_to_document(const std::string& ipath) override;
virtual void clear_impl() override {
m_fn.erase();
m_ipath.erase();
m_fn.erase();
m_ipath.erase();
}
protected:

View File

@ -27,22 +27,22 @@
class MimeHandlerHtml : public RecollFilter {
public:
MimeHandlerHtml(RclConfig *cnf, const std::string& id)
: RecollFilter(cnf, id) {
: RecollFilter(cnf, id) {
}
virtual ~MimeHandlerHtml() {}
virtual bool is_data_input_ok(DataInput input) const override {
if (input == DOCUMENT_FILE_NAME || input == DOCUMENT_STRING)
return true;
return false;
if (input == DOCUMENT_FILE_NAME || input == DOCUMENT_STRING)
return true;
return false;
}
virtual bool next_document() override;
const std::string& get_html() {
return m_html;
return m_html;
}
virtual void clear_impl() override {
m_filename.erase();
m_html.erase();
m_filename.erase();
m_html.erase();
}
protected:
virtual bool set_document_file_impl(const std::string& mt,

View File

@ -298,7 +298,7 @@ public:
};
MimeHandlerMbox::MimeHandlerMbox(RclConfig *cnf, const std::string& id)
: RecollFilter(cnf, id)
: RecollFilter(cnf, id)
{
m = new Internal(this);

View File

@ -35,7 +35,7 @@
class MimeHandlerNull : public RecollFilter {
public:
MimeHandlerNull(RclConfig *cnf, const std::string& id)
: RecollFilter(cnf, id) {
: RecollFilter(cnf, id) {
}
virtual ~MimeHandlerNull() {}
@ -45,12 +45,12 @@ class MimeHandlerNull : public RecollFilter {
virtual bool next_document()
{
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
}
};

View File

@ -36,33 +36,33 @@
class MimeHandlerSymlink : public RecollFilter {
public:
MimeHandlerSymlink(RclConfig *cnf, const std::string& id)
: RecollFilter(cnf, id) {
: RecollFilter(cnf, id) {
}
virtual ~MimeHandlerSymlink() {}
virtual bool next_document()
{
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
char lc[1024];
ssize_t bytes = readlink(m_fn.c_str(), lc, 1024);
if (bytes != (ssize_t)-1) {
string slc(lc, bytes);
transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent],
m_config->getDefCharset(true), "UTF-8");
} else {
LOGDEB("Symlink: readlink [" << m_fn << "] failed, errno " <<
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
char lc[1024];
ssize_t bytes = readlink(m_fn.c_str(), lc, 1024);
if (bytes != (ssize_t)-1) {
string slc(lc, bytes);
transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent],
m_config->getDefCharset(true), "UTF-8");
} else {
LOGDEB("Symlink: readlink [" << m_fn << "] failed, errno " <<
errno << "\n");
}
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
}
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
}
protected:
virtual bool set_document_file_impl(const string&, const string& fn) {
m_fn = fn;
return m_havedoc = true;
m_fn = fn;
return m_havedoc = true;
}
private:

View File

@ -86,9 +86,9 @@ bool MimeHandlerText::set_document_file_impl(const string&, const string &fn)
"), contents will not be indexed: " << fn << endl);
}
if (!m_forPreview) {
string md5, xmd5;
MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
string md5, xmd5;
MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
}
m_havedoc = true;
return true;
@ -99,9 +99,9 @@ bool MimeHandlerText::set_document_string_impl(const string&,
{
m_text = otext;
if (!m_forPreview) {
string md5, xmd5;
MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
string md5, xmd5;
MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
}
m_havedoc = true;
return true;
@ -112,9 +112,9 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
char *endptr;
int64_t t = strtoll(ipath.c_str(), &endptr, 10);
if (endptr == ipath.c_str()) {
LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" <<
LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" <<
ipath << "]\n");
return false;
return false;
}
m_offs = t;
readnext();
@ -126,12 +126,12 @@ bool MimeHandlerText::next_document()
LOGDEB("MimeHandlerText::next_document: m_havedoc " << m_havedoc << "\n");
if (m_havedoc == false)
return false;
return false;
if (m_charsetfromxattr.empty())
m_metaData[cstr_dj_keyorigcharset] = m_dfltInputCharset;
m_metaData[cstr_dj_keyorigcharset] = m_dfltInputCharset;
else
m_metaData[cstr_dj_keyorigcharset] = m_charsetfromxattr;
m_metaData[cstr_dj_keyorigcharset] = m_charsetfromxattr;
m_metaData[cstr_dj_keymt] = cstr_textplain;

View File

@ -29,7 +29,7 @@
class MimeHandlerUnknown : public RecollFilter {
public:
MimeHandlerUnknown(RclConfig *cnf, const string& id)
: RecollFilter(cnf, id) {
: RecollFilter(cnf, id) {
}
virtual ~MimeHandlerUnknown() {}
virtual bool is_data_input_ok(DataInput) const {
@ -37,12 +37,12 @@ class MimeHandlerUnknown : public RecollFilter {
}
virtual bool next_document() {
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
if (m_havedoc == false)
return false;
m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null;
m_metaData[cstr_dj_keymt] = cstr_textplain;
return true;
}
virtual bool is_unknown() {return true;}
};

View File

@ -31,63 +31,63 @@ class RclConfig;
class RecollFilter : public Dijon::Filter {
public:
RecollFilter(RclConfig *config, const std::string& id)
: m_config(config), m_id(id) {
: m_config(config), m_id(id) {
}
virtual ~RecollFilter() {}
virtual void setConfig(RclConfig *config) {
m_config = config;
m_config = config;
}
virtual bool set_property(Properties p, const std::string &v) {
switch (p) {
case DJF_UDI:
m_udi = v;
break;
case DEFAULT_CHARSET:
m_dfltInputCharset = v;
break;
case OPERATING_MODE:
if (!v.empty() && v[0] == 'v')
m_forPreview = true;
else
m_forPreview = false;
break;
}
return true;
switch (p) {
case DJF_UDI:
m_udi = v;
break;
case DEFAULT_CHARSET:
m_dfltInputCharset = v;
break;
case OPERATING_MODE:
if (!v.empty() && v[0] == 'v')
m_forPreview = true;
else
m_forPreview = false;
break;
}
return true;
}
// We don't use this for now
virtual bool set_document_uri(const std::string& mtype,
const std::string &) {
m_mimeType = mtype;
return false;
const std::string &) {
m_mimeType = mtype;
return false;
}
virtual bool set_document_file(const std::string& mtype,
const std::string &file_path) {
m_mimeType = mtype;
return set_document_file_impl(mtype, file_path);
const std::string &file_path) {
m_mimeType = mtype;
return set_document_file_impl(mtype, file_path);
}
virtual bool set_document_string(const std::string& mtype,
const std::string &contents) {
m_mimeType = mtype;
return set_document_string_impl(mtype, contents);
const std::string &contents) {
m_mimeType = mtype;
return set_document_string_impl(mtype, contents);
}
virtual bool set_document_data(const std::string& mtype,
const char *cp, size_t sz)
const char *cp, size_t sz)
{
return set_document_string(mtype, std::string(cp, sz));
return set_document_string(mtype, std::string(cp, sz));
}
virtual void set_docsize(int64_t size) {
m_docsize = size;
m_docsize = size;
}
virtual int64_t get_docsize() const {
return m_docsize;
return m_docsize;
}
virtual bool has_documents() const {
@ -96,33 +96,33 @@ public:
// Most doc types are single-doc
virtual bool skip_to_document(const std::string& s) {
if (s.empty())
return true;
return false;
if (s.empty())
return true;
return false;
}
virtual bool is_data_input_ok(DataInput input) const {
if (input == DOCUMENT_FILE_NAME)
return true;
return false;
if (input == DOCUMENT_FILE_NAME)
return true;
return false;
}
virtual std::string get_error() const {
return m_reason;
return m_reason;
}
virtual const std::string& get_id() const {
return m_id;
return m_id;
}
// Classes which need to do local work in clear() need
// to implement clear_impl()
virtual void clear() final {
clear_impl();
Dijon::Filter::clear();
m_forPreview = m_havedoc = false;
m_dfltInputCharset.clear();
m_reason.clear();
Dijon::Filter::clear();
m_forPreview = m_havedoc = false;
m_dfltInputCharset.clear();
m_reason.clear();
}
virtual void clear_impl() {}

View File

@ -62,8 +62,8 @@ class MyHtmlParser : public HtmlParser {
void reset_charsets() {fromcharset = tocharset = "";}
void set_charsets(const string& f, const string& t)
{
fromcharset = f;
tocharset = t;
fromcharset = f;
tocharset = t;
}
// Return charset as determined from html
const string& get_charset() {return charset;}

View File

@ -99,9 +99,9 @@ static string bomtocode(const string& itext)
bool RecollFilter::txtdcode(const string& who)
{
if (m_metaData[cstr_dj_keymt].compare(cstr_textplain)) {
LOGERR(who << "::txtdcode: called on non txt/plain: " <<
LOGERR(who << "::txtdcode: called on non txt/plain: " <<
m_metaData[cstr_dj_keymt] << "\n");
return false;
return false;
}
string& ocs = m_metaData[cstr_dj_keyorigcharset];
@ -120,17 +120,17 @@ bool RecollFilter::txtdcode(const string& who)
bool ret = transcode(itext, otext, ocs, cstr_utf8, &ecnt);
if (!ret || ecnt > int(itext.size() / 100)) {
LOGERR(who << "::txtdcode: transcode " << itext.size() <<
LOGERR(who << "::txtdcode: transcode " << itext.size() <<
" bytes to UTF-8 failed for input charset [" << ocs <<
"] ret " << ret << " ecnt " << ecnt << "\n");
ret = alternate_decode(itext, otext, ocs);
if (!ret) {
LOGDEB("txtdcode: failed. Doc is not text?\n" );
itext.erase();
return false;
}
if (!ret) {
LOGDEB("txtdcode: failed. Doc is not text?\n" );
itext.erase();
return false;
}
}
itext.swap(otext);

View File

@ -15,7 +15,7 @@
<li><b>Html interface</b>, close to a simplified QT Recoll
interface.</li>
<li><b>File manager interface</b>, <em>Only with KDE 4.1 and
newer</em>, which presents results as directory entries</li>
newer</em>, which presents results as directory entries</li>
</ul>
<p>The module is still in its infancy. You will undoubtedly obtain
@ -67,8 +67,8 @@
<li>Using an URL ending with a&nbsp;'/', ie:
<blockquote>
<a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a>
<a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a>
</blockquote>
</li>
<li>Users who will want to use the file manager view most of the

View File

@ -20,7 +20,7 @@
<input type="submit" value="Search">
<!-- This resets to the preset value. We'd like a real clear
<input type="reset" value="Clear"> -->
<input type="reset" value="Clear"> -->
</form>
</p>

View File

@ -49,7 +49,7 @@ using namespace KIO;
bool RecollKioPager::append(const string& data)
{
if (!m_parent)
return false;
return false;
m_parent->data(QByteArray(data.c_str()));
return true;
}
@ -58,20 +58,20 @@ string RecollProtocol::makeQueryUrl(int page, bool isdet)
{
ostringstream str;
str << "recoll://search/query?q=" <<
url_encode((const char*)m_query.query.toUtf8()) <<
"&qtp=" << (const char*)m_query.opt.toUtf8();
url_encode((const char*)m_query.query.toUtf8()) <<
"&qtp=" << (const char*)m_query.opt.toUtf8();
if (page >= 0)
str << "&p=" << page;
str << "&p=" << page;
if (isdet)
str << "&det=1";
str << "&det=1";
return str.str();
}
string RecollKioPager::detailsLink()
{
string chunk = string("<a href=\"") +
m_parent->makeQueryUrl(m_parent->m_pager.pageNumber(), true) + "\">"
+ "(show query)" + "</a>";
m_parent->makeQueryUrl(m_parent->m_pager.pageNumber(), true) + "\">"
+ "(show query)" + "</a>";
return chunk;
}
@ -81,24 +81,24 @@ const string& RecollKioPager::parFormat()
// Need to escape the % inside the query url
string qurl = m_parent->makeQueryUrl(-1, false), escurl;
for (string::size_type pos = 0; pos < qurl.length(); pos++) {
switch(qurl.at(pos)) {
case '%':
escurl += "%%";
break;
default:
escurl += qurl.at(pos);
}
switch(qurl.at(pos)) {
case '%':
escurl += "%%";
break;
default:
escurl += qurl.at(pos);
}
}
ostringstream str;
str <<
"<a href=\"%U\"><img src=\"%I\" align=\"left\"></a>"
"%R %S "
"<a href=\"" << escurl << "&cmd=pv&dn=%N\">Preview</a>&nbsp;&nbsp;" <<
"<a href=\"%U\">Open</a> " <<
"<b>%T</b><br>"
"%M&nbsp;%D&nbsp;&nbsp; <i>%U</i>&nbsp;&nbsp;%i<br>"
"%A %K";
"<a href=\"%U\"><img src=\"%I\" align=\"left\"></a>"
"%R %S "
"<a href=\"" << escurl << "&cmd=pv&dn=%N\">Preview</a>&nbsp;&nbsp;" <<
"<a href=\"%U\">Open</a> " <<
"<b>%T</b><br>"
"%M&nbsp;%D&nbsp;&nbsp; <i>%U</i>&nbsp;&nbsp;%i<br>"
"%A %K";
return parformat = str.str();
}
@ -111,9 +111,9 @@ string RecollKioPager::pageTop()
// Would be nice to have but doesnt work because the query may be executed
// by another kio instance which has no idea of the current page o
#if 0 && KDE_IS_VERSION(4,1,0)
" &nbsp;&nbsp;&nbsp;<a href=\"recoll:///" +
url_encode(string(m_parent->m_query.query.toUtf8())) +
"/\">Directory view</a> (you may need to reload the page)"
" &nbsp;&nbsp;&nbsp;<a href=\"recoll:///" +
url_encode(string(m_parent->m_query.query.toUtf8())) +
"/\">Directory view</a> (you may need to reload the page)"
#endif
}
@ -121,9 +121,9 @@ string RecollKioPager::nextUrl()
{
int pagenum = pageNumber();
if (pagenum < 0)
pagenum = 0;
pagenum = 0;
else
pagenum++;
pagenum++;
return m_parent->makeQueryUrl(pagenum);
}
@ -131,9 +131,9 @@ string RecollKioPager::prevUrl()
{
int pagenum = pageNumber();
if (pagenum <= 0)
pagenum = 0;
pagenum = 0;
else
pagenum--;
pagenum--;
return m_parent->makeQueryUrl(pagenum);
}
@ -143,17 +143,17 @@ void RecollProtocol::searchPage()
{
mimeType("text/html");
if (welcomedata.empty()) {
QString location =
KStandardDirs::locate("data", "kio_recoll/welcome.html");
string reason;
if (location.isEmpty() ||
!file_to_string((const char *)location.toUtf8(),
welcomedata, &reason)) {
welcomedata = "<html><head><title>Recoll Error</title></head>"
"<body><p>Could not locate Recoll welcome.html file: ";
welcomedata += reason;
welcomedata += "</p></body></html>";
}
QString location =
KStandardDirs::locate("data", "kio_recoll/welcome.html");
string reason;
if (location.isEmpty() ||
!file_to_string((const char *)location.toUtf8(),
welcomedata, &reason)) {
welcomedata = "<html><head><title>Recoll Error</title></head>"
"<body><p>Could not locate Recoll welcome.html file: ";
welcomedata += reason;
welcomedata += "</p></body></html>";
}
}
string catgq;
@ -164,12 +164,12 @@ void RecollProtocol::searchPage()
// language, but not too useful in this case, so scrap it for now.
list<string> cats;
if (o_rclconfig->getMimeCategories(cats) && !cats.empty()) {
catgq = "<p>Filter on types: "
"<input type=\"radio\" name=\"ct\" value=\"All\" checked>All";
for (list<string>::iterator it = cats.begin(); it != cats.end();it++) {
catgq += "\n<input type=\"radio\" name=\"ct\" value=\"" +
*it + "\">" + *it ;
}
catgq = "<p>Filter on types: "
"<input type=\"radio\" name=\"ct\" value=\"All\" checked>All";
for (list<string>::iterator it = cats.begin(); it != cats.end();it++) {
catgq += "\n<input type=\"radio\" name=\"ct\" value=\"" +
*it + "\">" + *it ;
}
}
#endif
@ -190,13 +190,13 @@ void RecollProtocol::queryDetails()
os << "<html><head>" << endl;
os << "<meta http-equiv=\"Content-Type\" content=\"text/html;"
"charset=utf-8\">" << endl;
"charset=utf-8\">" << endl;
os << "<title>" << "Recoll query details" << "</title>\n" << endl;
os << "</head>" << endl;
os << "<body><h3>Query details:</h3>" << endl;
os << "<p>" << m_pager.queryDescription().c_str() <<"</p>"<< endl;
os << "<p><a href=\"" << makeQueryUrl(m_pager.pageNumber()).c_str() <<
"\">Return to results</a>" << endl;
"\">Return to results</a>" << endl;
os << "</body></html>" << endl;
data(array);
}
@ -209,25 +209,25 @@ public:
}
virtual string header() {
if (m_inputhtml) {
return cstr_null;
} else {
return string("<html><head>"
"<META http-equiv=\"Content-Type\""
"content=\"text/html;charset=UTF-8\"><title>").
append(m_name).
append("</title></head><body><pre>");
}
if (m_inputhtml) {
return cstr_null;
} else {
return string("<html><head>"
"<META http-equiv=\"Content-Type\""
"content=\"text/html;charset=UTF-8\"><title>").
append(m_name).
append("</title></head><body><pre>");
}
}
virtual string startMatch(unsigned int)
{
return string("<font color=\"blue\">");
return string("<font color=\"blue\">");
}
virtual string endMatch()
{
return string("</font>");
return string("</font>");
}
const string &m_name;
@ -239,12 +239,12 @@ void RecollProtocol::showPreview(const Rcl::Doc& idoc)
Rcl::Doc fdoc;
string ipath = idoc.ipath;
if (!interner.internfile(fdoc, ipath)) {
error(KIO::ERR_SLAVE_DEFINED, "Cannot convert file to internal format");
return;
error(KIO::ERR_SLAVE_DEFINED, "Cannot convert file to internal format");
return;
}
if (!interner.get_html().empty()) {
fdoc.text = interner.get_html();
fdoc.mimetype = "text/html";
fdoc.text = interner.get_html();
fdoc.mimetype = "text/html";
}
mimeType("text/html");
@ -255,14 +255,14 @@ void RecollProtocol::showPreview(const Rcl::Doc& idoc)
list<string> otextlist;
HighlightData hdata;
if (m_source)
m_source->getTerms(hdata);
m_source->getTerms(hdata);
ptr.plaintorich(fdoc.text, otextlist, hdata);
QByteArray array;
QTextStream os(&array, QIODevice::WriteOnly);
for (list<string>::iterator it = otextlist.begin();
it != otextlist.end(); it++) {
os << (*it).c_str();
it != otextlist.end(); it++) {
os << (*it).c_str();
}
os << "</body></html>" << endl;
data(array);
@ -271,30 +271,30 @@ void RecollProtocol::showPreview(const Rcl::Doc& idoc)
void RecollProtocol::htmlDoSearch(const QueryDesc& qd)
{
kDebug() << "q" << qd.query << "option" << qd.opt << "page" << qd.page <<
"isdet" << qd.isDetReq << endl;
"isdet" << qd.isDetReq << endl;
mimeType("text/html");
if (!syncSearch(qd))
return;
return;
// syncSearch/doSearch do the setDocSource when needed
if (m_pager.pageNumber() < 0) {
m_pager.resultPageNext();
m_pager.resultPageNext();
}
if (qd.isDetReq) {
queryDetails();
return;
queryDetails();
return;
}
// Check / adjust page number
if (qd.page > m_pager.pageNumber()) {
int npages = qd.page - m_pager.pageNumber();
for (int i = 0; i < npages; i++)
m_pager.resultPageNext();
int npages = qd.page - m_pager.pageNumber();
for (int i = 0; i < npages; i++)
m_pager.resultPageNext();
} else if (qd.page < m_pager.pageNumber()) {
int npages = m_pager.pageNumber() - qd.page;
for (int i = 0; i < npages; i++)
m_pager.resultPageBack();
int npages = m_pager.pageNumber() - qd.page;
for (int i = 0; i < npages; i++)
m_pager.resultPageBack();
}
// Display
m_pager.displayPage(o_rclconfig);

View File

@ -55,25 +55,25 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
{
kDebug() << endl;
if (o_rclconfig == 0) {
o_rclconfig = recollinit(0, 0, 0, m_reason);
if (!o_rclconfig || !o_rclconfig->ok()) {
m_reason = string("Configuration problem: ") + m_reason;
return;
}
o_rclconfig = recollinit(0, 0, 0, m_reason);
if (!o_rclconfig || !o_rclconfig->ok()) {
m_reason = string("Configuration problem: ") + m_reason;
return;
}
}
if (o_rclconfig->getDbDir().empty()) {
// Note: this will have to be replaced by a call to a
// configuration building dialog for initial configuration? Or
// do we assume that the QT GUO is always used for this ?
m_reason = "No db directory in configuration ??";
return;
// Note: this will have to be replaced by a call to a
// configuration building dialog for initial configuration? Or
// do we assume that the QT GUO is always used for this ?
m_reason = "No db directory in configuration ??";
return;
}
rwSettings(false);
m_rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(o_rclconfig));
if (!m_rcldb) {
m_reason = "Could not build database object. (out of memory ?)";
return;
m_reason = "Could not build database object. (out of memory ?)";
return;
}
// Decide if we allow switching between html and file manager
@ -81,9 +81,9 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
// by switching proto names.
const char *cp = getenv("RECOLL_KIO_ALWAYS_DIR");
if (cp) {
m_alwaysdir = stringToBool(cp);
m_alwaysdir = stringToBool(cp);
} else {
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
}
cp = getenv("RECOLL_KIO_STEMLANG");
@ -107,12 +107,12 @@ RecollProtocol::~RecollProtocol()
bool RecollProtocol::maybeOpenDb(string &reason)
{
if (!m_rcldb) {
reason = "Internal error: initialization error";
return false;
reason = "Internal error: initialization error";
return false;
}
if (!m_rcldb->isopen() && !m_rcldb->open(Rcl::Db::DbRO)) {
reason = "Could not open database in " + o_rclconfig->getDbDir();
return false;
reason = "Could not open database in " + o_rclconfig->getDbDir();
return false;
}
return true;
}
@ -133,75 +133,75 @@ UrlIngester::UrlIngester(RecollProtocol *p, const KUrl& url)
m_alwaysdir = !url.protocol().compare("recollf");
QString path = url.path();
if (url.host().isEmpty()) {
if (path.isEmpty() || !path.compare("/")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_ROOT;
return;
} else if (!path.compare("/help.html")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_HELP;
return;
} else if (!path.compare("/search.html")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_SEARCH;
// Retrieve the query value for preloading the form
m_query.query = url.queryItem("q");
return;
} else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) {
m_type = UIMT_QUERYRESULT;
m_query.opt = "l";
m_query.page = 0;
} else {
// Have to think this is some search string
m_type = UIMT_QUERY;
m_query.query = url.path();
m_query.opt = "l";
m_query.page = 0;
}
if (path.isEmpty() || !path.compare("/")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_ROOT;
return;
} else if (!path.compare("/help.html")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_HELP;
return;
} else if (!path.compare("/search.html")) {
m_type = UIMT_ROOTENTRY;
m_retType = UIRET_SEARCH;
// Retrieve the query value for preloading the form
m_query.query = url.queryItem("q");
return;
} else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) {
m_type = UIMT_QUERYRESULT;
m_query.opt = "l";
m_query.page = 0;
} else {
// Non empty host, url must be something like :
// //search/query?q=query&param=value...
kDebug() << "host" << url.host() << "path" << url.path();
if (url.host().compare("search") || url.path().compare("/query")) {
return;
}
m_type = UIMT_QUERY;
// Decode the forms' arguments
m_query.query = url.queryItem("q");
// Have to think this is some search string
m_type = UIMT_QUERY;
m_query.query = url.path();
m_query.opt = "l";
m_query.page = 0;
}
} else {
// Non empty host, url must be something like :
// //search/query?q=query&param=value...
kDebug() << "host" << url.host() << "path" << url.path();
if (url.host().compare("search") || url.path().compare("/query")) {
return;
}
m_type = UIMT_QUERY;
// Decode the forms' arguments
m_query.query = url.queryItem("q");
m_query.opt = url.queryItem("qtp");
if (m_query.opt.isEmpty()) {
m_query.opt = "l";
}
QString p = url.queryItem("p");
if (p.isEmpty()) {
m_query.page = 0;
} else {
sscanf(p.toAscii(), "%d", &m_query.page);
}
p = url.queryItem("det");
m_query.isDetReq = !p.isEmpty();
m_query.opt = url.queryItem("qtp");
if (m_query.opt.isEmpty()) {
m_query.opt = "l";
}
QString p = url.queryItem("p");
if (p.isEmpty()) {
m_query.page = 0;
} else {
sscanf(p.toAscii(), "%d", &m_query.page);
}
p = url.queryItem("det");
m_query.isDetReq = !p.isEmpty();
p = url.queryItem("cmd");
if (!p.isEmpty() && !p.compare("pv")) {
p = url.queryItem("dn");
if (!p.isEmpty()) {
// Preview and no docnum ??
m_resnum = atoi((const char *)p.toUtf8());
// Result in page is 1+
m_resnum--;
m_type = UIMT_PREVIEW;
}
}
p = url.queryItem("cmd");
if (!p.isEmpty() && !p.compare("pv")) {
p = url.queryItem("dn");
if (!p.isEmpty()) {
// Preview and no docnum ??
m_resnum = atoi((const char *)p.toUtf8());
// Result in page is 1+
m_resnum--;
m_type = UIMT_PREVIEW;
}
}
}
if (m_query.query.startsWith("/"))
m_query.query.remove(0,1);
m_query.query.remove(0,1);
if (m_query.query.endsWith("/")) {
kDebug() << "Ends with /";
m_slashend = true;
m_query.query.chop(1);
kDebug() << "Ends with /";
m_slashend = true;
m_query.query.chop(1);
} else {
m_slashend = false;
m_slashend = false;
}
return;
}
@ -210,12 +210,12 @@ bool RecollProtocol::syncSearch(const QueryDesc &qd)
{
kDebug();
if (!m_initok || !maybeOpenDb(m_reason)) {
string reason = "RecollProtocol::listDir: Init error:" + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return false;
string reason = "RecollProtocol::listDir: Init error:" + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return false;
}
if (qd.sameQuery(m_query)) {
return true;
return true;
}
// doSearch() calls error() if appropriate.
return doSearch(qd);
@ -229,9 +229,9 @@ void RecollProtocol::get(const KUrl& url)
kDebug() << url << endl;
if (!m_initok || !maybeOpenDb(m_reason)) {
string reason = "Recoll: init error: " + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return;
string reason = "Recoll: init error: " + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return;
}
UrlIngester ingest(this, url);
@ -239,61 +239,61 @@ void RecollProtocol::get(const KUrl& url)
QueryDesc qd;
int resnum;
if (ingest.isRootEntry(&rettp)) {
switch(rettp) {
case UrlIngester::UIRET_HELP:
{
QString location =
KStandardDirs::locate("data", "kio_recoll/help.html");
redirection(location);
}
goto out;
default:
searchPage();
goto out;
}
switch(rettp) {
case UrlIngester::UIRET_HELP:
{
QString location =
KStandardDirs::locate("data", "kio_recoll/help.html");
redirection(location);
}
goto out;
default:
searchPage();
goto out;
}
} else if (ingest.isResult(&qd, &resnum)) {
// Url matched one generated by konqueror/Dolphin out of a
// search directory listing: ie:
// Url matched one generated by konqueror/Dolphin out of a
// search directory listing: ie:
// recoll:/some search string/recollResultxx
//
// This happens when the user drags/drop the result to another
// app, or with the "open-with" right-click. Does not happen
// if the entry itself is clicked (the UDS_URL is apparently
// used in this case
//
// Redirect to the result document URL
if (!syncSearch(qd)) {
return;
}
Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
mimeType(doc.mimetype.c_str());
redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7)));
goto out;
}
//
// This happens when the user drags/drop the result to another
// app, or with the "open-with" right-click. Does not happen
// if the entry itself is clicked (the UDS_URL is apparently
// used in this case
//
// Redirect to the result document URL
if (!syncSearch(qd)) {
return;
}
Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
mimeType(doc.mimetype.c_str());
redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7)));
goto out;
}
} else if (ingest.isPreview(&qd, &resnum)) {
if (!syncSearch(qd)) {
return;
}
Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
showPreview(doc);
goto out;
}
if (!syncSearch(qd)) {
return;
}
Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
showPreview(doc);
goto out;
}
} else if (ingest.isQuery(&qd)) {
#if 0
// Do we need this ?
if (host.isEmpty()) {
char cpage[20];sprintf(cpage, "%d", page);
QString nurl = QString::fromAscii("recoll://search/query?q=") +
query + "&qtp=" + opt + "&p=" + cpage;
redirection(KUrl(nurl));
goto out;
}
if (host.isEmpty()) {
char cpage[20];sprintf(cpage, "%d", page);
QString nurl = QString::fromAscii("recoll://search/query?q=") +
query + "&qtp=" + opt + "&p=" + cpage;
redirection(KUrl(nurl));
goto out;
}
#endif
// htmlDoSearch does the search syncing (needs to know about changes).
htmlDoSearch(qd);
goto out;
// htmlDoSearch does the search syncing (needs to know about changes).
htmlDoSearch(qd);
goto out;
}
error(KIO::ERR_SLAVE_DEFINED, "Unrecognized URL or internal error");
@ -311,40 +311,40 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
string qs = (const char *)qd.query.toUtf8();
Rcl::SearchData *sd = 0;
if (opt != 'l') {
Rcl::SearchDataClause *clp = 0;
if (opt == 'f') {
clp = new Rcl::SearchDataClauseFilename(qs);
} else {
Rcl::SearchDataClause *clp = 0;
if (opt == 'f') {
clp = new Rcl::SearchDataClauseFilename(qs);
} else {
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
Rcl::SCLT_AND, qs);
}
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang);
if (sd && clp)
sd->addClause(clp);
}
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang);
if (sd && clp)
sd->addClause(clp);
} else {
sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
}
if (!sd) {
m_reason = "Internal Error: cant build search";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false;
m_reason = "Internal Error: cant build search";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false;
}
std::shared_ptr<Rcl::SearchData> sdata(sd);
std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get()));
query->setCollapseDuplicates(prefs.collapseDuplicates);
if (!query->setQuery(sdata)) {
m_reason = "Query execute failed. Invalid query or syntax error?";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false;
m_reason = "Query execute failed. Invalid query or syntax error?";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false;
}
DocSequenceDb *src =
new DocSequenceDb(m_rcldb, std::shared_ptr<Rcl::Query>(query),
new DocSequenceDb(m_rcldb, std::shared_ptr<Rcl::Query>(query),
"Query results", sdata);
if (src == 0) {
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
return false;
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
return false;
}
m_source = std::shared_ptr<DocSequence>(src);
// Reset pager in all cases. Costs nothing, stays at page -1 initially
@ -368,8 +368,8 @@ int kdemain(int argc, char **argv)
kDebug() << "*** starting kio_recoll " << endl;
if (argc != 4) {
kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl;
exit(-1);
kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl;
exit(-1);
}
RecollProtocol slave(argv[2], argv[3]);

View File

@ -63,7 +63,7 @@ public:
int page;
bool isDetReq;
bool sameQuery(const QueryDesc& o) const {
return !opt.compare(o.opt) && !query.compare(o.query);
return !opt.compare(o.opt) && !query.compare(o.query);
}
};
@ -74,26 +74,26 @@ public:
UrlIngester(RecollProtocol *p, const KUrl& url);
enum RootEntryType {UIRET_NONE, UIRET_ROOT, UIRET_HELP, UIRET_SEARCH};
bool isRootEntry(RootEntryType *tp) {
if (m_type != UIMT_ROOTENTRY) return false;
*tp = m_retType;
return true;
if (m_type != UIMT_ROOTENTRY) return false;
*tp = m_retType;
return true;
}
bool isQuery(QueryDesc *q) {
if (m_type != UIMT_QUERY) return false;
*q = m_query;
return true;
if (m_type != UIMT_QUERY) return false;
*q = m_query;
return true;
}
bool isResult(QueryDesc *q, int *num) {
if (m_type != UIMT_QUERYRESULT) return false;
*q = m_query;
*num = m_resnum;
return true;
if (m_type != UIMT_QUERYRESULT) return false;
*q = m_query;
*num = m_resnum;
return true;
}
bool isPreview(QueryDesc *q, int *num) {
if (m_type != UIMT_PREVIEW) return false;
*q = m_query;
*num = m_resnum;
return true;
if (m_type != UIMT_PREVIEW) return false;
*q = m_query;
*num = m_resnum;
return true;
}
bool endSlashQuery() {return m_slashend;}
bool alwaysDir() {return m_alwaysdir;}
@ -106,7 +106,7 @@ private:
RootEntryType m_retType;
int m_resnum;
enum MyType {UIMT_NONE, UIMT_ROOTENTRY, UIMT_QUERY, UIMT_QUERYRESULT,
UIMT_PREVIEW};
UIMT_PREVIEW};
MyType m_type;
};

View File

@ -15,7 +15,7 @@
<li><b>Html interface</b>, close to a simplified QT Recoll
interface.</li>
<li><b>File manager interface</b>, <em>Only with KDE 4.1 and
newer</em>, which presents results as directory entries</li>
newer</em>, which presents results as directory entries</li>
</ul>
<p>With recent KDE versions (now: 2016), the file manager
@ -74,8 +74,8 @@
<li>Using an URL ending with a&nbsp;'/', ie:
<blockquote>
<a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a>
<a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a>
</blockquote>
</li>
<li>If you would like to use the file manager view most of the

View File

@ -20,7 +20,7 @@
<input type="submit" value="Search">
<!-- This resets to the preset value. We'd like a real clear
<input type="reset" value="Clear"> -->
<input type="reset" value="Clear"> -->
</form>
</p>

View File

@ -1,10 +1,10 @@
all:
@echo "This Makefile is only for the CVS repository"
@echo "This will be deleted before making the distribution"
@echo ""
$(MAKE) -f admin/Makefile.common cvs
@echo "This Makefile is only for the CVS repository"
@echo "This will be deleted before making the distribution"
@echo ""
$(MAKE) -f admin/Makefile.common cvs
dist:
$(MAKE) -f admin/Makefile.common dist
$(MAKE) -f admin/Makefile.common dist
.SILENT:

View File

@ -7,25 +7,25 @@
SHELL=/bin/sh
cvs dist configure configure.in configure.files subdirs package-messages package-merge Makefile.am acinclude.m4 extract-messages:
@admindir=$(admindir); \
if test "x$$admindir" = x; then \
admindir=.; until test -f $$admindir/admin/cvs.sh; do \
admindir=$$admindir/..; \
if test `cd $$admindir && pwd` = / ; then break; fi; \
done; \
admindir=$$admindir/admin; \
if test -f $$admindir/cvs.sh; then :; else \
echo "Can't find the admin/ directory in any parent of the"; \
echo "current directory. Please set it with admindir=..."; \
exit 1; \
fi; \
fi; \
if test "$@" = "package-merge"; then \
MAKE="$(MAKE)" POFILES="$(POFILES)" PACKAGE="$(PACKAGE)" \
$(SHELL) $$admindir/cvs.sh package-merge ;\
else \
MAKE="$(MAKE)" $(SHELL) $$admindir/cvs.sh $@ ;\
fi
@admindir=$(admindir); \
if test "x$$admindir" = x; then \
admindir=.; until test -f $$admindir/admin/cvs.sh; do \
admindir=$$admindir/..; \
if test `cd $$admindir && pwd` = / ; then break; fi; \
done; \
admindir=$$admindir/admin; \
if test -f $$admindir/cvs.sh; then :; else \
echo "Can't find the admin/ directory in any parent of the"; \
echo "current directory. Please set it with admindir=..."; \
exit 1; \
fi; \
fi; \
if test "$@" = "package-merge"; then \
MAKE="$(MAKE)" POFILES="$(POFILES)" PACKAGE="$(PACKAGE)" \
$(SHELL) $$admindir/cvs.sh package-merge ;\
else \
MAKE="$(MAKE)" $(SHELL) $$admindir/cvs.sh $@ ;\
fi
configure.in: configure.files subdirs
configure.files: subdirs

View File

@ -51,30 +51,30 @@ while (<>) {
# in later autoconf (2.14.1) there is no CONFIG_FILES= line,
# but instead the (2) directly follow (1)
if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) {
$flag = 1;
if ($1 eq 'lines') {
$flag = 1;
if ($1 eq 'lines') {
# lets hope its different with 2141,
# wasn't able to verify that
if ($2 eq '48') {
$ac_version = 250;
}
else {
$ac_version = 2141;
$ac_version = 2141;
}
} elsif ($1 eq 'cmds') {
$ac_version = 213;
}
# hmm, we don't know the autoconf version, but we try anyway
} else {
print;
}
} elsif ($1 eq 'cmds') {
$ac_version = 213;
}
# hmm, we don't know the autoconf version, but we try anyway
} else {
print;
}
} elsif ($flag == 1) {
if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) {
print;
$flag = 2;
} elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3;
}
print;
$flag = 2;
} elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3;
}
} elsif ($flag == 2) {
# 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1))
# end with: "rm -f conftest.s\*"
@ -84,22 +84,22 @@ while (<>) {
# stop there and insert a new loop to honor the case/esac.
# (pattern: /^\s+#\sRun the commands associated with the file./)
if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3;
} else {
print;
}
if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3;
} else {
print;
}
} elsif ($flag == 3) {
if (/^\s*rm\s+-f\s+conftest/ ) {
$flag = 4;
&insert_main_loop();
} elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) {
$flag = 4;
&insert_main_loop();
#die "hhhhhhh";
if ($ac_version != 2141) {
print STDERR "hmm, don't know autoconf version\n";
}
$flag = 4;
&insert_main_loop();
} elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) {
$flag = 4;
&insert_main_loop();
#die "hhhhhhh";
if ($ac_version != 2141) {
print STDERR "hmm, don't know autoconf version\n";
}
} elsif (/^\#\s*CONFIG_(HEADER|COMMANDS) section.*|^\s+#\s(Run) the commands associated/) {
$flag = 4;
my $commands = defined $2;
@ -108,9 +108,9 @@ while (<>) {
if($ac_version != 250) {
print STDERR "hmm, something went wrong :-(\n";
}
} elsif (/VPATH/ ) {
$vpath_seen = 1;
}
} elsif (/VPATH/ ) {
$vpath_seen = 1;
}
}
}
@ -135,7 +135,7 @@ EOF
if ($vpath_seen) {
print <<EOF;
# VPATH subst was seen in original config.status main loop
echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed
echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed
EOF
}
print <<EOF;
@ -165,7 +165,7 @@ EOF
if ($vpath_seen) {
print <<EOF;
# VPATH subst was seen in original config.status main loop
echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >> \$ac_cs_root.subs
echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >> \$ac_cs_root.subs
EOF
}
print <<EOF;

View File

@ -100,22 +100,22 @@ PHP_METHOD(Query, query)
long ctxwords;
if (zend_parse_parameters(3 TSRMLS_CC, "sll", &qs_c, &qs_len, &maxchars, &ctxwords) == FAILURE) {
printf("failed to get parameters\n");
RETURN_BOOL(false);
printf("failed to get parameters\n");
RETURN_BOOL(false);
}
string qs = qs_c;
RclConfig *rclconfig = recollinit(0, 0, 0, reason, &a_config);
if (!rclconfig || !rclconfig->ok()) {
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
RETURN_BOOL(false);
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
RETURN_BOOL(false);
}
Rcl::Db *pRclDb = new Rcl::Db(rclconfig);
if (!pRclDb->open(Rcl::Db::DbRO)) {
cerr << "Cant open database in " << rclconfig->getDbDir() <<
" reason: " << pRclDb->getReason() << endl;
RETURN_BOOL(false);
cerr << "Cant open database in " << rclconfig->getDbDir() <<
" reason: " << pRclDb->getReason() << endl;
RETURN_BOOL(false);
}
pRclDb->setAbstractParams(-1, maxchars, ctxwords);
@ -127,8 +127,8 @@ PHP_METHOD(Query, query)
sd = wasaStringToRcl(rclconfig, "english", qs, reason);
if (!sd) {
cerr << "Query string interpretation failed: " << reason << endl;
RETURN_BOOL(false);
cerr << "Query string interpretation failed: " << reason << endl;
RETURN_BOOL(false);
}
std::shared_ptr<Rcl::SearchData> rq(sd);
@ -151,19 +151,19 @@ PHP_METHOD(Query, get_doc)
pRclQuery = obj->pRclQuery;
if(NULL == pRclQuery)
{
printf("error, NULL pointer pRclQuery\n");
RETURN_BOOL(false);
printf("error, NULL pointer pRclQuery\n");
RETURN_BOOL(false);
}
long index;
if (zend_parse_parameters(1 TSRMLS_CC, "l", &index) == FAILURE) {
RETURN_BOOL(false);
RETURN_BOOL(false);
}
Rcl::Doc doc;
if (!pRclQuery->getDoc(index, doc))
{
RETURN_BOOL(false);
RETURN_BOOL(false);
}
string abs;
@ -172,10 +172,10 @@ PHP_METHOD(Query, get_doc)
char splitter[] = {7,8,1,2,0};
char ret_string[1000];
snprintf(ret_string, 1000, "mime:%s%surl:%s%stitle:%s%sabs:%s",
doc.mimetype.c_str(),splitter,
doc.url.c_str(),splitter,
doc.meta[Rcl::Doc::keytt].c_str(), splitter,
abs.c_str());
doc.mimetype.c_str(),splitter,
doc.url.c_str(),splitter,
doc.meta[Rcl::Doc::keytt].c_str(), splitter,
abs.c_str());
RETURN_STRING(ret_string, 1);
}
@ -200,8 +200,8 @@ PHP_FUNCTION(recoll_connect)
}
function_entry recoll_functions[] = {
PHP_FE(recoll_connect, NULL)
{NULL, NULL, NULL}
PHP_FE(recoll_connect, NULL)
{NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(recoll)

View File

@ -237,7 +237,7 @@
// success code
if (SWIG_IsNewObj(res) {
...
delete *ptr;
delete *ptr;
} else {
...
}
@ -338,32 +338,32 @@ typedef struct swig_type_info *(*swig_dycast_func)(void **);
/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
struct swig_cast_info *cast; /* linked list of types that can cast into this type */
void *clientdata; /* language specific type data */
int owndata; /* flag if the structure owns the clientdata */
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
struct swig_cast_info *cast; /* linked list of types that can cast into this type */
void *clientdata; /* language specific type data */
int owndata; /* flag if the structure owns the clientdata */
} swig_type_info;
/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
swig_type_info *type; /* pointer to type that is equivalent to this type */
swig_converter_func converter; /* function to cast the void pointers */
struct swig_cast_info *next; /* pointer to next cast in linked list */
struct swig_cast_info *prev; /* pointer to the previous cast */
swig_type_info *type; /* pointer to type that is equivalent to this type */
swig_converter_func converter; /* function to cast the void pointers */
struct swig_cast_info *next; /* pointer to next cast in linked list */
struct swig_cast_info *prev; /* pointer to the previous cast */
} swig_cast_info;
/* Structure used to store module information
* Each module generates one structure like this, and the runtime collects
* all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
size_t size; /* Number of types in this module */
struct swig_module_info *next; /* Pointer to next element in circularly linked list */
swig_type_info **type_initial; /* Array of initially generated type structures */
swig_cast_info **cast_initial; /* Array of initially generated casting structures */
void *clientdata; /* Language specific module data */
swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
size_t size; /* Number of types in this module */
struct swig_module_info *next; /* Pointer to next element in circularly linked list */
swig_type_info **type_initial; /* Array of initially generated type structures */
swig_cast_info **cast_initial; /* Array of initially generated casting structures */
void *clientdata; /* Language specific module data */
} swig_module_info;
/*
@ -375,7 +375,7 @@ typedef struct swig_module_info {
*/
SWIGRUNTIME int
SWIG_TypeNameComp(const char *f1, const char *l1,
const char *f2, const char *l2) {
const char *f2, const char *l2) {
for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
while ((*f1 == ' ') && (f1 != l1)) ++f1;
while ((*f2 == ' ') && (f2 != l2)) ++f2;
@ -531,7 +531,7 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
SWIG_TypeClientData(tc, clientdata);
SWIG_TypeClientData(tc, clientdata);
}
}
cast = cast->next;
@ -554,32 +554,32 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
const char *name) {
swig_module_info *iter = start;
do {
if (iter->size) {
size_t l = 0;
size_t r = iter->size - 1;
do {
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
int compare = strcmp(name, iname);
if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
r = i - 1;
} else {
break;
}
} else if (compare > 0) {
l = i + 1;
}
} else {
break; /* should never happen */
}
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
int compare = strcmp(name, iname);
if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
r = i - 1;
} else {
break;
}
} else if (compare > 0) {
l = i + 1;
}
} else {
break; /* should never happen */
}
} while (l <= r);
}
iter = iter->next;
@ -599,7 +599,7 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
if (ret) {
@ -611,8 +611,8 @@ SWIG_TypeQueryModule(swig_module_info *start,
do {
size_t i = 0;
for (; i < iter->size; ++i) {
if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
return iter->types[i];
if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
return iter->types[i];
}
iter = iter->next;
} while (iter != end);
@ -726,18 +726,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
#endif
/* Errors in SWIG */
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
#define SWIG_MemoryError -12
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
#define SWIG_MemoryError -12
#define SWIG_NullReferenceError -13
@ -920,13 +920,13 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
#endif
#if PY_VERSION_HEX < 0x02040000
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((op), arg); \
if (vret) \
return vret; \
} \
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((op), arg); \
if (vret) \
return vret; \
} \
} while (0)
#endif
@ -1165,7 +1165,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
#endif
#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
@ -1195,10 +1195,10 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
#define SWIG_fail goto fail
#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
#define SWIG_fail goto fail
/* Runtime API implementation */
@ -1314,7 +1314,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
return 1;
} else {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
name, (min == max ? "" : "at least "), (int)min);
name, (min == max ? "" : "at least "), (int)min);
return 0;
}
}
@ -1323,7 +1323,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
Py_ssize_t i;
objs[0] = args;
for (i = 1; i < max; ++i) {
objs[i] = 0;
objs[i] = 0;
}
return 2;
}
@ -1333,19 +1333,19 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
Py_ssize_t l = PyTuple_GET_SIZE(args);
if (l < min) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
name, (min == max ? "" : "at least "), (int)min, (int)l);
name, (min == max ? "" : "at least "), (int)min, (int)l);
return 0;
} else if (l > max) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
name, (min == max ? "" : "at most "), (int)max, (int)l);
name, (min == max ? "" : "at most "), (int)max, (int)l);
return 0;
} else {
Py_ssize_t i;
for (i = 0; i < l; ++i) {
objs[i] = PyTuple_GET_ITEM(args, i);
objs[i] = PyTuple_GET_ITEM(args, i);
}
for (; l < max; ++l) {
objs[l] = 0;
objs[l] = 0;
}
return i + 1;
}
@ -1354,9 +1354,9 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
/* A functor is a function object with one single object argument */
#if PY_VERSION_HEX >= 0x02020000
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
#else
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
#endif
/*
@ -1379,8 +1379,8 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
#ifdef __cplusplus
extern "C" {
@ -1474,11 +1474,11 @@ SwigPyClientData_New(PyObject* obj)
data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
#endif
if (data->newraw) {
Py_INCREF(data->newraw);
data->newargs = PyTuple_New(1);
PyTuple_SetItem(data->newargs, 0, obj);
Py_INCREF(data->newraw);
data->newargs = PyTuple_New(1);
PyTuple_SetItem(data->newargs, 0, obj);
} else {
data->newargs = obj;
data->newargs = obj;
}
Py_INCREF(data->newargs);
}
@ -1559,11 +1559,11 @@ SwigPyObject_format(const char* fmt, SwigPyObject *v)
PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
if (ofmt) {
#if PY_VERSION_HEX >= 0x03000000
res = PyUnicode_Format(ofmt,args);
res = PyUnicode_Format(ofmt,args);
#else
res = PyString_Format(ofmt,args);
res = PyString_Format(ofmt,args);
#endif
Py_DECREF(ofmt);
Py_DECREF(ofmt);
}
Py_DECREF(args);
}
@ -1798,17 +1798,17 @@ SwigPyObject_own(PyObject *v, PyObject *args)
PyObject *obj = PyBool_FromLong(sobj->own);
if (val) {
#ifdef METH_NOARGS
if (PyObject_IsTrue(val)) {
SwigPyObject_acquire(v);
} else {
SwigPyObject_disown(v);
}
if (PyObject_IsTrue(val)) {
SwigPyObject_acquire(v);
} else {
SwigPyObject_disown(v);
}
#else
if (PyObject_IsTrue(val)) {
SwigPyObject_acquire(v,args);
} else {
SwigPyObject_disown(v,args);
}
if (PyObject_IsTrue(val)) {
SwigPyObject_acquire(v,args);
} else {
SwigPyObject_disown(v,args);
}
#endif
}
return obj;
@ -1866,12 +1866,12 @@ SwigPyObject_TypeOnce(void) {
(unaryfunc)0, /*nb_positive*/
(unaryfunc)0, /*nb_absolute*/
(inquiry)0, /*nb_nonzero*/
0, /*nb_invert*/
0, /*nb_lshift*/
0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_invert*/
0, /*nb_lshift*/
0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
#if PY_VERSION_HEX < 0x03000000
0, /*nb_coerce*/
#endif
@ -1914,7 +1914,7 @@ SwigPyObject_TypeOnce(void) {
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
@ -1932,7 +1932,7 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
0, /* tp_str */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -2275,16 +2275,16 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
} else {
#ifdef PyWeakref_CheckProxy
if (PyWeakref_CheckProxy(pyobj)) {
PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
}
#endif
obj = PyObject_GetAttr(pyobj,SWIG_This());
if (obj) {
Py_DECREF(obj);
Py_DECREF(obj);
} else {
if (PyErr_Occurred()) PyErr_Clear();
return 0;
if (PyErr_Occurred()) PyErr_Clear();
return 0;
}
}
}
@ -2495,12 +2495,12 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
PyObject **dictptr = _PyObject_GetDictPtr(inst);
if (dictptr != NULL) {
PyObject *dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
PyDict_SetItem(dict, SWIG_This(), swig_this);
}
PyObject *dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
PyDict_SetItem(dict, SWIG_This(), swig_this);
}
}
#else
PyObject *key = SWIG_This();
@ -2616,7 +2616,7 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f
if (newobj->ptr) {
PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
while (newobj->next)
newobj = (SwigPyObject *) newobj->next;
newobj = (SwigPyObject *) newobj->next;
newobj->next = next_self;
newobj = (SwigPyObject *)next_self;
#ifdef SWIGPYTHON_BUILTIN
@ -2677,7 +2677,7 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
# else
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
# endif
if (PyErr_Occurred()) {
PyErr_Clear();
@ -2708,7 +2708,7 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
if (dict == NULL) {
/* Internal error -- modules must have a dict! */
PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
PyModule_GetName(m));
PyModule_GetName(m));
return SWIG_ERROR;
}
if (PyDict_SetItemString(dict, name, o))
@ -2827,9 +2827,9 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront)
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
} else {
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
}
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
@ -2869,27 +2869,27 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
if (obj && SwigPyObject_Check(obj)) {
const char *otype = (const char *) SwigPyObject_GetDesc(obj);
if (otype) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
type, otype);
return;
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
type, otype);
return;
}
} else
#endif
{
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
SWIG_Python_str_DelForPy3(cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
}
Py_XDECREF(str);
return;
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
}
Py_XDECREF(str);
return;
}
}
PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
@ -3149,10 +3149,10 @@ SWIG_AsVal_double (PyObject *obj, double *val)
if (!dispatch) {
long v = PyLong_AsLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
if (val) *val = v;
return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
} else {
PyErr_Clear();
PyErr_Clear();
}
}
}
@ -3235,8 +3235,8 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
double d;
int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
if (val) *val = (unsigned long)(d);
return res;
if (val) *val = (unsigned long)(d);
return res;
}
}
}
@ -3342,8 +3342,8 @@ SWIG_AsVal_long (PyObject *obj, long* val)
double d;
int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
if (val) *val = (long)(d);
return res;
if (val) *val = (long)(d);
return res;
}
}
}
@ -3413,36 +3413,36 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
#endif
if (cptr) {
if (alloc) {
/*
In python the user should not be able to modify the inner
string representation. To warranty that, if you define
SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
buffer is always returned.
/*
In python the user should not be able to modify the inner
string representation. To warranty that, if you define
SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
buffer is always returned.
The default behavior is just to return the pointer value,
so, be careful.
*/
The default behavior is just to return the pointer value,
so, be careful.
*/
#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
if (*alloc != SWIG_OLDOBJ)
if (*alloc != SWIG_OLDOBJ)
#else
if (*alloc == SWIG_NEWOBJ)
if (*alloc == SWIG_NEWOBJ)
#endif
{
*cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
*alloc = SWIG_NEWOBJ;
} else {
*cptr = cstr;
*alloc = SWIG_OLDOBJ;
}
{
*cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
*alloc = SWIG_NEWOBJ;
} else {
*cptr = cstr;
*alloc = SWIG_OLDOBJ;
}
} else {
#if PY_VERSION_HEX>=0x03000000
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
*cptr = PyBytes_AsString(obj);
*cptr = PyBytes_AsString(obj);
#else
assert(0); /* Should never reach here with Unicode strings in Python 3 */
assert(0); /* Should never reach here with Unicode strings in Python 3 */
#endif
#else
*cptr = SWIG_Python_str_AsChar(obj);
*cptr = SWIG_Python_str_AsChar(obj);
#endif
}
}
@ -3483,10 +3483,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
if (pchar_descriptor) {
void* vptr = 0;
if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
if (cptr) *cptr = (char *) vptr;
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
if (alloc) *alloc = SWIG_OLDOBJ;
return SWIG_OK;
if (cptr) *cptr = (char *) vptr;
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
if (alloc) *alloc = SWIG_OLDOBJ;
return SWIG_OK;
}
}
}
@ -3504,12 +3504,12 @@ SWIG_AsCharArray(PyObject * obj, char *val, size_t size)
if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize;
if (csize <= size) {
if (val) {
if (csize) memcpy(val, cptr, csize*sizeof(char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char));
if (csize) memcpy(val, cptr, csize*sizeof(char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char));
}
if (alloc == SWIG_NEWOBJ) {
free((char*)cptr);
res = SWIG_DelNewMask(res);
free((char*)cptr);
res = SWIG_DelNewMask(res);
}
return res;
}
@ -3526,7 +3526,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
if (size > INT_MAX) {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
return pchar_descriptor ?
SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#if PY_VERSION_HEX >= 0x03000000
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
@ -4185,26 +4185,26 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
{ (char *)"chmUnitInfo_start_set", _wrap_chmUnitInfo_start_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_start_get", _wrap_chmUnitInfo_start_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_length_set", _wrap_chmUnitInfo_length_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_length_get", _wrap_chmUnitInfo_length_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_space_set", _wrap_chmUnitInfo_space_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_space_get", _wrap_chmUnitInfo_space_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_path_set", _wrap_chmUnitInfo_path_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_path_get", _wrap_chmUnitInfo_path_get, METH_VARARGS, NULL},
{ (char *)"new_chmUnitInfo", _wrap_new_chmUnitInfo, METH_VARARGS, NULL},
{ (char *)"delete_chmUnitInfo", _wrap_delete_chmUnitInfo, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_swigregister", chmUnitInfo_swigregister, METH_VARARGS, NULL},
{ (char *)"chm_open", _wrap_chm_open, METH_VARARGS, NULL},
{ (char *)"chm_close", _wrap_chm_close, METH_VARARGS, NULL},
{ (char *)"chm_set_param", _wrap_chm_set_param, METH_VARARGS, NULL},
{ (char *)"chm_resolve_object", _wrap_chm_resolve_object, METH_VARARGS, NULL},
{ (char *)"chm_retrieve_object", _wrap_chm_retrieve_object, METH_VARARGS, NULL},
{ (char *)"chm_enumerate", _wrap_chm_enumerate, METH_VARARGS, NULL},
{ (char *)"chm_enumerate_dir", _wrap_chm_enumerate_dir, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
{ (char *)"chmUnitInfo_start_set", _wrap_chmUnitInfo_start_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_start_get", _wrap_chmUnitInfo_start_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_length_set", _wrap_chmUnitInfo_length_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_length_get", _wrap_chmUnitInfo_length_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_space_set", _wrap_chmUnitInfo_space_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_space_get", _wrap_chmUnitInfo_space_get, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_path_set", _wrap_chmUnitInfo_path_set, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_path_get", _wrap_chmUnitInfo_path_get, METH_VARARGS, NULL},
{ (char *)"new_chmUnitInfo", _wrap_new_chmUnitInfo, METH_VARARGS, NULL},
{ (char *)"delete_chmUnitInfo", _wrap_delete_chmUnitInfo, METH_VARARGS, NULL},
{ (char *)"chmUnitInfo_swigregister", chmUnitInfo_swigregister, METH_VARARGS, NULL},
{ (char *)"chm_open", _wrap_chm_open, METH_VARARGS, NULL},
{ (char *)"chm_close", _wrap_chm_close, METH_VARARGS, NULL},
{ (char *)"chm_set_param", _wrap_chm_set_param, METH_VARARGS, NULL},
{ (char *)"chm_resolve_object", _wrap_chm_resolve_object, METH_VARARGS, NULL},
{ (char *)"chm_retrieve_object", _wrap_chm_retrieve_object, METH_VARARGS, NULL},
{ (char *)"chm_enumerate", _wrap_chm_enumerate, METH_VARARGS, NULL},
{ (char *)"chm_enumerate_dir", _wrap_chm_enumerate_dir, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};

View File

@ -63,9 +63,9 @@ Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
LOGDEB("Extractor_new\n" );
rclx_ExtractorObject *self =
(rclx_ExtractorObject *)type->tp_alloc(type, 0);
(rclx_ExtractorObject *)type->tp_alloc(type, 0);
if (self == 0)
return 0;
return 0;
self->xtr = 0;
self->docobject = 0;
return (PyObject *)self;
@ -79,19 +79,19 @@ Extractor_init(rclx_ExtractorObject *self, PyObject *args, PyObject *kwargs)
PyObject *pdobj;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", (char**)kwlist,
recoll_DocType, &pdobj))
return -1;
recoll_DocType, &pdobj))
return -1;
recoll_DocObject *dobj = (recoll_DocObject *)pdobj;
if (dobj->doc == 0) {
PyErr_SetString(PyExc_AttributeError, "Null Doc ?");
return -1;
return -1;
}
self->docobject = dobj;
Py_INCREF(dobj);
self->rclconfig = dobj->rclconfig;
self->xtr = new FileInterner(*dobj->doc, self->rclconfig.get(),
FileInterner::FIF_forPreview);
FileInterner::FIF_forPreview);
return 0;
}
@ -104,30 +104,30 @@ PyDoc_STRVAR(doc_Extractor_textextract,
static PyObject *
Extractor_textextract(rclx_ExtractorObject* self, PyObject *args,
PyObject *kwargs)
PyObject *kwargs)
{
LOGDEB("Extractor_textextract\n" );
static const char* kwlist[] = {"ipath", NULL};
char *sipath = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "es:Extractor_textextract",
(char**)kwlist,
"utf-8", &sipath))
return 0;
(char**)kwlist,
"utf-8", &sipath))
return 0;
string ipath(sipath);
PyMem_Free(sipath);
if (self->xtr == 0) {
PyErr_SetString(PyExc_AttributeError, "extract: null object");
return 0;
return 0;
}
/* Call the doc class object to create a new doc. */
recoll_DocObject *result =
(recoll_DocObject *)PyObject_CallObject((PyObject *)recoll_DocType, 0);
if (!result) {
PyErr_SetString(PyExc_AttributeError, "extract: doc create failed");
return 0;
return 0;
}
FileInterner::Status status = self->xtr->internfile(*(result->doc), ipath);
if (status != FileInterner::FIDone && status != FileInterner::FIAgain) {
@ -137,14 +137,14 @@ Extractor_textextract(rclx_ExtractorObject* self, PyObject *args,
string html = self->xtr->get_html();
if (!html.empty()) {
result->doc->text = html;
result->doc->mimetype = "text/html";
result->doc->text = html;
result->doc->mimetype = "text/html";
}
// Is this actually needed ? Useful for url which is also formatted .
Rcl::Doc *doc = result->doc;
printableUrl(self->rclconfig->getDefCharset(), doc->url,
doc->meta[Rcl::Doc::keyurl]);
doc->meta[Rcl::Doc::keyurl]);
doc->meta[Rcl::Doc::keytp] = doc->mimetype;
doc->meta[Rcl::Doc::keyipt] = doc->ipath;
doc->meta[Rcl::Doc::keyfs] = doc->fbytes;
@ -158,7 +158,7 @@ PyDoc_STRVAR(doc_Extractor_idoctofile,
);
static PyObject *
Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args,
PyObject *kwargs)
PyObject *kwargs)
{
LOGDEB("Extractor_idoctofile\n" );
static const char* kwlist[] = {"ipath", "mimetype", "ofilename", NULL};
@ -166,11 +166,11 @@ Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args,
char *smt = 0;
char *soutfile = 0; // no freeing
if (!PyArg_ParseTupleAndKeywords(args,kwargs, "eses|s:Extractor_idoctofile",
(char**)kwlist,
"utf-8", &sipath,
"utf-8", &smt,
&soutfile))
return 0;
(char**)kwlist,
"utf-8", &sipath,
"utf-8", &smt,
&soutfile))
return 0;
string ipath(sipath);
PyMem_Free(sipath);
@ -178,11 +178,11 @@ Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args,
PyMem_Free(smt);
string outfile;
if (soutfile && *soutfile)
outfile.assign(soutfile);
outfile.assign(soutfile);
if (self->xtr == 0) {
PyErr_SetString(PyExc_AttributeError, "idoctofile: null object");
return 0;
return 0;
}
// If ipath is empty and we want the original mimetype, we can't
@ -209,9 +209,9 @@ Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args,
return 0;
}
if (outfile.empty())
temp.setnoremove(1);
temp.setnoremove(1);
PyObject *result = outfile.empty() ? PyBytes_FromString(temp.filename()) :
PyBytes_FromString(outfile.c_str());
PyBytes_FromString(outfile.c_str());
return (PyObject *)result;
}
@ -251,12 +251,12 @@ static PyTypeObject rclx_ExtractorType = {
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
doc_ExtractorObject, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Extractor_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
@ -275,7 +275,7 @@ static PyMethodDef rclextract_methods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyDoc_STRVAR(rclx_doc_string,
"This is an interface to the Recoll text extraction features.");
"This is an interface to the Recoll text extraction features.");
struct module_state {
PyObject *error;
@ -332,8 +332,8 @@ initrclextract(void)
string reason;
RclConfig *rclconfig = recollinit(RCLINIT_PYTHON, 0, 0, reason, 0);
if (rclconfig == 0) {
PyErr_SetString(PyExc_EnvironmentError, reason.c_str());
INITERROR;
PyErr_SetString(PyExc_EnvironmentError, reason.c_str());
INITERROR;
} else {
delete rclconfig;
}

File diff suppressed because it is too large Load Diff

View File

@ -39,10 +39,10 @@ class AdvSearch : public QDialog, public Ui::AdvSearchBase
public:
AdvSearch(QDialog* parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
init();
setupUi(this);
init();
}
public slots:

View File

@ -33,7 +33,7 @@ AdvSearchHist::AdvSearchHist()
AdvSearchHist::~AdvSearchHist()
{
for (auto& entry : m_entries) {
entry.reset();
entry.reset();
}
}
@ -49,8 +49,8 @@ std::shared_ptr<Rcl::SearchData> AdvSearchHist::getolder()
{
m_current++;
if (m_current >= int(m_entries.size())) {
m_current--;
return std::shared_ptr<Rcl::SearchData>();
m_current--;
return std::shared_ptr<Rcl::SearchData>();
}
return m_entries[m_current];
}
@ -58,7 +58,7 @@ std::shared_ptr<Rcl::SearchData> AdvSearchHist::getolder()
std::shared_ptr<Rcl::SearchData> AdvSearchHist::getnewer()
{
if (m_current == -1 || m_current == 0 || m_entries.empty())
return std::shared_ptr<Rcl::SearchData>();
return std::shared_ptr<Rcl::SearchData>();
return m_entries[--m_current];
}
@ -66,7 +66,7 @@ bool AdvSearchHist::push(std::shared_ptr<SearchData> sd)
{
m_entries.insert(m_entries.begin(), sd);
if (m_current != -1)
m_current++;
m_current++;
string xml = sd->asXML();
// dynconf interprets <= 0 as unlimited size, but we want 0 to
@ -80,7 +80,7 @@ bool AdvSearchHist::push(std::shared_ptr<SearchData> sd)
bool AdvSearchHist::read()
{
if (!g_dynconf)
return false;
return false;
// getStringEntries() return the entries in order (lower key
// first), but we want most recent first, so revert

View File

@ -254,8 +254,8 @@ bool ConfIndexW::setupTopPanel(int idx)
tr("Stemming languages"),
tr("The languages for which stemming expansion "
"dictionaries will be built.<br>See the Xapian stemmer "
"documentation for possible values. E.g. english, "
"french, german..."), 0, 0, &m_stemlangs);
"documentation for possible values. E.g. english, "
"french, german..."), 0, 0, &m_stemlangs);
m_w->addParam(idx, ConfTabsW::CFPT_FN, "logfilename",
tr("Log file name"),
@ -292,7 +292,7 @@ bool ConfIndexW::setupTopPanel(int idx)
tr("Aspell language"),
tr("The language for the aspell dictionary. "
"The values are are 2-letter "
"language codes, e.g. 'en', 'fr' ...<br>"
"language codes, e.g. 'en', 'fr' ...<br>"
"If this value is not set, the NLS environment "
"will be used to compute it, which usually works. "
"To get an idea of what is installed on your system, "

View File

@ -48,12 +48,12 @@ void CronToolW::init()
// Try to read the current values
if (!theconfig)
return;
return;
if (checkCrontabUnmanaged(marker, "recollindex")) {
QMessageBox::warning(0, "Recoll",
tr("It seems that manually edited entries exist for recollindex, cannot edit crontab"));
QTimer::singleShot(0, this, SLOT(close()));
QMessageBox::warning(0, "Recoll",
tr("It seems that manually edited entries exist for recollindex, cannot edit crontab"));
QTimer::singleShot(0, this, SLOT(close()));
}
string id = idstring(theconfig->getConfDir());
@ -77,7 +77,7 @@ void CronToolW::disableCron()
void CronToolW::changeCron(bool enable)
{
if (!theconfig)
return;
return;
string id = idstring(theconfig->getConfDir());
string cmd("recollindex");
@ -85,18 +85,18 @@ void CronToolW::changeCron(bool enable)
string reason;
if (!enable) {
editCrontab(marker, id, "", "", reason);
accept();
editCrontab(marker, id, "", "", reason);
accept();
} else {
string mins(qs2utf8s(minsLE->text().remove(QChar(' '))));
string hours(qs2utf8s(hoursLE->text().remove(QChar(' '))));
string days(qs2utf8s(daysLE->text().remove(QChar(' '))));
string sched = mins + " " + hours + " * * " + days;
if (editCrontab(marker, id, sched, cmd, reason)) {
accept();
} else {
QMessageBox::warning(0, "Recoll",
tr("Error installing cron entry. Bad syntax in fields ?"));
}
string sched = mins + " " + hours + " * * " + days;
if (editCrontab(marker, id, sched, cmd, reason)) {
accept();
} else {
QMessageBox::warning(0, "Recoll",
tr("Error installing cron entry. Bad syntax in fields ?"));
}
}
}

View File

@ -25,12 +25,12 @@ class CronToolW : public QDialog, public Ui::CronToolW {
Q_OBJECT
public:
CronToolW(QWidget * parent = 0)
: QDialog(parent),
enableButton(0),
disableButton(0)
: QDialog(parent),
enableButton(0),
disableButton(0)
{
setupUi(this);
init();
setupUi(this);
init();
}
QPushButton *enableButton;
QPushButton *disableButton;

View File

@ -23,9 +23,9 @@ class FirstIdxDialog : public QDialog, public Ui::FirstIdxDialog {
Q_OBJECT
public:
FirstIdxDialog(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
setupUi(this);
}
};

View File

@ -49,7 +49,7 @@ public:
};
void getfrags(std::vector<std::string>&);
bool ok() {return m_ok;}
bool ok() {return m_ok;}
bool isStale(time_t *reftime);
private slots:
void onButtonClicked(bool);

View File

@ -72,7 +72,7 @@ class PrefsPack {
int toolArea; // Area for "tools" toolbar
int resArea; // Area for "results" toolbar
bool ssearchTypSav; // Remember last search mode (else always
// start with same)
// start with same)
int ssearchTyp{0};
// Use single app (default: xdg-open), instead of per-mime settings
bool useDesktopOpen;
@ -109,9 +109,9 @@ class PrefsPack {
// Extra query indexes. This are stored in the history file, not qt prefs
vector<string> allExtraDbs;
vector<string> activeExtraDbs;
// Temporary value while we run a saved query. Erased right after use.
// Temporary value while we run a saved query. Erased right after use.
bool useTmpActiveExtraDbs{false};
vector<string> tmpActiveExtraDbs;
vector<string> tmpActiveExtraDbs;
// Advanced search subdir restriction: we don't activate the last value
// but just remember previously entered values
QStringList asearchSubdirHist;

View File

@ -24,12 +24,12 @@ class IdxSchedW : public QDialog, public Ui::IdxSchedW {
Q_OBJECT
public:
IdxSchedW(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
(void)new HelpClient(this);
HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.INDEXING");
setupUi(this);
(void)new HelpClient(this);
HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.INDEXING");
}
};

View File

@ -104,10 +104,10 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(theconfig));
}
rcldb->rmQueryDb("");
auto edbs = &prefs.activeExtraDbs;
if (prefs.useTmpActiveExtraDbs) {
edbs = &prefs.tmpActiveExtraDbs;
}
auto edbs = &prefs.activeExtraDbs;
if (prefs.useTmpActiveExtraDbs) {
edbs = &prefs.tmpActiveExtraDbs;
}
if (!edbs->empty()) {
rcldb->setExtraQueryDbs(*edbs);
}
@ -163,7 +163,7 @@ static void recollCleanup()
void applyStyleSheet(const QString& ssfname)
{
const std::string cfname = qs2path(ssfname);
const std::string cfname = qs2path(ssfname);
LOGDEB0("Applying style sheet: [" << cfname << "]\n");
if (!cfname.empty()) {
string stylesheet;

View File

@ -43,13 +43,13 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
fdialog.setFileMode(QFileDialog::Directory);
fdialog.setOption(QFileDialog::ShowDirsOnly);
if (fdialog.exec() == 0)
return;
return;
QStringList dirl = fdialog.selectedFiles();
if (dirl.size() != 1) {
// Can't happen ?
QMessageBox::warning(0, "Recoll",
QWidget::tr("Choose exactly one directory"));
return;
// Can't happen ?
QMessageBox::warning(0, "Recoll",
QWidget::tr("Choose exactly one directory"));
return;
}
string dir(qs2path(dirl[0]));
LOGDEB2("multiSave: got dir " << dir << "\n");
@ -78,63 +78,63 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
set<string> existingNames;
string reason;
if (!listdir(dir, reason, existingNames)) {
QMessageBox::warning(0, "Recoll",
QWidget::tr("Could not read directory: ") +
path2qs(reason));
return;
QMessageBox::warning(0, "Recoll",
QWidget::tr("Could not read directory: ") +
path2qs(reason));
return;
}
set<string> toBeCreated;
vector<string> filenames;
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
string utf8fn;
it->getmeta(Rcl::Doc::keyfn, &utf8fn);
string suffix = path_suffix(utf8fn);
LOGDEB("Multisave: [" << (utf8fn) << "] suff [" << (suffix) << "]\n" );
if (suffix.empty() || suffix.size() > 10) {
suffix = theconfig->getSuffixFromMimeType(it->mimetype);
LOGDEB("Multisave: suff from config [" << (suffix) << "]\n" );
}
string simple = path_basename(utf8fn, string(".") + suffix);
LOGDEB("Multisave: simple [" << (simple) << "]\n" );
if (simple.empty())
simple = "rclsave";
if (simple.size() > maxlen) {
simple = simple.substr(0, maxlen);
}
for (int vers = 0; ; vers++) {
ostringstream ss;
ss << simple;
if (vers)
ss << "." << vers;
if (!suffix.empty())
ss << "." << suffix;
string utf8fn;
it->getmeta(Rcl::Doc::keyfn, &utf8fn);
string suffix = path_suffix(utf8fn);
LOGDEB("Multisave: [" << (utf8fn) << "] suff [" << (suffix) << "]\n" );
if (suffix.empty() || suffix.size() > 10) {
suffix = theconfig->getSuffixFromMimeType(it->mimetype);
LOGDEB("Multisave: suff from config [" << (suffix) << "]\n" );
}
string simple = path_basename(utf8fn, string(".") + suffix);
LOGDEB("Multisave: simple [" << (simple) << "]\n" );
if (simple.empty())
simple = "rclsave";
if (simple.size() > maxlen) {
simple = simple.substr(0, maxlen);
}
for (int vers = 0; ; vers++) {
ostringstream ss;
ss << simple;
if (vers)
ss << "." << vers;
if (!suffix.empty())
ss << "." << suffix;
string fn = qs2path(u8s2qs(ss.str()));
if (existingNames.find(fn) == existingNames.end() &&
toBeCreated.find(fn) == toBeCreated.end()) {
toBeCreated.insert(fn);
filenames.push_back(fn);
break;
}
}
string fn = qs2path(u8s2qs(ss.str()));
if (existingNames.find(fn) == existingNames.end() &&
toBeCreated.find(fn) == toBeCreated.end()) {
toBeCreated.insert(fn);
filenames.push_back(fn);
break;
}
}
}
for (unsigned int i = 0; i != docs.size(); i++) {
string fn = path_cat(dir, filenames[i]);
if (path_exists(fn)) {
QMessageBox::warning(0, "Recoll",
QWidget::tr("Unexpected file name collision, "
"cancelling."));
return;
}
// There is still a race condition here, should we care ?
TempFile temp;// not used
if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) {
QMessageBox::warning(
string fn = path_cat(dir, filenames[i]);
if (path_exists(fn)) {
QMessageBox::warning(0, "Recoll",
QWidget::tr("Unexpected file name collision, "
"cancelling."));
return;
}
// There is still a race condition here, should we care ?
TempFile temp;// not used
if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) {
QMessageBox::warning(
0, "Recoll", QWidget::tr("Cannot extract document: ") +
path2qs(docs[i].url) + " | " + u8s2qs(docs[i].ipath));
}
}
}
}

View File

@ -44,7 +44,7 @@ void EditTrans::init(const string& dbdir)
{
m_dbdir = path_canon(dbdir);
connect(transTW, SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
connect(cancelPB, SIGNAL(clicked()), this, SLOT(close()));
QString lab = whatIdxLA->text();
@ -57,18 +57,18 @@ void EditTrans::init(const string& dbdir)
ConfSimple *conftrans = theconfig->getPTrans();
if (!conftrans)
return;
return;
int row = 0;
vector<string> opaths = conftrans->getNames(m_dbdir);
for (vector<string>::const_iterator it = opaths.begin();
it != opaths.end(); it++) {
transTW->setRowCount(row+1);
transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it)));
string npath;
conftrans->get(*it, npath, m_dbdir);
transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath)));
row++;
it != opaths.end(); it++) {
transTW->setRowCount(row+1);
transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it)));
string npath;
conftrans->get(*it, npath, m_dbdir);
transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath)));
row++;
}
resize(QSize(640, 300).expandedTo(minimumSizeHint()));
@ -83,18 +83,18 @@ void EditTrans::on_savePB_clicked()
{
ConfSimple *conftrans = theconfig->getPTrans();
if (!conftrans) {
QMessageBox::warning(0, "Recoll", tr("Config error"));
return;
QMessageBox::warning(0, "Recoll", tr("Config error"));
return;
}
conftrans->holdWrites(true);
conftrans->eraseKey(m_dbdir);
for (int row = 0; row < transTW->rowCount(); row++) {
QTableWidgetItem *item0 = transTW->item(row, 0);
string from = path_canon(qs2path(item0->text()));
QTableWidgetItem *item1 = transTW->item(row, 1);
string to = path_canon(qs2path(item1->text()));
conftrans->set(from, to, m_dbdir);
QTableWidgetItem *item0 = transTW->item(row, 0);
string from = path_canon(qs2path(item0->text()));
QTableWidgetItem *item1 = transTW->item(row, 1);
string to = path_canon(qs2path(item1->text()));
conftrans->set(from, to, m_dbdir);
}
conftrans->holdWrites(false);
// The rcldb does not use the same configuration object, but a
@ -118,12 +118,12 @@ void EditTrans::on_delPB_clicked()
QModelIndexList indexes = transTW->selectionModel()->selectedIndexes();
vector<int> rows;
for (int i = 0; i < indexes.size(); i++) {
rows.push_back(indexes.at(i).row());
rows.push_back(indexes.at(i).row());
}
sort(rows.begin(), rows.end());
rows.resize(unique(rows.begin(), rows.end()) - rows.begin());
for (int i = rows.size()-1; i >= 0; i--) {
transTW->removeRow(rows[i]);
transTW->removeRow(rows[i]);
}
}
@ -131,8 +131,8 @@ void EditTrans::on_transTW_itemSelectionChanged()
{
QModelIndexList indexes = transTW->selectionModel()->selectedIndexes();
if(indexes.size() < 1)
delPB->setEnabled(0);
delPB->setEnabled(0);
else
delPB->setEnabled(1);
delPB->setEnabled(1);
}

View File

@ -32,10 +32,10 @@ class EditTrans : public QDialog, public Ui::EditTransBase
public:
EditTrans(const std::string& dbdir, QWidget* parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
init(dbdir);
setupUi(this);
init(dbdir);
}
public slots:

View File

@ -41,32 +41,32 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event)
{
static time_t last_start;
if (event->type() == QEvent::KeyPress ||
event->type() == QEvent::ShortcutOverride) {
// LOGDEB("HelpClient::eventFilter: " << ((int)event->type()) << "\n" );
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) {
if (obj->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(obj)->focusWidget();
map<string, string>::iterator it = helpmap.end();
while (widget) {
it = helpmap.find((const char *)widget->objectName().toUtf8());
if (it != helpmap.end())
break;
widget = widget->parentWidget();
}
if (time(0) - last_start > 5) {
last_start = time(0);
if (it != helpmap.end()) {
LOGDEB("HelpClient::eventFilter: " << (it->first) << "->" << (it->second) << "\n" );
startManual(it->second);
} else {
LOGDEB("HelpClient::eventFilter: no help section\n" );
startManual("");
}
}
}
return true;
}
event->type() == QEvent::ShortcutOverride) {
// LOGDEB("HelpClient::eventFilter: " << ((int)event->type()) << "\n" );
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) {
if (obj->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(obj)->focusWidget();
map<string, string>::iterator it = helpmap.end();
while (widget) {
it = helpmap.find((const char *)widget->objectName().toUtf8());
if (it != helpmap.end())
break;
widget = widget->parentWidget();
}
if (time(0) - last_start > 5) {
last_start = time(0);
if (it != helpmap.end()) {
LOGDEB("HelpClient::eventFilter: " << (it->first) << "->" << (it->second) << "\n" );
startManual(it->second);
} else {
LOGDEB("HelpClient::eventFilter: no help section\n" );
startManual("");
}
}
}
return true;
}
}
return false;
}

View File

@ -668,11 +668,11 @@ void RclMain::fileExit()
}
// Don't save geometry if we're currently maximized. At least under X11
// this saves the maximized size. otoh isFullscreen() does not seem needed
// this saves the maximized size. otoh isFullscreen() does not seem needed
if (!isMaximized()) {
QSettings settings;
settings.setValue("/Recoll/geometry/maingeom", saveGeometry());
}
QSettings settings;
settings.setValue("/Recoll/geometry/maingeom", saveGeometry());
}
prefs.toolArea = toolBarArea(m_toolsTB);
prefs.resArea = toolBarArea(m_resTB);

View File

@ -78,7 +78,7 @@ inline std::string qs2path(const QString& qs)
/** Specialized version of the qt file dialog. Can't use getOpenFile()
etc. cause they hide dot files... */
extern QString myGetFileName(bool isdir, QString caption = QString(),
bool filenosave = false,
bool filenosave = false,
QString dirlocation = QString(),
QString dlftnm = QString()
);

View File

@ -20,12 +20,12 @@
namespace ResultPopup {
enum Options {showExpand = 0x1, showSubs = 0x2, isMain = 0x3,
showSaveOne = 0x4, showSaveSel = 0x8};
showSaveOne = 0x4, showSaveSel = 0x8};
extern QMenu *create(QWidget *me, int opts,
std::shared_ptr<DocSequence> source,
Rcl::Doc& doc);
std::shared_ptr<DocSequence> source,
Rcl::Doc& doc);
extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source,
Rcl::Doc& doc);
Rcl::Doc& doc);
extern void copyFN(const Rcl::Doc &doc);
extern void copyURL(const Rcl::Doc &doc);
};

View File

@ -45,9 +45,9 @@ public:
virtual int rowCount (const QModelIndex& = QModelIndex()) const;
virtual int columnCount(const QModelIndex& = QModelIndex()) const;
virtual QVariant headerData (int col, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const;
int role = Qt::DisplayRole ) const;
virtual QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole ) const;
int role = Qt::DisplayRole ) const;
virtual void saveAsCSV(std::fstream& fp);
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
// Specific methods
@ -58,7 +58,7 @@ public:
virtual const std::vector<std::string>& getFields() {return m_fields;}
virtual const std::map<std::string, QString>& getAllFields()
{
return o_displayableFields;
return o_displayableFields;
}
virtual void addColumn(int, const std::string&);
// Some column name are aliases/translator for base document field
@ -112,12 +112,12 @@ class ResTable : public QWidget, public Ui::ResTable
public:
ResTable(QWidget* parent = 0)
: QWidget(parent),
m_model(0), m_pager(0), m_detail(0), m_detaildocnum(-1),
m_rclmain(0), m_ismainres(true)
: QWidget(parent),
m_model(0), m_pager(0), m_detail(0), m_detaildocnum(-1),
m_rclmain(0), m_ismainres(true)
{
setupUi(this);
init();
setupUi(this);
init();
}
virtual ~ResTable() {}

View File

@ -25,10 +25,10 @@ class RTIToolW : public QDialog, public Ui::RTIToolW {
Q_OBJECT
public:
RTIToolW(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
init();
setupUi(this);
init();
}
public slots:
#ifdef _WIN32

View File

@ -85,14 +85,14 @@ void SearchClauseW::languageChange()
fldCMB->addItem(tr("No field"));
if (theconfig) {
set<string> fields = theconfig->getIndexedFields();
for (set<string>::const_iterator it = fields.begin();
it != fields.end(); it++) {
// Some fields don't make sense here
if (it->compare("filename")) {
fldCMB->addItem(QString::fromUtf8(it->c_str()));
}
}
set<string> fields = theconfig->getIndexedFields();
for (set<string>::const_iterator it = fields.begin();
it != fields.end(); it++) {
// Some fields don't make sense here
if (it->compare("filename")) {
fldCMB->addItem(QString::fromUtf8(it->c_str()));
}
}
}
// Ensure that the spinbox will be enabled/disabled depending on
// combobox state
@ -106,35 +106,35 @@ void SearchClauseW::languageChange()
SearchDataClause *SearchClauseW::getClause()
{
if (wordsLE->text().isEmpty())
return 0;
return 0;
string field;
if (fldCMB->currentIndex() != 0) {
field = (const char *)fldCMB->currentText().toUtf8();
field = (const char *)fldCMB->currentText().toUtf8();
}
string text = (const char *)wordsLE->text().toUtf8();
switch (sTpCMB->currentIndex()) {
case 0:
return new SearchDataClauseSimple(SCLT_OR, text, field);
return new SearchDataClauseSimple(SCLT_OR, text, field);
case 1:
return new SearchDataClauseSimple(SCLT_AND, text, field);
return new SearchDataClauseSimple(SCLT_AND, text, field);
case 2:
{
SearchDataClauseSimple *cl =
new SearchDataClauseSimple(SCLT_OR, text, field);
cl->setexclude(true);
return cl;
SearchDataClauseSimple *cl =
new SearchDataClauseSimple(SCLT_OR, text, field);
cl->setexclude(true);
return cl;
}
case 3:
return new SearchDataClauseDist(SCLT_PHRASE, text,
proxSlackSB->value(), field);
return new SearchDataClauseDist(SCLT_PHRASE, text,
proxSlackSB->value(), field);
case 4:
return new SearchDataClauseDist(SCLT_NEAR, text,
proxSlackSB->value(), field);
return new SearchDataClauseDist(SCLT_NEAR, text,
proxSlackSB->value(), field);
case 5:
return new SearchDataClauseFilename(text);
return new SearchDataClauseFilename(text);
case 6:
default:
return 0;
return 0;
}
}
@ -147,7 +147,7 @@ void SearchClauseW::setFromClause(SearchDataClauseSimple *cl)
case SCLT_AND: tpChange(1); break;
case SCLT_PHRASE: tpChange(3); break;
case SCLT_NEAR: tpChange(4); break;
case SCLT_FILENAME: tpChange(5); break;
case SCLT_FILENAME: tpChange(5); break;
default: return;
}
LOGDEB("SearchClauseW::setFromClause: calling erase\n" );
@ -159,26 +159,26 @@ void SearchClauseW::setFromClause(SearchDataClauseSimple *cl)
switch(cl->getTp()) {
case SCLT_OR: case SCLT_AND:
case SCLT_PHRASE: case SCLT_NEAR:
if (!field.isEmpty()) {
int idx = fldCMB->findText(field);
if (field >= 0) {
fldCMB->setCurrentIndex(idx);
} else {
fldCMB->setEditText(field);
}
}
/* FALLTHROUGH */
if (!field.isEmpty()) {
int idx = fldCMB->findText(field);
if (field >= 0) {
fldCMB->setCurrentIndex(idx);
} else {
fldCMB->setEditText(field);
}
}
/* FALLTHROUGH */
case SCLT_FILENAME:
wordsLE->setText(text);
break;
wordsLE->setText(text);
break;
default: break;
}
switch(cl->getTp()) {
case SCLT_PHRASE: case SCLT_NEAR:
{
SearchDataClauseDist *cls = dynamic_cast<SearchDataClauseDist*>(cl);
proxSlackSB->setValue(cls->getslack());
SearchDataClauseDist *cls = dynamic_cast<SearchDataClauseDist*>(cl);
proxSlackSB->setValue(cls->getslack());
}
break;
default: break;
@ -197,26 +197,26 @@ void SearchClauseW::clear()
void SearchClauseW::tpChange(int index)
{
if (index < 0 || index > 5)
return;
return;
if (sTpCMB->currentIndex() != index)
sTpCMB->setCurrentIndex(index);
sTpCMB->setCurrentIndex(index);
switch (index) {
case 3:
case 4:
proxSlackSB->show();
proxSlackSB->setEnabled(true);
if (index == 4)
proxSlackSB->setValue(10);
proxSlackSB->show();
proxSlackSB->setEnabled(true);
if (index == 4)
proxSlackSB->setValue(10);
else
proxSlackSB->setValue(0);
break;
break;
default:
proxSlackSB->close();
proxSlackSB->close();
}
if (index == 5) {
fldCMB->close();
fldCMB->close();
} else {
fldCMB->show();
fldCMB->show();
}
}

View File

@ -30,9 +30,9 @@ class SpecIdxW : public QDialog, public Ui::SpecIdxW {
public:
SpecIdxW(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
setupUi(this);
selPatsLE->setEnabled(false);
connect(browsePB, SIGNAL(clicked()), this, SLOT(onBrowsePB_clicked()));
connect(targLE, SIGNAL(textChanged(const QString&)),

View File

@ -28,15 +28,15 @@ class SpellW : public QWidget, public Ui::SpellBase
Q_OBJECT;
public:
SpellW(QWidget* parent = 0)
: QWidget(parent), m_prevmode(TYPECMB_NONE) {
setupUi(this);
init();
: QWidget(parent), m_prevmode(TYPECMB_NONE) {
setupUi(this);
init();
}
virtual bool eventFilter(QObject *target, QEvent *event );
enum comboboxchoice {TYPECMB_NONE, TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM,
TYPECMB_SPELL, TYPECMB_STATS, TYPECMB_FAILED};
TYPECMB_SPELL, TYPECMB_STATS, TYPECMB_FAILED};
public slots:
virtual void doExpand();
virtual void wordChanged(const QString&);

View File

@ -537,12 +537,12 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
bool SSearch::checkExtIndexes(const std::vector<std::string>& dbs)
{
std::string reason;
if (!maybeOpenDb(reason, false)) {
std::string reason;
if (!maybeOpenDb(reason, false)) {
QMessageBox::critical(0, "Recoll", tr("Can't open index") +
u8s2qs(reason));
return false;
}
}
if (!rcldb->setExtraQueryDbs(dbs)) {
return false;
}

View File

@ -31,12 +31,12 @@ class UIPrefsDialog : public QDialog, public Ui::uiPrefsDialogBase
public:
UIPrefsDialog(RclMain* parent)
: QDialog((QWidget*)parent), m_mainWindow(parent)
{
setupUi(this);
init();
}
~UIPrefsDialog(){};
: QDialog((QWidget*)parent), m_mainWindow(parent)
{
setupUi(this);
init();
}
~UIPrefsDialog(){};
QString reslistFontFamily;
int reslistFontSize;

View File

@ -40,9 +40,9 @@ public:
virtual int rowCount (const QModelIndex& = QModelIndex()) const;
virtual int columnCount(const QModelIndex& = QModelIndex()) const;
virtual QVariant headerData (int col, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
int role = Qt::DisplayRole) const;
virtual QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole ) const;
int role = Qt::DisplayRole ) const;
bool deleteIdx(unsigned int idx);
std::string getURL(unsigned int idx);

View File

@ -25,9 +25,9 @@ class EditDialog : public QDialog, public Ui::EditDialog {
Q_OBJECT
public:
EditDialog(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
setupUi(this);
}
};

View File

@ -22,9 +22,9 @@ class ListDialog : public QDialog, public Ui::ListDialog {
Q_OBJECT
public:
ListDialog(QWidget * parent = 0)
: QDialog(parent)
: QDialog(parent)
{
setupUi(this);
setupUi(this);
}
};

View File

@ -220,11 +220,11 @@ public:
}
inline PVT * operator->()
{
return static_cast<PVT*>(pvt);
return static_cast<PVT*>(pvt);
}
inline const PVT * operator->() const
{
return static_cast<PVT*>(pvt);
return static_cast<PVT*>(pvt);
}
private:
QxtPrivateInterface(const QxtPrivateInterface&) { }

View File

@ -36,9 +36,9 @@ using namespace std;
void WinSchedToolW::init()
{
if (!theconfig) {
QMessageBox::warning(0, tr("Error"),
tr("Configuration not initialized"));
return;
QMessageBox::warning(0, tr("Error"),
tr("Configuration not initialized"));
return;
}
connect(startPB, SIGNAL(clicked()), this, SLOT(startWinScheduler()));

View File

@ -35,19 +35,19 @@ public:
SDHXMLHandler()
: isvalid(false)
{
resetTemps();
resetTemps();
}
bool startElement(const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attributes);
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attributes);
bool endElement(const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qName);
const QString & /* localName */,
const QString &qName);
bool characters(const QString &str)
{
currentText += str;
return true;
currentText += str;
return true;
}
// The object we set up
@ -57,14 +57,14 @@ public:
private:
void resetTemps()
{
currentText = whatclause = "";
text.clear();
currentText = whatclause = "";
text.clear();
text2.clear();
field.clear();
slack = 0;
d = m = y = di.d1 = di.m1 = di.y1 = di.d2 = di.m2 = di.y2 = 0;
hasdates = false;
exclude = false;
field.clear();
slack = 0;
d = m = y = di.d1 = di.m1 = di.y1 = di.d2 = di.m2 = di.y2 = 0;
hasdates = false;
exclude = false;
}
// Temporary data while parsing.
@ -79,9 +79,9 @@ private:
};
bool SDHXMLHandler::startElement(const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attrs)
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attrs)
{
LOGDEB2("SDHXMLHandler::startElement: name [" << qs2utf8s(qName) << "]\n");
if (qName == "SD") {
@ -90,15 +90,15 @@ bool SDHXMLHandler::startElement(const QString & /* namespaceURI */,
int idx = attrs.index("type");
if (idx >= 0 && attrs.value(idx).compare("searchdata")) {
LOGDEB("XMLTOSD: bad type: " << qs2utf8s(attrs.value(idx)) << endl);
return false;
}
resetTemps();
// A new search descriptor. Allocate data structure
return false;
}
resetTemps();
// A new search descriptor. Allocate data structure
sd = std::shared_ptr<SearchData>(new SearchData);
if (!sd) {
LOGERR("SDHXMLHandler::startElement: out of memory\n");
return false;
}
if (!sd) {
LOGERR("SDHXMLHandler::startElement: out of memory\n");
return false;
}
}
return true;
}
@ -110,101 +110,101 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */,
LOGDEB2("SDHXMLHandler::endElement: name [" << qs2utf8s(qName) << "]\n");
if (qName == "CLT") {
if (currentText == "OR") {
sd->setTp(SCLT_OR);
}
if (currentText == "OR") {
sd->setTp(SCLT_OR);
}
} else if (qName == "CT") {
whatclause = currentText.trimmed();
whatclause = currentText.trimmed();
} else if (qName == "NEG") {
exclude = true;
exclude = true;
} else if (qName == "F") {
field = base64_decode(qs2utf8s(currentText.trimmed()));
field = base64_decode(qs2utf8s(currentText.trimmed()));
} else if (qName == "T") {
text = base64_decode(qs2utf8s(currentText.trimmed()));
text = base64_decode(qs2utf8s(currentText.trimmed()));
} else if (qName == "T2") {
text2 = base64_decode(qs2utf8s(currentText.trimmed()));
text2 = base64_decode(qs2utf8s(currentText.trimmed()));
} else if (qName == "S") {
slack = atoi((const char *)currentText.toUtf8());
slack = atoi((const char *)currentText.toUtf8());
} else if (qName == "C") {
SearchDataClause *c;
if (whatclause == "AND" || whatclause.isEmpty()) {
c = new SearchDataClauseSimple(SCLT_AND, text, field);
c->setexclude(exclude);
} else if (whatclause == "OR") {
c = new SearchDataClauseSimple(SCLT_OR, text, field);
c->setexclude(exclude);
} else if (whatclause == "RG") {
c = new SearchDataClauseRange(text, text2, field);
c->setexclude(exclude);
} else if (whatclause == "EX") {
// Compat with old hist. We don't generete EX (SCLT_EXCL) anymore
// it's replaced with OR + exclude flag
c = new SearchDataClauseSimple(SCLT_OR, text, field);
c->setexclude(true);
} else if (whatclause == "FN") {
c = new SearchDataClauseFilename(text);
c->setexclude(exclude);
} else if (whatclause == "PH") {
c = new SearchDataClauseDist(SCLT_PHRASE, text, slack, field);
c->setexclude(exclude);
} else if (whatclause == "NE") {
c = new SearchDataClauseDist(SCLT_NEAR, text, slack, field);
c->setexclude(exclude);
} else {
LOGERR("Bad clause type [" << qs2utf8s(whatclause) << "]\n");
return false;
}
sd->addClause(c);
whatclause = "";
text.clear();
field.clear();
slack = 0;
exclude = false;
SearchDataClause *c;
if (whatclause == "AND" || whatclause.isEmpty()) {
c = new SearchDataClauseSimple(SCLT_AND, text, field);
c->setexclude(exclude);
} else if (whatclause == "OR") {
c = new SearchDataClauseSimple(SCLT_OR, text, field);
c->setexclude(exclude);
} else if (whatclause == "RG") {
c = new SearchDataClauseRange(text, text2, field);
c->setexclude(exclude);
} else if (whatclause == "EX") {
// Compat with old hist. We don't generete EX (SCLT_EXCL) anymore
// it's replaced with OR + exclude flag
c = new SearchDataClauseSimple(SCLT_OR, text, field);
c->setexclude(true);
} else if (whatclause == "FN") {
c = new SearchDataClauseFilename(text);
c->setexclude(exclude);
} else if (whatclause == "PH") {
c = new SearchDataClauseDist(SCLT_PHRASE, text, slack, field);
c->setexclude(exclude);
} else if (whatclause == "NE") {
c = new SearchDataClauseDist(SCLT_NEAR, text, slack, field);
c->setexclude(exclude);
} else {
LOGERR("Bad clause type [" << qs2utf8s(whatclause) << "]\n");
return false;
}
sd->addClause(c);
whatclause = "";
text.clear();
field.clear();
slack = 0;
exclude = false;
} else if (qName == "D") {
d = atoi((const char *)currentText.toUtf8());
d = atoi((const char *)currentText.toUtf8());
} else if (qName == "M") {
m = atoi((const char *)currentText.toUtf8());
m = atoi((const char *)currentText.toUtf8());
} else if (qName == "Y") {
y = atoi((const char *)currentText.toUtf8());
y = atoi((const char *)currentText.toUtf8());
} else if (qName == "DMI") {
di.d1 = d;
di.m1 = m;
di.y1 = y;
hasdates = true;
di.d1 = d;
di.m1 = m;
di.y1 = y;
hasdates = true;
} else if (qName == "DMA") {
di.d2 = d;
di.m2 = m;
di.y2 = y;
hasdates = true;
di.d2 = d;
di.m2 = m;
di.y2 = y;
hasdates = true;
} else if (qName == "MIS") {
sd->setMinSize(atoll((const char *)currentText.toUtf8()));
sd->setMinSize(atoll((const char *)currentText.toUtf8()));
} else if (qName == "MAS") {
sd->setMaxSize(atoll((const char *)currentText.toUtf8()));
sd->setMaxSize(atoll((const char *)currentText.toUtf8()));
} else if (qName == "ST") {
string types = (const char *)currentText.toUtf8();
vector<string> vt;
stringToTokens(types, vt);
for (unsigned int i = 0; i < vt.size(); i++)
sd->addFiletype(vt[i]);
string types = (const char *)currentText.toUtf8();
vector<string> vt;
stringToTokens(types, vt);
for (unsigned int i = 0; i < vt.size(); i++)
sd->addFiletype(vt[i]);
} else if (qName == "IT") {
string types(qs2utf8s(currentText));
vector<string> vt;
stringToTokens(types, vt);
for (unsigned int i = 0; i < vt.size(); i++)
sd->remFiletype(vt[i]);
string types(qs2utf8s(currentText));
vector<string> vt;
stringToTokens(types, vt);
for (unsigned int i = 0; i < vt.size(); i++)
sd->remFiletype(vt[i]);
} else if (qName == "YD") {
string d;
base64_decode(qs2utf8s(currentText.trimmed()), d);
sd->addClause(new SearchDataClausePath(d));
string d;
base64_decode(qs2utf8s(currentText.trimmed()), d);
sd->addClause(new SearchDataClausePath(d));
} else if (qName == "ND") {
string d;
base64_decode(qs2utf8s(currentText.trimmed()), d);
sd->addClause(new SearchDataClausePath(d, true));
string d;
base64_decode(qs2utf8s(currentText.trimmed()), d);
sd->addClause(new SearchDataClausePath(d, true));
} else if (qName == "SD") {
// Closing current search descriptor. Finishing touches...
if (hasdates)
sd->setDateSpan(&di);
resetTemps();
// Closing current search descriptor. Finishing touches...
if (hasdates)
sd->setDateSpan(&di);
resetTemps();
isvalid = true;
}
currentText.clear();
@ -242,12 +242,12 @@ public:
resetTemps();
}
bool startElement(const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attributes);
const QString & /* localName */,
const QString &qName,
const QXmlAttributes &attributes);
bool endElement(const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qName);
const QString & /* localName */,
const QString &qName);
bool characters(const QString &str)
{
currentText += str;
@ -289,7 +289,7 @@ bool SSHXMLHandler::startElement(const QString & /* namespaceURI */,
}
return false;
}
resetTemps();
resetTemps();
}
return true;
}
@ -326,8 +326,8 @@ bool SSHXMLHandler::endElement(const QString & /* namespaceURI */,
} else if (qName == "AP") {
data.autophrase = true;
} else if (qName == "SD") {
// Closing current search descriptor. Finishing touches...
resetTemps();
// Closing current search descriptor. Finishing touches...
resetTemps();
isvalid = true;
}
currentText.clear();

View File

@ -30,11 +30,11 @@ int DocSequence::getSeqSlice(int offs, int cnt, vector<ResListEntry>& result)
{
int ret = 0;
for (int num = offs; num < offs + cnt; num++, ret++) {
result.push_back(ResListEntry());
if (!getDoc(num, result.back().doc, &result.back().subHeader)) {
result.pop_back();
return ret;
}
result.push_back(ResListEntry());
if (!getDoc(num, result.back().doc, &result.back().subHeader)) {
result.pop_back();
return ret;
}
}
return ret;
}
@ -43,8 +43,8 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
{
std::shared_ptr<Rcl::Db> db = getDb();
if (!db) {
LOGERR("DocSequence::getEnclosing: no db\n" );
return false;
LOGERR("DocSequence::getEnclosing: no db\n" );
return false;
}
std::unique_lock<std::mutex> locker(o_dblock);
string udi;
@ -59,9 +59,9 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
void DocSource::stripStack()
{
if (!m_seq)
return;
return;
while (m_seq->getSourceSeq()) {
m_seq = m_seq->getSourceSeq();
m_seq = m_seq->getSourceSeq();
}
}
@ -71,29 +71,29 @@ bool DocSource::buildStack()
stripStack();
if (!m_seq)
return false;
return false;
// Filtering must be done before sorting, (which may
// truncates the original list)
if (m_seq->canFilter()) {
if (!m_seq->setFiltSpec(m_fspec)) {
LOGERR("DocSource::buildStack: setfiltspec failed\n" );
}
if (!m_seq->setFiltSpec(m_fspec)) {
LOGERR("DocSource::buildStack: setfiltspec failed\n" );
}
} else {
if (m_fspec.isNotNull()) {
m_seq =
std::shared_ptr<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
}
if (m_fspec.isNotNull()) {
m_seq =
std::shared_ptr<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
}
}
if (m_seq->canSort()) {
if (!m_seq->setSortSpec(m_sspec)) {
LOGERR("DocSource::buildStack: setsortspec failed\n" );
}
if (!m_seq->setSortSpec(m_sspec)) {
LOGERR("DocSource::buildStack: setsortspec failed\n" );
}
} else {
if (m_sspec.isNotNull()) {
m_seq = std::shared_ptr<DocSequence>(new DocSeqSorted(m_seq, m_sspec));
}
if (m_sspec.isNotNull()) {
m_seq = std::shared_ptr<DocSequence>(new DocSeqSorted(m_seq, m_sspec));
}
}
return true;
}
@ -101,14 +101,14 @@ bool DocSource::buildStack()
string DocSource::title()
{
if (!m_seq)
return string();
return string();
string qual;
if (m_fspec.isNotNull() && !m_sspec.isNotNull())
qual = string(" (") + o_filt_trans + string(")");
qual = string(" (") + o_filt_trans + string(")");
else if (!m_fspec.isNotNull() && m_sspec.isNotNull())
qual = string(" (") + o_sort_trans + string(")");
qual = string(" (") + o_sort_trans + string(")");
else if (m_fspec.isNotNull() && m_sspec.isNotNull())
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
return m_seq->title() + qual;
}

View File

@ -28,7 +28,7 @@ class DocSequenceDb : public DocSequence {
public:
DocSequenceDb(std::shared_ptr<Rcl::Db> db,
std::shared_ptr<Rcl::Query> q, const std::string &t,
std::shared_ptr<Rcl::SearchData> sdata);
std::shared_ptr<Rcl::SearchData> sdata);
virtual ~DocSequenceDb() {}
virtual bool getDoc(int num, Rcl::Doc &doc, std::string * = 0) override;
virtual int getResCnt() override;
@ -55,7 +55,7 @@ class DocSequenceDb : public DocSequence {
}
virtual bool snippetsCapable() override {
return true;
return true;
}
virtual std::string title() override;

View File

@ -31,30 +31,30 @@ class DocSequenceDocs : public DocSequence {
public:
DocSequenceDocs(std::shared_ptr<Rcl::Db> d,
const std::vector<Rcl::Doc> docs, const string &t)
: DocSequence(t), m_db(d), m_docs(docs) {
: DocSequence(t), m_db(d), m_docs(docs) {
}
virtual ~DocSequenceDocs() {
}
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) {
if (sh)
*sh = string();
if (num < 0 || num >= int(m_docs.size()))
return false;
doc = m_docs[num];
return true;
if (sh)
*sh = string();
if (num < 0 || num >= int(m_docs.size()))
return false;
doc = m_docs[num];
return true;
}
virtual int getResCnt() {
return m_docs.size();
return m_docs.size();
}
virtual string getDescription() {
return m_description;
return m_description;
}
void setDescription(const string& desc) {
m_description = desc;
m_description = desc;
}
protected:
virtual std::shared_ptr<Rcl::Db> getDb() {
return m_db;
return m_db;
}
private:
std::shared_ptr<Rcl::Db> m_db;

View File

@ -125,31 +125,31 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
{
// Retrieve history list
if (!m_hist)
return false;
return false;
if (m_history.empty())
m_history = getDocHistory(m_hist);
m_history = getDocHistory(m_hist);
if (num < 0 || num >= (int)m_history.size())
return false;
return false;
// We get the history oldest first, but our users expect newest first
RclDHistoryEntry& hentry = m_history[m_history.size() - 1 - num];
if (sh) {
if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) {
m_prevtime = hentry.unixtime;
time_t t = (time_t)(hentry.unixtime);
*sh = string(ctime(&t));
// Get rid of the final \n in ctime
sh->erase(sh->length()-1);
} else {
sh->erase();
if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) {
m_prevtime = hentry.unixtime;
time_t t = (time_t)(hentry.unixtime);
*sh = string(ctime(&t));
// Get rid of the final \n in ctime
sh->erase(sh->length()-1);
} else {
sh->erase();
}
}
bool ret = m_db->getDoc(hentry.udi, hentry.dbdir, doc);
if (!ret || doc.pc == -1) {
doc.url = "UNKNOWN";
doc.url = "UNKNOWN";
doc.ipath = "";
}
@ -163,7 +163,7 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
int DocSequenceHistory::getResCnt()
{
if (m_history.empty())
m_history = getDocHistory(m_hist);
m_history = getDocHistory(m_hist);
return int(m_history.size());
}

View File

@ -33,7 +33,7 @@ class RclDHistoryEntry : public DynConfEntry {
public:
RclDHistoryEntry() : unixtime(0) {}
RclDHistoryEntry(time_t t, const std::string& u, const std::string& d)
: unixtime(t), udi(u), dbdir(d) {}
: unixtime(t), udi(u), dbdir(d) {}
virtual ~RclDHistoryEntry() {}
virtual bool decode(const std::string &value);
virtual bool encode(std::string& value);
@ -50,7 +50,7 @@ class DocSequenceHistory : public DocSequence {
public:
DocSequenceHistory(std::shared_ptr<Rcl::Db> db, RclDynConf *h,
const std::string &t)
: DocSequence(t), m_db(db), m_hist(h) {}
: DocSequence(t), m_db(db), m_hist(h) {}
virtual ~DocSequenceHistory() {}
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0);

View File

@ -47,7 +47,7 @@ RclDynConf::RclDynConf(const std::string &fn)
}
bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
int maxlen)
int maxlen)
{
if (!rw()) {
LOGDEB("RclDynConf::insertNew: not writable\n");
@ -58,38 +58,38 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
vector<string>::const_iterator it;
bool changed = false;
for (it = names.begin(); it != names.end(); it++) {
string oval;
if (!m_data.get(*it, oval, sk)) {
LOGDEB("No data for " << *it << "\n");
continue;
}
s.decode(oval);
string oval;
if (!m_data.get(*it, oval, sk)) {
LOGDEB("No data for " << *it << "\n");
continue;
}
s.decode(oval);
if (s.equal(n)) {
LOGDEB("Erasing old entry\n");
m_data.erase(*it, sk);
changed = true;
}
if (s.equal(n)) {
LOGDEB("Erasing old entry\n");
m_data.erase(*it, sk);
changed = true;
}
}
// Maybe reget things
if (changed)
names = m_data.getNames(sk);
names = m_data.getNames(sk);
// Need to prune ?
if (maxlen > 0 && names.size() >= (unsigned int)maxlen) {
// Need to erase entries until we're back to size. Note that
// we don't ever reset numbers. Problems will arise when
// history is 4 billion entries old
it = names.begin();
for (unsigned int i = 0; i < names.size() - maxlen + 1; i++, it++) {
m_data.erase(*it, sk);
}
// Need to erase entries until we're back to size. Note that
// we don't ever reset numbers. Problems will arise when
// history is 4 billion entries old
it = names.begin();
for (unsigned int i = 0; i < names.size() - maxlen + 1; i++, it++) {
m_data.erase(*it, sk);
}
}
// Increment highest number
unsigned int hi = names.empty() ? 0 :
(unsigned int)atoi(names.back().c_str());
(unsigned int)atoi(names.back().c_str());
hi++;
char nname[20];
sprintf(nname, "%010u", hi);
@ -98,8 +98,8 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
n.encode(value);
LOGDEB1("Encoded value [" << value << "] (" << value.size() << ")\n");
if (!m_data.set(string(nname), value, sk)) {
LOGERR("RclDynConf::insertNew: set failed\n");
return false;
LOGERR("RclDynConf::insertNew: set failed\n");
return false;
}
return true;
}
@ -111,7 +111,7 @@ bool RclDynConf::eraseAll(const string &sk)
return false;
}
for (const auto& nm : m_data.getNames(sk)) {
m_data.erase(nm, sk);
m_data.erase(nm, sk);
}
return true;
}
@ -173,25 +173,25 @@ int main(int argc, char **argv)
argc--; argv++;
while (argc > 0 && **argv == '-') {
(*argv)++;
if (!(**argv))
/* Cas du "adb - core" */
Usage();
while (**argv)
switch (*(*argv)++) {
case 'a': op_flags |= OPT_a; if (argc < 2) Usage();
value = *(++argv); argc--;
goto b1;
case 's': op_flags |= OPT_s; if (argc < 2) Usage();
sk = *(++argv); argc--;
goto b1;
case 'e': op_flags |= OPT_e; break;
default: Usage(); break;
}
(*argv)++;
if (!(**argv))
/* Cas du "adb - core" */
Usage();
while (**argv)
switch (*(*argv)++) {
case 'a': op_flags |= OPT_a; if (argc < 2) Usage();
value = *(++argv); argc--;
goto b1;
case 's': op_flags |= OPT_s; if (argc < 2) Usage();
sk = *(++argv); argc--;
goto b1;
case 'e': op_flags |= OPT_e; break;
default: Usage(); break;
}
b1: argc--; argv++;
}
if (argc != 1)
Usage();
Usage();
string filename = *argv++;argc--;
RclDynConf hist(filename, 5);
@ -199,26 +199,26 @@ int main(int argc, char **argv)
DebugLog::setfilename("stderr");
if (op_flags & OPT_e) {
hist.eraseAll(sk);
hist.eraseAll(sk);
} else if (op_flags & OPT_a) {
if (!(op_flags & OPT_s))
Usage();
hist.enterString(sk, value);
if (!(op_flags & OPT_s))
Usage();
hist.enterString(sk, value);
} else {
for (int i = 0; i < 10; i++) {
char docname[200];
sprintf(docname, "A very long document document name"
"is very long indeed and this is the end of "
"it here and exactly here:\n%d", i);
hist.enterDoc(string(docname), "ipathx");
}
for (int i = 0; i < 10; i++) {
char docname[200];
sprintf(docname, "A very long document document name"
"is very long indeed and this is the end of "
"it here and exactly here:\n%d", i);
hist.enterDoc(string(docname), "ipathx");
}
list<RclDHistoryEntry> hlist = hist.getDocHistory();
for (list<RclDHistoryEntry>::const_iterator it = hlist.begin();
it != hlist.end(); it++) {
printf("[%ld] [%s] [%s]\n", it->unixtime,
it->fn.c_str(), it->ipath.c_str());
}
list<RclDHistoryEntry> hlist = hist.getDocHistory();
for (list<RclDHistoryEntry>::const_iterator it = hlist.begin();
it != hlist.end(); it++) {
printf("[%ld] [%s] [%s]\n", it->unixtime,
it->fn.c_str(), it->ipath.c_str());
}
}
}

View File

@ -67,16 +67,16 @@ class RclSListEntry : public DynConfEntry {
: value(v) {
}
virtual bool decode(const std::string &enc) {
base64_decode(enc, value);
return true;
base64_decode(enc, value);
return true;
}
virtual bool encode(std::string& enc) {
base64_encode(value, enc);
return true;
base64_encode(value, enc);
return true;
}
virtual bool equal(const DynConfEntry& other) {
const RclSListEntry& e = dynamic_cast<const RclSListEntry&>(other);
return e.value == value;
const RclSListEntry& e = dynamic_cast<const RclSListEntry&>(other);
return e.value == value;
}
std::string value;
@ -88,16 +88,16 @@ class RclDynConf {
RclDynConf(const std::string &fn);
bool ro() {
return m_data.getStatus() == ConfSimple::STATUS_RO;
return m_data.getStatus() == ConfSimple::STATUS_RO;
}
bool rw() {
return m_data.getStatus() == ConfSimple::STATUS_RW;
return m_data.getStatus() == ConfSimple::STATUS_RW;
}
bool ok() {
return m_data.getStatus() != ConfSimple::STATUS_ERROR;
return m_data.getStatus() != ConfSimple::STATUS_ERROR;
}
std::string getFilename() {
return m_data.getFilename();
return m_data.getFilename();
}
// Generic methods
@ -140,12 +140,12 @@ Container<Type, std::allocator<Type>>
Type entry;
std::vector<std::string> names = m_data.getNames(sk);
for (const auto& name : names) {
std::string value;
if (m_data.get(name, value, sk)) {
if (!entry.decode(value))
continue;
out.push_back(entry);
}
std::string value;
if (m_data.get(name, value, sk)) {
if (!entry.decode(value))
continue;
out.push_back(entry);
}
}
return out;
}
@ -157,7 +157,7 @@ Container<std::string, std::allocator<std::string>>
std::vector<RclSListEntry> el = getEntries<std::vector, RclSListEntry>(sk);
Container<std::string, std::allocator<std::string>> sl;
for (const auto& entry : el) {
sl.push_back(entry.value);
sl.push_back(entry.value);
}
return sl;
}

View File

@ -28,27 +28,27 @@ static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
// Compare using each criterion in term. We're doing an or:
// 1st ok ends
for (unsigned int i = 0; i < fs.crits.size(); i++) {
switch (fs.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE:
LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" );
if (x->mimetype == fs.values[i])
return true;
break;
case DocSeqFiltSpec::DSFS_QLANG:
{
LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" );
}
break;
case DocSeqFiltSpec::DSFS_PASSALL:
return true;
}
switch (fs.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE:
LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" );
if (x->mimetype == fs.values[i])
return true;
break;
case DocSeqFiltSpec::DSFS_QLANG:
{
LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" );
}
break;
case DocSeqFiltSpec::DSFS_PASSALL:
return true;
}
}
// Did all comparisons
return false;
}
DocSeqFiltered::DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq,
DocSeqFiltSpec &filtspec)
DocSeqFiltSpec &filtspec)
: DocSeqModifier(iseq), m_config(conf)
{
setFiltSpec(filtspec);
@ -58,35 +58,35 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
{
LOGDEB0("DocSeqFiltered::setFiltSpec\n" );
for (unsigned int i = 0; i < filtspec.crits.size(); i++) {
switch (filtspec.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE:
m_spec.orCrit(filtspec.crits[i], filtspec.values[i]);
break;
case DocSeqFiltSpec::DSFS_QLANG:
{
// There are very few lang constructs that we can
// interpret. The default config uses rclcat:value
// only. That will be all for now...
string val = filtspec.values[i];
if (val.find("rclcat:") == 0) {
string catg = val.substr(7);
vector<string> tps;
m_config->getMimeCatTypes(catg, tps);
for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) {
LOGDEB2("Adding mime: [" << (it) << "]\n" );
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
}
}
}
break;
default:
break;
}
switch (filtspec.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE:
m_spec.orCrit(filtspec.crits[i], filtspec.values[i]);
break;
case DocSeqFiltSpec::DSFS_QLANG:
{
// There are very few lang constructs that we can
// interpret. The default config uses rclcat:value
// only. That will be all for now...
string val = filtspec.values[i];
if (val.find("rclcat:") == 0) {
string catg = val.substr(7);
vector<string> tps;
m_config->getMimeCatTypes(catg, tps);
for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) {
LOGDEB2("Adding mime: [" << (it) << "]\n" );
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
}
}
}
break;
default:
break;
}
}
// If m_spec ends up empty, pass everything, better than filtering all.
if (m_spec.crits.empty()) {
m_spec.orCrit(DocSeqFiltSpec::DSFS_PASSALL, "");
m_spec.orCrit(DocSeqFiltSpec::DSFS_PASSALL, "");
}
m_dbindices.clear();
return true;
@ -97,28 +97,28 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" );
if (idx >= (int)m_dbindices.size()) {
// Have to fetch docs and filter until we get enough or
// fail
m_dbindices.reserve(idx+1);
// Have to fetch docs and filter until we get enough or
// fail
m_dbindices.reserve(idx+1);
// First backend seq doc we fetch is the one after last stored
int backend_idx = m_dbindices.size() > 0 ? m_dbindices.back() + 1 : 0;
// First backend seq doc we fetch is the one after last stored
int backend_idx = m_dbindices.size() > 0 ? m_dbindices.back() + 1 : 0;
// Loop until we get enough docs
Rcl::Doc tdoc;
while (idx >= (int)m_dbindices.size()) {
if (!m_seq->getDoc(backend_idx, tdoc))
return false;
if (filter(m_spec, &tdoc)) {
m_dbindices.push_back(backend_idx);
}
backend_idx++;
}
doc = tdoc;
// Loop until we get enough docs
Rcl::Doc tdoc;
while (idx >= (int)m_dbindices.size()) {
if (!m_seq->getDoc(backend_idx, tdoc))
return false;
if (filter(m_spec, &tdoc)) {
m_dbindices.push_back(backend_idx);
}
backend_idx++;
}
doc = tdoc;
} else {
// The corresponding backend indice is already known
if (!m_seq->getDoc(m_dbindices[idx], doc))
return false;
// The corresponding backend indice is already known
if (!m_seq->getDoc(m_dbindices[idx], doc))
return false;
}
return true;
}

View File

@ -33,7 +33,7 @@ class RclConfig;
class DocSeqFiltered : public DocSeqModifier {
public:
DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq,
DocSeqFiltSpec &filtspec);
DocSeqFiltSpec &filtspec);
virtual ~DocSeqFiltered() {}
virtual bool canFilter() {return true;}
virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec);

View File

@ -33,13 +33,13 @@ public:
// behaves as operator<
int operator()(const Rcl::Doc *x, const Rcl::Doc *y)
{
LOGDEB1("Comparing .. \n" );
LOGDEB1("Comparing .. \n" );
const auto xit = x->meta.find(ss.field);
const auto yit = y->meta.find(ss.field);
if (xit == x->meta.end() || yit == y->meta.end())
return 0;
return ss.desc ? yit->second < xit->second : xit->second < yit->second;
const auto xit = x->meta.find(ss.field);
const auto yit = y->meta.find(ss.field);
if (xit == x->meta.end() || yit == y->meta.end())
return 0;
return ss.desc ? yit->second < xit->second : xit->second < yit->second;
}
};
@ -52,16 +52,16 @@ bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec)
m_docs.resize(count);
int i;
for (i = 0; i < count; i++) {
if (!m_seq->getDoc(i, m_docs[i])) {
LOGERR("DocSeqSorted: getDoc failed for doc " << (i) << "\n" );
count = i;
break;
}
if (!m_seq->getDoc(i, m_docs[i])) {
LOGERR("DocSeqSorted: getDoc failed for doc " << (i) << "\n" );
count = i;
break;
}
}
m_docs.resize(count);
m_docsp.resize(count);
for (i = 0; i < count; i++)
m_docsp[i] = &m_docs[i];
m_docsp[i] = &m_docs[i];
CompareDocs cmp(sortspec);
sort(m_docsp.begin(), m_docsp.end(), cmp);
@ -72,7 +72,7 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, string *)
{
LOGDEB("DocSeqSorted::getDoc(" << (num) << ")\n" );
if (num < 0 || num >= int(m_docsp.size()))
return false;
return false;
doc = *m_docsp[num];
return true;
}

View File

@ -31,9 +31,9 @@
class DocSeqSorted : public DocSeqModifier {
public:
DocSeqSorted(std::shared_ptr<DocSequence> iseq, DocSeqSortSpec &sortspec)
: DocSeqModifier(iseq)
: DocSeqModifier(iseq)
{
setSortSpec(sortspec);
setSortSpec(sortspec);
}
virtual ~DocSeqSorted() {}
virtual bool canSort() {return true;}

View File

@ -1465,7 +1465,7 @@ static void qualify(Rcl::SearchDataClauseDist *cl, const string& quals)
case 's':
cl->addModifier(Rcl::SearchDataClause::SDCM_NOSYNS);
break;
case 'S':
case 'S':
break;
case '.':case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':
@ -1528,7 +1528,7 @@ out:
int yylex(yy::parser::semantic_type *yylval, yy::parser::location_type *,
WasaParserDriver *d)
WasaParserDriver *d)
{
if (!d->qualifiers().empty()) {
yylval->str = new string();

Some files were not shown because too many files have changed in this diff Show More