1 /* dn11.c 4.5 81/06/21 */ 2 3 #if DN11 4 /* 5 * Routines for dialing up on DN-11 6 */ 7 #include "tip.h" 8 #include <setjmp.h> 9 #include <errno.h> 10 11 int dn_abort(); 12 13 int alarmtr(); 14 15 static jmp_buf jmpbuf; 16 static int child = -1, dn; 17 18 dn_dialer(num, acu) 19 char *num, *acu; 20 { 21 extern errno; 22 char *p, *q, phone[40]; 23 int lt, nw, connected = 1; 24 register int timelim; 25 26 if (boolean(value(VERBOSE))) 27 printf("\nstarting call..."); 28 if ((dn = open(acu, 1)) < 0) { 29 if (errno == ENXIO) 30 printf("line busy..."); 31 else 32 printf("acu open error..."); 33 return(0); 34 } 35 if (setjmp(jmpbuf)) { 36 kill(child, SIGKILL); 37 close(dn); 38 return(0); 39 } 40 signal(SIGALRM, alarmtr); 41 timelim = 5 * strlen(num); 42 alarm(timelim < 30 ? 30 : timelim); 43 if ((child = fork()) == 0) { 44 /* 45 * ignore this stuff for aborts 46 */ 47 signal(SIGALRM, SIG_IGN); 48 signal(SIGINT, SIG_IGN); 49 signal(SIGQUIT, SIG_IGN); 50 sleep(2); 51 nw = write(dn, num, lt = strlen(num)); 52 if (nw != lt) { 53 printf("dn11 write failed..."); 54 exit(1); 55 } 56 exit(0); 57 } 58 /* 59 * open line - will return on carrier 60 */ 61 FD = open(DV, 2); 62 if (FD < 0) { 63 if (errno == EIO) 64 printf("lost carrier..."); 65 else 66 printf("dialup line open failed..."); 67 alarm(0); 68 kill(child, SIGKILL); 69 close(dn); 70 return(0); 71 } 72 ioctl(dn, TIOCHPCL, 0); 73 signal(SIGALRM, SIG_DFL); 74 while ((nw = wait(<)) != child && nw != -1) 75 ; 76 alarm(0); 77 fflush(stdout); 78 if (lt != 0) { 79 close(FD); 80 close(dn); 81 return(0); 82 } 83 return(1); 84 } 85 86 alarmtr() 87 { 88 alarm(0); 89 signal(SIGINT, SIG_IGN); 90 signal(SIGQUIT, SIG_IGN); 91 longjmp(jmpbuf, 1); 92 } 93 94 /* 95 * Insurance, for some reason we don't seem to be 96 * hanging up... 97 */ 98 dn_disconnect() 99 { 100 sleep(2); 101 #ifdef VMUNIX 102 if (FD > 0) 103 ioctl(FD, TIOCCDTR, 0); 104 #endif 105 close(FD); 106 } 107 108 dn_abort() 109 { 110 sleep(2); 111 if (child > 0) 112 kill(child, SIGKILL); 113 if (dn > 0) 114 close(dn); 115 #ifdef VMUNIX 116 if (FD > 0) 117 ioctl(FD, TIOCCDTR, 0); 118 #endif 119 close(FD); 120 } 121 #endif 122