[Scummvm-cvs-logs] SF.net SVN: scummvm:[45603] scummvm/trunk/tools/create_kyradat/ create_kyradat.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Nov 1 23:27:11 CET 2009


Revision: 45603
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45603&view=rev
Author:   lordhoto
Date:     2009-11-01 22:27:10 +0000 (Sun, 01 Nov 2009)

Log Message:
-----------
Add command line parameter to automatically create a search table entry from a given file + offset/size pair.

Modified Paths:
--------------
    scummvm/trunk/tools/create_kyradat/create_kyradat.cpp

Modified: scummvm/trunk/tools/create_kyradat/create_kyradat.cpp
===================================================================
--- scummvm/trunk/tools/create_kyradat/create_kyradat.cpp	2009-11-01 21:19:39 UTC (rev 45602)
+++ scummvm/trunk/tools/create_kyradat/create_kyradat.cpp	2009-11-01 22:27:10 UTC (rev 45603)
@@ -478,6 +478,47 @@
 		return -1;
 	}
 
+	// Special case for developer mode of this tool:
+	// With "--create filename offset size" the tool will output
+	// a search entry for the specifed data in the specified file.
+	if (!strcmp(argv[1], "--create")) {
+		if (argc < 5) {
+			printf("Developer usage: %s --create input_file hex_offset hex_size\n", argv[0]);
+			return -1;
+		}
+
+		uint offset, size;
+		sscanf(argv[3], "%x", &offset);
+		sscanf(argv[4], "%x", &size);
+
+		FILE *input = fopen(argv[2], "rb");
+		if (!input)
+			error("Couldn't open file '%s'", argv[2]);
+
+		byte *buffer = new byte[size];
+		fseek(input, offset, SEEK_SET);
+		if (fread(buffer, 1, size, input) != size) {
+			delete[] buffer;
+			error("Couldn't read from file '%s'", argv[2]);
+		}
+
+		fclose(input);
+
+		SearchData d = SearchCreator::create(buffer, size);
+		delete[] buffer;
+
+		printf("{ 0x%.08X, 0x%.08X, { {", d.size, d.byteSum);
+		for (int j = 0; j < 16; ++j) {
+			printf(" 0x%.2X", d.hash.digest[j]);
+			if (j != 15)
+				printf(",");
+			else
+				printf(" } } }\n");
+		}
+
+		return 0;
+	}
+
 	PAKFile out;
 	out.loadFile(argv[1], false);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list