1: #include <X/mit-copyright.h>
   2: /* Copyright 1986, Massachusetts Institute of Technology */
   3: 
   4: #ifndef lint
   5: static char *rcsid_xcons_c = "$Header: xcons.c,v 10.1 86/02/02 13:10:50 jg Exp $";
   6: #endif lint
   7: 
   8: #include <stdio.h>
   9: #include <fcntl.h>
  10: #include <sys/ioctl.h>
  11: #include <sys/errno.h>
  12: 
  13: extern int errno;
  14: 
  15: main(argc, argv)
  16:     int argc;
  17:     char **argv;
  18: {
  19:     char fromdev[30], todev[30];
  20:     int from, to, n;
  21:     char buf[2048];
  22: 
  23:     if (argc != 3)
  24:         exit(1);
  25:     strcpy(fromdev, "/dev/");
  26:     strcat(fromdev, argv[2]);
  27:     strcpy(todev, "/dev/");
  28:     strcat(todev, argv[1]);
  29:     if (argc != 3 || (from = open(fromdev, O_RDONLY, 0)) < 0)
  30:         exit(1);
  31:     while (1) {
  32:         if ((n = read(from, buf, sizeof(buf))) <= 0)
  33:             exit(1);
  34:         if (fcntl(from, F_SETFL, FNDELAY) < 0)
  35:             exit(1);
  36:         /* we only open the tty when we need to, because it won't
  37: 		 * be preserved across logins */
  38:         if ((to = open(todev, O_WRONLY, 0)) < 0)
  39:             exit(1);
  40:         while (n > 0) {
  41:             write(to, buf, n);
  42:             n = read(from, buf, n);
  43:         }
  44:         close(to);
  45:         if (errno != EWOULDBLOCK || fcntl(from, F_SETFL, 0) < 0)
  46:             exit(1);
  47:     }
  48: }

Defined functions

main defined in line 15; never used

Defined variables

rcsid_xcons_c defined in line 5; never used
Last modified: 1986-02-02
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 865
Valid CSS Valid XHTML 1.0 Strict