1 /* df.c 4.2 81/10/09 */ 2 /* 3 * Dial the DF02-AC or DF03-AC 4 */ 5 6 #if defined(DF02) || defined(DF03) 7 #include "tip.h" 8 #include <setjmp.h> 9 10 static jmp_buf Sjbuf; 11 static timeout(); 12 13 #if DF02 14 df02_dialer(num, acu) 15 char *num, *acu; 16 { 17 return(df_dialer(acu, num, 0)); 18 } 19 #endif 20 21 #if DF03 22 df03_dialer(num, acu) 23 char *num, *acu; 24 { 25 return(df_dialer(acu, num, 1)); 26 } 27 #endif 28 29 df_dialer(num, acu, df03) 30 char *num, *acu; 31 int df03; 32 { 33 register int f = FD; 34 struct sgttyb buf; 35 int speed = 0, c = 0; 36 int st = MST; /* Secondary Transmit flag, for speed select */ 37 38 ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 39 if (setjmp(Sjbuf)) { 40 printf("connection timed out\r\n"); 41 df_disconnect(); 42 return(0); 43 } 44 if (boolean(value(VERBOSE))) 45 printf("\ndialing..."); 46 fflush(stdout); 47 #ifdef TIOCMSET 48 if (df03) { 49 ioctl(f, TIOCGETP, &buf); 50 if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 51 speed = buf.sg_ospeed; 52 buf.sg_ospeed = buf.sg_ispeed = B1200; 53 ioctl(f, TIOCSETP, &buf); 54 ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 55 } else 56 ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 57 } 58 #endif 59 signal(SIGALRM, timeout); 60 alarm(5 * strlen(num) + 10); 61 ioctl(f, TIOCFLUSH, 0); 62 write(f, "\001", 1); 63 sleep(1); 64 write(f, "\002", 1); 65 write(f, num, strlen(num)); 66 read(f, (char *)&c, 1); 67 #ifdef TIOCMSET 68 if (df03 && speed) { 69 buf.sg_ispeed = buf.sg_ospeed = speed; 70 ioctl(f, TIOCSETP, &buf); 71 } 72 #endif 73 return(c == 'A'); 74 } 75 76 77 df_disconnect() 78 { 79 write(FD, "\001", 1); 80 sleep(1); 81 ioctl(FD, TIOCFLUSH, 0); 82 } 83 84 85 df_abort() 86 { 87 write(FD, "\001", 1); 88 sleep(1); 89 ioctl(FD, TIOCFLUSH, 0); 90 } 91 92 93 static 94 timeout() 95 { 96 longjmp(Sjbuf, 1); 97 } 98 #endif 99