1*4962Ssam /* df.c 4.4 81/11/20 */ 23690Sroot /* 34480Ssam * Dial the DF02-AC or DF03-AC 43690Sroot */ 53690Sroot 64480Ssam #if defined(DF02) || defined(DF03) 73690Sroot #include "tip.h" 83690Sroot #include <setjmp.h> 93690Sroot 103690Sroot static jmp_buf Sjbuf; 113690Sroot static timeout(); 123690Sroot 134480Ssam #if DF02 144480Ssam df02_dialer(num, acu) 15*4962Ssam char *num, *acu; 163690Sroot { 174568Ssam return(df_dialer(num, acu, 0)); 184480Ssam } 194480Ssam #endif 204480Ssam 214480Ssam #if DF03 224480Ssam df03_dialer(num, acu) 23*4962Ssam char *num, *acu; 244480Ssam { 254568Ssam return(df_dialer(num, acu, 1)); 264480Ssam } 274480Ssam #endif 284480Ssam 294480Ssam df_dialer(num, acu, df03) 30*4962Ssam char *num, *acu; 31*4962Ssam int df03; 324480Ssam { 333690Sroot register int f = FD; 344480Ssam struct sgttyb buf; 354480Ssam int speed = 0, c = 0; 364568Ssam #ifdef TIOCMSET 374480Ssam int st = MST; /* Secondary Transmit flag, for speed select */ 384568Ssam #endif 393690Sroot 403690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 413690Sroot if (setjmp(Sjbuf)) { 423690Sroot printf("connection timed out\r\n"); 433690Sroot df_disconnect(); 443690Sroot return(0); 453690Sroot } 463690Sroot if (boolean(value(VERBOSE))) 473690Sroot printf("\ndialing..."); 483690Sroot fflush(stdout); 494480Ssam #ifdef TIOCMSET 504480Ssam if (df03) { 514480Ssam ioctl(f, TIOCGETP, &buf); 524480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 534480Ssam speed = buf.sg_ospeed; 544480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200; 554480Ssam ioctl(f, TIOCSETP, &buf); 564480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 574480Ssam } else 584480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 594480Ssam } 604480Ssam #endif 613690Sroot signal(SIGALRM, timeout); 623690Sroot alarm(5 * strlen(num) + 10); 633690Sroot ioctl(f, TIOCFLUSH, 0); 643690Sroot write(f, "\001", 1); 654480Ssam sleep(1); 663690Sroot write(f, "\002", 1); 673690Sroot write(f, num, strlen(num)); 683690Sroot read(f, (char *)&c, 1); 694480Ssam #ifdef TIOCMSET 704480Ssam if (df03 && speed) { 714480Ssam buf.sg_ispeed = buf.sg_ospeed = speed; 724480Ssam ioctl(f, TIOCSETP, &buf); 734480Ssam } 744480Ssam #endif 753690Sroot return(c == 'A'); 763690Sroot } 773690Sroot 783690Sroot 793690Sroot df_disconnect() 803690Sroot { 813690Sroot write(FD, "\001", 1); 823690Sroot sleep(1); 833690Sroot ioctl(FD, TIOCFLUSH, 0); 843690Sroot } 853690Sroot 863690Sroot 873690Sroot df_abort() 883690Sroot { 893690Sroot write(FD, "\001", 1); 903690Sroot sleep(1); 913690Sroot ioctl(FD, TIOCFLUSH, 0); 923690Sroot } 933690Sroot 943690Sroot 953690Sroot static 963690Sroot timeout() 973690Sroot { 983690Sroot longjmp(Sjbuf, 1); 993690Sroot } 1003690Sroot #endif 101