1*3901Ssam /* dn11.c 4.4 81/06/16 */ 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; 163897Ssam 173691Sroot dn_dialer(num, acu) 183691Sroot char *num, *acu; 193691Sroot { 203691Sroot extern errno; 213897Ssam char *p, *q, phone[40]; 223897Ssam int child = -1, dn, lt, nw, connected = 1; 233897Ssam register int timelim; 243691Sroot 25*3901Ssam if (boolean(value(VERBOSE))) 26*3901Ssam printf("\nstarting call..."); 273691Sroot if ((dn = open(acu, 1)) < 0) { 283897Ssam if (errno == ENXIO) 29*3901Ssam printf("line busy..."); 303897Ssam else 31*3901Ssam printf("acu open error..."); 323691Sroot return(0); 333691Sroot } 343897Ssam if (setjmp(jmpbuf)) { 353897Ssam kill(child, SIGKILL); 363897Ssam close(dn); 373691Sroot return(0); 383691Sroot } 393897Ssam signal(SIGALRM, alarmtr); 403897Ssam timelim = 5 * strlen(num); 413897Ssam alarm(timelim < 30 ? 30 : timelim); 423897Ssam if ((child = fork()) == 0) { 43*3901Ssam /* 44*3901Ssam * ignore this stuff for aborts 45*3901Ssam */ 463691Sroot signal(SIGALRM, SIG_IGN); 47*3901Ssam signal(SIGINT, SIG_IGN); 48*3901Ssam signal(SIGQUIT, SIG_IGN); 493897Ssam sleep(2); 503897Ssam nw = write(dn, num, lt = strlen(num)); 513897Ssam if (nw != lt) { 523897Ssam printf("dn11 write failed..."); 533897Ssam exit(1); 543897Ssam } 553897Ssam exit(0); 563691Sroot } 57*3901Ssam /* 58*3901Ssam * open line - will return on carrier 59*3901Ssam */ 603691Sroot FD = open(DV, 2); 613691Sroot if (FD < 0) { 623897Ssam if (errno == EIO) 633897Ssam printf("lost carrier..."); 643897Ssam else 653897Ssam printf("dialup line open failed..."); 663897Ssam alarm(0); 673897Ssam kill(child, SIGKILL); 683897Ssam close(dn); 693897Ssam return(0); 703691Sroot } 713897Ssam ioctl(dn, TIOCHPCL, 0); 723897Ssam signal(SIGALRM, SIG_DFL); 733897Ssam while ((nw = wait(<)) != child && nw != -1) 743691Sroot ; 753691Sroot alarm(0); 763897Ssam fflush(stdout); 773897Ssam if (lt != 0) { 783897Ssam close(FD); 793897Ssam close(dn); 803897Ssam return(0); 813897Ssam } 823897Ssam return(1); 833691Sroot } 843691Sroot 853897Ssam alarmtr() 863897Ssam { 873897Ssam alarm(0); 883897Ssam signal(SIGINT, SIG_IGN); 893897Ssam signal(SIGQUIT, SIG_IGN); 903897Ssam longjmp(jmpbuf, 1); 913897Ssam } 923691Sroot 933897Ssam /* 943897Ssam * Insurance, for some reason we don't seem to be 953897Ssam * hanging up... 963897Ssam */ 973897Ssam dn_disconnect() 983897Ssam { 99*3901Ssam sleep(2); 1003897Ssam #ifdef VMUNIX 1013897Ssam if (FD > 0) 1023897Ssam ioctl(FD, TIOCCDTR, 0); 1033691Sroot #endif 1043897Ssam close(FD); 1053897Ssam } 1063897Ssam 1073897Ssam dn_abort() 1083897Ssam { 109*3901Ssam sleep(2); 1103897Ssam #ifdef VMUNIX 1113897Ssam if (FD > 0) 1123897Ssam ioctl(FD, TIOCCDTR, 0); 1133897Ssam #endif 1143897Ssam close(FD); 1153897Ssam } 1163897Ssam #endif 117