#ifndef lint
static char *RCSid = "$Header: wai.c,v 1.6 90/03/19 11:00:17 mr-frog Exp $";
#endif /* not lint */

/*
 * wai.c
 *
 * continuously wait for telegrams; print them out when
 * you get them.
 *
 */

#include "misc.h"
#include "nat.h"
#include "tel.h"
#include "file.h"
#include "io.h"

#include <fcntl.h>

wai()
{
	extern	char *argp[];
	extern	int aborted;
	extern	iop_t iop, playerio;
	struct	natstr *np;
	char	buf[128];

	np = getnatp(cnum);
	io_flush();
	while (np->nat_tgms == 0) {
		if (io_select(0) <= 0)
			return RET_FAIL;
		if (aborted || io_eof(playerio) || io_eof(iop) ||
		    io_read(playerio, buf, sizeof(buf)) > 0) {
			return RET_OK;
		}
	}
	argp[0] = "read";
	return rea();
}
