1 /* dn11.c 4.11 81/11/29 */ 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 == EBUSY) 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 exit(nw != lt); 53 } 54 /* 55 * open line - will return on carrier 56 */ 57 if ((FD = open(DV, 2)) < 0) { 58 if (errno == EIO) 59 printf("lost carrier..."); 60 else 61 printf("dialup line open failed..."); 62 alarm(0); 63 kill(child, SIGKILL); 64 close(dn); 65 return (0); 66 } 67 alarm(0); 68 ioctl(dn, TIOCHPCL, 0); 69 signal(SIGALRM, SIG_DFL); 70 while ((nw = wait(<)) != child && nw != -1) 71 ; 72 fflush(stdout); 73 close(dn); 74 if (lt != 0) { 75 close(FD); 76 return (0); 77 } 78 return (1); 79 } 80 81 alarmtr() 82 { 83 alarm(0); 84 longjmp(jmpbuf, 1); 85 } 86 87 /* 88 * Insurance, for some reason we don't seem to be 89 * hanging up... 90 */ 91 dn_disconnect() 92 { 93 sleep(2); 94 #ifdef VMUNIX 95 if (FD > 0) 96 ioctl(FD, TIOCCDTR, 0); 97 #endif 98 close(FD); 99 } 100 101 dn_abort() 102 { 103 sleep(2); 104 if (child > 0) 105 kill(child, SIGKILL); 106 if (dn > 0) 107 close(dn); 108 #ifdef VMUNIX 109 if (FD > 0) 110 ioctl(FD, TIOCCDTR, 0); 111 #endif 112 close(FD); 113 } 114 #endif 115