|
|
|
@ -24,12 +24,46 @@
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <pathTools.h>
|
|
|
|
#include <pathTools.h>
|
|
|
|
|
|
|
|
#include <zim/file.h>
|
|
|
|
#include <kiwix/manager.h>
|
|
|
|
#include <kiwix/manager.h>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
|
|
|
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline char hi(char v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char hex[] = "0123456789abcdef";
|
|
|
|
|
|
|
|
return hex[(v >> 4) & 0xf];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline char lo(char v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char hex[] = "0123456789abcdef";
|
|
|
|
|
|
|
|
return hex[v & 0xf];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string hexUUID (std::string in)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::ostringstream out;
|
|
|
|
|
|
|
|
for (unsigned n = 0; n < 4; ++n)
|
|
|
|
|
|
|
|
out << hi(in[n]) << lo(in[n]);
|
|
|
|
|
|
|
|
out << '-';
|
|
|
|
|
|
|
|
for (unsigned n = 4; n < 6; ++n)
|
|
|
|
|
|
|
|
out << hi(in[n]) << lo(in[n]);
|
|
|
|
|
|
|
|
out << '-';
|
|
|
|
|
|
|
|
for (unsigned n = 6; n < 8; ++n)
|
|
|
|
|
|
|
|
out << hi(in[n]) << lo(in[n]);
|
|
|
|
|
|
|
|
out << '-';
|
|
|
|
|
|
|
|
for (unsigned n = 8; n < 10; ++n)
|
|
|
|
|
|
|
|
out << hi(in[n]) << lo(in[n]);
|
|
|
|
|
|
|
|
out << '-';
|
|
|
|
|
|
|
|
for (unsigned n = 10; n < 16; ++n)
|
|
|
|
|
|
|
|
out << hi(in[n]) << lo(in[n]);
|
|
|
|
|
|
|
|
std::string op=out.str();
|
|
|
|
|
|
|
|
return op;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void show(kiwix::Library library) {
|
|
|
|
void show(kiwix::Library library) {
|
|
|
|
std::vector<kiwix::Book>::iterator itr;
|
|
|
|
std::vector<kiwix::Book>::iterator itr;
|
|
|
|
unsigned int inc = 1;
|
|
|
|
unsigned int inc = 1;
|
|
|
|
@ -160,6 +194,29 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
|
|
|
|
if (zimPath != "") {
|
|
|
|
if (zimPath != "") {
|
|
|
|
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
|
|
|
|
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
|
|
|
|
|
|
|
|
zim::File zimFile(zimPath);
|
|
|
|
|
|
|
|
if(zimFile.getArticleByUrl("M/startfileuid").getIndex()!=std::numeric_limits<unsigned int>::max())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string id=zimFile.getArticleByUrl("M/endfileuid").getPage();
|
|
|
|
|
|
|
|
std::string temp="";
|
|
|
|
|
|
|
|
unsigned int k=0;
|
|
|
|
|
|
|
|
char tempArray[16]="";
|
|
|
|
|
|
|
|
for(unsigned int i=0; i<id.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(id[i]=='\n')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tempArray[k]= atoi(temp.c_str());
|
|
|
|
|
|
|
|
temp="";
|
|
|
|
|
|
|
|
k++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
temp+=id[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
origID=hexUUID(tempArray);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//std::cout<<"\nORIGID: "<<origID;
|
|
|
|
string bookId = libraryManager.addBookFromPathAndGetId(zimPath, zimPathToSave, url,origID, false);
|
|
|
|
string bookId = libraryManager.addBookFromPathAndGetId(zimPath, zimPathToSave, url,origID, false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!bookId.empty()) {
|
|
|
|
if (!bookId.empty()) {
|
|
|
|
|