summaryrefslogtreecommitdiff
path: root/utilities/tei2mod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utilities/tei2mod.cpp')
-rw-r--r--utilities/tei2mod.cpp60
1 files changed, 45 insertions, 15 deletions
diff --git a/utilities/tei2mod.cpp b/utilities/tei2mod.cpp
index 575d882..58778f2 100644
--- a/utilities/tei2mod.cpp
+++ b/utilities/tei2mod.cpp
@@ -2,9 +2,9 @@
*
* tei2mod.cpp - Utility to import documents encoded as TEI
*
- * $Id: tei2mod.cpp 2978 2013-09-10 14:39:31Z scribe $
+ * $Id: tei2mod.cpp 3416 2016-03-15 14:07:18Z dmsmith $
*
- * Copyright 2008-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2008-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -62,8 +62,16 @@
#include <rawld.h>
#include <rawld4.h>
#include <zld.h>
-#include <zipcomprs.h>
#include <lzsscomprs.h>
+#ifndef EXCLUDEZLIB
+#include <zipcomprs.h>
+#endif
+#ifndef EXCLUDEBZIP2
+#include <bz2comprs.h>
+#endif
+#ifndef EXCLUDEXZ
+#include <xzcomprs.h>
+#endif
#include <stdio.h>
#include <cipherfil.h>
@@ -344,16 +352,16 @@ void usage(const char *app, const char *error = 0) {
fprintf(stderr, "TEI Lexicon/Dictionary/Daily Devotional/Glossary module creation tool for\n\tThe SWORD Project\n");
fprintf(stderr, "\nusage: %s <output/path> <teiDoc> [OPTIONS]\n", app);
- fprintf(stderr, " -z\t\t\t use ZIP compression (default no compression)\n");
- fprintf(stderr, " -Z\t\t\t use LZSS compression (default no compression)\n");
- fprintf(stderr, " -s <2|4>\t\t max text size per entry(default 4):\n");
+ fprintf(stderr, " -z <l|z|b|x>\t\t use compression (default: none)\n");
+ fprintf(stderr, "\t\t\t\t l - LZSS; z - ZIP; b - bzip2; x - xz\n");
+ fprintf(stderr, " -s <2|4>\t\t max text size per entry (default: 4)\n");
fprintf(stderr, " -c <cipher_key>\t encipher module using supplied key\n");
- fprintf(stderr, "\t\t\t\t (default no enciphering)\n");
+ fprintf(stderr, "\t\t\t\t (default: none)\n");
fprintf(stderr, " -N\t\t\t Do not convert UTF-8 or normalize UTF-8 to NFC\n");
fprintf(stderr, "\t\t\t\t (default is to convert to UTF-8, if needed,\n");
fprintf(stderr, "\t\t\t\t and then normalize to NFC. Note: all UTF-8\n");
fprintf(stderr, "\t\t\t\t texts should be normalized to NFC.)\n");
- fprintf(stderr, "\n\tThe options -z, -Z, and -s are mutually exclusive.\n");
+ fprintf(stderr, "\n\tThe options -z and -s are mutually exclusive.\n");
exit(-1);
}
@@ -364,7 +372,7 @@ int main(int argc, char **argv) {
#endif
SWBuf program = argv[0];
- fprintf(stderr, "You are running %s: $Rev: 2138 $\n", argv[0]);
+ fprintf(stderr, "You are running %s: $Rev: 3416 $\n", argv[0]);
// Let's test our command line arguments
if (argc < 3) {
@@ -382,9 +390,16 @@ int main(int argc, char **argv) {
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "-z")) {
- if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
if (modDrv.size()) usage(*argv, "Cannot specify both -z and -s");
compType = "ZIP";
+ if (i+1 < argc && argv[i+1][0] != '-') {
+ switch (argv[++i][0]) {
+ case 'l': compType = "LZSS"; break;
+ case 'z': compType = "ZIP"; break;
+ case 'b': compType = "BZIP2"; break;
+ case 'x': compType = "XZ"; break;
+ }
+ }
modDrv = "zLD";
recommendedPath += "zld/";
}
@@ -392,10 +407,11 @@ int main(int argc, char **argv) {
if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
if (modDrv.size()) usage(*argv, "Cannot specify both -Z and -s");
compType = "LZSS";
+ modDrv = "zLD";
recommendedPath += "zld/";
}
else if (!strcmp(argv[i], "-s")) {
- if (compType.size()) usage(*argv, "Cannot specify both -s and -z or -Z");
+ if (compType.size()) usage(*argv, "Cannot specify both -s and -z");
if (i+1 < argc) {
int size = atoi(argv[++i]);
if (size == 2) {
@@ -432,15 +448,29 @@ int main(int argc, char **argv) {
}
#endif
- if (compType == "ZIP") {
+ if (compType == "LZSS") {
+ compressor = new LZSSCompress();
+ }
+ else if (compType == "ZIP") {
#ifndef EXCLUDEZLIB
compressor = new ZipCompress();
#else
- usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library");
+ usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libz is available when compiling SWORD library");
#endif
}
- else if (compType == "LZSS") {
- compressor = new LZSSCompress();
+ else if (compType == "BZIP2") {
+#ifndef EXCLUDEBZIP2
+ compressor = new Bzip2Compress();
+#else
+ usage(*argv, "ERROR: SWORD library not compiled with bzip2 compression support.\n\tBe sure libbz2 is available when compiling SWORD library");
+#endif
+ }
+ else if (compType == "XZ") {
+#ifndef EXCLUDEXZ
+ compressor = new XzCompress();
+#else
+ usage(*argv, "ERROR: SWORD library not compiled with xz compression support.\n\tBe sure liblzma is available when compiling SWORD library");
+#endif
}
#ifdef DEBUG