|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)df.c 4.8 (Berkeley) 6/25/83";
3: #endif
4:
5: /*
6: * Dial the DF02-AC or DF03-AC
7: */
8:
9: #include "tip.h"
10:
11: static jmp_buf Sjbuf;
12: static timeout();
13:
14: df02_dialer(num, acu)
15: char *num, *acu;
16: {
17:
18: return (df_dialer(num, acu, 0));
19: }
20:
21: df03_dialer(num, acu)
22: char *num, *acu;
23: {
24:
25: return (df_dialer(num, acu, 1));
26: }
27:
28: df_dialer(num, acu, df03)
29: char *num, *acu;
30: int df03;
31: {
32: register int f = FD;
33: struct sgttyb buf;
34: int speed = 0, rw = 2;
35: char c = '\0';
36:
37: ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
38: if (setjmp(Sjbuf)) {
39: printf("connection timed out\r\n");
40: df_disconnect();
41: return (0);
42: }
43: if (boolean(value(VERBOSE)))
44: printf("\ndialing...");
45: fflush(stdout);
46: #ifdef TIOCMSET
47: if (df03) {
48: int st = TIOCM_ST; /* secondary Transmit flag */
49:
50: ioctl(f, TIOCGETP, &buf);
51: if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
52: speed = buf.sg_ospeed;
53: buf.sg_ospeed = buf.sg_ispeed = B1200;
54: ioctl(f, TIOCSETP, &buf);
55: ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
56: } else
57: ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
58: }
59: #endif
60: signal(SIGALRM, timeout);
61: alarm(5 * strlen(num) + 10);
62: ioctl(f, TIOCFLUSH, &rw);
63: write(f, "\001", 1);
64: sleep(1);
65: write(f, "\002", 1);
66: write(f, num, strlen(num));
67: read(f, &c, 1);
68: #ifdef TIOCMSET
69: if (df03 && speed) {
70: buf.sg_ispeed = buf.sg_ospeed = speed;
71: ioctl(f, TIOCSETP, &buf);
72: }
73: #endif
74: return (c == 'A');
75: }
76:
77: df_disconnect()
78: {
79: int rw = 2;
80:
81: write(FD, "\001", 1);
82: sleep(1);
83: ioctl(FD, TIOCFLUSH, &rw);
84: }
85:
86:
87: df_abort()
88: {
89:
90: df_disconnect();
91: }
92:
93:
94: static
95: timeout()
96: {
97:
98: longjmp(Sjbuf, 1);
99: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.