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