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