The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mkfastmod.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * mkfastmod.cpp -
4  *
5  * $Id: mkfastmod.cpp 3063 2014-03-04 13:04:11Z chrislit $
6  *
7  * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 #ifdef _MSC_VER
24  #pragma warning( disable: 4251 )
25 #endif
26 
27 #include <stdio.h>
28 #include <rawtext.h>
29 #include <swmgr.h>
30 #include <versekey.h>
31 #include <markupfiltmgr.h>
32 #include <swbuf.h>
33 
34 #ifndef NO_SWORD_NAMESPACE
35 using sword::SWMgr;
36 using sword::SWModule;
37 using sword::ListKey;
38 using sword::VerseKey;
39 using sword::ModMap;
40 using sword::SWBuf;
41 #endif
42 
43 void percentUpdate(char percent, void *userData) {
44  static char printed = 0;
45  char maxHashes = *((char *)userData);
46 
47  while ((((float)percent)/100) * maxHashes > printed) {
48  printf("=");
49  printed++;
50  fflush(stdout);
51  }
52 /*
53  std::cout << (int)percent << "% ";
54 */
55  fflush(stdout);
56 }
57 
58 
59 int main(int argc, char **argv)
60 {
61  if (argc != 2) {
62  fprintf(stderr, "usage: %s <modname>\n", argv[0]);
63  exit(-1);
64  }
65 
66  SWModule *target;
67  ListKey listkey;
68  ModMap::iterator it;
69 
70  SWMgr manager;
71  it = manager.Modules.find(argv[1]);
72  if (it == manager.Modules.end()) {
73  fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]);
74  for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) {
75  fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription());
76  }
77  exit(-1);
78  }
79  target = it->second;
80 
81  if (!target->hasSearchFramework()) {
82  fprintf(stderr, "%s: error: %s does not support a search framework.\n", *argv, it->second->getName());
83  exit(-2);
84  }
85 
86  printf("Deleting any existing framework...\n");
87  target->deleteSearchFramework();
88  printf("Building framework, please wait...\n");
89  char lineLen = 70;
90  printf("[0=================================50==============================100]\n ");
91  char error = target->createSearchFramework(&percentUpdate, &lineLen);
92  if (error) {
93  fprintf(stderr, "%s: couldn't create search framework (permissions?)\n", *argv);
94  }
95  printf("\n");
96 }
Definition: swmgr.h:93
virtual bool hasSearchFramework()
Definition: swmodule.cpp:1170
virtual signed char createSearchFramework(void(*percent)(char, void *)=&nullPercent, void *percentUserData=0)
Definition: swmodule.cpp:1193
ModMap Modules
Definition: swmgr.h:322
int main(int argc, char **argv)
Definition: addcomment.cpp:32
virtual void deleteSearchFramework()
Definition: swmodule.cpp:1178
std::map< SWBuf, SWModule *, std::less< SWBuf > > ModMap
Definition: swmgr.h:74
void percentUpdate(char percent, void *userData)
Definition: mkfastmod.cpp:43