diff options
author | Max Horn | 2006-02-16 18:00:22 +0000 |
---|---|---|
committer | Max Horn | 2006-02-16 18:00:22 +0000 |
commit | 200320c2376ed07941f7fad2abb05154f1c8eb38 (patch) | |
tree | 6335ebe237b93c351c5953947a7cee1554a8fa1b /tools/md5table.c | |
parent | 6e3686e4943c3797ea889a0d230f06481b4552f8 (diff) | |
download | scummvm-rg350-200320c2376ed07941f7fad2abb05154f1c8eb38.tar.gz scummvm-rg350-200320c2376ed07941f7fad2abb05154f1c8eb38.tar.bz2 scummvm-rg350-200320c2376ed07941f7fad2abb05154f1c8eb38.zip |
- Further extended the file format of tools/scumm-md5.txt: One can now specify
a variant ID, and the description field has been split into two parts.
- Updated the PHP output, removing duplicate information and hopefully
increasing the readability at the same time.
svn-id: r20729
Diffstat (limited to 'tools/md5table.c')
-rw-r--r-- | tools/md5table.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/tools/md5table.c b/tools/md5table.c index f01087bcdc..804156d179 100644 --- a/tools/md5table.c +++ b/tools/md5table.c @@ -60,6 +60,8 @@ typedef struct { const char *md5; const char *language; const char *platform; + const char *variant; + const char *extra; const char *desc; const char *comments; const char *infoSource; @@ -118,6 +120,7 @@ static const char *php_header = " This file was generated by the md5table tool on %s" " DO NOT EDIT MANUALLY!\n" " -->\n" + "<?php\n" "\n"; static const char *c_header = @@ -149,6 +152,8 @@ static void parseEntry(Entry *entry, char *line) { entry->md5 = strtok(line, "\t\n\r"); entry->language = strtok(NULL, "\t\n\r"); entry->platform = strtok(NULL, "\t\n\r"); + entry->variant = strtok(NULL, "\t\n\r"); + entry->extra = strtok(NULL, "\t\n\r"); entry->desc = strtok(NULL, "\t\n\r"); entry->infoSource = strtok(NULL, "\t\n\r"); } @@ -248,20 +253,30 @@ int main(int argc, char *argv[]) assert(section[0]); parseEntry(&entry, line+1); if (outputMode == kPHPOutput) { - fprintf(outFile, "\t\t<?php addEntry("); - fprintf(outFile, "\"%s\", ", entry.desc); + fprintf(outFile, "\taddEntry("); + + // Print the description string + fprintf(outFile, "\""); + if (entry.extra && strcmp(entry.extra, "-")) { + fprintf(outFile, "%s", entry.extra); + if (entry.desc && strcmp(entry.desc, "-")) + fprintf(outFile, " (%s)", entry.desc); + } + fprintf(outFile, "\", "); + fprintf(outFile, "\"%s\", ", entry.platform); fprintf(outFile, "\"%s\", ", entry.language); - fprintf(outFile, "\"%s\", ", entry.md5); - fprintf(outFile, "\"%s\"", gameid); + fprintf(outFile, "\"%s\"", entry.md5); if (entry.infoSource) fprintf(outFile, ", \"%s\"", entry.infoSource); - fprintf(outFile, "); ?>\n"); + fprintf(outFile, ");\n"); } else if (outputMode == kTXTOutput) { - fprintf(outFile, "\t%s\t%s\t%s\t%s\t%s\n", + fprintf(outFile, "\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", entry.md5, entry.language, entry.platform, + entry.variant, + entry.extra, entry.desc, entry.infoSource ? entry.infoSource : "" ); @@ -270,12 +285,20 @@ int main(int argc, char *argv[]) maxEntries *= 2; entriesBuffer = realloc(entriesBuffer, maxEntries * entrySize); } + if (0 == strcmp(entry.variant, "-")) + entry.variant = ""; + if (0 == strcmp(entry.extra, "-")) + entry.extra = ""; snprintf(entriesBuffer + numEntries * entrySize, entrySize, - "\t{ \"%s\", \"%s\", \"TODO\", \"%s\", Common::%s, Common::%s },\n", - entry.md5, gameid, entry.desc, mapStr(entry.language, langMap), mapStr(entry.platform, platformMap)); + "\t{ \"%s\", \"%s\", \"%s\", \"%s\", Common::%s, Common::%s },\n", + entry.md5, gameid, entry.variant, entry.extra, mapStr(entry.language, langMap), mapStr(entry.platform, platformMap)); numEntries++; } } else { + if (outputMode == kPHPOutput && gameid[0] != 0) { + // If there is an active section, close it now + fprintf(outFile, "endSection();\n"); + } // Read the gameid, followed by a tab for (i = 0; *line && *line != '\t'; ++i) gameid[i] = *line++; @@ -292,7 +315,7 @@ int main(int argc, char *argv[]) // If in PHP or TXT mode, we write the output immediately if (outputMode == kPHPOutput) { - fprintf(outFile, "\t<tr><td colspan='7'><strong>%s</strong></td></tr>\n", section); + fprintf(outFile, "beginSection(\"%s\", \"%s\");\n", section, gameid); } else if (outputMode == kTXTOutput) { fprintf(outFile, "%s\t%s\n", gameid, section); } @@ -303,6 +326,13 @@ int main(int argc, char *argv[]) if (err) error("Failed reading from input file, error %d", err); + if (outputMode == kPHPOutput) { + if (gameid[0] != 0) // If there is an active section, close it now + fprintf(outFile, "endSection();\n"); + + fprintf(outFile, "?>\n"); + } + if (outputMode == kCPPOutput) { /* Printf header */ fprintf(outFile, c_header, generationDate); |