|
|
1.1 root 1: /*
2: * Copyright (c) 1983 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)df.c 5.3 (Berkeley) 6/1/90";
22: #endif /* not lint */
23:
24: /*
25: * Dial the DF02-AC or DF03-AC
26: */
27:
28: #include "tip.h"
29:
30: static jmp_buf Sjbuf;
31: static timeout();
32:
33: df02_dialer(num, acu)
34: char *num, *acu;
35: {
36:
37: return (df_dialer(num, acu, 0));
38: }
39:
40: df03_dialer(num, acu)
41: char *num, *acu;
42: {
43:
44: return (df_dialer(num, acu, 1));
45: }
46:
47: df_dialer(num, acu, df03)
48: char *num, *acu;
49: int df03;
50: {
51: register int f = FD;
52: struct sgttyb buf;
53: int speed = 0, rw = 2;
54: char c = '\0';
55:
56: ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
57: if (setjmp(Sjbuf)) {
58: printf("connection timed out\r\n");
59: df_disconnect();
60: return (0);
61: }
62: if (boolean(value(VERBOSE)))
63: printf("\ndialing...");
64: fflush(stdout);
65: #ifdef TIOCMSET
66: if (df03) {
67: int st = TIOCM_ST; /* secondary Transmit flag */
68:
69: ioctl(f, TIOCGETP, &buf);
70: if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
71: speed = buf.sg_ospeed;
72: buf.sg_ospeed = buf.sg_ispeed = B1200;
73: ioctl(f, TIOCSETP, &buf);
74: ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
75: } else
76: ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
77: }
78: #endif
79: signal(SIGALRM, timeout);
80: alarm(5 * strlen(num) + 10);
81: ioctl(f, TIOCFLUSH, &rw);
82: write(f, "\001", 1);
83: sleep(1);
84: write(f, "\002", 1);
85: write(f, num, strlen(num));
86: read(f, &c, 1);
87: #ifdef TIOCMSET
88: if (df03 && speed) {
89: buf.sg_ispeed = buf.sg_ospeed = speed;
90: ioctl(f, TIOCSETP, &buf);
91: }
92: #endif
93: return (c == 'A');
94: }
95:
96: df_disconnect()
97: {
98: int rw = 2;
99:
100: write(FD, "\001", 1);
101: sleep(1);
102: ioctl(FD, TIOCFLUSH, &rw);
103: }
104:
105:
106: df_abort()
107: {
108:
109: df_disconnect();
110: }
111:
112:
113: static
114: timeout()
115: {
116:
117: longjmp(Sjbuf, 1);
118: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.