diff options
author | Johannes Schickel | 2009-11-01 22:27:10 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-11-01 22:27:10 +0000 |
commit | 8a7c5dbc6fdf54d1dce1c1d279ccbe3c2b7f2189 (patch) | |
tree | 03dea9d7f6104539cfe1ea0b37f0f2cdcb0a19b4 /tools | |
parent | 0470c25881a59815dcc2bd14312de1530c92e27b (diff) | |
download | scummvm-rg350-8a7c5dbc6fdf54d1dce1c1d279ccbe3c2b7f2189.tar.gz scummvm-rg350-8a7c5dbc6fdf54d1dce1c1d279ccbe3c2b7f2189.tar.bz2 scummvm-rg350-8a7c5dbc6fdf54d1dce1c1d279ccbe3c2b7f2189.zip |
Add command line parameter to automatically create a search table entry from a given file + offset/size pair.
svn-id: r45603
Diffstat (limited to 'tools')
-rw-r--r-- | tools/create_kyradat/create_kyradat.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/create_kyradat/create_kyradat.cpp b/tools/create_kyradat/create_kyradat.cpp index a739dda52e..5fbbe56eeb 100644 --- a/tools/create_kyradat/create_kyradat.cpp +++ b/tools/create_kyradat/create_kyradat.cpp @@ -478,6 +478,47 @@ int main(int argc, char *argv[]) { 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); |