diff options
author | Teus Benschop <teusjannette@gmail.com> | 2018-11-10 21:10:09 +0700 |
---|---|---|
committer | Teus Benschop <teusjannette@gmail.com> | 2018-11-10 21:10:09 +0700 |
commit | 2a58bdf9b682f462b63be719fc441a679f7d52f3 (patch) | |
tree | 4b8fce727ab045eef1a846659bb90f18719477e6 /utilities/mod2zmod.cpp | |
parent | 018216c25c73b221df0810e6c909623abd46c321 (diff) | |
parent | 70090da73f95ee90e15650d853744526b5f47e68 (diff) |
Record sword (1.8.1+dfsg-7) in archive suite sid
Diffstat (limited to 'utilities/mod2zmod.cpp')
-rw-r--r-- | utilities/mod2zmod.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/utilities/mod2zmod.cpp b/utilities/mod2zmod.cpp index 03fd8c5..512749f 100644 --- a/utilities/mod2zmod.cpp +++ b/utilities/mod2zmod.cpp @@ -2,9 +2,9 @@ * * mod2zmod.cpp - Compression on variable granularity * - * $Id: mod2zmod.cpp 2833 2013-06-29 06:40:28Z chrislit $ + * $Id: mod2zmod.cpp 3130 2014-03-15 05:43:52Z chrislit $ * - * 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 @@ -42,7 +42,16 @@ #include <swtext.h> #include <swmgr.h> #include <lzsscomprs.h> +#ifndef EXCLUDEZLIB #include <zipcomprs.h> +#endif +#ifndef EXCLUDEBZIP2 +#include <bz2comprs.h> +#endif +#ifndef EXCLUDEXZ +#include <xzcomprs.h> +#endif + #include <versekey.h> #include <stdio.h> #include <cipherfil.h> @@ -58,10 +67,11 @@ using std::cout; 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"; + 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); } @@ -75,9 +85,9 @@ int main(int argc, char **argv) SWCompress *compressor = 0; SWModule *inModule = 0; SWModule *outModule = 0; - + int compLevel = 0; - if ((argc < 3) || (argc > 6)) { + if ((argc < 3) || (argc > 7)) { errorOutHelp(argv[0]); } @@ -86,12 +96,15 @@ int main(int argc, char **argv) if (argc > 4) { compType = atoi(argv[4]); if (argc > 5) { - cipherKey = argv[5]; + compLevel = atoi(argv[5]); + if (argc > 6) { + cipherKey = argv[6]; + } } } } - 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) || 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]); } @@ -119,7 +132,18 @@ int main(int argc, char **argv) switch (compType) { // these are deleted by zText case 1: compressor = new LZSSCompress(); break; + #ifndef EXCLUDEZLIB case 2: compressor = new ZipCompress(); break; + #endif + #ifndef EXCLUDEBZIP2 + case 3: compressor = new Bzip2Compress(); break; + #endif + #ifndef EXCLUDEXZ + case 4: compressor = new XzCompress(); break; + #endif + } + if (compressor && compLevel > 0) { + compressor->setLevel(compLevel); } int result = 0; |