/****************************************************************/
/*								*/
/*	NEWIO to POSTSCRIPT conversion filter			*/
/*								*/
/*	by Tom Heynemann, May 1992				*/
/*	   email: tom@nice.usergroup.ethz.ch			*/
/*								*/
/*	look at .doc file for correct NewIO settings		*/
/*								*/
/****************************************************************/

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

int main(int argc, char *argv[])
{
	FILE	*fp_in = NULL, *fp_out = NULL;
	int	x, y;
	char	str[8], tmp1[32], tmp2[32];

	if (argc != 3) {
		printf("Usage: %s <infile> <outfile>\n", argv[0]);
		return -1;
	} else {
		if (NULL == (fp_in = fopen(argv[1],"r"))) {
			printf("Could not open input file %s !\n",
				argv[1]);
			return -2;
		} else {
			if (NULL == (fp_out = fopen(argv[2],"w"))) {
				printf("Could not open output file %s !\n",
					argv[2]);
				return -2;
			}
		}
	}
	fprintf(fp_out,"%%! PS-Adobe\n.072 .072 scale\n600 600 translate\
		\nnewpath\n8 setlinewidth\n");
	while (!feof(fp_in)) {
		fscanf(fp_in," %s %d %d", str, &x, &y);
		strcpy(tmp2,tmp1);
		sprintf(tmp1,"%1d %1d %s\n", x, y, str);
		if ( strcmp(tmp1,tmp2) )
			fprintf(fp_out,tmp1);
	}
	fprintf(fp_out,"stroke\nshowpage\n");
	fclose(fp_in);
	fclose(fp_out);
	return 1;
}
