1*22416Sdist /* 2*22416Sdist * Copyright (c) 1983 Regents of the University of California. 3*22416Sdist * All rights reserved. The Berkeley software License Agreement 4*22416Sdist * specifies the terms and conditions for redistribution. 5*22416Sdist */ 6*22416Sdist 713278Ssam #ifndef lint 8*22416Sdist static char sccsid[] = "@(#)df.c 5.1 (Berkeley) 06/06/85"; 9*22416Sdist #endif not lint 1013278Ssam 113690Sroot /* 124480Ssam * Dial the DF02-AC or DF03-AC 133690Sroot */ 143690Sroot 153690Sroot #include "tip.h" 163690Sroot 1713278Ssam static jmp_buf Sjbuf; 183690Sroot static timeout(); 193690Sroot 204480Ssam df02_dialer(num, acu) 214962Ssam char *num, *acu; 223690Sroot { 2313278Ssam 245134Ssam return (df_dialer(num, acu, 0)); 254480Ssam } 264480Ssam 274480Ssam df03_dialer(num, acu) 284962Ssam char *num, *acu; 294480Ssam { 3013278Ssam 315134Ssam return (df_dialer(num, acu, 1)); 324480Ssam } 334480Ssam 344480Ssam df_dialer(num, acu, df03) 354962Ssam char *num, *acu; 364962Ssam int df03; 374480Ssam { 383690Sroot register int f = FD; 394480Ssam struct sgttyb buf; 4013278Ssam int speed = 0, rw = 2; 4113278Ssam char c = '\0'; 423690Sroot 433690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 443690Sroot if (setjmp(Sjbuf)) { 453690Sroot printf("connection timed out\r\n"); 463690Sroot df_disconnect(); 475134Ssam return (0); 483690Sroot } 493690Sroot if (boolean(value(VERBOSE))) 503690Sroot printf("\ndialing..."); 513690Sroot fflush(stdout); 524480Ssam #ifdef TIOCMSET 534480Ssam if (df03) { 5413278Ssam int st = TIOCM_ST; /* secondary Transmit flag */ 5513278Ssam 564480Ssam ioctl(f, TIOCGETP, &buf); 574480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 584480Ssam speed = buf.sg_ospeed; 594480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200; 604480Ssam ioctl(f, TIOCSETP, &buf); 614480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 624480Ssam } else 634480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 644480Ssam } 654480Ssam #endif 663690Sroot signal(SIGALRM, timeout); 673690Sroot alarm(5 * strlen(num) + 10); 6813278Ssam ioctl(f, TIOCFLUSH, &rw); 693690Sroot write(f, "\001", 1); 704480Ssam sleep(1); 713690Sroot write(f, "\002", 1); 723690Sroot write(f, num, strlen(num)); 7313278Ssam read(f, &c, 1); 744480Ssam #ifdef TIOCMSET 754480Ssam if (df03 && speed) { 764480Ssam buf.sg_ispeed = buf.sg_ospeed = speed; 774480Ssam ioctl(f, TIOCSETP, &buf); 784480Ssam } 794480Ssam #endif 805134Ssam return (c == 'A'); 813690Sroot } 823690Sroot 833690Sroot df_disconnect() 843690Sroot { 8513278Ssam int rw = 2; 8613278Ssam 873690Sroot write(FD, "\001", 1); 883690Sroot sleep(1); 8913278Ssam ioctl(FD, TIOCFLUSH, &rw); 903690Sroot } 913690Sroot 923690Sroot 933690Sroot df_abort() 943690Sroot { 9513278Ssam 9613278Ssam df_disconnect(); 973690Sroot } 983690Sroot 993690Sroot 1003690Sroot static 1013690Sroot timeout() 1023690Sroot { 10313278Ssam 1043690Sroot longjmp(Sjbuf, 1); 1053690Sroot } 106