#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <math.h>
#include <dos.h>
#define true (!false)
#define false 0
FILE *inf;
char put_out(char c);
int status(void);

main(int argc, char **argv)
{
	char infile[80];
	strcpy(infile,"OUT.BIT");
	if (argc==2) strcpy(infile,argv[1]);
	printf("Printing {%s} \n",infile);
#ifdef ultrix
	inf = fopen(infile,"r");
#else
	inf = fopen(infile,"rb");
#endif
	if (inf==NULL) {
		printf("Unable to open input file \n");
		exit(1);
	}
	send_file();
	fclose(inf);
}
send_file(void)
{
	char c,lc;
	int l=0;
	do {
		c = fgetc(inf);
		if (lc=='*' && c=='r') printf("line %d \x0d",++l);
		put_out(c);
		lc = c;
	} while (!feof(inf));
}
status(void)
{
	union REGS reg;

	reg.h.ah = 2;
	reg.x.dx = 0;
	int86(0x17, &reg, &reg);
	return (reg.h.ah & 0x80);
}
char put_out(char c)
{
	union REGS reg;

	while (!status());
	reg.h.ah = 0;
	reg.h.al = c;
	reg.x.dx = 0;
	int86(0x17,&reg,&reg);
	return (reg.h.ah);
}


