
/*
 *  SETSTDIN.C
 *
 *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
 *
 *  Sets stdin, stdout, and stderr to UUSER: handler
 */

#include <stdio.h>

SetStdin(ac, av)
char *av[];
{
    short i;
    short getty = 0;			/*  from getty	*/
    char *device = "serial.device";     /*  device name */
    long unit = 0;			/*  unit no.	*/
    char buf[64];
    FILE *f1, *f2, *f3;

    for (i = 1; i < ac; ++i) {
	char *ptr = av[i];
	if (*ptr != '-')
	    continue;
	if (ptr[1] == 'D')
	    device = av[++i];
	if (ptr[1] == 'U')
	    unit = atoi(av[++i]);
	if (ptr[1] == 'G')
	    getty = 1;
    }
    sprintf(buf, "UUSER:%s/%d/R1000G%d", device, unit, getty);
    f1 = freopen(buf, "r", stdin);
    f2 = freopen(buf, "w+", stdout);
    f3 = freopen(buf, "w+", stderr);
    return(f1 && f2 && f3);
}

