1*4480Ssam /* df.c 4.2 81/10/09 */ 23690Sroot /* 3*4480Ssam * Dial the DF02-AC or DF03-AC 43690Sroot */ 53690Sroot 6*4480Ssam #if defined(DF02) || defined(DF03) 73690Sroot #include "tip.h" 83690Sroot #include <setjmp.h> 93690Sroot 103690Sroot static jmp_buf Sjbuf; 113690Sroot static timeout(); 123690Sroot 13*4480Ssam #if DF02 14*4480Ssam df02_dialer(num, acu) 153690Sroot char *num, *acu; 163690Sroot { 17*4480Ssam return(df_dialer(acu, num, 0)); 18*4480Ssam } 19*4480Ssam #endif 20*4480Ssam 21*4480Ssam #if DF03 22*4480Ssam df03_dialer(num, acu) 23*4480Ssam char *num, *acu; 24*4480Ssam { 25*4480Ssam return(df_dialer(acu, num, 1)); 26*4480Ssam } 27*4480Ssam #endif 28*4480Ssam 29*4480Ssam df_dialer(num, acu, df03) 30*4480Ssam char *num, *acu; 31*4480Ssam int df03; 32*4480Ssam { 333690Sroot register int f = FD; 34*4480Ssam struct sgttyb buf; 35*4480Ssam int speed = 0, c = 0; 36*4480Ssam int st = MST; /* Secondary Transmit flag, for speed select */ 373690Sroot 383690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 393690Sroot if (setjmp(Sjbuf)) { 403690Sroot printf("connection timed out\r\n"); 413690Sroot df_disconnect(); 423690Sroot return(0); 433690Sroot } 443690Sroot if (boolean(value(VERBOSE))) 453690Sroot printf("\ndialing..."); 463690Sroot fflush(stdout); 47*4480Ssam #ifdef TIOCMSET 48*4480Ssam if (df03) { 49*4480Ssam ioctl(f, TIOCGETP, &buf); 50*4480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 51*4480Ssam speed = buf.sg_ospeed; 52*4480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200; 53*4480Ssam ioctl(f, TIOCSETP, &buf); 54*4480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 55*4480Ssam } else 56*4480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 57*4480Ssam } 58*4480Ssam #endif 593690Sroot signal(SIGALRM, timeout); 603690Sroot alarm(5 * strlen(num) + 10); 613690Sroot ioctl(f, TIOCFLUSH, 0); 623690Sroot write(f, "\001", 1); 63*4480Ssam sleep(1); 643690Sroot write(f, "\002", 1); 653690Sroot write(f, num, strlen(num)); 663690Sroot read(f, (char *)&c, 1); 67*4480Ssam #ifdef TIOCMSET 68*4480Ssam if (df03 && speed) { 69*4480Ssam buf.sg_ispeed = buf.sg_ospeed = speed; 70*4480Ssam ioctl(f, TIOCSETP, &buf); 71*4480Ssam } 72*4480Ssam #endif 733690Sroot return(c == 'A'); 743690Sroot } 753690Sroot 763690Sroot 773690Sroot df_disconnect() 783690Sroot { 793690Sroot write(FD, "\001", 1); 803690Sroot sleep(1); 813690Sroot ioctl(FD, TIOCFLUSH, 0); 823690Sroot } 833690Sroot 843690Sroot 853690Sroot df_abort() 863690Sroot { 873690Sroot write(FD, "\001", 1); 883690Sroot sleep(1); 893690Sroot ioctl(FD, TIOCFLUSH, 0); 903690Sroot } 913690Sroot 923690Sroot 933690Sroot static 943690Sroot timeout() 953690Sroot { 963690Sroot longjmp(Sjbuf, 1); 973690Sroot } 983690Sroot #endif 99