Merge back windows and shared code changes
This commit is contained in:
parent
d6c24c3da5
commit
0aa6e3ca75
@ -34,7 +34,7 @@ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \
|
|||||||
$(XSLT_CFLAGS) \
|
$(XSLT_CFLAGS) \
|
||||||
$(X_CFLAGS) \
|
$(X_CFLAGS) \
|
||||||
-DRECOLL_DATADIR=\"${pkgdatadir}\" \
|
-DRECOLL_DATADIR=\"${pkgdatadir}\" \
|
||||||
-DREADFILE_ENABLE_ZLIB -DREADFILE_ENABLE_MINIZ \
|
-DREADFILE_ENABLE_ZLIB -DREADFILE_ENABLE_MINIZ -DREADFILE_ENABLE_MD5 \
|
||||||
-D_GNU_SOURCE \
|
-D_GNU_SOURCE \
|
||||||
$(DEFS)
|
$(DEFS)
|
||||||
|
|
||||||
|
|||||||
@ -507,6 +507,13 @@ int ConfSimple::eraseKey(const string& sk)
|
|||||||
return write();
|
return write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ConfSimple::clear()
|
||||||
|
{
|
||||||
|
m_submaps.clear();
|
||||||
|
m_order.clear();
|
||||||
|
return write();
|
||||||
|
}
|
||||||
|
|
||||||
// Walk the tree, calling user function at each node
|
// Walk the tree, calling user function at each node
|
||||||
ConfSimple::WalkerCode
|
ConfSimple::WalkerCode
|
||||||
ConfSimple::sortwalk(WalkerCode(*walker)(void *, const string&, const string&),
|
ConfSimple::sortwalk(WalkerCode(*walker)(void *, const string&, const string&),
|
||||||
@ -692,6 +699,13 @@ bool ConfSimple::commentsAsXML(ostream& out)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ConfLine::CFL_SK:
|
||||||
|
out << "<subkey>" << it->m_data << "</subkey>" << endl;
|
||||||
|
break;
|
||||||
|
case ConfLine::CFL_VAR:
|
||||||
|
out << "<varsetting>" << it->m_data << " = " <<
|
||||||
|
it->m_value << "</varsetting>" << endl;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,10 +159,7 @@ public:
|
|||||||
void reparse(const std::string& in);
|
void reparse(const std::string& in);
|
||||||
|
|
||||||
/** Clear all content */
|
/** Clear all content */
|
||||||
void clear() {
|
int clear();
|
||||||
m_submaps.clear();
|
|
||||||
m_order.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get string value for named parameter, from specified subsection (looks
|
* Get string value for named parameter, from specified subsection (looks
|
||||||
|
|||||||
@ -2955,6 +2955,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|||||||
#ifndef MINIZ_NO_TIME
|
#ifndef MINIZ_NO_TIME
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
#define MZ_FOPENREAD mz_fopen
|
||||||
#define MZ_FOPEN mz_fopen
|
#define MZ_FOPEN mz_fopen
|
||||||
#define MZ_FCLOSE fclose
|
#define MZ_FCLOSE fclose
|
||||||
#define MZ_FREAD fread
|
#define MZ_FREAD fread
|
||||||
@ -2986,6 +2987,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|||||||
#ifndef MINIZ_NO_TIME
|
#ifndef MINIZ_NO_TIME
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
#define MZ_FOPENREAD(f, m) fopen(f, m)
|
||||||
#define MZ_FOPEN(f, m) fopen(f, m)
|
#define MZ_FOPEN(f, m) fopen(f, m)
|
||||||
#define MZ_FCLOSE fclose
|
#define MZ_FCLOSE fclose
|
||||||
#define MZ_FREAD fread
|
#define MZ_FREAD fread
|
||||||
@ -3002,6 +3004,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
#define MZ_FOPEN(f, m) fopen64(f, m)
|
#define MZ_FOPEN(f, m) fopen64(f, m)
|
||||||
|
#define MZ_FOPENREAD(f, m) fopen64(f, m)
|
||||||
#define MZ_FCLOSE fclose
|
#define MZ_FCLOSE fclose
|
||||||
#define MZ_FREAD fread
|
#define MZ_FREAD fread
|
||||||
#define MZ_FWRITE fwrite
|
#define MZ_FWRITE fwrite
|
||||||
@ -3017,6 +3020,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
#define MZ_FOPEN(f, m) fopen(f, m)
|
#define MZ_FOPEN(f, m) fopen(f, m)
|
||||||
|
#define MZ_FOPENREAD(f, m) fopen(f, m)
|
||||||
#define MZ_FCLOSE fclose
|
#define MZ_FCLOSE fclose
|
||||||
#define MZ_FREAD fread
|
#define MZ_FREAD fread
|
||||||
#define MZ_FWRITE fwrite
|
#define MZ_FWRITE fwrite
|
||||||
@ -3033,6 +3037,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|||||||
#ifndef MINIZ_NO_TIME
|
#ifndef MINIZ_NO_TIME
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
#define MZ_FOPENREAD(f, m) fopen(f, m)
|
||||||
#define MZ_FOPEN(f, m) fopen(f, m)
|
#define MZ_FOPEN(f, m) fopen(f, m)
|
||||||
#define MZ_FCLOSE fclose
|
#define MZ_FCLOSE fclose
|
||||||
#define MZ_FREAD fread
|
#define MZ_FREAD fread
|
||||||
|
|||||||
@ -65,7 +65,6 @@
|
|||||||
|
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,10 @@
|
|||||||
|
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MDU_INCLUDE_LOG
|
#ifdef MDU_INCLUDE_LOG
|
||||||
#include MDU_INCLUDE_LOG
|
#include MDU_INCLUDE_LOG
|
||||||
@ -88,7 +91,11 @@ bool file_to_string(const string& fn, string& data, int64_t offs, size_t cnt,
|
|||||||
string *reason)
|
string *reason)
|
||||||
{
|
{
|
||||||
FileToString accum(data);
|
FileToString accum(data);
|
||||||
return file_scan(fn, &accum, offs, cnt, reason, nullptr);
|
return file_scan(fn, &accum, offs, cnt, reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, nullptr
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_to_string(const string& fn, string& data, string *reason)
|
bool file_to_string(const string& fn, string& data, string *reason)
|
||||||
@ -254,6 +261,8 @@ public:
|
|||||||
};
|
};
|
||||||
#endif // GZ
|
#endif // GZ
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
|
||||||
class FileScanMd5 : public FileScanFilter {
|
class FileScanMd5 : public FileScanFilter {
|
||||||
public:
|
public:
|
||||||
FileScanMd5(string& d) : digest(d) {}
|
FileScanMd5(string& d) : digest(d) {}
|
||||||
@ -281,7 +290,7 @@ public:
|
|||||||
string &digest;
|
string &digest;
|
||||||
MD5_CTX ctx;
|
MD5_CTX ctx;
|
||||||
};
|
};
|
||||||
|
#endif // MD5
|
||||||
|
|
||||||
// Source taking data from a regular file
|
// Source taking data from a regular file
|
||||||
class FileScanSourceFile : public FileScanSource {
|
class FileScanSourceFile : public FileScanSource {
|
||||||
@ -488,7 +497,11 @@ bool file_scan(const std::string& filename, const std::string& membername,
|
|||||||
FileScanDo* doer, std::string *reason)
|
FileScanDo* doer, std::string *reason)
|
||||||
{
|
{
|
||||||
if (membername.empty()) {
|
if (membername.empty()) {
|
||||||
return file_scan(filename, doer, 0, -1, reason, nullptr);
|
return file_scan(filename, doer, 0, -1, reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, nullptr
|
||||||
|
#endif
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
FileScanSourceZip source(doer, filename, membername, reason);
|
FileScanSourceZip source(doer, filename, membername, reason);
|
||||||
return source.scan();
|
return source.scan();
|
||||||
@ -499,7 +512,11 @@ bool string_scan(const char *data, size_t cnt, const std::string& membername,
|
|||||||
FileScanDo* doer, std::string *reason)
|
FileScanDo* doer, std::string *reason)
|
||||||
{
|
{
|
||||||
if (membername.empty()) {
|
if (membername.empty()) {
|
||||||
return string_scan(data, cnt, doer, reason, nullptr);
|
return string_scan(data, cnt, doer, reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, nullptr
|
||||||
|
#endif
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
FileScanSourceZip source(data, cnt, doer, membername, reason);
|
FileScanSourceZip source(data, cnt, doer, membername, reason);
|
||||||
return source.scan();
|
return source.scan();
|
||||||
@ -509,9 +526,13 @@ bool string_scan(const char *data, size_t cnt, const std::string& membername,
|
|||||||
#endif // READFILE_ENABLE_ZIP
|
#endif // READFILE_ENABLE_ZIP
|
||||||
|
|
||||||
bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
|
bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
|
||||||
int64_t cnttoread, string *reason, string *md5p)
|
int64_t cnttoread, string *reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, string *md5p
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
LOGDEB("file_scan: doer " << doer << endl);
|
LOGDEB1("file_scan: doer " << doer << endl);
|
||||||
#if defined(READFILE_ENABLE_ZLIB)
|
#if defined(READFILE_ENABLE_ZLIB)
|
||||||
bool nodecomp = startoffs != 0;
|
bool nodecomp = startoffs != 0;
|
||||||
#endif
|
#endif
|
||||||
@ -521,7 +542,7 @@ bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
|
|||||||
|
|
||||||
FileScanSourceFile source(doer, fn, startoffs, cnttoread, reason);
|
FileScanSourceFile source(doer, fn, startoffs, cnttoread, reason);
|
||||||
FileScanUpstream *up = &source;
|
FileScanUpstream *up = &source;
|
||||||
|
up = up;
|
||||||
|
|
||||||
#if defined(READFILE_ENABLE_ZLIB)
|
#if defined(READFILE_ENABLE_ZLIB)
|
||||||
GzFilter gzfilter;
|
GzFilter gzfilter;
|
||||||
@ -531,6 +552,7 @@ bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
// We compute the MD5 on the uncompressed data, so insert this
|
// We compute the MD5 on the uncompressed data, so insert this
|
||||||
// right at the source (after the decompressor).
|
// right at the source (after the decompressor).
|
||||||
string digest;
|
string digest;
|
||||||
@ -539,19 +561,26 @@ bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
|
|||||||
md5filter.insertAtSink(doer, up);
|
md5filter.insertAtSink(doer, up);
|
||||||
up = &md5filter;
|
up = &md5filter;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ret = source.scan();
|
bool ret = source.scan();
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
if (md5p) {
|
if (md5p) {
|
||||||
md5filter.finish();
|
md5filter.finish();
|
||||||
MD5HexPrint(digest, *md5p);
|
MD5HexPrint(digest, *md5p);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_scan(const string& fn, FileScanDo* doer, string *reason)
|
bool file_scan(const string& fn, FileScanDo* doer, string *reason)
|
||||||
{
|
{
|
||||||
return file_scan(fn, doer, 0, -1, reason, nullptr);
|
return file_scan(fn, doer, 0, -1, reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, nullptr
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -579,24 +608,33 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool string_scan(const char *data, size_t cnt, FileScanDo* doer,
|
bool string_scan(const char *data, size_t cnt, FileScanDo* doer,
|
||||||
std::string *reason, std::string *md5p)
|
std::string *reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, std::string *md5p
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
FileScanSourceBuffer source(doer, data, cnt, reason);
|
FileScanSourceBuffer source(doer, data, cnt, reason);
|
||||||
FileScanUpstream *up = &source;
|
FileScanUpstream *up = &source;
|
||||||
|
up = up;
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
string digest;
|
string digest;
|
||||||
FileScanMd5 md5filter(digest);
|
FileScanMd5 md5filter(digest);
|
||||||
if (md5p) {
|
if (md5p) {
|
||||||
md5filter.insertAtSink(doer, up);
|
md5filter.insertAtSink(doer, up);
|
||||||
up = &md5filter;
|
up = &md5filter;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ret = source.scan();
|
bool ret = source.scan();
|
||||||
|
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
if (md5p) {
|
if (md5p) {
|
||||||
md5filter.finish();
|
md5filter.finish();
|
||||||
MD5HexPrint(digest, *md5p);
|
MD5HexPrint(digest, *md5p);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,11 @@ public:
|
|||||||
* @return true if the operation ended normally, else false.
|
* @return true if the operation ended normally, else false.
|
||||||
*/
|
*/
|
||||||
bool file_scan(const std::string& fn, FileScanDo* doer, int64_t startoffs,
|
bool file_scan(const std::string& fn, FileScanDo* doer, int64_t startoffs,
|
||||||
int64_t cnttoread, std::string *reason, std::string *md5p);
|
int64_t cnttoread, std::string *reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, std::string *md5p
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
/** Same as above, not offset/cnt/md5 */
|
/** Same as above, not offset/cnt/md5 */
|
||||||
bool file_scan(const std::string& filename, FileScanDo* doer,
|
bool file_scan(const std::string& filename, FileScanDo* doer,
|
||||||
@ -71,7 +75,11 @@ bool file_scan(const std::string& filename, FileScanDo* doer,
|
|||||||
|
|
||||||
/** Same as file_scan, from a memory buffer. No libz processing */
|
/** Same as file_scan, from a memory buffer. No libz processing */
|
||||||
bool string_scan(const char *data, size_t cnt, FileScanDo* doer,
|
bool string_scan(const char *data, size_t cnt, FileScanDo* doer,
|
||||||
std::string *reason, std::string *md5p);
|
std::string *reason
|
||||||
|
#ifdef READFILE_ENABLE_MD5
|
||||||
|
, std::string *md5p
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
#if defined(READFILE_ENABLE_MINIZ)
|
#if defined(READFILE_ENABLE_MINIZ)
|
||||||
/* Process a zip archive member */
|
/* Process a zip archive member */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user