1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.14 6/25/83 */
/*
* Routines for dialing up on DN-11
*/
#include "tip.h"
int dn_abort();
void alarmtr();
static sigjmp_buf jmpbuf;
static int child = -1, dn;
dn_dialer(num, acu)
char *num, *acu;
{
extern errno;
char *p, *q, phone[40];
int lt, nw, connected = 1;
register int timelim;
struct termios buf;
if (boolean(value(VERBOSE)))
printf("\nstarting call...");
if ((dn = open(acu, 1)) < 0) {
if (errno == EBUSY)
printf("line busy...");
else
printf("acu open error...");
return (0);
}
if (sigsetjmp(jmpbuf, 1)) {
kill(child, SIGKILL);
close(dn);
return (0);
}
signal(SIGALRM, alarmtr);
timelim = 5 * strlen(num);
alarm(timelim < 30 ? 30 : timelim);
if ((child = fork()) == 0) {
/*
* ignore this stuff for aborts
*/
signal(SIGALRM, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
sleep(2);
nw = write(dn, num, lt = strlen(num));
exit(nw != lt);
}
/*
* open line - will return on carrier
*/
if ((FD = open(DV, 2)) < 0) {
if (errno == EIO)
printf("lost carrier...");
else
printf("dialup line open failed...");
alarm(0);
kill(child, SIGKILL);
close(dn);
return (0);
}
alarm(0);
ioctl(dn, TCGETS, &buf);
buf.c_cflag |= HUPCL;
ioctl(dn, TCSETSF, &buf);
signal(SIGALRM, SIG_DFL);
while ((nw = wait(<)) != child && nw != -1)
;
fflush(stdout);
close(dn);
if (lt != 0) {
close(FD);
return (0);
}
return (1);
}
void
alarmtr()
{
alarm(0);
siglongjmp(jmpbuf, 1);
}
/*
* Insurance, for some reason we don't seem to be
* hanging up...
*/
dn_disconnect()
{
int dtr = TIOCM_DTR;
sleep(2);
if (FD > 0)
ioctl(FD, TIOCMBIC, &dtr);
close(FD);
}
dn_abort()
{
int dtr = TIOCM_DTR;
sleep(2);
if (child > 0)
kill(child, SIGKILL);
if (dn > 0)
close(dn);
if (FD > 0)
ioctl(FD, TIOCMBIC, &dtr);
close(FD);
}
|