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