[sword-svn] r3123 - trunk/utilities
chrislit at crosswire.org
chrislit at crosswire.org
Fri Mar 14 02:29:39 MST 2014
Author: chrislit
Date: 2014-03-14 02:29:39 -0700 (Fri, 14 Mar 2014)
New Revision: 3123
Modified:
trunk/utilities/mod2zmod.cpp
trunk/utilities/osis2mod.cpp
Log:
added compression level switches to mod2zmod & osis2mod
Modified: trunk/utilities/mod2zmod.cpp
===================================================================
--- trunk/utilities/mod2zmod.cpp 2014-03-14 08:08:28 UTC (rev 3122)
+++ trunk/utilities/mod2zmod.cpp 2014-03-14 09:29:39 UTC (rev 3123)
@@ -67,10 +67,11 @@
void errorOutHelp(char *appName) {
cerr << appName << " - a tool to create compressed Sword modules\n";
cerr << "version 0.1\n\n";
- cerr << "usage: "<< appName << " <modname> <datapath> [blockType [compressType [cipherKey]]]\n\n";
+ cerr << "usage: "<< appName << " <modname> <datapath> [blockType [compressType [compressLevel [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\t3 - bzip2\n\t4 - xz\n";
+ cerr << "compressLevel: (default varies by compressType):\n\tA digit from 1-9. Greater values compress more, but require more\n\ttime/memory. Use 0 for the default compression level.\n";
cerr << "\n\n";
exit(-1);
}
@@ -84,7 +85,7 @@
SWCompress *compressor = 0;
SWModule *inModule = 0;
SWModule *outModule = 0;
-
+ int compLevel = 0;
if ((argc < 3) || (argc > 6)) {
errorOutHelp(argv[0]);
@@ -95,12 +96,15 @@
if (argc > 4) {
compType = atoi(argv[4]);
if (argc > 5) {
- cipherKey = argv[5];
+ compLevel = atoi(argv[5]);
+ if (argc > 6) {
+ cipherKey = argv[5];
+ }
}
}
}
- 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"))) {
+ if ((iType < 2) || (compType < 1) || (compType > 4) || compLevel < 0 || compLevel > 9 || (!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "-help"))) {
errorOutHelp(argv[0]);
}
@@ -138,6 +142,9 @@
case 4: compressor = new XzCompress(); break;
#endif
}
+ if (compressor && compLevel > 0) {
+ compressor->setLevel(compLevel);
+ }
int result = 0;
switch (modType) {
Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp 2014-03-14 08:08:28 UTC (rev 3122)
+++ trunk/utilities/osis2mod.cpp 2014-03-14 09:29:39 UTC (rev 3123)
@@ -1308,10 +1308,11 @@
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 <l|z|b|x>\t\t use compression (default: none)\n");
+ fprintf(stderr, " -z <l|z|b|x>\t\t compression type (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, " -l <1-9>\t\t compression level (default varies by compression type)\n");
fprintf(stderr, " -c <cipher_key>\t encipher module using supplied key\n");
fprintf(stderr, "\t\t\t\t (default no enciphering)\n");
@@ -1600,6 +1601,7 @@
int entrySize = 0;
SWBuf cipherKey = "";
SWCompress *compressor = 0;
+ int compLevel = 0;
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "-a")) {
@@ -1669,6 +1671,16 @@
if (i+1 < argc) debug |= atoi(argv[++i]);
else usage(*argv, "-d requires <flags>");
}
+ else if (!strcmp(argv[i], "-l")) {
+ if (i+1 < argc) {
+ compLevel = atoi(argv[++i]);
+ }
+ else usage(*argv, "-l requires a value from 1-9");
+
+ if (compLevel < 0 || compLevel > 10) {
+ usage(*argv, "-l requires a value from 1-9");
+ }
+ }
else usage(*argv, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str());
}
@@ -1699,6 +1711,10 @@
#endif
}
+ if (compressor && compLevel > 0) {
+ compressor->setLevel(compLevel);
+ }
+
#ifndef _ICU_
if (normalize) {
normalize = false;
More information about the sword-cvs
mailing list