24 #pragma warning( disable: 4251 )
59 #ifndef NO_SWORD_NAMESPACE
60 using namespace sword;
68 cerr << appName <<
" - a tool to create compressed Sword modules\n";
69 cerr <<
"version 0.1\n\n";
70 cerr <<
"usage: "<< appName <<
" <modname> <datapath> [blockType [compressType [compressLevel [cipherKey]]]]\n\n";
71 cerr <<
"datapath: the directory in which to write the zModule\n";
72 cerr <<
"blockType : (default 4)\n\t2 - verses\n\t3 - chapters\n\t4 - books\n";
73 cerr <<
"compressType: (default 1):\n\t1 - LZSS\n\t2 - Zip\n\t3 - bzip2\n\t4 - xz\n";
74 cerr <<
"compressLevel: (default varies by compressType):\n\tA digit from 1-9. Greater values compress more, but require more\n\ttime/memory. Use 0 for the default compression level.\n";
80 int main(
int argc,
char **argv)
84 string cipherKey =
"";
86 SWModule *inModule = 0;
87 SWModule *outModule = 0;
90 if ((argc < 3) || (argc > 7)) {
95 iType = atoi(argv[3]);
97 compType = atoi(argv[4]);
99 compLevel = atoi(argv[5]);
107 if ((iType < 2) || (compType < 1) || (compType > 4) || compLevel < 0 || compLevel > 9 || (!strcmp(argv[1],
"-h")) || (!strcmp(argv[1],
"--help")) || (!strcmp(argv[1],
"/?")) || (!strcmp(argv[1],
"-?")) || (!strcmp(argv[1],
"-help"))) {
113 ModMap::iterator it = mgr.Modules.find(argv[1]);
114 if (it == mgr.Modules.end()) {
115 fprintf(stderr,
"error: %s: couldn't find module: %s\n", argv[0], argv[1]);
119 inModule = it->second;
129 if (!strcmp(inModule->getType(),
"Biblical Texts")) modType =
BIBLE;
130 if (!strcmp(inModule->getType(),
"Lexicons / Dictionaries")) modType =
LEX;
131 if (!strcmp(inModule->getType(),
"Commentaries")) modType =
COM;
136 case 2: compressor =
new ZipCompress();
break;
145 if (compressor && compLevel > 0) {
153 SWKey *k = inModule->getKey();
164 fprintf(stderr,
"error: %s: couldn't create module at path: %s\n", argv[0], argv[2]);
171 SWKey *k = inModule->getKey();
173 outModule =
new zText(argv[2], 0, 0, iType, compressor,
175 vk->getVersificationSystem());
176 ((VerseKey *)(SWKey *)(*inModule))->setIntros(
true);
180 outModule =
new zLD(argv[2], 0, 0, iType, compressor);
185 if (!cipherKey.empty()) {
187 outModule->addRawFilter(cipherFilter);
190 string lastBuffer =
"Something that would never be first module entry";
193 SWKey *outModuleKey = outModule->createKey();
195 outModuleKey->setPersist(
true);
197 vkey->setIntros(
true);
198 vkey->setAutoNormalize(
false);
200 outModule->setKey(*outModuleKey);
202 inModule->setSkipConsecutiveLinks(
false);
204 while (!inModule->popError()) {
205 bufferKey = *(SWKey *)(*inModule);
207 if ((lastBuffer == inModule->getRawEntry()) &&(lastBuffer.length() > 0)) {
208 *outModuleKey = bufferKey;
209 outModule->linkEntry(&lastBufferKey);
210 cout <<
"Adding [" << bufferKey <<
"] link to: [" << lastBufferKey <<
"]\n";
213 lastBuffer = inModule->getRawEntry();
214 lastBufferKey = inModule->getKeyText();
215 if (lastBuffer.length() > 0) {
216 cout <<
"Adding [" << bufferKey <<
"] new text.\n";
217 *outModuleKey = bufferKey;
220 (*outModule) << lastBuffer.c_str();
223 cout <<
"Skipping [" << bufferKey <<
"] no entry in Module.\n";
virtual void setLevel(int l)
#define SWDYNAMIC_CAST(className, object)
static char createModule(const char *path, int blockBound, const char *v11n="KJV")
static char createModule(const char *path)
void errorOutHelp(char *appName)