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 */ /** Return a list of possible expansions for a given word */
bool suggest(Rcl::Db &db, const std::string& term, 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: private:
std::string dicPath(); std::string dicPath();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,13 +64,13 @@ static const unsigned unipuncblocks[] = {
0x2600, 0x26FF, 0x2600, 0x26FF,
// Dingbats // Dingbats
0x2700, 0x27BF, 0x2700, 0x27BF,
// Miscellaneous Mathematical Symbols-A // Miscellaneous Mathematical Symbols-A
0x27C0, 0x27EF, 0x27C0, 0x27EF,
// Supplemental Arrows-A // Supplemental Arrows-A
0x27F0, 0x27FF, 0x27F0, 0x27FF,
// Supplemental Arrows-B // Supplemental Arrows-B
0x2900, 0x297F, 0x2900, 0x297F,
// Miscellaneous Mathematical Symbols-B // Miscellaneous Mathematical Symbols-B
0x2980, 0x29FF, 0x2980, 0x29FF,
// Supplemental Mathematical Operators // Supplemental Mathematical Operators
0x2A00, 0x2AFF, 0x2A00, 0x2AFF,
@ -170,7 +170,7 @@ static const unsigned int uniskip[] = {
0x200C, /* ZERO WIDTH NON-JOINER */ 0x200C, /* ZERO WIDTH NON-JOINER */
0x200D, /* ZERO WIDTH JOINER */ 0x200D, /* ZERO WIDTH JOINER */
0x2060, /* WORD JOINER . Actually this should not be ignored but used to 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 /* 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; string utf8fn;
int ercnt; int ercnt;
if (!transcode(lfn, utf8fn, charset, "UTF-8", &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"); "] to UTF-8 for: [" << lfn << "]\n");
} else if (ercnt) { } else if (ercnt) {
LOGDEB("compute_utf8fn: " << ercnt << " transcode errors from [" << LOGDEB("compute_utf8fn: " << ercnt << " transcode errors from [" <<
charset << "] to UTF-8 for: [" << lfn << "]\n"); charset << "] to UTF-8 for: [" << lfn << "]\n");
} }
LOGDEB1("compute_utf8fn: transcoded from [" << lfn << "] to [" << LOGDEB1("compute_utf8fn: transcoded from [" << lfn << "] to [" <<

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,33 +36,33 @@
class MimeHandlerSymlink : public RecollFilter { class MimeHandlerSymlink : public RecollFilter {
public: public:
MimeHandlerSymlink(RclConfig *cnf, const std::string& id) MimeHandlerSymlink(RclConfig *cnf, const std::string& id)
: RecollFilter(cnf, id) { : RecollFilter(cnf, id) {
} }
virtual ~MimeHandlerSymlink() {} virtual ~MimeHandlerSymlink() {}
virtual bool next_document() virtual bool next_document()
{ {
if (m_havedoc == false) if (m_havedoc == false)
return false; return false;
m_havedoc = false; m_havedoc = false;
m_metaData[cstr_dj_keycontent] = cstr_null; m_metaData[cstr_dj_keycontent] = cstr_null;
char lc[1024]; char lc[1024];
ssize_t bytes = readlink(m_fn.c_str(), lc, 1024); ssize_t bytes = readlink(m_fn.c_str(), lc, 1024);
if (bytes != (ssize_t)-1) { if (bytes != (ssize_t)-1) {
string slc(lc, bytes); string slc(lc, bytes);
transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent], transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent],
m_config->getDefCharset(true), "UTF-8"); m_config->getDefCharset(true), "UTF-8");
} else { } else {
LOGDEB("Symlink: readlink [" << m_fn << "] failed, errno " << LOGDEB("Symlink: readlink [" << m_fn << "] failed, errno " <<
errno << "\n"); errno << "\n");
} }
m_metaData[cstr_dj_keymt] = cstr_textplain; m_metaData[cstr_dj_keymt] = cstr_textplain;
return true; return true;
} }
protected: protected:
virtual bool set_document_file_impl(const string&, const string& fn) { virtual bool set_document_file_impl(const string&, const string& fn) {
m_fn = fn; m_fn = fn;
return m_havedoc = true; return m_havedoc = true;
} }
private: 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); "), contents will not be indexed: " << fn << endl);
} }
if (!m_forPreview) { if (!m_forPreview) {
string md5, xmd5; string md5, xmd5;
MD5String(m_text, md5); MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} }
m_havedoc = true; m_havedoc = true;
return true; return true;
@ -99,9 +99,9 @@ bool MimeHandlerText::set_document_string_impl(const string&,
{ {
m_text = otext; m_text = otext;
if (!m_forPreview) { if (!m_forPreview) {
string md5, xmd5; string md5, xmd5;
MD5String(m_text, md5); MD5String(m_text, md5);
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} }
m_havedoc = true; m_havedoc = true;
return true; return true;
@ -112,9 +112,9 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
char *endptr; char *endptr;
int64_t t = strtoll(ipath.c_str(), &endptr, 10); int64_t t = strtoll(ipath.c_str(), &endptr, 10);
if (endptr == ipath.c_str()) { if (endptr == ipath.c_str()) {
LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" << LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" <<
ipath << "]\n"); ipath << "]\n");
return false; return false;
} }
m_offs = t; m_offs = t;
readnext(); readnext();
@ -126,12 +126,12 @@ bool MimeHandlerText::next_document()
LOGDEB("MimeHandlerText::next_document: m_havedoc " << m_havedoc << "\n"); LOGDEB("MimeHandlerText::next_document: m_havedoc " << m_havedoc << "\n");
if (m_havedoc == false) if (m_havedoc == false)
return false; return false;
if (m_charsetfromxattr.empty()) if (m_charsetfromxattr.empty())
m_metaData[cstr_dj_keyorigcharset] = m_dfltInputCharset; m_metaData[cstr_dj_keyorigcharset] = m_dfltInputCharset;
else else
m_metaData[cstr_dj_keyorigcharset] = m_charsetfromxattr; m_metaData[cstr_dj_keyorigcharset] = m_charsetfromxattr;
m_metaData[cstr_dj_keymt] = cstr_textplain; m_metaData[cstr_dj_keymt] = cstr_textplain;

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
<li><b>Html interface</b>, close to a simplified QT Recoll <li><b>Html interface</b>, close to a simplified QT Recoll
interface.</li> interface.</li>
<li><b>File manager interface</b>, <em>Only with KDE 4.1 and <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> </ul>
<p>The module is still in its infancy. You will undoubtedly obtain <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: <li>Using an URL ending with a&nbsp;'/', ie:
<blockquote> <blockquote>
<a href="recoll:/red apples ext:html/"> <a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a> recoll:/red apples ext:html/</a>
</blockquote> </blockquote>
</li> </li>
<li>Users who will want to use the file manager view most of the <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"> <input type="submit" value="Search">
<!-- This resets to the preset value. We'd like a real clear <!-- This resets to the preset value. We'd like a real clear
<input type="reset" value="Clear"> --> <input type="reset" value="Clear"> -->
</form> </form>
</p> </p>

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
<li><b>Html interface</b>, close to a simplified QT Recoll <li><b>Html interface</b>, close to a simplified QT Recoll
interface.</li> interface.</li>
<li><b>File manager interface</b>, <em>Only with KDE 4.1 and <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> </ul>
<p>With recent KDE versions (now: 2016), the file manager <p>With recent KDE versions (now: 2016), the file manager
@ -74,8 +74,8 @@
<li>Using an URL ending with a&nbsp;'/', ie: <li>Using an URL ending with a&nbsp;'/', ie:
<blockquote> <blockquote>
<a href="recoll:/red apples ext:html/"> <a href="recoll:/red apples ext:html/">
recoll:/red apples ext:html/</a> recoll:/red apples ext:html/</a>
</blockquote> </blockquote>
</li> </li>
<li>If you would like to use the file manager view most of the <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"> <input type="submit" value="Search">
<!-- This resets to the preset value. We'd like a real clear <!-- This resets to the preset value. We'd like a real clear
<input type="reset" value="Clear"> --> <input type="reset" value="Clear"> -->
</form> </form>
</p> </p>

View File

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

View File

@ -7,25 +7,25 @@
SHELL=/bin/sh SHELL=/bin/sh
cvs dist configure configure.in configure.files subdirs package-messages package-merge Makefile.am acinclude.m4 extract-messages: cvs dist configure configure.in configure.files subdirs package-messages package-merge Makefile.am acinclude.m4 extract-messages:
@admindir=$(admindir); \ @admindir=$(admindir); \
if test "x$$admindir" = x; then \ if test "x$$admindir" = x; then \
admindir=.; until test -f $$admindir/admin/cvs.sh; do \ admindir=.; until test -f $$admindir/admin/cvs.sh; do \
admindir=$$admindir/..; \ admindir=$$admindir/..; \
if test `cd $$admindir && pwd` = / ; then break; fi; \ if test `cd $$admindir && pwd` = / ; then break; fi; \
done; \ done; \
admindir=$$admindir/admin; \ admindir=$$admindir/admin; \
if test -f $$admindir/cvs.sh; then :; else \ if test -f $$admindir/cvs.sh; then :; else \
echo "Can't find the admin/ directory in any parent of the"; \ echo "Can't find the admin/ directory in any parent of the"; \
echo "current directory. Please set it with admindir=..."; \ echo "current directory. Please set it with admindir=..."; \
exit 1; \ exit 1; \
fi; \ fi; \
fi; \ fi; \
if test "$@" = "package-merge"; then \ if test "$@" = "package-merge"; then \
MAKE="$(MAKE)" POFILES="$(POFILES)" PACKAGE="$(PACKAGE)" \ MAKE="$(MAKE)" POFILES="$(POFILES)" PACKAGE="$(PACKAGE)" \
$(SHELL) $$admindir/cvs.sh package-merge ;\ $(SHELL) $$admindir/cvs.sh package-merge ;\
else \ else \
MAKE="$(MAKE)" $(SHELL) $$admindir/cvs.sh $@ ;\ MAKE="$(MAKE)" $(SHELL) $$admindir/cvs.sh $@ ;\
fi fi
configure.in: configure.files subdirs configure.in: configure.files subdirs
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, # in later autoconf (2.14.1) there is no CONFIG_FILES= line,
# but instead the (2) directly follow (1) # but instead the (2) directly follow (1)
if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) { if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) {
$flag = 1; $flag = 1;
if ($1 eq 'lines') { if ($1 eq 'lines') {
# lets hope its different with 2141, # lets hope its different with 2141,
# wasn't able to verify that # wasn't able to verify that
if ($2 eq '48') { if ($2 eq '48') {
$ac_version = 250; $ac_version = 250;
} }
else { else {
$ac_version = 2141; $ac_version = 2141;
} }
} elsif ($1 eq 'cmds') { } elsif ($1 eq 'cmds') {
$ac_version = 213; $ac_version = 213;
} }
# hmm, we don't know the autoconf version, but we try anyway # hmm, we don't know the autoconf version, but we try anyway
} else { } else {
print; print;
} }
} elsif ($flag == 1) { } elsif ($flag == 1) {
if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) { if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) {
print; print;
$flag = 2; $flag = 2;
} elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) { } elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3; $flag = 3;
} }
} elsif ($flag == 2) { } elsif ($flag == 2) {
# 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1)) # 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1))
# end with: "rm -f conftest.s\*" # end with: "rm -f conftest.s\*"
@ -84,22 +84,22 @@ while (<>) {
# stop there and insert a new loop to honor the case/esac. # stop there and insert a new loop to honor the case/esac.
# (pattern: /^\s+#\sRun the commands associated with the file./) # (pattern: /^\s+#\sRun the commands associated with the file./)
if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) { if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
$flag = 3; $flag = 3;
} else { } else {
print; print;
} }
} elsif ($flag == 3) { } elsif ($flag == 3) {
if (/^\s*rm\s+-f\s+conftest/ ) { if (/^\s*rm\s+-f\s+conftest/ ) {
$flag = 4; $flag = 4;
&insert_main_loop(); &insert_main_loop();
} elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) { } elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) {
$flag = 4; $flag = 4;
&insert_main_loop(); &insert_main_loop();
#die "hhhhhhh"; #die "hhhhhhh";
if ($ac_version != 2141) { if ($ac_version != 2141) {
print STDERR "hmm, don't know autoconf version\n"; print STDERR "hmm, don't know autoconf version\n";
} }
} elsif (/^\#\s*CONFIG_(HEADER|COMMANDS) section.*|^\s+#\s(Run) the commands associated/) { } elsif (/^\#\s*CONFIG_(HEADER|COMMANDS) section.*|^\s+#\s(Run) the commands associated/) {
$flag = 4; $flag = 4;
my $commands = defined $2; my $commands = defined $2;
@ -108,9 +108,9 @@ while (<>) {
if($ac_version != 250) { if($ac_version != 250) {
print STDERR "hmm, something went wrong :-(\n"; print STDERR "hmm, something went wrong :-(\n";
} }
} elsif (/VPATH/ ) { } elsif (/VPATH/ ) {
$vpath_seen = 1; $vpath_seen = 1;
} }
} }
} }
@ -135,7 +135,7 @@ EOF
if ($vpath_seen) { if ($vpath_seen) {
print <<EOF; print <<EOF;
# VPATH subst was seen in original config.status main loop # VPATH subst was seen in original config.status main loop
echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed
EOF EOF
} }
print <<EOF; print <<EOF;
@ -165,7 +165,7 @@ EOF
if ($vpath_seen) { if ($vpath_seen) {
print <<EOF; print <<EOF;
# VPATH subst was seen in original config.status main loop # 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 EOF
} }
print <<EOF; print <<EOF;

View File

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

View File

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

View File

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

View File

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

View File

@ -254,8 +254,8 @@ bool ConfIndexW::setupTopPanel(int idx)
tr("Stemming languages"), tr("Stemming languages"),
tr("The languages for which stemming expansion " tr("The languages for which stemming expansion "
"dictionaries will be built.<br>See the Xapian stemmer " "dictionaries will be built.<br>See the Xapian stemmer "
"documentation for possible values. E.g. english, " "documentation for possible values. E.g. english, "
"french, german..."), 0, 0, &m_stemlangs); "french, german..."), 0, 0, &m_stemlangs);
m_w->addParam(idx, ConfTabsW::CFPT_FN, "logfilename", m_w->addParam(idx, ConfTabsW::CFPT_FN, "logfilename",
tr("Log file name"), tr("Log file name"),
@ -292,7 +292,7 @@ bool ConfIndexW::setupTopPanel(int idx)
tr("Aspell language"), tr("Aspell language"),
tr("The language for the aspell dictionary. " tr("The language for the aspell dictionary. "
"The values are are 2-letter " "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 " "If this value is not set, the NLS environment "
"will be used to compute it, which usually works. " "will be used to compute it, which usually works. "
"To get an idea of what is installed on your system, " "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 // Try to read the current values
if (!theconfig) if (!theconfig)
return; return;
if (checkCrontabUnmanaged(marker, "recollindex")) { if (checkCrontabUnmanaged(marker, "recollindex")) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("It seems that manually edited entries exist for recollindex, cannot edit crontab")); tr("It seems that manually edited entries exist for recollindex, cannot edit crontab"));
QTimer::singleShot(0, this, SLOT(close())); QTimer::singleShot(0, this, SLOT(close()));
} }
string id = idstring(theconfig->getConfDir()); string id = idstring(theconfig->getConfDir());
@ -77,7 +77,7 @@ void CronToolW::disableCron()
void CronToolW::changeCron(bool enable) void CronToolW::changeCron(bool enable)
{ {
if (!theconfig) if (!theconfig)
return; return;
string id = idstring(theconfig->getConfDir()); string id = idstring(theconfig->getConfDir());
string cmd("recollindex"); string cmd("recollindex");
@ -85,18 +85,18 @@ void CronToolW::changeCron(bool enable)
string reason; string reason;
if (!enable) { if (!enable) {
editCrontab(marker, id, "", "", reason); editCrontab(marker, id, "", "", reason);
accept(); accept();
} else { } else {
string mins(qs2utf8s(minsLE->text().remove(QChar(' ')))); string mins(qs2utf8s(minsLE->text().remove(QChar(' '))));
string hours(qs2utf8s(hoursLE->text().remove(QChar(' ')))); string hours(qs2utf8s(hoursLE->text().remove(QChar(' '))));
string days(qs2utf8s(daysLE->text().remove(QChar(' ')))); string days(qs2utf8s(daysLE->text().remove(QChar(' '))));
string sched = mins + " " + hours + " * * " + days; string sched = mins + " " + hours + " * * " + days;
if (editCrontab(marker, id, sched, cmd, reason)) { if (editCrontab(marker, id, sched, cmd, reason)) {
accept(); accept();
} else { } else {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Error installing cron entry. Bad syntax in fields ?")); tr("Error installing cron entry. Bad syntax in fields ?"));
} }
} }
} }

View File

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

View File

@ -23,9 +23,9 @@ class FirstIdxDialog : public QDialog, public Ui::FirstIdxDialog {
Q_OBJECT Q_OBJECT
public: public:
FirstIdxDialog(QWidget * parent = 0) 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>&); void getfrags(std::vector<std::string>&);
bool ok() {return m_ok;} bool ok() {return m_ok;}
bool isStale(time_t *reftime); bool isStale(time_t *reftime);
private slots: private slots:
void onButtonClicked(bool); void onButtonClicked(bool);

View File

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

View File

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

View File

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

View File

@ -43,13 +43,13 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
fdialog.setFileMode(QFileDialog::Directory); fdialog.setFileMode(QFileDialog::Directory);
fdialog.setOption(QFileDialog::ShowDirsOnly); fdialog.setOption(QFileDialog::ShowDirsOnly);
if (fdialog.exec() == 0) if (fdialog.exec() == 0)
return; return;
QStringList dirl = fdialog.selectedFiles(); QStringList dirl = fdialog.selectedFiles();
if (dirl.size() != 1) { if (dirl.size() != 1) {
// Can't happen ? // Can't happen ?
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
QWidget::tr("Choose exactly one directory")); QWidget::tr("Choose exactly one directory"));
return; return;
} }
string dir(qs2path(dirl[0])); string dir(qs2path(dirl[0]));
LOGDEB2("multiSave: got dir " << dir << "\n"); LOGDEB2("multiSave: got dir " << dir << "\n");
@ -78,63 +78,63 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
set<string> existingNames; set<string> existingNames;
string reason; string reason;
if (!listdir(dir, reason, existingNames)) { if (!listdir(dir, reason, existingNames)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
QWidget::tr("Could not read directory: ") + QWidget::tr("Could not read directory: ") +
path2qs(reason)); path2qs(reason));
return; return;
} }
set<string> toBeCreated; set<string> toBeCreated;
vector<string> filenames; vector<string> filenames;
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) { for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
string utf8fn; string utf8fn;
it->getmeta(Rcl::Doc::keyfn, &utf8fn); it->getmeta(Rcl::Doc::keyfn, &utf8fn);
string suffix = path_suffix(utf8fn); string suffix = path_suffix(utf8fn);
LOGDEB("Multisave: [" << (utf8fn) << "] suff [" << (suffix) << "]\n" ); LOGDEB("Multisave: [" << (utf8fn) << "] suff [" << (suffix) << "]\n" );
if (suffix.empty() || suffix.size() > 10) { if (suffix.empty() || suffix.size() > 10) {
suffix = theconfig->getSuffixFromMimeType(it->mimetype); suffix = theconfig->getSuffixFromMimeType(it->mimetype);
LOGDEB("Multisave: suff from config [" << (suffix) << "]\n" ); LOGDEB("Multisave: suff from config [" << (suffix) << "]\n" );
} }
string simple = path_basename(utf8fn, string(".") + suffix); string simple = path_basename(utf8fn, string(".") + suffix);
LOGDEB("Multisave: simple [" << (simple) << "]\n" ); LOGDEB("Multisave: simple [" << (simple) << "]\n" );
if (simple.empty()) if (simple.empty())
simple = "rclsave"; simple = "rclsave";
if (simple.size() > maxlen) { if (simple.size() > maxlen) {
simple = simple.substr(0, maxlen); simple = simple.substr(0, maxlen);
} }
for (int vers = 0; ; vers++) { for (int vers = 0; ; vers++) {
ostringstream ss; ostringstream ss;
ss << simple; ss << simple;
if (vers) if (vers)
ss << "." << vers; ss << "." << vers;
if (!suffix.empty()) if (!suffix.empty())
ss << "." << suffix; ss << "." << suffix;
string fn = qs2path(u8s2qs(ss.str())); string fn = qs2path(u8s2qs(ss.str()));
if (existingNames.find(fn) == existingNames.end() && if (existingNames.find(fn) == existingNames.end() &&
toBeCreated.find(fn) == toBeCreated.end()) { toBeCreated.find(fn) == toBeCreated.end()) {
toBeCreated.insert(fn); toBeCreated.insert(fn);
filenames.push_back(fn); filenames.push_back(fn);
break; break;
} }
} }
} }
for (unsigned int i = 0; i != docs.size(); i++) { for (unsigned int i = 0; i != docs.size(); i++) {
string fn = path_cat(dir, filenames[i]); string fn = path_cat(dir, filenames[i]);
if (path_exists(fn)) { if (path_exists(fn)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
QWidget::tr("Unexpected file name collision, " QWidget::tr("Unexpected file name collision, "
"cancelling.")); "cancelling."));
return; return;
} }
// There is still a race condition here, should we care ? // There is still a race condition here, should we care ?
TempFile temp;// not used TempFile temp;// not used
if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) { if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) {
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", QWidget::tr("Cannot extract document: ") + 0, "Recoll", QWidget::tr("Cannot extract document: ") +
path2qs(docs[i].url) + " | " + u8s2qs(docs[i].ipath)); 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); m_dbdir = path_canon(dbdir);
connect(transTW, SIGNAL(itemDoubleClicked(QTableWidgetItem *)), connect(transTW, SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
this, SLOT(onItemDoubleClicked(QTableWidgetItem *))); this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
connect(cancelPB, SIGNAL(clicked()), this, SLOT(close())); connect(cancelPB, SIGNAL(clicked()), this, SLOT(close()));
QString lab = whatIdxLA->text(); QString lab = whatIdxLA->text();
@ -57,18 +57,18 @@ void EditTrans::init(const string& dbdir)
ConfSimple *conftrans = theconfig->getPTrans(); ConfSimple *conftrans = theconfig->getPTrans();
if (!conftrans) if (!conftrans)
return; return;
int row = 0; int row = 0;
vector<string> opaths = conftrans->getNames(m_dbdir); vector<string> opaths = conftrans->getNames(m_dbdir);
for (vector<string>::const_iterator it = opaths.begin(); for (vector<string>::const_iterator it = opaths.begin();
it != opaths.end(); it++) { it != opaths.end(); it++) {
transTW->setRowCount(row+1); transTW->setRowCount(row+1);
transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it))); transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it)));
string npath; string npath;
conftrans->get(*it, npath, m_dbdir); conftrans->get(*it, npath, m_dbdir);
transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath))); transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath)));
row++; row++;
} }
resize(QSize(640, 300).expandedTo(minimumSizeHint())); resize(QSize(640, 300).expandedTo(minimumSizeHint()));
@ -83,18 +83,18 @@ void EditTrans::on_savePB_clicked()
{ {
ConfSimple *conftrans = theconfig->getPTrans(); ConfSimple *conftrans = theconfig->getPTrans();
if (!conftrans) { if (!conftrans) {
QMessageBox::warning(0, "Recoll", tr("Config error")); QMessageBox::warning(0, "Recoll", tr("Config error"));
return; return;
} }
conftrans->holdWrites(true); conftrans->holdWrites(true);
conftrans->eraseKey(m_dbdir); conftrans->eraseKey(m_dbdir);
for (int row = 0; row < transTW->rowCount(); row++) { for (int row = 0; row < transTW->rowCount(); row++) {
QTableWidgetItem *item0 = transTW->item(row, 0); QTableWidgetItem *item0 = transTW->item(row, 0);
string from = path_canon(qs2path(item0->text())); string from = path_canon(qs2path(item0->text()));
QTableWidgetItem *item1 = transTW->item(row, 1); QTableWidgetItem *item1 = transTW->item(row, 1);
string to = path_canon(qs2path(item1->text())); string to = path_canon(qs2path(item1->text()));
conftrans->set(from, to, m_dbdir); conftrans->set(from, to, m_dbdir);
} }
conftrans->holdWrites(false); conftrans->holdWrites(false);
// The rcldb does not use the same configuration object, but a // 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(); QModelIndexList indexes = transTW->selectionModel()->selectedIndexes();
vector<int> rows; vector<int> rows;
for (int i = 0; i < indexes.size(); i++) { 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()); sort(rows.begin(), rows.end());
rows.resize(unique(rows.begin(), rows.end()) - rows.begin()); rows.resize(unique(rows.begin(), rows.end()) - rows.begin());
for (int i = rows.size()-1; i >= 0; i--) { 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(); QModelIndexList indexes = transTW->selectionModel()->selectedIndexes();
if(indexes.size() < 1) if(indexes.size() < 1)
delPB->setEnabled(0); delPB->setEnabled(0);
else else
delPB->setEnabled(1); delPB->setEnabled(1);
} }

View File

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

View File

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

View File

@ -668,12 +668,12 @@ void RclMain::fileExit()
} }
// Don't save geometry if we're currently maximized. At least under X11 // 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()) { if (!isMaximized()) {
QSettings settings; QSettings settings;
settings.setValue("/Recoll/geometry/maingeom", saveGeometry()); settings.setValue("/Recoll/geometry/maingeom", saveGeometry());
} }
prefs.toolArea = toolBarArea(m_toolsTB); prefs.toolArea = toolBarArea(m_toolsTB);
prefs.resArea = toolBarArea(m_resTB); prefs.resArea = toolBarArea(m_resTB);
restable->saveColState(); restable->saveColState();

View File

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

View File

@ -20,12 +20,12 @@
namespace ResultPopup { namespace ResultPopup {
enum Options {showExpand = 0x1, showSubs = 0x2, isMain = 0x3, enum Options {showExpand = 0x1, showSubs = 0x2, isMain = 0x3,
showSaveOne = 0x4, showSaveSel = 0x8}; showSaveOne = 0x4, showSaveSel = 0x8};
extern QMenu *create(QWidget *me, int opts, extern QMenu *create(QWidget *me, int opts,
std::shared_ptr<DocSequence> source, std::shared_ptr<DocSequence> source,
Rcl::Doc& doc); Rcl::Doc& doc);
extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source, extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source,
Rcl::Doc& doc); Rcl::Doc& doc);
extern void copyFN(const Rcl::Doc &doc); extern void copyFN(const Rcl::Doc &doc);
extern void copyURL(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 rowCount (const QModelIndex& = QModelIndex()) const;
virtual int columnCount(const QModelIndex& = QModelIndex()) const; virtual int columnCount(const QModelIndex& = QModelIndex()) const;
virtual QVariant headerData (int col, Qt::Orientation orientation, virtual QVariant headerData (int col, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const; int role = Qt::DisplayRole ) const;
virtual QVariant data(const QModelIndex& index, virtual QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole ) const; int role = Qt::DisplayRole ) const;
virtual void saveAsCSV(std::fstream& fp); virtual void saveAsCSV(std::fstream& fp);
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
// Specific methods // Specific methods
@ -58,7 +58,7 @@ public:
virtual const std::vector<std::string>& getFields() {return m_fields;} virtual const std::vector<std::string>& getFields() {return m_fields;}
virtual const std::map<std::string, QString>& getAllFields() virtual const std::map<std::string, QString>& getAllFields()
{ {
return o_displayableFields; return o_displayableFields;
} }
virtual void addColumn(int, const std::string&); virtual void addColumn(int, const std::string&);
// Some column name are aliases/translator for base document field // Some column name are aliases/translator for base document field
@ -112,14 +112,14 @@ class ResTable : public QWidget, public Ui::ResTable
public: public:
ResTable(QWidget* parent = 0) ResTable(QWidget* parent = 0)
: QWidget(parent), : QWidget(parent),
m_model(0), m_pager(0), m_detail(0), m_detaildocnum(-1), m_model(0), m_pager(0), m_detail(0), m_detaildocnum(-1),
m_rclmain(0), m_ismainres(true) m_rclmain(0), m_ismainres(true)
{ {
setupUi(this); setupUi(this);
init(); init();
} }
virtual ~ResTable() {} virtual ~ResTable() {}
virtual RecollModel *getModel() {return m_model;} virtual RecollModel *getModel() {return m_model;}
virtual ResTableDetailArea* getDetailArea() {return m_detail;} virtual ResTableDetailArea* getDetailArea() {return m_detail;}

View File

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

View File

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

View File

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

View File

@ -28,15 +28,15 @@ class SpellW : public QWidget, public Ui::SpellBase
Q_OBJECT; Q_OBJECT;
public: public:
SpellW(QWidget* parent = 0) SpellW(QWidget* parent = 0)
: QWidget(parent), m_prevmode(TYPECMB_NONE) { : QWidget(parent), m_prevmode(TYPECMB_NONE) {
setupUi(this); setupUi(this);
init(); init();
} }
virtual bool eventFilter(QObject *target, QEvent *event ); virtual bool eventFilter(QObject *target, QEvent *event );
enum comboboxchoice {TYPECMB_NONE, TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM, enum comboboxchoice {TYPECMB_NONE, TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM,
TYPECMB_SPELL, TYPECMB_STATS, TYPECMB_FAILED}; TYPECMB_SPELL, TYPECMB_STATS, TYPECMB_FAILED};
public slots: public slots:
virtual void doExpand(); virtual void doExpand();
virtual void wordChanged(const QString&); 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) bool SSearch::checkExtIndexes(const std::vector<std::string>& dbs)
{ {
std::string reason; std::string reason;
if (!maybeOpenDb(reason, false)) { if (!maybeOpenDb(reason, false)) {
QMessageBox::critical(0, "Recoll", tr("Can't open index") + QMessageBox::critical(0, "Recoll", tr("Can't open index") +
u8s2qs(reason)); u8s2qs(reason));
return false; return false;
} }
if (!rcldb->setExtraQueryDbs(dbs)) { if (!rcldb->setExtraQueryDbs(dbs)) {
return false; return false;
} }

View File

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

View File

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

View File

@ -25,9 +25,9 @@ class EditDialog : public QDialog, public Ui::EditDialog {
Q_OBJECT Q_OBJECT
public: public:
EditDialog(QWidget * parent = 0) 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 Q_OBJECT
public: public:
ListDialog(QWidget * parent = 0) ListDialog(QWidget * parent = 0)
: QDialog(parent) : QDialog(parent)
{ {
setupUi(this); setupUi(this);
} }
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,30 +31,30 @@ class DocSequenceDocs : public DocSequence {
public: public:
DocSequenceDocs(std::shared_ptr<Rcl::Db> d, DocSequenceDocs(std::shared_ptr<Rcl::Db> d,
const std::vector<Rcl::Doc> docs, const string &t) 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 ~DocSequenceDocs() {
} }
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) { virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) {
if (sh) if (sh)
*sh = string(); *sh = string();
if (num < 0 || num >= int(m_docs.size())) if (num < 0 || num >= int(m_docs.size()))
return false; return false;
doc = m_docs[num]; doc = m_docs[num];
return true; return true;
} }
virtual int getResCnt() { virtual int getResCnt() {
return m_docs.size(); return m_docs.size();
} }
virtual string getDescription() { virtual string getDescription() {
return m_description; return m_description;
} }
void setDescription(const string& desc) { void setDescription(const string& desc) {
m_description = desc; m_description = desc;
} }
protected: protected:
virtual std::shared_ptr<Rcl::Db> getDb() { virtual std::shared_ptr<Rcl::Db> getDb() {
return m_db; return m_db;
} }
private: private:
std::shared_ptr<Rcl::Db> m_db; 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 // Retrieve history list
if (!m_hist) if (!m_hist)
return false; return false;
if (m_history.empty()) if (m_history.empty())
m_history = getDocHistory(m_hist); m_history = getDocHistory(m_hist);
if (num < 0 || num >= (int)m_history.size()) if (num < 0 || num >= (int)m_history.size())
return false; return false;
// We get the history oldest first, but our users expect newest first // We get the history oldest first, but our users expect newest first
RclDHistoryEntry& hentry = m_history[m_history.size() - 1 - num]; RclDHistoryEntry& hentry = m_history[m_history.size() - 1 - num];
if (sh) { if (sh) {
if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) { if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) {
m_prevtime = hentry.unixtime; m_prevtime = hentry.unixtime;
time_t t = (time_t)(hentry.unixtime); time_t t = (time_t)(hentry.unixtime);
*sh = string(ctime(&t)); *sh = string(ctime(&t));
// Get rid of the final \n in ctime // Get rid of the final \n in ctime
sh->erase(sh->length()-1); sh->erase(sh->length()-1);
} else { } else {
sh->erase(); sh->erase();
} }
} }
bool ret = m_db->getDoc(hentry.udi, hentry.dbdir, doc); bool ret = m_db->getDoc(hentry.udi, hentry.dbdir, doc);
if (!ret || doc.pc == -1) { if (!ret || doc.pc == -1) {
doc.url = "UNKNOWN"; doc.url = "UNKNOWN";
doc.ipath = ""; doc.ipath = "";
} }
@ -161,9 +161,9 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
} }
int DocSequenceHistory::getResCnt() int DocSequenceHistory::getResCnt()
{ {
if (m_history.empty()) if (m_history.empty())
m_history = getDocHistory(m_hist); m_history = getDocHistory(m_hist);
return int(m_history.size()); return int(m_history.size());
} }

View File

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

View File

@ -67,16 +67,16 @@ class RclSListEntry : public DynConfEntry {
: value(v) { : value(v) {
} }
virtual bool decode(const std::string &enc) { virtual bool decode(const std::string &enc) {
base64_decode(enc, value); base64_decode(enc, value);
return true; return true;
} }
virtual bool encode(std::string& enc) { virtual bool encode(std::string& enc) {
base64_encode(value, enc); base64_encode(value, enc);
return true; return true;
} }
virtual bool equal(const DynConfEntry& other) { virtual bool equal(const DynConfEntry& other) {
const RclSListEntry& e = dynamic_cast<const RclSListEntry&>(other); const RclSListEntry& e = dynamic_cast<const RclSListEntry&>(other);
return e.value == value; return e.value == value;
} }
std::string value; std::string value;
@ -88,16 +88,16 @@ class RclDynConf {
RclDynConf(const std::string &fn); RclDynConf(const std::string &fn);
bool ro() { bool ro() {
return m_data.getStatus() == ConfSimple::STATUS_RO; return m_data.getStatus() == ConfSimple::STATUS_RO;
} }
bool rw() { bool rw() {
return m_data.getStatus() == ConfSimple::STATUS_RW; return m_data.getStatus() == ConfSimple::STATUS_RW;
} }
bool ok() { bool ok() {
return m_data.getStatus() != ConfSimple::STATUS_ERROR; return m_data.getStatus() != ConfSimple::STATUS_ERROR;
} }
std::string getFilename() { std::string getFilename() {
return m_data.getFilename(); return m_data.getFilename();
} }
// Generic methods // Generic methods
@ -140,12 +140,12 @@ Container<Type, std::allocator<Type>>
Type entry; Type entry;
std::vector<std::string> names = m_data.getNames(sk); std::vector<std::string> names = m_data.getNames(sk);
for (const auto& name : names) { for (const auto& name : names) {
std::string value; std::string value;
if (m_data.get(name, value, sk)) { if (m_data.get(name, value, sk)) {
if (!entry.decode(value)) if (!entry.decode(value))
continue; continue;
out.push_back(entry); out.push_back(entry);
} }
} }
return out; return out;
} }
@ -157,7 +157,7 @@ Container<std::string, std::allocator<std::string>>
std::vector<RclSListEntry> el = getEntries<std::vector, RclSListEntry>(sk); std::vector<RclSListEntry> el = getEntries<std::vector, RclSListEntry>(sk);
Container<std::string, std::allocator<std::string>> sl; Container<std::string, std::allocator<std::string>> sl;
for (const auto& entry : el) { for (const auto& entry : el) {
sl.push_back(entry.value); sl.push_back(entry.value);
} }
return sl; 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: // Compare using each criterion in term. We're doing an or:
// 1st ok ends // 1st ok ends
for (unsigned int i = 0; i < fs.crits.size(); i++) { for (unsigned int i = 0; i < fs.crits.size(); i++) {
switch (fs.crits[i]) { switch (fs.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE: case DocSeqFiltSpec::DSFS_MIMETYPE:
LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" ); LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" );
if (x->mimetype == fs.values[i]) if (x->mimetype == fs.values[i])
return true; return true;
break; break;
case DocSeqFiltSpec::DSFS_QLANG: case DocSeqFiltSpec::DSFS_QLANG:
{ {
LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" ); LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" );
} }
break; break;
case DocSeqFiltSpec::DSFS_PASSALL: case DocSeqFiltSpec::DSFS_PASSALL:
return true; return true;
} }
} }
// Did all comparisons // Did all comparisons
return false; return false;
} }
DocSeqFiltered::DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq, DocSeqFiltered::DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq,
DocSeqFiltSpec &filtspec) DocSeqFiltSpec &filtspec)
: DocSeqModifier(iseq), m_config(conf) : DocSeqModifier(iseq), m_config(conf)
{ {
setFiltSpec(filtspec); setFiltSpec(filtspec);
@ -58,35 +58,35 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
{ {
LOGDEB0("DocSeqFiltered::setFiltSpec\n" ); LOGDEB0("DocSeqFiltered::setFiltSpec\n" );
for (unsigned int i = 0; i < filtspec.crits.size(); i++) { for (unsigned int i = 0; i < filtspec.crits.size(); i++) {
switch (filtspec.crits[i]) { switch (filtspec.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE: case DocSeqFiltSpec::DSFS_MIMETYPE:
m_spec.orCrit(filtspec.crits[i], filtspec.values[i]); m_spec.orCrit(filtspec.crits[i], filtspec.values[i]);
break; break;
case DocSeqFiltSpec::DSFS_QLANG: case DocSeqFiltSpec::DSFS_QLANG:
{ {
// There are very few lang constructs that we can // There are very few lang constructs that we can
// interpret. The default config uses rclcat:value // interpret. The default config uses rclcat:value
// only. That will be all for now... // only. That will be all for now...
string val = filtspec.values[i]; string val = filtspec.values[i];
if (val.find("rclcat:") == 0) { if (val.find("rclcat:") == 0) {
string catg = val.substr(7); string catg = val.substr(7);
vector<string> tps; vector<string> tps;
m_config->getMimeCatTypes(catg, tps); m_config->getMimeCatTypes(catg, tps);
for (vector<string>::const_iterator it = tps.begin(); for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) { it != tps.end(); it++) {
LOGDEB2("Adding mime: [" << (it) << "]\n" ); LOGDEB2("Adding mime: [" << (it) << "]\n" );
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it); m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
} }
} }
} }
break; break;
default: default:
break; break;
} }
} }
// If m_spec ends up empty, pass everything, better than filtering all. // If m_spec ends up empty, pass everything, better than filtering all.
if (m_spec.crits.empty()) { if (m_spec.crits.empty()) {
m_spec.orCrit(DocSeqFiltSpec::DSFS_PASSALL, ""); m_spec.orCrit(DocSeqFiltSpec::DSFS_PASSALL, "");
} }
m_dbindices.clear(); m_dbindices.clear();
return true; return true;
@ -97,28 +97,28 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" ); LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" );
if (idx >= (int)m_dbindices.size()) { if (idx >= (int)m_dbindices.size()) {
// Have to fetch docs and filter until we get enough or // Have to fetch docs and filter until we get enough or
// fail // fail
m_dbindices.reserve(idx+1); m_dbindices.reserve(idx+1);
// First backend seq doc we fetch is the one after last stored // First backend seq doc we fetch is the one after last stored
int backend_idx = m_dbindices.size() > 0 ? m_dbindices.back() + 1 : 0; int backend_idx = m_dbindices.size() > 0 ? m_dbindices.back() + 1 : 0;
// Loop until we get enough docs // Loop until we get enough docs
Rcl::Doc tdoc; Rcl::Doc tdoc;
while (idx >= (int)m_dbindices.size()) { while (idx >= (int)m_dbindices.size()) {
if (!m_seq->getDoc(backend_idx, tdoc)) if (!m_seq->getDoc(backend_idx, tdoc))
return false; return false;
if (filter(m_spec, &tdoc)) { if (filter(m_spec, &tdoc)) {
m_dbindices.push_back(backend_idx); m_dbindices.push_back(backend_idx);
} }
backend_idx++; backend_idx++;
} }
doc = tdoc; doc = tdoc;
} else { } else {
// The corresponding backend indice is already known // The corresponding backend indice is already known
if (!m_seq->getDoc(m_dbindices[idx], doc)) if (!m_seq->getDoc(m_dbindices[idx], doc))
return false; return false;
} }
return true; return true;
} }

View File

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

View File

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

View File

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

View File

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

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