1*4219Ssam /* dn11.c 4.8 81/08/24 */ 23897Ssam 33897Ssam #if DN11 43691Sroot /* 53691Sroot * Routines for dialing up on DN-11 63691Sroot */ 73691Sroot #include "tip.h" 83897Ssam #include <setjmp.h> 93897Ssam #include <errno.h> 103691Sroot 113691Sroot int dn_abort(); 123691Sroot 133897Ssam int alarmtr(); 143897Ssam 153897Ssam static jmp_buf jmpbuf; 163909Ssam static int child = -1, dn; 173897Ssam 183691Sroot dn_dialer(num, acu) 193691Sroot char *num, *acu; 203691Sroot { 213691Sroot extern errno; 223897Ssam char *p, *q, phone[40]; 233909Ssam int lt, nw, connected = 1; 243897Ssam register int timelim; 253691Sroot 263901Ssam if (boolean(value(VERBOSE))) 273901Ssam printf("\nstarting call..."); 283691Sroot if ((dn = open(acu, 1)) < 0) { 294003Ssam if (errno == EBUSY) 303901Ssam printf("line busy..."); 313897Ssam else 323901Ssam printf("acu open error..."); 333691Sroot return(0); 343691Sroot } 353897Ssam if (setjmp(jmpbuf)) { 363897Ssam kill(child, SIGKILL); 373897Ssam close(dn); 383691Sroot return(0); 393691Sroot } 403897Ssam signal(SIGALRM, alarmtr); 413897Ssam timelim = 5 * strlen(num); 423897Ssam alarm(timelim < 30 ? 30 : timelim); 433897Ssam if ((child = fork()) == 0) { 443901Ssam /* 453901Ssam * ignore this stuff for aborts 463901Ssam */ 473691Sroot signal(SIGALRM, SIG_IGN); 483901Ssam signal(SIGINT, SIG_IGN); 493901Ssam signal(SIGQUIT, SIG_IGN); 503897Ssam sleep(2); 513897Ssam nw = write(dn, num, lt = strlen(num)); 524003Ssam exit(nw != lt); 533691Sroot } 543901Ssam /* 553901Ssam * open line - will return on carrier 563901Ssam */ 574003Ssam if ((FD = open(DV, 2)) < 0) { 583897Ssam if (errno == EIO) 593897Ssam printf("lost carrier..."); 603897Ssam else 613897Ssam printf("dialup line open failed..."); 623897Ssam alarm(0); 633897Ssam kill(child, SIGKILL); 643897Ssam close(dn); 653897Ssam return(0); 663691Sroot } 673897Ssam ioctl(dn, TIOCHPCL, 0); 683897Ssam signal(SIGALRM, SIG_DFL); 693897Ssam while ((nw = wait(<)) != child && nw != -1) 703691Sroot ; 713691Sroot alarm(0); 723897Ssam fflush(stdout); 73*4219Ssam close(dn); 743897Ssam if (lt != 0) { 753897Ssam close(FD); 763897Ssam return(0); 773897Ssam } 783897Ssam return(1); 793691Sroot } 803691Sroot 813897Ssam alarmtr() 823897Ssam { 833897Ssam alarm(0); 843897Ssam longjmp(jmpbuf, 1); 853897Ssam } 863691Sroot 873897Ssam /* 883897Ssam * Insurance, for some reason we don't seem to be 893897Ssam * hanging up... 903897Ssam */ 913897Ssam dn_disconnect() 923897Ssam { 933901Ssam sleep(2); 943897Ssam #ifdef VMUNIX 953897Ssam if (FD > 0) 963897Ssam ioctl(FD, TIOCCDTR, 0); 973691Sroot #endif 983897Ssam close(FD); 993897Ssam } 1003897Ssam 1013897Ssam dn_abort() 1023897Ssam { 1033901Ssam sleep(2); 1043909Ssam if (child > 0) 1053909Ssam kill(child, SIGKILL); 1063909Ssam if (dn > 0) 1073909Ssam close(dn); 1083897Ssam #ifdef VMUNIX 1093897Ssam if (FD > 0) 1103897Ssam ioctl(FD, TIOCCDTR, 0); 1113897Ssam #endif 1123897Ssam close(FD); 1133897Ssam } 1143897Ssam #endif 115