2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)biz31.c 8.1 (Berkeley) 6/6/93
39 #define MAXRETRY 3 /* sync up retry count */
40 #define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */
42 static void sigALRM();
43 static int timeout
= 0;
44 static jmp_buf timeoutbuf
;
47 * Dial up on a BIZCOMP Model 1031 with either
48 * tone dialing (mod = "f")
49 * pulse dialing (mod = "w")
55 register int connected
= 0;
58 logent(value(HOST
), "", "biz", "out of sync");
59 printf("bizcomp out of sync\n");
63 if (boolean(value(VERBOSE
)))
64 printf("\nstarting call...");
65 echo("#\rk$\r$\n"); /* disable auto-answer */
66 echo("$>$.$ #\r"); /* tone/pulse dialing */
69 echo("$>$.$ #\re$ "); /* disconnection sequence */
72 echo("$>$.$ #\rr$ "); /* repeat dial */
75 if (boolean(value(VERBOSE
)))
78 * The reply from the BIZCOMP should be:
79 * `^G NO CONNECTION\r\n^G\r\n' failure
80 * ` CONNECTION\r\n^G' success
82 connected
= detect(" ");
87 sprintf(line
, "%d second dial timeout",
88 number(value(DIALTIMEOUT
)));
89 logent(value(HOST
), num
, "biz", line
);
93 flush(" NO CONNECTION\r\n\07\r\n");
95 flush("CONNECTION\r\n\07");
97 biz31_disconnect(); /* insurance */
101 biz31w_dialer(num
, acu
)
105 return (biz_dialer(num
, "w"));
108 biz31f_dialer(num
, acu
)
112 return (biz_dialer(num
, "f"));
118 write(FD
, DISCONNECT_CMD
, 4);
120 ioctl(FD
, TIOCFLUSH
);
135 while (c
= *s
++) switch (c
) {
158 longjmp(timeoutbuf
, 1);
168 f
= signal(SIGALRM
, sigALRM
);
171 if (setjmp(timeoutbuf
)) {
172 printf("\07timeout waiting for reply\n");
176 alarm(number(value(DIALTIMEOUT
)));
183 return (timeout
== 0);
193 f
= signal(SIGALRM
, sigALRM
);
195 if (setjmp(timeoutbuf
))
202 timeout
= 0; /* guard against disconnection */
206 * This convoluted piece of code attempts to get
207 * the bizcomp in sync. If you don't have the capacity or nread
208 * call there are gory ways to simulate this.
215 # define chars(b) ((b).cp_nbytes)
216 # define IOCTL FIOCAPACITY
220 # define chars(b) (b)
221 # define IOCTL FIONREAD
223 register int already
= 0;
227 if (ioctl(fd
, IOCTL
, (caddr_t
)&b
) >= 0 && chars(b
) > 0)
228 ioctl(fd
, TIOCFLUSH
);
229 write(fd
, "\rp>\r", 4);
231 if (ioctl(fd
, IOCTL
, (caddr_t
)&b
) >= 0) {
232 if (chars(b
) != 10) {
234 if (already
> MAXRETRY
)
236 write(fd
, DISCONNECT_CMD
, 4);
242 if (strncmp(buf
, "p >\r\n\r\n>", 8))