[sword-svn] r3050 - trunk/utilities

chrislit at crosswire.org chrislit at crosswire.org
Sun Mar 2 04:49:23 MST 2014


Author: chrislit
Date: 2014-03-02 04:49:22 -0700 (Sun, 02 Mar 2014)
New Revision: 3050

Modified:
   trunk/utilities/imp2ld.cpp
   trunk/utilities/imp2vs.cpp
   trunk/utilities/mod2zmod.cpp
   trunk/utilities/osis2mod.cpp
   trunk/utilities/tei2mod.cpp
Log:
utilities updated for bzip2/xz


Modified: trunk/utilities/imp2ld.cpp
===================================================================
--- trunk/utilities/imp2ld.cpp	2014-03-02 11:47:47 UTC (rev 3049)
+++ trunk/utilities/imp2ld.cpp	2014-03-02 11:49:22 UTC (rev 3050)
@@ -4,7 +4,7 @@
  *
  * $Id$
  *
- * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2014 CrossWire Bible Society (http://www.crosswire.org)
  *	CrossWire Bible Society
  *	P. O. Box 2528
  *	Tempe, AZ  85280-2528
@@ -31,8 +31,10 @@
 #include <rawld.h>
 #include <rawld4.h>
 #include <zld.h>
+#include <lzsscomprs.h>
 #include <zipcomprs.h>
-#include <lzsscomprs.h>
+#include <bz2comprs.h>
+#include <xzcomprs.h>
 #include <stdio.h>
 
 using std::string;
@@ -46,10 +48,10 @@
 	fprintf(stderr, "\n=== imp2ld (Revision $Rev: 2234 $) SWORD lexicon importer.\n");
 	fprintf(stderr, "\nusage: %s <imp_file> [options]\n", progName);
 	fprintf(stderr, "  -a\t\t\t augment module if exists (default is to create new)\n");
-	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, "  -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, "  -o <output_path>\t where to write data files.\n");
-	fprintf(stderr, "  -4\t\t\t use 4 byte size entries (default is 2).\n");
+	fprintf(stderr, "  -4\t\t\t use 4 byte size entries (default: 2).\n");
 	fprintf(stderr, "  -b <entry_count>\t\t compression block size (default 30 entries)\n");
 	fprintf(stderr, "  -s\t\t\t case sensitive keys (default is not case sensitive)\n");
 	fprintf(stderr, "\n");
@@ -90,9 +92,16 @@
 			append = true;
 		}
 		else if (!strcmp(argv[i], "-z")) {
-			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
 			if (fourByteSize) usage(*argv, "Cannot specify both -z and -4");
 			compType = "ZIP";
+			if (i+1 < argc && argv[i+1][0] != '-') {
+				switch (argv[i+1][0]) {
+				case 'l': compType = "LZSS";
+				case 'z': compType = "ZIP";
+				case 'b': compType = "BZIP2";
+				case 'x': compType = "XZ";
+				}
+			}
 		}
 		else if (!strcmp(argv[i], "-Z")) {
 			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
@@ -133,17 +142,32 @@
 	SWModule *mod = 0;
 	SWKey *key, *linkKey;
 
-	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		
+	}
 
