Commits

Andreas Tscharner  committed b563efa

Update examples

* ExtractText (texts.rdf) is now encrypted (and compressed)

  • Participants
  • Parent commits e7cbaae

Comments (0)

Files changed (5)

File src/example/ExtractText.cxx

 
 
 #include <iostream>
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
 #include "../include/ResourceManager.hxx"
 
+#ifdef HAVE_CONFIG_H
+#include "../lrc_config.h"
+#endif
+
+
 using namespace lrc;
 
 int main(int argc, char **argv)
 {
+	const unsigned char PWD[] = "Yadda";
+
 	ResourceManager *texts;
 	Resource *singleText;
 	char **textList;
 	int numTexts, fileNameLen, writtenBytes;
 	FILE *txtFile;
 	char *filename;
-
+#ifdef NO_ENCRYPTION
+	lrc::EncryptionType encText = lrc::NoneEncryption;
+#else
+	lrc::EncryptionType encText = lrc::SerpentEncryption;
+#endif
 
 	try {
-		texts = new ResourceManager("texts.rdf", lrc::NoneCompression);
+		texts = new ResourceManager("texts.rdf", lrc::bz2LibCompression, encText, PWD);
 	} catch (lrcFileNotFoundException const &fnfEx) {
 		std::cout << fnfEx.what() << std::endl;
 		return -1;

File src/example/ListResources.cxx

 	};
 
 	try {
-		cliRes = new ResourceManager(argv[1], comprType);
+		cliRes = new ResourceManager(argv[1], comprType, lrc::NoneEncryption, nullptr);
 	} catch (lrcFileNotFoundException const &fnfE) {
 		std::cout << fnfE.what() << std::endl;
 		return -1;

File src/example/Makefile.am

 ShowImage_DEPENDENCIES = OSLogos.rdf
 if !NO_ENCRYPTION
 ShowImage_DEPENDENCIES += logos.rdf
+ExtractText_LRC_OPTS = -e Serpent -p Yadda
+else
+ExtractText_LRC_OPTS =
 endif
 endif
 ExtractText_DEPENDENCIES = texts.rdf
 EXTRA_DIST = RIFExample.sh logos.rc texts.rc OSLogos.rif Password.txt data
 
 #
+# Create text.rdf files from text.rc
+texts.rdf: texts.rc
+	../compiler/lrc texts.rc -c bzip2 $(ExtractText_LRC_OPTS)
+
+#
 # Create rdf files from RC files
 .rc.rdf:
 	../compiler/lrc $<
 # Use own clean target
 clean-local:
 	-rm -f *.rdf
+	-rm -f README.txt Resource.txt ResourceMgr.txt

File src/example/ShowImage.cxx

 	};
 
 	try {
-		logos = new ResourceManager(rdfFilename, comprType);
+		logos = new ResourceManager(rdfFilename, comprType, lrc::NoneEncryption, nullptr);
 	} catch (lrcFileNotFoundException const &fnfEx) {
 		std::cout << fnfEx.what() << std::endl;
 		return -1;

File src/example/texts.rc

 
 #
 # Resource ID		Resource File				Compression	Encryption
-README				"../../README.rst"			zLib		None
-Resource			"../include/Resource.hxx"	zLib		None
-ResourceMgr			"../include/ResourceManager.hxx"		zLib		None
+README				"../../README.rst"
+Resource			"../include/Resource.hxx"
+ResourceMgr			"../include/ResourceManager.hxx"