/*----------------------------------------------------------------------*\
 | Simple utility to indicate version numbers of metadata tools.		|
 |																		|
 | Peter N. Schweitzer (U.S. Geological Survey, Reston, VA 20192)		|
\*----------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "revision.h"
#include "stricmp.h"

enum format {
	TABLE,
	LIST,
	PERL,
	PLAIN,
	NONE
	};

int main (int argc, char *argv[]) {
	enum format format = NONE;
	if (argc > 1) {
		if (stricmp (argv[1],"table") == 0) format = TABLE;
		if (stricmp (argv[1],"list" ) == 0) format = LIST;
		if (stricmp (argv[1],"perl" ) == 0) format = PERL;
		if (stricmp (argv[1],"plain") == 0) format = PLAIN;
		}
	else format = PLAIN;
	switch (format) {
		case TABLE:
			printf ("<tr><td>mp</td><td>%s</td></tr>\n",revision.mp);
			printf ("<tr><td>cns</td><td>%s</td></tr>\n",revision.cns);
			printf ("<tr><td>Xtme</td><td>%s</td></tr>\n",revision.xtme);
			printf ("<tr><td>Tkme</td><td>%s</td></tr>\n",revision.tkme);
			printf ("<tr><td>mq</td><td>%s</td></tr>\n",revision.mq);
			printf ("<tr><td>err2html</td><td>%s</td></tr>\n",revision.err2html);
			break;
		case LIST:
			printf ("<dt>mp\n");
			printf ("<dd>%s\n",revision.mp);
			printf ("<dt>cns\n");
			printf ("<dd>%s\n",revision.cns);
			printf ("<dt>Xtme\n");
			printf ("<dd>%s\n",revision.xtme);
			printf ("<dt>Tkme\n");
			printf ("<dd>%s\n",revision.tkme);
			printf ("<dt>mq\n");
			printf ("<dd>%s\n",revision.mq);
			printf ("<dt>err2html\n");
			printf ("<dd>%s\n",revision.err2html);
			break;
		case PERL:
			printf ("#!/usr/bin/perl\n");
			printf ("if (scalar(@ARGV) > 0) {\n");
			/* printf ("\tprint \"Content-type: text/plain\\n\\n\";\n"); */
			printf ("\tif (@ARGV[0] =~ /^mp$/i  ) { print \"%s\" };\n",revision.mp);
			printf ("\tif (@ARGV[0] =~ /^mq$/i  ) { print \"%s\" };\n",revision.mq);
			printf ("\tif (@ARGV[0] =~ /^cns$/i ) { print \"%s\" };\n",revision.cns);
			printf ("\tif (@ARGV[0] =~ /^xtme$/i) { print \"%s\" };\n",revision.xtme);
			printf ("\tif (@ARGV[0] =~ /^tkme$/i) { print \"%s\" };\n",revision.tkme);
			printf ("\tif (@ARGV[0] =~ /^err2html$/i) { print \"%s\" };\n",revision.err2html);
			printf ("\t}\n");
			printf ("else {\n");
			/* printf ("\tprint \"Content-type: text/plain\\n\\n\";\n"); */
			printf ("\tprint \"mp:       %s\\n\";\n",revision.mp);
			printf ("\tprint \"cns:      %s\\n\";\n",revision.cns);
			printf ("\tprint \"Xtme:     %s\\n\";\n",revision.xtme);
			printf ("\tprint \"Tkme:     %s\\n\";\n",revision.tkme);
			printf ("\tprint \"mq:       %s\\n\";\n",revision.mq);
			printf ("\tprint \"err2html: %s\\n\";\n",revision.err2html);
			printf ("\t}\n");
			break;
		case PLAIN:
			printf ("mp:       %s\n",revision.mp);
			printf ("cns:      %s\n",revision.cns);
			printf ("Xtme:     %s\n",revision.xtme);
			printf ("Tkme:     %s\n",revision.tkme);
			printf ("mq:       %s\n",revision.mq);
			printf ("err2html: %s\n",revision.err2html);
			break;
		default:
			if (argc > 1) {
				if (stricmp (argv[1],"mp"      ) == 0) printf ("%s",revision.mp);
				if (stricmp (argv[1],"mq"      ) == 0) printf ("%s",revision.mq);
				if (stricmp (argv[1],"cns"     ) == 0) printf ("%s",revision.cns);
				if (stricmp (argv[1],"xtme"    ) == 0) printf ("%s",revision.xtme);
				if (stricmp (argv[1],"tkme"    ) == 0) printf ("%s",revision.tkme);
				if (stricmp (argv[1],"err2html") == 0) printf ("%s",revision.err2html);
				}
			break;
		}
	return (0);
	}

/*----------------------------------------------------------------------*\
\*----------------------------------------------------------------------*/