1*3897Ssam /* dn11.c 4.3 81/06/16 */ 2*3897Ssam 3*3897Ssam #if DN11 43691Sroot /* 53691Sroot * Routines for dialing up on DN-11 63691Sroot */ 73691Sroot #include "tip.h" 8*3897Ssam #include <setjmp.h> 9*3897Ssam #include <errno.h> 103691Sroot 113691Sroot int dn_abort(); 123691Sroot 13*3897Ssam int alarmtr(); 14*3897Ssam 15*3897Ssam static jmp_buf jmpbuf; 16*3897Ssam 173691Sroot dn_dialer(num, acu) 183691Sroot char *num, *acu; 193691Sroot { 203691Sroot extern errno; 21*3897Ssam char *p, *q, phone[40]; 22*3897Ssam int child = -1, dn, lt, nw, connected = 1; 23*3897Ssam register int timelim; 243691Sroot 253691Sroot if ((dn = open(acu, 1)) < 0) { 26*3897Ssam if (errno == ENXIO) 273691Sroot printf("line busy\n"); 28*3897Ssam else 29*3897Ssam printf("acu open error\n"); 303691Sroot return(0); 313691Sroot } 32*3897Ssam if (setjmp(jmpbuf)) { 33*3897Ssam printf("dn11 write error..."); 34*3897Ssam kill(child, SIGKILL); 35*3897Ssam close(dn); 363691Sroot return(0); 373691Sroot } 38*3897Ssam signal(SIGALRM, alarmtr); 39*3897Ssam timelim = 5 * strlen(num); 40*3897Ssam alarm(timelim < 30 ? 30 : timelim); 41*3897Ssam if ((child = fork()) == 0) { 423691Sroot signal(SIGALRM, SIG_IGN); 43*3897Ssam sleep(2); 44*3897Ssam nw = write(dn, num, lt = strlen(num)); 45*3897Ssam if (nw != lt) { 46*3897Ssam printf("dn11 write failed..."); 47*3897Ssam exit(1); 48*3897Ssam } 49*3897Ssam exit(0); 503691Sroot } 51*3897Ssam /* open line - will return on carrier */ 523691Sroot FD = open(DV, 2); 533691Sroot if (FD < 0) { 54*3897Ssam if (errno == EIO) 55*3897Ssam printf("lost carrier..."); 56*3897Ssam else 57*3897Ssam printf("dialup line open failed..."); 58*3897Ssam alarm(0); 59*3897Ssam kill(child, SIGKILL); 60*3897Ssam close(dn); 61*3897Ssam return(0); 623691Sroot } 63*3897Ssam ioctl(dn, TIOCHPCL, 0); 64*3897Ssam signal(SIGALRM, SIG_DFL); 65*3897Ssam while ((nw = wait(<)) != child && nw != -1) 663691Sroot ; 673691Sroot alarm(0); 68*3897Ssam fflush(stdout); 69*3897Ssam if (lt != 0) { 70*3897Ssam close(FD); 71*3897Ssam close(dn); 72*3897Ssam return(0); 73*3897Ssam } 74*3897Ssam return(1); 753691Sroot } 763691Sroot 77*3897Ssam alarmtr() 78*3897Ssam { 79*3897Ssam alarm(0); 80*3897Ssam signal(SIGINT, SIG_IGN); 81*3897Ssam signal(SIGQUIT, SIG_IGN); 82*3897Ssam longjmp(jmpbuf, 1); 83*3897Ssam } 843691Sroot 85*3897Ssam /* 86*3897Ssam * Insurance, for some reason we don't seem to be 87*3897Ssam * hanging up... 88*3897Ssam */ 89*3897Ssam dn_disconnect() 90*3897Ssam { 91*3897Ssam #ifdef VMUNIX 92*3897Ssam if (FD > 0) 93*3897Ssam ioctl(FD, TIOCCDTR, 0); 943691Sroot #endif 95*3897Ssam close(FD); 96*3897Ssam } 97*3897Ssam 98*3897Ssam dn_abort() 99*3897Ssam { 100*3897Ssam #ifdef VMUNIX 101*3897Ssam if (FD > 0) 102*3897Ssam ioctl(FD, TIOCCDTR, 0); 103*3897Ssam #endif 104*3897Ssam close(FD); 105*3897Ssam } 106*3897Ssam #endif 107