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 * SPDX-License-Identifier: BSD-3-Clause
7 * Copyright (c) 1983, 1993
8 * The Regents of the University of California. All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
40 static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
41 static const char rcsid[] = "$OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
47 #define DISCONNECT_CMD "\20\04" /* disconnection string */
49 static int dialtimeout = 0;
50 static jmp_buf timeoutbuf;
52 static int biz_dialer(char *, char *);
53 static void sigALRM(int);
54 static int cmd(char *);
55 static int detect(char *);
58 * Dial up on a BIZCOMP Model 1022 with either
59 * tone dialing (mod = "V")
60 * pulse dialing (mod = "W")
63 biz_dialer(char *num, char *mod)
68 if (boolean(value(VERBOSE)))
69 printf("\nstarting call...");
71 * Disable auto-answer and configure for tone/pulse
75 printf("can't initialize bizcomp...");
78 (void)strlcpy(cbuf, "\02.\r", sizeof cbuf);
81 printf("can't set dialing mode...");
84 (void)snprintf(cbuf, sizeof(cbuf), "\02D%s\r", num);
85 write(FD, cbuf, strlen(cbuf));
87 printf("can't get dial tone...");
90 if (boolean(value(VERBOSE)))
93 * The reply from the BIZCOMP should be:
94 * 2 \r or 7 \r failure
97 connected = detect("1\r");
102 (void)snprintf(line, sizeof line, "%ld second dial timeout",
103 number(value(DIALTIMEOUT)));
104 logent(value(HOST), num, "biz1022", line);
108 biz22_disconnect(); /* insurance */
113 biz22w_dialer(char *num, char *acu)
115 return (biz_dialer(num, "W"));
119 biz22f_dialer(char *num, char *acu)
121 return (biz_dialer(num, "V"));
125 biz22_disconnect(void)
127 write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
129 tcflush(FD, TCIOFLUSH);
143 longjmp(timeoutbuf, 1);
152 write(FD, s, strlen(s));
153 f = signal(SIGALRM, sigALRM);
154 if (setjmp(timeoutbuf)) {
159 alarm(number(value(DIALTIMEOUT)));
173 f = signal(SIGALRM, sigALRM);
176 if (setjmp(timeoutbuf)) {
180 alarm(number(value(DIALTIMEOUT)));
188 return (dialtimeout == 0);