122416Sdist /*
2*62317Sbostic * Copyright (c) 1983, 1993
3*62317Sbostic * The Regents of the University of California. All rights reserved.
435492Sbostic *
542770Sbostic * %sccs.include.redist.c%
622416Sdist */
722416Sdist
813278Ssam #ifndef lint
9*62317Sbostic static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 06/06/93";
1035492Sbostic #endif /* not lint */
1113278Ssam
123690Sroot /*
134480Ssam * Dial the DF02-AC or DF03-AC
143690Sroot */
153690Sroot
163690Sroot #include "tip.h"
173690Sroot
1813278Ssam static jmp_buf Sjbuf;
1946867Sbostic static void timeout();
203690Sroot
df02_dialer(num,acu)214480Ssam df02_dialer(num, acu)
224962Ssam char *num, *acu;
233690Sroot {
2413278Ssam
255134Ssam return (df_dialer(num, acu, 0));
264480Ssam }
274480Ssam
df03_dialer(num,acu)284480Ssam df03_dialer(num, acu)
294962Ssam char *num, *acu;
304480Ssam {
3113278Ssam
325134Ssam return (df_dialer(num, acu, 1));
334480Ssam }
344480Ssam
df_dialer(num,acu,df03)354480Ssam df_dialer(num, acu, df03)
364962Ssam char *num, *acu;
374962Ssam int df03;
384480Ssam {
393690Sroot register int f = FD;
404480Ssam struct sgttyb buf;
4113278Ssam int speed = 0, rw = 2;
4213278Ssam char c = '\0';
433690Sroot
443690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
453690Sroot if (setjmp(Sjbuf)) {
463690Sroot printf("connection timed out\r\n");
473690Sroot df_disconnect();
485134Ssam return (0);
493690Sroot }
503690Sroot if (boolean(value(VERBOSE)))
513690Sroot printf("\ndialing...");
523690Sroot fflush(stdout);
534480Ssam #ifdef TIOCMSET
544480Ssam if (df03) {
5513278Ssam int st = TIOCM_ST; /* secondary Transmit flag */
5613278Ssam
574480Ssam ioctl(f, TIOCGETP, &buf);
584480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
594480Ssam speed = buf.sg_ospeed;
604480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200;
614480Ssam ioctl(f, TIOCSETP, &buf);
624480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
634480Ssam } else
644480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
654480Ssam }
664480Ssam #endif
673690Sroot signal(SIGALRM, timeout);
683690Sroot alarm(5 * strlen(num) + 10);
6913278Ssam ioctl(f, TIOCFLUSH, &rw);
703690Sroot write(f, "\001", 1);
714480Ssam sleep(1);
723690Sroot write(f, "\002", 1);
733690Sroot write(f, num, strlen(num));
7413278Ssam read(f, &c, 1);
754480Ssam #ifdef TIOCMSET
764480Ssam if (df03 && speed) {
774480Ssam buf.sg_ispeed = buf.sg_ospeed = speed;
784480Ssam ioctl(f, TIOCSETP, &buf);
794480Ssam }
804480Ssam #endif
815134Ssam return (c == 'A');
823690Sroot }
833690Sroot
df_disconnect()843690Sroot df_disconnect()
853690Sroot {
8613278Ssam int rw = 2;
8713278Ssam
883690Sroot write(FD, "\001", 1);
893690Sroot sleep(1);
9013278Ssam ioctl(FD, TIOCFLUSH, &rw);
913690Sroot }
923690Sroot
933690Sroot
df_abort()943690Sroot df_abort()
953690Sroot {
9613278Ssam
9713278Ssam df_disconnect();
983690Sroot }
993690Sroot
1003690Sroot
10146867Sbostic static void
timeout()1023690Sroot timeout()
1033690Sroot {
10413278Ssam
1053690Sroot longjmp(Sjbuf, 1);
1063690Sroot }
107