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