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