added some hooks for pdx
[unix-history] / usr / src / usr.bin / tip / cu.c
CommitLineData
c731dacc 1/* cu.c 4.3 81/12/16 */
24f09632
SL
2
3#include "tip.h"
4
5int cleanup();
6int timeout();
7
8/*
9 * Botch the interface to look like cu's
10 */
11cumain(argc, argv)
12 char *argv[];
13{
14 register int i;
c731dacc 15 static char sbuf[12];
24f09632 16
24f09632 17 if (argc < 2) {
c731dacc 18 printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
24f09632
SL
19 exit(8);
20 }
c731dacc 21 CU = DV = NOSTR;
24f09632
SL
22 for (; argc > 1; argv++, argc--) {
23 if (argv[1][0] != '-')
24 PN = argv[1];
3f48242d 25 else switch (argv[1][1]) {
24f09632
SL
26
27 case 't':
28 HW = 1, DU = -1;
29 --argc;
30 continue;
31
32 case 'a':
33 CU = argv[2]; ++argv; --argc;
34 break;
35
36 case 's':
37 if (speed(atoi(argv[2])) == 0) {
c731dacc
BS
38 fprintf(stderr, "cu: unsupported speed %s\n",
39 argv[2]);
24f09632
SL
40 exit(3);
41 }
42 BR = atoi(argv[2]); ++argv; --argc;
43 break;
44
45 case 'l':
46 DV = argv[2]; ++argv; --argc;
47 break;
48
49 case '0': case '1': case '2': case '3': case '4':
50 case '5': case '6': case '7': case '8': case '9':
c731dacc
BS
51 if (CU)
52 CU[strlen(CU)-1] = argv[1][1];
53 if (DV)
54 DV[strlen(DV)-1] = argv[1][1];
24f09632
SL
55 break;
56
57 default:
58 printf("Bad flag %s", argv[1]);
59 break;
60 }
61 }
c731dacc
BS
62 signal(SIGINT, cleanup);
63 signal(SIGQUIT, cleanup);
64 signal(SIGHUP, cleanup);
65 signal(SIGTERM, cleanup);
66
24f09632
SL
67 /*
68 * The "cu" host name is used to define the
69 * attributes of the generic dialer.
70 */
c731dacc 71 if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) {
24f09632
SL
72 printf("all ports busy\n");
73 exit(3);
74 }
75 if (i == -1) {
76 printf("link down\n");
77 delock(uucplock);
78 exit(3);
79 }
c731dacc
BS
80 setbuf(stdout, NULL);
81 loginit();
82 setuid(getuid());
83 setgid(getgid());
84 vinit();
85 boolean(value(VERBOSE)) = 0;
24f09632
SL
86 if (HW)
87 ttysetup(speed(BR));
88 if (connect()) {
89 printf("Connect failed\n");
90 delock(uucplock);
91 exit(1);
92 }
93 if (!HW)
94 ttysetup(speed(BR));
95}