summaryrefslogtreecommitdiff
path: root/utilities/mkfastmod.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:59 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:59 -0400
commit03134fa5f6f25d92724ce4c183f9bbe12a9e37dc (patch)
tree847326a4de82f0241ac87cbbc427a1b92a696a02 /utilities/mkfastmod.cpp
parentd7469385b05b9510338407fa123e9ad090f80af6 (diff)
Imported Upstream version 1.5.11
Diffstat (limited to 'utilities/mkfastmod.cpp')
-rw-r--r--utilities/mkfastmod.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/utilities/mkfastmod.cpp b/utilities/mkfastmod.cpp
new file mode 100644
index 0000000..eeebcaf
--- /dev/null
+++ b/utilities/mkfastmod.cpp
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <rawtext.h>
+#include <swmgr.h>
+#include <versekey.h>
+#include <markupfiltmgr.h>
+#include <swbuf.h>
+
+
+#ifndef NO_SWORD_NAMESPACE
+using sword::SWMgr;
+using sword::SWModule;
+using sword::ListKey;
+using sword::VerseKey;
+using sword::ModMap;
+using sword::SWBuf;
+#endif
+
+void percentUpdate(char percent, void *userData) {
+ static char printed = 0;
+ char maxHashes = *((char *)userData);
+
+ while ((((float)percent)/100) * maxHashes > printed) {
+ printf("=");
+ printed++;
+ fflush(stdout);
+ }
+/*
+ std::cout << (int)percent << "% ";
+*/
+ fflush(stdout);
+}
+
+
+int main(int argc, char **argv)
+{
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <modname>\n", argv[0]);
+ exit(-1);
+ }
+
+ SWModule *target;
+ ListKey listkey;
+ VerseKey vk;
+ ModMap::iterator it;
+
+ SWMgr manager;
+ it = manager.Modules.find(argv[1]);
+ if (it == manager.Modules.end()) {
+ fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]);
+ for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) {
+ fprintf(stderr, "[%s]\t - %s\n", (*it).second->Name(), (*it).second->Description());
+ }
+ exit(-1);
+ }
+ target = it->second;
+
+ if (!target->hasSearchFramework()) {
+ fprintf(stderr, "%s: error: %s does not support a search framework.\n", *argv, it->second->Name());
+ exit(-2);
+ }
+
+ printf("Deleting any existing framework...\n");
+ target->deleteSearchFramework();
+ printf("Building framework, please wait...\n");
+ char lineLen = 70;
+ printf("[0=================================50===============================100]\n ");
+ char error = target->createSearchFramework(&percentUpdate, &lineLen);
+ if (error) {
+ fprintf(stderr, "%s: couldn't create search framework (permissions?)\n", *argv);
+ }
+}