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