1 /* $OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $ */
2 /* $NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
38 static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
39 static const char rcsid[] = "$OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
45 #define DISCONNECT_CMD "\20\04" /* disconnection string */
47 static int dialtimeout = 0;
48 static jmp_buf timeoutbuf;
50 static int biz_dialer(char *, char *);
51 static void sigALRM(int);
52 static int cmd(char *);
53 static int detect(char *);
56 * Dial up on a BIZCOMP Model 1022 with either
57 * tone dialing (mod = "V")
58 * pulse dialing (mod = "W")
61 biz_dialer(char *num, char *mod)
66 if (boolean(value(VERBOSE)))
67 printf("\nstarting call...");
69 * Disable auto-answer and configure for tone/pulse
73 printf("can't initialize bizcomp...");
76 (void)strlcpy(cbuf, "\02.\r", sizeof cbuf);
79 printf("can't set dialing mode...");
82 (void)snprintf(cbuf, sizeof(cbuf), "\02D%s\r", num);
83 write(FD, cbuf, strlen(cbuf));
85 printf("can't get dial tone...");
88 if (boolean(value(VERBOSE)))
91 * The reply from the BIZCOMP should be:
92 * 2 \r or 7 \r failure
95 connected = detect("1\r");
100 (void)snprintf(line, sizeof line, "%ld second dial timeout",
101 number(value(DIALTIMEOUT)));
102 logent(value(HOST), num, "biz1022", line);
106 biz22_disconnect(); /* insurance */
111 biz22w_dialer(char *num, char *acu)
113 return (biz_dialer(num, "W"));
117 biz22f_dialer(char *num, char *acu)
119 return (biz_dialer(num, "V"));
123 biz22_disconnect(void)
125 write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
127 tcflush(FD, TCIOFLUSH);
141 longjmp(timeoutbuf, 1);
150 write(FD, s, strlen(s));
151 f = signal(SIGALRM, sigALRM);
152 if (setjmp(timeoutbuf)) {
157 alarm(number(value(DIALTIMEOUT)));
171 f = signal(SIGALRM, sigALRM);
174 if (setjmp(timeoutbuf)) {
178 alarm(number(value(DIALTIMEOUT)));
186 return (dialtimeout == 0);