[Scummvm-cvs-logs] CVS: tools md5table.c,1.1,1.2

Max Horn fingolfin at users.sourceforge.net
Tue Dec 30 08:43:03 CET 2003


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv1888

Modified Files:
	md5table.c 
Log Message:
added command line options to choose between C++ and PHP output; added simple header to generated files

Index: md5table.c
===================================================================
RCS file: /cvsroot/scummvm/tools/md5table.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- md5table.c	30 Dec 2003 16:33:45 -0000	1.1
+++ md5table.c	30 Dec 2003 16:42:52 -0000	1.2
@@ -77,6 +77,25 @@
 	{ 0,		"UNK_LANG" }
 };
 
+static const char *legal_header =
+	"/* This file was generated by the md5table tool. DO NOT EDIT!\n"
+	" */\n"
+	"\n";
+
+static const char *c_header =
+	"struct MD5Table {\n"
+	"	const char *md5;\n"
+	"	const char *target;\n"
+	"	Common::Language language;\n"
+	"	Common::Platform platform;\n"
+	"};\n"
+	"\n"
+	"static const MD5Table md5table[] = {\n";
+
+static const char *c_footer =
+	"	{ 0, 0, 0, 0 }\n"
+	"};\n";
+
 static void parseEntry(Entry *entry, char *line) {
 	assert(entry);
 	assert(line);
@@ -112,19 +131,14 @@
 	return map->value;
 }
 
-static const char *c_header =
-	"struct MD5Table {\n"
-	"	const char *md5;\n"
-	"	const char *target;\n"
-	"	Common::Language language;\n"
-	"	Common::Platform platform;\n"
-	"};\n"
-	"\n"
-	"static const MD5Table md5table[] = {\n";
-
-static const char *c_footer =
-	"	{ 0, 0, 0, 0 }\n"
-	"};\n";
+void showhelp(const char *exename)
+{
+	printf("\nUsage: %s <params>\n", exename);
+	printf("\nParams:\n");
+	printf(" --c++   output C++ code for inclusion in ScummVM (default)\n");
+	printf(" --php   output PHP code for the web site\n");
+	exit(2);
+}
 
 int main(int argc, char *argv[])
 {
@@ -140,9 +154,20 @@
 	int numEntries = 0, maxEntries = 1;
 	char *entriesBuffer = malloc(maxEntries * entrySize);
 
-	const bool phpOutput = false;
+	bool phpOutput = false;
+
+	if (argc != 2)
+		showhelp(argv[0]);
+	if (strcmp(argv[1], "--c++") == 0) {
+		phpOutput = false;
+	} else if (strcmp(argv[1], "--php") == 0) {
+		phpOutput = true;
+	} else {
+		showhelp(argv[0]);
+	}
+
+	fprintf(outFile, legal_header);
 
-	
 	while ((line = fgets(buffer, sizeof(buffer), inFile))) {
 		/* Parse line */
 		if (line[0] == '#' || isEmptyLine(line))





More information about the Scummvm-git-logs mailing list