|
|
@ -44,11 +44,11 @@ typedef int off_t;
|
|
|
|
#include <zim/article.h>
|
|
|
|
#include <zim/article.h>
|
|
|
|
#include <zim/fileiterator.h>
|
|
|
|
#include <zim/fileiterator.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <regex.h>
|
|
|
|
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <kiwix/reader.h>
|
|
|
|
#include <kiwix/reader.h>
|
|
|
|
#include <kiwix/xapianSearcher.h>
|
|
|
|
#include <kiwix/xapianSearcher.h>
|
|
|
|
#include <pathTools.h>
|
|
|
|
#include <pathTools.h>
|
|
|
|
|
|
|
|
#include <regexTools.h>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
@ -178,19 +178,6 @@ static pthread_mutex_t searcherLock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
static bool hasSearchIndex = false;
|
|
|
|
static bool hasSearchIndex = false;
|
|
|
|
|
|
|
|
|
|
|
|
static void appendToFirstOccurence(string &content, const string regex, const string &replacement) {
|
|
|
|
|
|
|
|
regmatch_t matchs[1];
|
|
|
|
|
|
|
|
regex_t regexp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regcomp(®exp, regex.data(), REG_ICASE);
|
|
|
|
|
|
|
|
if (!regexec(®exp, content.data(), 1, matchs, 0)) {
|
|
|
|
|
|
|
|
if (matchs[0].rm_so > 0)
|
|
|
|
|
|
|
|
content.insert(matchs[0].rm_eo, replacement);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regfree(®exp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For compression */
|
|
|
|
/* For compression */
|
|
|
|
#define COMPRESSOR_BUFFER_SIZE 5000000
|
|
|
|
#define COMPRESSOR_BUFFER_SIZE 5000000
|
|
|
|
static Bytef *compr = (Bytef *)malloc(COMPRESSOR_BUFFER_SIZE);
|
|
|
|
static Bytef *compr = (Bytef *)malloc(COMPRESSOR_BUFFER_SIZE);
|
|
|
|