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