+
 	// setup module
 	if (!append) {
 		if (compressor) {

Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp	2014-03-02 11:47:47 UTC (rev 3049)
+++ trunk/utilities/imp2vs.cpp	2014-03-02 11:49:22 UTC (rev 3050)
@@ -4,7 +4,7 @@
  *
  * $Id$
  *
- * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2014 CrossWire Bible Society (http://www.crosswire.org)
  *	CrossWire Bible Society
  *	P. O. Box 2528
  *	Tempe, AZ  85280-2528
@@ -35,6 +35,8 @@
 #include <ztext.h>
 #include <lzsscomprs.h>
 #include <zipcomprs.h>
+#include <bz2comprs.h>
+#include <xzcomprs.h>
 #include <localemgr.h>
 
 #ifndef NO_SWORD_NAMESPACE
@@ -50,8 +52,8 @@
 	fprintf(stderr, "\n=== imp2vs (Revision $Rev: 2234 $) SWORD Bible/Commentary importer.\n");
 	fprintf(stderr, "\nusage: %s <imp_file> [options]\n", progName);
 	fprintf(stderr, "  -a\t\t\t augment module if exists (default is to create new)\n");
-	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, "  -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, "  -o <output_path>\t where to write data files.\n");
 	fprintf(stderr, "  -4\t\t\t use 4 byte size entries (default is 2).\n");
 	fprintf(stderr, "  -b <2|3|4>\t\t compression block size (default 4):\n");
@@ -104,9 +106,16 @@
 			append = true;
 		}
 		else if (!strcmp(argv[i], "-z")) {
-			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
 			if (fourByteSize) usage(*argv, "Cannot specify both -z and -4");
 			compType = "ZIP";
+			if (i+1 < argc && argv[i+1][0] != '-') {
+				switch (argv[i+1][0]) {
+				case 'l': compType = "LZSS";
+				case 'z': compType = "ZIP";
+				case 'b': compType = "BZIP2";
+				case 'x': compType = "XZ";
+				}
+			}
 		}
 		else if (!strcmp(argv[i], "-Z")) {
 			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
@@ -141,17 +150,32 @@
 	const VersificationMgr::System *v = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem(v11n);
 	if (!v) std::cout << "Warning: Versification " << v11n << " not found. Using KJV versification...\n";
 
-	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		
+	}
 
+
 	// setup module
 	if (!append) {
 		if (compressor) {

Modified: trunk/utilities/mod2zmod.cpp
===================================================================
--- trunk/utilities/mod2zmod.cpp	2014-03-02 11:47:47 UTC (rev 3049)
+++ trunk/utilities/mod2zmod.cpp	2014-03-02 11:49:22 UTC (rev 3050)
@@ -4,7 +4,7 @@
  *
  * $Id$
  *
- * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2014 CrossWire Bible Society (http://www.crosswire.org)
  *	CrossWire Bible Society
  *	P. O. Box 2528
  *	Tempe, AZ  85280-2528
@@ -43,6 +43,8 @@
 #include <swmgr.h>
 #include <lzsscomprs.h>
 #include <zipcomprs.h>
+#include <bz2comprs.h>
+#include <xzcomprs.h>
 #include <versekey.h>
 #include <stdio.h>
 #include <cipherfil.h>
@@ -61,7 +63,7 @@
 	cerr << "usage: "<< appName << " <modname> <datapath> [blockType [compressType [cipherKey]]]\n\n";
 	cerr << "datapath: the directory in which to write the zModule\n";
 	cerr << "blockType  : (default 4)\n\t2 - verses\n\t3 - chapters\n\t4 - books\n";
-	cerr << "compressType: (default 1):\n\t1 - LZSS\n\t2 - Zip\n";
+	cerr << "compressType: (default 1):\n\t1 - LZSS\n\t2 - Zip\n\t3 - bzip2\n\t4 - xz\n";
 	cerr << "\n\n";
 	exit(-1);
 }
@@ -91,7 +93,7 @@
 		}
 	}
 
-	if ((iType < 2) || (compType < 1) || (compType > 2) || (!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "-help"))) {
+	if ((iType < 2) || (compType < 1) || (compType > 4) || (!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "-help"))) {
 		errorOutHelp(argv[0]);
 	}
 
@@ -120,6 +122,8 @@
 	switch (compType) {	// these are deleted by zText
 	case 1: compressor = new LZSSCompress(); break;
 	case 2: compressor = new ZipCompress(); break;
+	case 3: compressor = new Bzip2Compress(); break;
+	case 4: compressor = new XzCompress(); break;
 	}
 
 	int result = 0;

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2014-03-02 11:47:47 UTC (rev 3049)
+++ trunk/utilities/osis2mod.cpp	2014-03-02 11:49:22 UTC (rev 3050)
@@ -46,6 +46,8 @@
 #include <ztext.h>
 #include <lzsscomprs.h>
 #include <zipcomprs.h>
+#include <bz2comprs.h>
+#include <xzcomprs.h>
 #include <cipherfil.h>
 
 #ifdef _ICU_
@@ -1287,9 +1289,9 @@
 	fprintf(stderr, "  <osisDoc>\t\t path to the validated OSIS document, or '-' to\n");
 	fprintf(stderr, "\t\t\t\t read from standard input\n");
 	fprintf(stderr, "  -a\t\t\t augment module if exists (default is to create new)\n");
-	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, "  -b <2|3|4>\t\t compression block size (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, "  -b <2|3|4>\t\t compression block size (default: 4)\n");
 	fprintf(stderr, "\t\t\t\t 2 - verse; 3 - chapter; 4 - book\n");
 	fprintf(stderr, "  -c <cipher_key>\t encipher module using supplied key\n");
 	fprintf(stderr, "\t\t\t\t (default no enciphering)\n");
@@ -1583,9 +1585,16 @@
 			append = 1;
 		}
 		else if (!strcmp(argv[i], "-z")) {
-			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
 			if (entrySize) usage(*argv, "Cannot specify both -z and -s");
 			compType = "ZIP";
+			if (i+1 < argc && argv[i+1][0] != '-') {
+				switch (argv[i+1][0]) {
+				case 'l': compType = "LZSS";
+				case 'z': compType = "ZIP";
+				case 'b': compType = "BZIP2";
+				case 'x': compType = "XZ";
+				}
+			}
 		}
 		else if (!strcmp(argv[i], "-Z")) {
 			if (compType.size()) usage(*argv, "Cannot specify both -z and -Z");
@@ -1611,7 +1620,7 @@
 			else usage(*argv, "-v requires <v11n>");
 		}
 		else if (!strcmp(argv[i], "-s")) {
-			if (compType.size()) usage(*argv, "Cannot specify -s and -z or -Z");
+			if (compType.size()) usage(*argv, "Cannot specify -s and -z");
 			if (i+1 < argc) {
 				entrySize = atoi(argv[++i]);
 				if (entrySize == 2 || entrySize == 4) {
@@ -1632,16 +1641,30 @@
 
 	if (isCommentary) isCommentary = true;	// avoid unused warning for now
 
-	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		
+	}
 
 #ifndef _ICU_
 	if (normalize) {

Modified: trunk/utilities/tei2mod.cpp
===================================================================
--- trunk/utilities/tei2mod.cpp	2014-03-02 11:47:47 UTC (rev 3049)
+++ trunk/utilities/tei2mod.cpp	2014-03-02 11:49:22 UTC (rev 3050)
@@ -4,7 +4,7 @@
  *
  * $Id$
  *
- * 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,10 @@
 #include <rawld.h>
 #include <rawld4.h>
 #include <zld.h>
+#include <lzsscomprs.h>
 #include <zipcomprs.h>
-#include <lzsscomprs.h>
+#include <bz2comprs.h>
+#include <xzcomprs.h>
 #include <stdio.h>
 #include <cipherfil.h>
 
@@ -344,16 +346,16 @@
 		
 	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);
 }
 
@@ -382,9 +384,16 @@
 
 	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+1][0]) {
+				case 'l': compType = "LZSS";
+				case 'z': compType = "ZIP";
+				case 'b': compType = "BZIP2";
+				case 'x': compType = "XZ";
+				}
+			}
 			modDrv = "zLD";
 			recommendedPath += "zld/";
 		}
@@ -392,10 +401,11 @@
 			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,16 +442,30 @@
 	}
 #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
 	// cout << "path: " << path << " teiDoc: " << teiDoc << " compressType: " << compType << " ldType: " << modDrv << " cipherKey: " << cipherKey.c_str() << " normalize: " << normalize << "\n";




More information about the sword-cvs mailing list