home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / uucp / amigauucpsrc / lib / setstdin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  885 b   |  45 lines

  1.  
  2. /*
  3.  *  SETSTDIN.C
  4.  *
  5.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  6.  *
  7.  *  Sets stdin, stdout, and stderr to UUSER: handler
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include "config.h"
  12.  
  13. Prototype int SetStdin(int, char **);
  14.  
  15. int
  16. SetStdin(ac, av)
  17. int ac;
  18. char **av;
  19. {
  20.     short i;
  21.     short getty = 0;            /*  from getty    */
  22.     char *device = "serial.device";     /*  device name */
  23.     long unit = 0;            /*  unit no.    */
  24.     char buf[64];
  25.     FILE *f1, *f2, *f3;
  26.  
  27.     for (i = 1; i < ac; ++i) {
  28.     char *ptr = av[i];
  29.     if (*ptr != '-')
  30.         continue;
  31.     if (ptr[1] == 'D')
  32.         device = av[++i];
  33.     if (ptr[1] == 'U')
  34.         unit = atoi(av[++i]);
  35.     if (ptr[1] == 'G')
  36.         getty = 1;
  37.     }
  38.     sprintf(buf, "UUSER:%s/%d/R1000G%d", device, unit, getty);
  39.     f1 = freopen(buf, "r", stdin);
  40.     f2 = freopen(buf, "w+", stdout);
  41.     f3 = freopen(buf, "w+", stderr);
  42.     return(f1 && f2 && f3);
  43. }
  44.  
  45.