1*13278Ssam #ifndef lint 2*13278Ssam static char sccsid[] = "@(#)df.c 4.7 (Berkeley) 06/25/83"; 3*13278Ssam #endif 4*13278Ssam 53690Sroot /* 64480Ssam * Dial the DF02-AC or DF03-AC 73690Sroot */ 83690Sroot 94480Ssam #if defined(DF02) || defined(DF03) 103690Sroot #include "tip.h" 113690Sroot 12*13278Ssam static jmp_buf Sjbuf; 133690Sroot static timeout(); 143690Sroot 154480Ssam #if DF02 164480Ssam df02_dialer(num, acu) 174962Ssam char *num, *acu; 183690Sroot { 19*13278Ssam 205134Ssam return (df_dialer(num, acu, 0)); 214480Ssam } 224480Ssam #endif 234480Ssam 244480Ssam #if DF03 254480Ssam df03_dialer(num, acu) 264962Ssam char *num, *acu; 274480Ssam { 28*13278Ssam 295134Ssam return (df_dialer(num, acu, 1)); 304480Ssam } 314480Ssam #endif 324480Ssam 334480Ssam df_dialer(num, acu, df03) 344962Ssam char *num, *acu; 354962Ssam int df03; 364480Ssam { 373690Sroot register int f = FD; 384480Ssam struct sgttyb buf; 39*13278Ssam int speed = 0, rw = 2; 40*13278Ssam char c = '\0'; 413690Sroot 423690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 433690Sroot if (setjmp(Sjbuf)) { 443690Sroot printf("connection timed out\r\n"); 453690Sroot df_disconnect(); 465134Ssam return (0); 473690Sroot } 483690Sroot if (boolean(value(VERBOSE))) 493690Sroot printf("\ndialing..."); 503690Sroot fflush(stdout); 514480Ssam #ifdef TIOCMSET 524480Ssam if (df03) { 53*13278Ssam int st = TIOCM_ST; /* secondary Transmit flag */ 54*13278Ssam 554480Ssam ioctl(f, TIOCGETP, &buf); 564480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 574480Ssam speed = buf.sg_ospeed; 584480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200; 594480Ssam ioctl(f, TIOCSETP, &buf); 604480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 614480Ssam } else 624480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 634480Ssam } 644480Ssam #endif 653690Sroot signal(SIGALRM, timeout); 663690Sroot alarm(5 * strlen(num) + 10); 67*13278Ssam ioctl(f, TIOCFLUSH, &rw); 683690Sroot write(f, "\001", 1); 694480Ssam sleep(1); 703690Sroot write(f, "\002", 1); 713690Sroot write(f, num, strlen(num)); 72*13278Ssam read(f, &c, 1); 734480Ssam #ifdef TIOCMSET 744480Ssam if (df03 && speed) { 754480Ssam buf.sg_ispeed = buf.sg_ospeed = speed; 764480Ssam ioctl(f, TIOCSETP, &buf); 774480Ssam } 784480Ssam #endif 795134Ssam return (c == 'A'); 803690Sroot } 813690Sroot 823690Sroot df_disconnect() 833690Sroot { 84*13278Ssam int rw = 2; 85*13278Ssam 863690Sroot write(FD, "\001", 1); 873690Sroot sleep(1); 88*13278Ssam ioctl(FD, TIOCFLUSH, &rw); 893690Sroot } 903690Sroot 913690Sroot 923690Sroot df_abort() 933690Sroot { 94*13278Ssam 95*13278Ssam df_disconnect(); 963690Sroot } 973690Sroot 983690Sroot 993690Sroot static 1003690Sroot timeout() 1013690Sroot { 102*13278Ssam 1033690Sroot longjmp(Sjbuf, 1); 1043690Sroot } 1053690Sroot #endif 106