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 * Routines for dialing up on Vadic 831
21 static char dialit(char *, char *);
22 static char *sanitize(char *);
23 static void alarmtr(void);
25 static sigjmp_buf jmpbuf
;
26 static int child
= -1;
29 v831_dialer(char *num
, char *acu
)
34 if (boolean(value(VERBOSE
)))
35 (void) printf("\nstarting call...");
37 (void) printf("(acu=%s)\n", acu
);
39 if ((AC
= open(acu
, O_RDWR
)) < 0) {
41 (void) printf("line busy...");
43 (void) printf("acu open error...");
46 if (sigsetjmp(jmpbuf
, 1)) {
47 (void) kill(child
, SIGKILL
);
51 (void) signal(SIGALRM
, (sig_handler_t
)alarmtr
);
52 timelim
= 5 * strlen(num
);
53 (void) alarm(timelim
< 30 ? 30 : timelim
);
54 if ((child
= fork()) == 0) {
56 * ignore this stuff for aborts
58 (void) signal(SIGALRM
, SIG_IGN
);
59 (void) signal(SIGINT
, SIG_IGN
);
60 (void) signal(SIGQUIT
, SIG_IGN
);
62 exit(dialit(num
, acu
) != 'A');
65 * open line - will return on carrier
67 if ((FD
= open(DV
, O_RDWR
)) < 0) {
69 (void) printf("(after open, errno=%d)\n", errno
);
72 (void) printf("lost carrier...");
74 (void) printf("dialup line open failed...");
76 (void) kill(child
, SIGKILL
);
81 (void) signal(SIGALRM
, SIG_DFL
);
82 while ((pid
= wait(&status
)) != child
&& pid
!= -1)
96 siglongjmp(jmpbuf
, 1);
100 * Insurance, for some reason we don't seem to be
104 v831_disconnect(void)
106 struct termios cntrl
;
111 printf("[disconnect: FD=%d]\n", FD
);
114 (void) ioctl(FD
, TIOCMBIC
, &dtr
);
115 (void) ioctl(FD
, TCGETS
, &cntrl
);
116 (void) cfsetospeed(&cntrl
, B0
);
117 cntrl
.c_cflag
&= ~XCLUDE
;
118 (void) ioctl(FD
, TCSETSF
, &cntrl
);
130 (void) printf("[abort: AC=%d]\n", AC
);
134 (void) kill(child
, SIGKILL
);
136 (void) ioctl(FD
, TCGETS
, &buf
);
137 buf
.c_cflag
&= ~XCLUDE
;
138 (void) ioctl(FD
, TCSETSF
, &buf
);
142 (void) ioctl(FD
, TIOCMBIC
, &dtr
);
147 * Sigh, this probably must be changed at each site.
154 { "/dev/cua0", '4', '0' },
155 { "/dev/cua1", '4', '1' },
159 #define pc(x) (c = x, (void) write(AC, &c, 1))
166 dialit(char *phonenum
, char *acu
)
169 struct termios cntrl
;
173 phonenum
= sanitize(phonenum
);
175 (void) printf("(dial phonenum=%s)\n", phonenum
);
177 if (*phonenum
== '<' && phonenum
[1] == 0)
179 for (vp
= vaconfig
; vp
->vc_name
; vp
++)
180 if (strcmp(vp
->vc_name
, acu
) == 0)
182 if (vp
->vc_name
== 0) {
183 (void) printf("Unable to locate dialer (%s)\n", acu
);
186 (void) ioctl(AC
, TCGETS
, &cntrl
);
187 (void) cfsetospeed(&cntrl
, B0
);
188 (void) cfsetispeed(&cntrl
, B0
);
189 cntrl
.c_cflag
&= ~(CSIZE
|PARENB
|PARODD
);
190 (void) cfsetospeed(&cntrl
, B2400
);
191 cntrl
.c_cflag
|= CS8
;
192 cntrl
.c_iflag
&= IXOFF
|IXANY
;
193 cntrl
.c_lflag
&= ~(ICANON
|ISIG
);
195 cntrl
.c_cc
[VMIN
] = cntrl
.c_cc
[VTIME
] = 0;
196 (void) ioctl(AC
, TCSETSF
, &cntrl
);
197 (void) ioctl(AC
, TCFLSH
, TCOFLUSH
);
201 while (*phonenum
&& *phonenum
!= '<')
208 printf("read %d chars, char=%c, errno %d\n", i
, c
, errno
);
212 if (c
== 'B' || c
== 'G') {
216 (void) read(AC
, &cc
, 1);
218 (void) printf("abort response=%c\n", cc
);
225 (void) printf("dialit: returns %c\n", c
);
233 static char buf
[128];
236 for (cp
= buf
; *s
; s
++) {
237 if (!isdigit(*s
) && *s
== '<' && *s
!= '_')