|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)dn11.c 4.14 (Berkeley) 6/25/83";
3: #endif
4:
5: /*
6: * Routines for dialing up on DN-11
7: */
8: #include "tip.h"
9:
10: int dn_abort(), alarmtr();
11: static jmp_buf jmpbuf;
12: static int child = -1, dn;
13:
14: dn_dialer(num, acu)
15: char *num, *acu;
16: {
17: extern errno;
18: char *p, *q, phone[40];
19: int lt, nw, connected = 1;
20: register int timelim;
21:
22: if (boolean(value(VERBOSE)))
23: printf("\nstarting call...");
24: if ((dn = open(acu, 1)) < 0) {
25: if (errno == EBUSY)
26: printf("line busy...");
27: else
28: printf("acu open error...");
29: return (0);
30: }
31: if (setjmp(jmpbuf)) {
32: kill(child, SIGKILL);
33: close(dn);
34: return (0);
35: }
36: signal(SIGALRM, alarmtr);
37: timelim = 5 * strlen(num);
38: alarm(timelim < 30 ? 30 : timelim);
39: if ((child = fork()) == 0) {
40: /*
41: * ignore this stuff for aborts
42: */
43: signal(SIGALRM, SIG_IGN);
44: signal(SIGINT, SIG_IGN);
45: signal(SIGQUIT, SIG_IGN);
46: sleep(2);
47: nw = write(dn, num, lt = strlen(num));
48: exit(nw != lt);
49: }
50: /*
51: * open line - will return on carrier
52: */
53: if ((FD = open(DV, 2)) < 0) {
54: if (errno == EIO)
55: printf("lost carrier...");
56: else
57: printf("dialup line open failed...");
58: alarm(0);
59: kill(child, SIGKILL);
60: close(dn);
61: return (0);
62: }
63: alarm(0);
64: ioctl(dn, TIOCHPCL, 0);
65: signal(SIGALRM, SIG_DFL);
66: while ((nw = wait(<)) != child && nw != -1)
67: ;
68: fflush(stdout);
69: close(dn);
70: if (lt != 0) {
71: close(FD);
72: return (0);
73: }
74: return (1);
75: }
76:
77: alarmtr()
78: {
79:
80: alarm(0);
81: longjmp(jmpbuf, 1);
82: }
83:
84: /*
85: * Insurance, for some reason we don't seem to be
86: * hanging up...
87: */
88: dn_disconnect()
89: {
90:
91: sleep(2);
92: if (FD > 0)
93: ioctl(FD, TIOCCDTR, 0);
94: close(FD);
95: }
96:
97: dn_abort()
98: {
99:
100: sleep(2);
101: if (child > 0)
102: kill(child, SIGKILL);
103: if (dn > 0)
104: close(dn);
105: if (FD > 0)
106: ioctl(FD, TIOCCDTR, 0);
107: close(FD);
108: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.