[sword-svn] r3500 - trunk/utilities

scribe at crosswire.org scribe at crosswire.org
Wed Nov 1 03:35:54 MST 2017


Author: scribe
Date: 2017-11-01 03:35:53 -0700 (Wed, 01 Nov 2017)
New Revision: 3500

Modified:
   trunk/utilities/imp2vs.cpp
Log:
added -c cipherKey functionality to imp2vs

Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp	2017-11-01 10:35:49 UTC (rev 3499)
+++ trunk/utilities/imp2vs.cpp	2017-11-01 10:35:53 UTC (rev 3500)
@@ -44,6 +44,7 @@
 #include <xzcomprs.h>
 #endif
 #include <localemgr.h>
+#include <cipherfil.h>
 
 #ifndef NO_SWORD_NAMESPACE
 using namespace sword;
@@ -72,6 +73,8 @@
 		fprintf(stderr, "\t\t\t\t\t%s\n", (*loop).c_str());
 	}
 	fprintf(stderr, "  -l <locale>\t\t specify a locale scheme to use (default is en)\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, "\n");
 	fprintf(stderr, "'imp' format is a simple standard for importing data into SWORD modules.\n"
 		"Required is a plain text file containing $$$key lines followed by content.\n\n"
@@ -104,6 +107,7 @@
 	bool fourByteSize      = false;
 	bool append	    = false;
 	int iType	      = 4;
+	SWBuf cipherKey        = "";
 	SWCompress *compressor = 0;
 	SWBuf compType	 = "";
 
@@ -150,6 +154,10 @@
 			if (i+1 < argc) locale = argv[++i];
 			else usage(progName, "-l requires <locale>");
 		}
+		else if (!strcmp(argv[i], "-c")) {
+			if (i+1 < argc) cipherKey = argv[++i];
+			else usage(*argv, "-c requires <cipher_key>");
+		}
 		else usage(progName, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str());
 	}
 	// -----------------------------------------------------
@@ -220,6 +228,14 @@
 			? (SWModule *)new RawText(outPath, 0, 0, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, v11n)
 			: (SWModule *)new RawText4(outPath, 0, 0, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, v11n);
 	}
+
+	SWFilter *cipherFilter = 0;
+
+	if (cipherKey.length()) {
+		fprintf(stderr, "Adding cipher filter with phrase: %s\n", cipherKey.c_str() );
+		cipherFilter = new CipherFilter(cipherKey.c_str());
+		module->addRawFilter(cipherFilter);
+	}
 	// -----------------------------------------------------
 	
 	// setup locale manager
@@ -268,6 +284,8 @@
 	}
 
 	delete module;
+	if (cipherFilter)
+		delete cipherFilter;
 	delete vkey;
 
 	FileMgr::getSystemFileMgr()->close(fd);




More information about the sword-cvs mailing list