
/*
 *  READ1006.C
 *
 *  READ1006 name
 *
 *  Open file with modes 1006 and read from it until EOF.  Used	to show
 *  how	reading	from the MASTER	side of	a PIPE with the	SLAVE side connected
 *  to a NEWCLI	works.
 */

extern long Open(), Read();

#define	NULL 0L

main(ac, av)
char *av[];
{
    char buf[256];
    long fh;
    long n;

    disablebreak();
    if (av[1] == NULL) {
	puts ("filename required... usually PIPE:a/tq");
	puts ("Warning: you should have another CLI around");
	puts ("in case you get caught so you can recover.");
	exit(1);
    }

    fh = Open(av[1], 1006);
    if (fh == NULL) {
	puts ("Unable to open file or SLAVE part of pipe not active");
	exit(1);
    }
    while ((n =	Read(fh, buf, 256)) > 0)
	write(1, buf, n);
    Close(fh);
    puts("Done");
}

