/*
 * Jaguar BIOS Test
 *
 * Copyright 1995 ATARI Corp.
 */

#define CON	2
#define AUX	1

char linebuf[128];
char *lp;

	void
main()
{
	
	long x;
	char c;
	int input;

	Bconout(2, '>');
	lp = linebuf;


	/* empty buffer */

	while (Bconstat(CON) == -1) 
		c = Bconin(CON) & 0xff;

	for (; ;) {
		input = 0;
		do {
			if (Bconstat(CON) == -1) 
				input += 2;
			if (Bconstat(AUX) == -1)
				input += 1;
		} while (!input);

		if (input & 1) {
			c = Bconin(AUX);
			if (c != 0xff)
			Bconout(CON, c & 0xff);
		}
		if (input & 2) {

			c = Bconin(CON) & 0xff;
			switch (c) {

			case 0x0d:		/* carriage return */
				*lp++ = c;
				*lp++ = 0x0a;
				*lp = '\0';
				send2modem(linebuf);
				lp = linebuf;
			default:
				*lp++ = c;
				Bconout(2, c);
				break;
			}
		}
	}
}

	int
send2modem(line) 
	char *line;
{
	char *s = line;

	for (; *s; s++)
		Bconout(AUX, *s);

	return 0;
}
