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