100 if (argc < 2)
usage(*argv);
102 const char *progName = argv[0];
103 const char *inFileName = argv[1];
108 bool fourByteSize =
false;
110 bool replace =
false;
112 SWBuf cipherKey =
"";
116 for (
int i = 2; i < argc; i++) {
117 if (!strcmp(argv[i],
"-a")) {
120 else if (!strcmp(argv[i],
"-r")) {
123 else if (!strcmp(argv[i],
"-z")) {
124 if (fourByteSize)
usage(*argv,
"Cannot specify both -z and -4");
126 if (i+1 < argc && argv[i+1][0] !=
'-') {
127 switch (argv[++i][0]) {
128 case 'l': compType =
"LZSS";
break;
129 case 'z': compType =
"ZIP";
break;
130 case 'b': compType =
"BZIP2";
break;
131 case 'x': compType =
"XZ";
break;
135 else if (!strcmp(argv[i],
"-Z")) {
136 if (compType.size())
usage(*argv,
"Cannot specify both -z and -Z");
137 if (fourByteSize)
usage(*argv,
"Cannot specify both -Z and -4");
140 else if (!strcmp(argv[i],
"-4")) {
143 else if (!strcmp(argv[i],
"-b")) {
145 iType = atoi(argv[++i]);
146 if ((iType >= 2) && (iType <= 4))
continue;
148 usage(*argv,
"-b requires one of <2|3|4>");
150 else if (!strcmp(argv[i],
"-o")) {
151 if (i+1 < argc) outPath = argv[++i];
152 else usage(progName,
"-o requires <output_path>");
154 else if (!strcmp(argv[i],
"-v")) {
155 if (i+1 < argc) v11n = argv[++i];
156 else usage(progName,
"-v requires <v11n>");
158 else if (!strcmp(argv[i],
"-l")) {
159 if (i+1 < argc) locale = argv[++i];
160 else usage(progName,
"-l requires <locale>");
162 else if (!strcmp(argv[i],
"-c")) {
163 if (i+1 < argc) cipherKey = argv[++i];
164 else usage(*argv,
"-c requires <cipher_key>");
166 else usage(progName, (((SWBuf)
"Unknown argument: ")+ argv[i]).c_str());
170 if (!v) std::cout <<
"Warning: Versification " << v11n <<
" not found. Using KJV versification...\n";
172 if (compType ==
"LZSS") {
175 else if (compType ==
"ZIP") {
177 compressor =
new ZipCompress();
179 usage(*argv,
"ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libz is available when compiling SWORD library");
182 else if (compType ==
"BZIP2") {
186 usage(*argv,
"ERROR: SWORD library not compiled with bzip2 compression support.\n\tBe sure libbz2 is available when compiling SWORD library");
189 else if (compType ==
"XZ") {
193 usage(*argv,
"ERROR: SWORD library not compiled with xz compression support.\n\tBe sure liblzma is available when compiling SWORD library");
202 fprintf(stderr,
"ERROR: %s: couldn't create module at path: %s \n", *argv, outPath.c_str());
232 module = (!fourByteSize)
239 if (cipherKey.length()) {
240 fprintf(stderr,
"Adding cipher filter with phrase: %s\n", cipherKey.c_str() );
242 module->addRawFilter(cipherFilter);
253 VerseKey *vkey = (VerseKey *)module->createKey();
254 vkey->setIntros(
true);
255 vkey->setAutoNormalize(
false);
256 vkey->setPersist(
true);
257 module->setKey(*vkey);
271 if (lineBuffer.startsWith(
"$$$")) {
272 if ((keyBuffer.size()) && (entBuffer.size())) {
273 writeEntry(module, keyBuffer, entBuffer, replace);
275 keyBuffer = lineBuffer;
281 if (keyBuffer.size()) {
282 entBuffer += lineBuffer;
287 if ((keyBuffer.size()) && (entBuffer.size())) {
288 writeEntry(module, keyBuffer, entBuffer, replace);
virtual void setDefaultLocaleName(const char *name)
static unsigned int RDONLY
static char createModule(const char *path, const char *v11n="KJV")
static LocaleMgr * getSystemLocaleMgr()
void writeEntry(SWModule *book, SWBuf keyBuffer, SWBuf entBuffer)
static char createModule(const char *path, const char *v11n="KJV")
static char createModule(const char *path, int blockBound, const char *v11n="KJV")
void usage(const char *app)
static char getLine(FileDesc *fDesc, SWBuf &line)
static VersificationMgr * getSystemVersificationMgr()
const System * getVersificationSystem(const char *name) const
static FileMgr * getSystemFileMgr()