2 * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
7 * Copyright (c) 1983 Regents of the University of California.
8 * All rights reserved. The Berkeley software License Agreement
9 * specifies the terms and conditions for redistribution.
12 #pragma ident "%Z%%M% %I% %E% SMI"
16 #define DISCONNECT_CMD "\20\04" /* disconnection string */
18 static void sigALRM(void);
19 static int cmd(char *);
20 static int detect(char *);
22 static int timeout
= 0;
23 static sigjmp_buf timeoutbuf
;
25 void biz22_disconnect(void);
28 * Dial up on a BIZCOMP Model 1022 with either
29 * tone dialing (mod = "V")
30 * pulse dialing (mod = "W")
33 biz_dialer(char *num
, char *mod
)
38 if (boolean(value(VERBOSE
)))
39 (void) printf("\nstarting call...");
41 * Disable auto-answer and configure for tone/pulse
45 (void) printf("can't initialize bizcomp...");
48 (void) strcpy(cbuf
, "\02.\r");
51 (void) printf("can't set dialing mode...");
54 (void) strcpy(cbuf
, "\02D");
55 (void) strlcat(cbuf
, num
, sizeof (cbuf
));
56 (void) strlcat(cbuf
, "\r", sizeof (cbuf
));
57 (void) write(FD
, cbuf
, strlen(cbuf
));
59 (void) printf("can't get dial tone...");
62 if (boolean(value(VERBOSE
)))
63 (void) printf("ringing...");
65 * The reply from the BIZCOMP should be:
66 * 2 \r or 7 \r failure
69 connected
= detect("1\r");
74 (void) sprintf(line
, "%d second dial timeout",
75 number(value(DIALTIMEOUT
)));
76 logent(value(HOST
), num
, "biz1022", line
);
80 biz22_disconnect(); /* insurance */
86 biz22w_dialer(char *num
, char *acu
)
89 return (biz_dialer(num
, "W"));
94 biz22f_dialer(char *num
, char *acu
)
97 return (biz_dialer(num
, "V"));
101 biz22_disconnect(void)
104 (void) write(FD
, DISCONNECT_CMD
, 4);
106 (void) ioctl(FD
, TCFLSH
, TCOFLUSH
);
113 (void) write(FD
, "\02", 1);
121 siglongjmp(timeoutbuf
, 1);
130 (void) write(FD
, s
, strlen(s
));
131 f
= signal(SIGALRM
, (sig_handler_t
)sigALRM
);
132 if (sigsetjmp(timeoutbuf
, 1)) {
134 (void) signal(SIGALRM
, f
);
137 (void) alarm(number(value(DIALTIMEOUT
)));
138 (void) read(FD
, &c
, 1);
140 (void) signal(SIGALRM
, f
);
151 f
= signal(SIGALRM
, (sig_handler_t
)sigALRM
);
154 if (sigsetjmp(timeoutbuf
, 1)) {
158 (void) alarm(number(value(DIALTIMEOUT
)));
159 (void) read(FD
, &c
, 1);
165 (void) signal(SIGALRM
, f
);
166 return (timeout
== 0);