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"
15 * Routines for calling up on a Vadic 3451 Modem
19 static int expect(char *);
20 static int notin(char *, char *);
21 static int prefix(char *, char *);
22 static void vawrite(char *, int);
23 static void alarmtr(void);
25 static sigjmp_buf Sjbuf
;
29 v3451_dialer(char *num
, char *acu
)
34 int slow
= number(value(BAUDRATE
)) < 1200;
43 vawrite("I\r", 1 + slow
);
44 vawrite("I\r", 1 + slow
);
45 vawrite("I\r", 1 + slow
);
46 vawrite("\005\r", 2 + slow
);
47 if (!expect("READY")) {
48 (void) printf("can't synchronize with vadic 3451\n");
50 logent(value(HOST
), num
, "vadic", "can't synch up");
54 (void) ioctl(FD
, TCGETS
, &buf
);
56 (void) ioctl(FD
, TCSETSF
, &buf
);
58 vawrite("D\r", 2 + slow
);
59 if (!expect("NUMBER?")) {
60 (void) printf("Vadic will not accept dial command\n");
62 logent(value(HOST
), num
, "vadic", "will not accept dial");
66 (void) strlcpy(phone
, num
, sizeof (phone
));
67 (void) strlcat(phone
, "\r", sizeof (phone
));
68 vawrite(phone
, 1 + slow
);
70 (void) printf("Vadic will not accept phone number\n");
72 logent(value(HOST
), num
, "vadic", "will not accept number");
76 func
= signal(SIGINT
, SIG_IGN
);
78 * You cannot interrupt the Vadic when its dialing;
79 * even dropping DTR does not work (definitely a
80 * brain damaged design).
82 vawrite("\r", 1 + slow
);
83 vawrite("\r", 1 + slow
);
84 if (!expect("DIALING:")) {
85 (void) printf("Vadic failed to dial\n");
87 logent(value(HOST
), num
, "vadic", "failed to dial");
91 if (boolean(value(VERBOSE
)))
92 (void) printf("\ndialing...");
93 ok
= expect("ON LINE");
94 (void) signal(SIGINT
, func
);
96 (void) printf("call failed\n");
98 logent(value(HOST
), num
, "vadic", "call failed");
102 (void) ioctl(FD
, TCFLSH
, TCOFLUSH
);
107 v3451_disconnect(void)
121 vawrite(char *cp
, int delay
)
124 for (; *cp
; (void) sleep(delay
), cp
++)
125 (void) write(FD
, cp
, 1);
133 int timeout
= 30, online
= 0;
135 if (strcmp(cp
, "\"\"") == 0)
139 * If we are waiting for the Vadic to complete
140 * dialing and get a connection, allow more time
141 * Unfortunately, the Vadic times out 24 seconds after
142 * the last digit is dialed
144 online
= strcmp(cp
, "ON LINE") == 0;
146 timeout
= number(value(DIALTIMEOUT
));
147 (void) signal(SIGALRM
, (sig_handler_t
)alarmtr
);
148 if (sigsetjmp(Sjbuf
, 1))
150 (void) alarm(timeout
);
151 while (notin(cp
, buf
) && rp
< buf
+ sizeof (buf
) - 1) {
152 if (online
&& notin("FAILED CALL", buf
) == 0)
154 if (read(FD
, rp
, 1) < 0) {
170 siglongjmp(Sjbuf
, 1);
174 notin(char *sh
, char *lg
)
184 prefix(char *s1
, char *s2
)
188 while ((c
= *s1
++) == *s2
++)