so much...clean up after ralph's merge of wendel and mo code;
[unix-history] / usr / src / usr.bin / tip / aculib / df.c
CommitLineData
05862919
SL
1#ifndef lint
2static char sccsid[] = "@(#)df.c 4.7 (Berkeley) %G%";
3#endif
4
6476f6e0 5/*
1a99c50b 6 * Dial the DF02-AC or DF03-AC
6476f6e0
BJ
7 */
8
1a99c50b 9#if defined(DF02) || defined(DF03)
6476f6e0 10#include "tip.h"
6476f6e0 11
05862919 12static jmp_buf Sjbuf;
6476f6e0
BJ
13static timeout();
14
1a99c50b
SL
15#if DF02
16df02_dialer(num, acu)
d8feebc2 17 char *num, *acu;
1a99c50b 18{
05862919 19
3f48242d 20 return (df_dialer(num, acu, 0));
1a99c50b
SL
21}
22#endif
23
24#if DF03
25df03_dialer(num, acu)
d8feebc2 26 char *num, *acu;
1a99c50b 27{
05862919 28
3f48242d 29 return (df_dialer(num, acu, 1));
1a99c50b
SL
30}
31#endif
32
33df_dialer(num, acu, df03)
d8feebc2
SL
34 char *num, *acu;
35 int df03;
6476f6e0
BJ
36{
37 register int f = FD;
1a99c50b 38 struct sgttyb buf;
05862919
SL
39 int speed = 0, rw = 2;
40 char c = '\0';
6476f6e0
BJ
41
42 ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
43 if (setjmp(Sjbuf)) {
44 printf("connection timed out\r\n");
45 df_disconnect();
3f48242d 46 return (0);
6476f6e0
BJ
47 }
48 if (boolean(value(VERBOSE)))
49 printf("\ndialing...");
50 fflush(stdout);
1a99c50b
SL
51#ifdef TIOCMSET
52 if (df03) {
05862919
SL
53 int st = TIOCM_ST; /* secondary Transmit flag */
54
1a99c50b
SL
55 ioctl(f, TIOCGETP, &buf);
56 if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
57 speed = buf.sg_ospeed;
58 buf.sg_ospeed = buf.sg_ispeed = B1200;
59 ioctl(f, TIOCSETP, &buf);
60 ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
61 } else
62 ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
63 }
64#endif
6476f6e0
BJ
65 signal(SIGALRM, timeout);
66 alarm(5 * strlen(num) + 10);
05862919 67 ioctl(f, TIOCFLUSH, &rw);
6476f6e0 68 write(f, "\001", 1);
1a99c50b 69 sleep(1);
6476f6e0
BJ
70 write(f, "\002", 1);
71 write(f, num, strlen(num));
05862919 72 read(f, &c, 1);
1a99c50b
SL
73#ifdef TIOCMSET
74 if (df03 && speed) {
75 buf.sg_ispeed = buf.sg_ospeed = speed;
76 ioctl(f, TIOCSETP, &buf);
77 }
78#endif
3f48242d 79 return (c == 'A');
6476f6e0
BJ
80}
81
6476f6e0
BJ
82df_disconnect()
83{
05862919
SL
84 int rw = 2;
85
6476f6e0
BJ
86 write(FD, "\001", 1);
87 sleep(1);
05862919 88 ioctl(FD, TIOCFLUSH, &rw);
6476f6e0
BJ
89}
90
91
92df_abort()
93{
05862919
SL
94
95 df_disconnect();
6476f6e0
BJ
96}
97
98
99static
100timeout()
101{
05862919 102
6476f6e0
BJ
103 longjmp(Sjbuf, 1);
104}
105#endif