2 * Copyright 2005 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"
15 * Dial the DF02-AC or DF03-AC
20 static sigjmp_buf Sjbuf
;
21 static void timeout(void);
23 void df_disconnect(void);
24 int df_dialer(char *, char *, int);
27 df02_dialer(char *num
, char *acu
)
30 return (df_dialer(num
, acu
, 0));
34 df03_dialer(char *num
, char *acu
)
37 return (df_dialer(num
, acu
, 1));
42 df_dialer(char *num
, char *acu
, int df03
)
49 (void) ioctl(f
, TCGETS
, &buf
);
51 (void) ioctl(f
, TCSETS
, &buf
);
52 if (sigsetjmp(Sjbuf
, 1)) {
53 (void) printf("connection timed out\r\n");
57 if (boolean(value(VERBOSE
)))
58 (void) printf("\ndialing...");
59 (void) fflush(stdout
);
62 int st
= TIOCM_ST
; /* secondary Transmit flag */
64 (void) ioctl(f
, TCGETS
, &buf
);
65 if (cfgetospeed(&buf
) != B1200
) { /* must dial at 1200 baud */
66 speed
= cfgetospeed(&buf
);
67 (void) cfsetospeed(&buf
, B0
);
68 (void) cfsetispeed(&buf
, B0
);
69 (void) cfsetospeed(&buf
, B1200
);
70 (void) ioctl(f
, TCSETSW
, &buf
);
71 /* clear ST for 300 baud */
72 (void) ioctl(f
, TIOCMBIC
, &st
);
74 /* set ST for 1200 baud */
75 (void) ioctl(f
, TIOCMBIS
, &st
);
78 (void) signal(SIGALRM
, (sig_handler_t
)timeout
);
79 (void) alarm(5 * strlen(num
) + 10);
80 (void) ioctl(f
, TCFLSH
, TCOFLUSH
);
81 (void) write(f
, "\001", 1);
83 (void) write(f
, "\002", 1);
84 (void) write(f
, num
, strlen(num
));
85 (void) read(f
, &c
, 1);
88 (void) cfsetospeed(&buf
, B0
);
89 (void) cfsetispeed(&buf
, B0
);
90 (void) cfsetospeed(&buf
, speed
);
91 (void) ioctl(f
, TCSETSW
, &buf
);
101 (void) write(FD
, "\001", 1);
103 (void) ioctl(FD
, TCFLSH
, TCOFLUSH
);
118 siglongjmp(Sjbuf
, 1);