Commit | Line | Data |
---|---|---|
d0aeaf5a | 1 | /* |
be11e13c KB |
2 | * Copyright (c) 1983 The Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
1c15e888 C |
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. | |
d0aeaf5a DF |
18 | */ |
19 | ||
05862919 | 20 | #ifndef lint |
1c15e888 | 21 | static char sccsid[] = "@(#)df.c 5.3 (Berkeley) 6/1/90"; |
be11e13c | 22 | #endif /* not lint */ |
05862919 | 23 | |
6476f6e0 | 24 | /* |
1a99c50b | 25 | * Dial the DF02-AC or DF03-AC |
6476f6e0 BJ |
26 | */ |
27 | ||
28 | #include "tip.h" | |
6476f6e0 | 29 | |
05862919 | 30 | static jmp_buf Sjbuf; |
6476f6e0 BJ |
31 | static timeout(); |
32 | ||
1a99c50b | 33 | df02_dialer(num, acu) |
d8feebc2 | 34 | char *num, *acu; |
1a99c50b | 35 | { |
05862919 | 36 | |
3f48242d | 37 | return (df_dialer(num, acu, 0)); |
1a99c50b | 38 | } |
1a99c50b | 39 | |
1a99c50b | 40 | df03_dialer(num, acu) |
d8feebc2 | 41 | char *num, *acu; |
1a99c50b | 42 | { |
05862919 | 43 | |
3f48242d | 44 | return (df_dialer(num, acu, 1)); |
1a99c50b | 45 | } |
1a99c50b SL |
46 | |
47 | df_dialer(num, acu, df03) | |
d8feebc2 SL |
48 | char *num, *acu; |
49 | int df03; | |
6476f6e0 BJ |
50 | { |
51 | register int f = FD; | |
1a99c50b | 52 | struct sgttyb buf; |
05862919 SL |
53 | int speed = 0, rw = 2; |
54 | char c = '\0'; | |
6476f6e0 BJ |
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(); | |
3f48242d | 60 | return (0); |
6476f6e0 BJ |
61 | } |
62 | if (boolean(value(VERBOSE))) | |
63 | printf("\ndialing..."); | |
64 | fflush(stdout); | |
1a99c50b SL |
65 | #ifdef TIOCMSET |
66 | if (df03) { | |
05862919 SL |
67 | int st = TIOCM_ST; /* secondary Transmit flag */ |
68 | ||
1a99c50b SL |
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 | |
6476f6e0 BJ |
79 | signal(SIGALRM, timeout); |
80 | alarm(5 * strlen(num) + 10); | |
05862919 | 81 | ioctl(f, TIOCFLUSH, &rw); |
6476f6e0 | 82 | write(f, "\001", 1); |
1a99c50b | 83 | sleep(1); |
6476f6e0 BJ |
84 | write(f, "\002", 1); |
85 | write(f, num, strlen(num)); | |
05862919 | 86 | read(f, &c, 1); |
1a99c50b SL |
87 | #ifdef TIOCMSET |
88 | if (df03 && speed) { | |
89 | buf.sg_ispeed = buf.sg_ospeed = speed; | |
90 | ioctl(f, TIOCSETP, &buf); | |
91 | } | |
92 | #endif | |
3f48242d | 93 | return (c == 'A'); |
6476f6e0 BJ |
94 | } |
95 | ||
6476f6e0 BJ |
96 | df_disconnect() |
97 | { | |
05862919 SL |
98 | int rw = 2; |
99 | ||
6476f6e0 BJ |
100 | write(FD, "\001", 1); |
101 | sleep(1); | |
05862919 | 102 | ioctl(FD, TIOCFLUSH, &rw); |
6476f6e0 BJ |
103 | } |
104 | ||
105 | ||
106 | df_abort() | |
107 | { | |
05862919 SL |
108 | |
109 | df_disconnect(); | |
6476f6e0 BJ |
110 | } |
111 | ||
112 | ||
113 | static | |
114 | timeout() | |
115 | { | |
05862919 | 116 | |
6476f6e0 BJ |
117 | longjmp(Sjbuf, 1); |
118 | } |