1 /* cu.c 4.2 81/11/29 */ 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 16 signal(SIGINT, cleanup); 17 signal(SIGQUIT, cleanup); 18 signal(SIGHUP, cleanup); 19 signal(SIGTERM, cleanup); 20 setbuf(stdout, NULL); 21 loginit(); 22 setuid(getuid()); 23 setgid(getgid()); 24 vinit(); 25 boolean(value(VERBOSE)) = 0; 26 if (argc < 2) { 27 printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line]\n"); 28 exit(8); 29 } 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 printf("cu: unsupported speed %s\n", argv[2]); 47 exit(3); 48 } 49 BR = atoi(argv[2]); ++argv; --argc; 50 break; 51 52 case 'l': 53 DV = argv[2]; ++argv; --argc; 54 break; 55 56 case '0': case '1': case '2': case '3': case '4': 57 case '5': case '6': case '7': case '8': case '9': 58 CU[strlen(CU)-1] = argv[1][1]; 59 break; 60 61 default: 62 printf("Bad flag %s", argv[1]); 63 break; 64 } 65 } 66 /* 67 * The "cu" host name is used to define the 68 * attributes of the generic dialer. 69 */ 70 if ((i = hunt("cu")) == 0) { 71 printf("all ports busy\n"); 72 exit(3); 73 } 74 if (i == -1) { 75 printf("link down\n"); 76 delock(uucplock); 77 exit(3); 78 } 79 if (HW) 80 ttysetup(speed(BR)); 81 if (connect()) { 82 printf("Connect failed\n"); 83 delock(uucplock); 84 exit(1); 85 } 86 if (!HW) 87 ttysetup(speed(BR)); 88 } 89