/***************
*
* g:\exe\txf\src\txfrmz.c
*/
#include "txf.h"

void removeeof()
{
	int chr = NUL;
	char *tmpinname, *tmpoutname;
	FILE *tmpin, *tmpout;

	if (viewmode > 1) {
		fprintf(stderr, "TXF Remove ctrl-Z module. Ver1.20\n");
	}

	tmpinname = ((tmpinfile == -1) ? inputfile : tfile[tmpinfile]);
	tmpoutname = tfile[((tmpinfile > 0) ? 0 : 1)];

	if (*tmpinname != NUL) {
		tmpin = fopen(tmpinname, "rb");
	}
	else {
		errexit("Cannot open inputfile.");
	}
	tmpout = fopen(tmpoutname, "wb");
	if (viewmode > 2) {
		fprintf(stderr, "Info:readfile=%s,(%d)/writefile=%s,(%d)\n",
			tmpinname, tmpin, tmpoutname, tmpout);
	}
	if ((tmpin == NULL) || (tmpout == NULL)) {
		errexit("cannot open TMP/input file(remove ctrl-Z)\n");
	}

	while (chr != EOF) {
		chr = getc(tmpin);
		if ((chr != 0x1a) && (chr != EOF)) {
			putc((char)chr, tmpout);
		}
	}

	tmpinfile = ((tmpinfile > 0) ? 0 : 1);
	tmpinname = tfile[tmpinfile];
	tmpoutname = tfile[1 - tmpinfile];

	fclose(tmpin);
	fclose(tmpout);

}
