1 /* cu.c 4.3 81/12/16 */ 2 3 #include "tip.h" 4 5 int cleanup(); 6 int timeout(); 7 8 /* 9 * Botch the interface to look like cu's 10 */ 11 cumain(argc, argv) 12 char *argv[]; 13 { 14 register int i; 15 static char sbuf[12]; 16 17 if (argc < 2) { 18 printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n"); 19 exit(8); 20 } 21 CU = DV = NOSTR; 22 for (; argc > 1; argv++, argc--) { 23 if (argv[1][0] != '-') 24 PN = argv[1]; 25 else switch (argv[1][1]) { 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) { 38 fprintf(stderr, "cu: unsupported speed %s\n", 39 argv[2]); 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': 51 if (CU) 52 CU[strlen(CU)-1] = argv[1][1]; 53 if (DV) 54 DV[strlen(DV)-1] = argv[1][1]; 55 break; 56 57 default: 58 printf("Bad flag %s", argv[1]); 59 break; 60 } 61 } 62 signal(SIGINT, cleanup); 63 signal(SIGQUIT, cleanup); 64 signal(SIGHUP, cleanup); 65 signal(SIGTERM, cleanup); 66 67 /* 68 * The "cu" host name is used to define the 69 * attributes of the generic dialer. 70 */ 71 if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) { 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 } 80 setbuf(stdout, NULL); 81 loginit(); 82 setuid(getuid()); 83 setgid(getgid()); 84 vinit(); 85 boolean(value(VERBOSE)) = 0; 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 } 96