// TSMorph - Amiga Morphing program
// Copyright (C) © 1993  Topicsave Limited

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

// mpaddock@cix.compulink.co.uk

// Generate the message header file

#include <stdio.h>
#include <string.h>
#include <proto/dos.h>
#include "messages.h"

/* Version string for CLI version */
char *Version = "$VER: GenMsg 3.2 (12.3.95)";

int main(void) {
	BPTR in,out;
	char buffer[513];
	char *res,*f;
	int xres=10;
	int i=0;
	res = "...Failed!\n";
	printf(&(Version[6]));
	if (in = Open("TSMorph-Messages",MODE_OLDFILE)) {
		if (out = Open("tMessages.h",MODE_NEWFILE)) {
			FPuts(out,"// This file generated by");
			FPuts(out,&(Version[6]));
			FPuts(out,"\n");
			FPuts(out,"#include <exec/types.h>\n");
			FPuts(out,"#include \"Messages.h\"\n");
			FPuts(out,"UBYTE *message[MSG_COUNT] = {\n");
			while (FGets(in,buffer,511) && (i < MSG_COUNT)) {
				FPuts(out,"\t\"");
				f = &(buffer[4]);
				if (strlen(f)) {
					f[strlen(f)-1]=0;
				}
				FPuts(out,f);
				FPuts(out,"\",\n");
				++i;
			}
			FPuts(out,"};\n");
			res = "...Worked ok!\n";
			xres = 0;
			Close(out);
		}
		Close(in);
	}
	printf(res);
	return xres;
}
