1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)cu.c	5.2 (Berkeley) 1/13/86";
   9: #endif not lint
  10: 
  11: #include "tip.h"
  12: 
  13: int cleanup();
  14: int timeout();
  15: 
  16: /*
  17:  * Botch the interface to look like cu's
  18:  */
  19: cumain(argc, argv)
  20:     char *argv[];
  21: {
  22:     register int i;
  23:     static char sbuf[12];
  24: 
  25:     if (argc < 2) {
  26:         printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
  27:         exit(8);
  28:     }
  29:     CU = DV = NOSTR;
  30:     for (; argc > 1; argv++, argc--) {
  31:         if (argv[1][0] != '-')
  32:             PN = argv[1];
  33:         else switch (argv[1][1]) {
  34: 
  35:         case 't':
  36:             HW = 1, DU = -1;
  37:             --argc;
  38:             continue;
  39: 
  40:         case 'a':
  41:             CU = argv[2]; ++argv; --argc;
  42:             break;
  43: 
  44:         case 's':
  45:             if (speed(atoi(argv[2])) == 0) {
  46:                 fprintf(stderr, "cu: unsupported speed %s\n",
  47:                     argv[2]);
  48:                 exit(3);
  49:             }
  50:             BR = atoi(argv[2]); ++argv; --argc;
  51:             break;
  52: 
  53:         case 'l':
  54:             DV = argv[2]; ++argv; --argc;
  55:             break;
  56: 
  57:         case '0': case '1': case '2': case '3': case '4':
  58:         case '5': case '6': case '7': case '8': case '9':
  59:             if (CU)
  60:                 CU[strlen(CU)-1] = argv[1][1];
  61:             if (DV)
  62:                 DV[strlen(DV)-1] = argv[1][1];
  63:             break;
  64: 
  65:         default:
  66:             printf("Bad flag %s", argv[1]);
  67:             break;
  68:         }
  69:     }
  70:     signal(SIGINT, cleanup);
  71:     signal(SIGQUIT, cleanup);
  72:     signal(SIGHUP, cleanup);
  73:     signal(SIGTERM, cleanup);
  74: 
  75:     /*
  76: 	 * The "cu" host name is used to define the
  77: 	 * attributes of the generic dialer.
  78: 	 */
  79:     if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) {
  80:         printf("all ports busy\n");
  81:         exit(3);
  82:     }
  83:     if (i == -1) {
  84:         printf("link down\n");
  85:         delock(uucplock);
  86:         exit(3);
  87:     }
  88:     setbuf(stdout, NULL);
  89:     loginit();
  90:     gid = getgid();
  91:     egid = getegid();
  92:     uid = getuid();
  93:     euid = geteuid();
  94:     setregid(egid, gid);
  95:     setreuid(euid, uid);
  96:     vinit();
  97:     setparity("none");
  98:     boolean(value(VERBOSE)) = 0;
  99:     if (HW)
 100:         ttysetup(speed(BR));
 101:     if (connect()) {
 102:         printf("Connect failed\n");
 103:         setreuid(uid, euid);
 104:         setregid(gid, egid);
 105:         delock(uucplock);
 106:         exit(1);
 107:     }
 108:     if (!HW)
 109:         ttysetup(speed(BR));
 110: }

Defined functions

cumain defined in line 19; used 1 times

Defined variables

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