1 /* $NetBSD: df.c,v 1.8 2006/04/03 00:51:14 perry Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)df.c 8.1 (Berkeley) 6/6/93";
37 __RCSID("$NetBSD: df.c,v 1.8 2006/04/03 00:51:14 perry Exp $");
41 * Dial the DF02-AC or DF03-AC
48 static int df_dialer(char *, char *, int);
49 static void timeout(int);
52 df02_dialer(char *num
, char *acu
)
55 return (df_dialer(num
, acu
, 0));
59 df03_dialer(char *num
, char *acu
)
62 return (df_dialer(num
, acu
, 1));
67 df_dialer(char *num
, char *acu __unused
, int df03
)
76 (void)tcgetattr(f
, &cntrl
);
77 cntrl
.c_cflag
|= HUPCL
;
78 (void)tcsetattr(f
, TCSANOW
, &cntrl
);
80 (void)printf("connection timed out\r\n");
84 if (boolean(value(VERBOSE
)))
85 (void)printf("\ndialing...");
89 int st
= TIOCM_ST
; /* secondary Transmit flag */
91 (void)tcgetattr(f
, &cntrl
);
92 spd
= cfgetospeed(&cntrl
);
93 if (spd
!= B1200
) { /* must dial at 1200 baud */
94 (void)cfsetospeed(&cntrl
, B1200
);
95 (void)cfsetispeed(&cntrl
, B1200
);
96 (void)tcsetattr(f
, TCSAFLUSH
, &cntrl
);
97 (void)ioctl(f
, TIOCMBIC
, &st
); /* clear ST for 300 baud */
99 (void)ioctl(f
, TIOCMBIS
, &st
); /* set ST for 1200 baud */
102 (void)signal(SIGALRM
, timeout
);
103 (void)alarm(5 * strlen(num
) + 10);
104 (void)tcflush(f
, TCIOFLUSH
);
105 (void)write(f
, "\001", 1);
107 (void)write(f
, "\002", 1);
108 (void)write(f
, num
, strlen(num
));
109 (void)read(f
, &c
, 1);
111 if (df03
&& spd
!= B1200
) {
112 (void)cfsetospeed(&cntrl
, spd
);
113 (void)cfsetispeed(&cntrl
, spd
);
114 (void)tcsetattr(f
, TCSAFLUSH
, &cntrl
);
124 (void)write(FD
, "\001", 1);
126 (void)tcflush(FD
, TCIOFLUSH
);
140 timeout(int dummy __unused
)