Commit | Line | Data |
---|---|---|
f0211bf2 SL |
1 | /* dn11.c 4.3 81/06/16 */ |
2 | ||
3 | #if DN11 | |
55e3be1a BJ |
4 | /* |
5 | * Routines for dialing up on DN-11 | |
6 | */ | |
7 | #include "tip.h" | |
f0211bf2 SL |
8 | #include <setjmp.h> |
9 | #include <errno.h> | |
55e3be1a BJ |
10 | |
11 | int dn_abort(); | |
12 | ||
f0211bf2 SL |
13 | int alarmtr(); |
14 | ||
15 | static jmp_buf jmpbuf; | |
16 | ||
55e3be1a BJ |
17 | dn_dialer(num, acu) |
18 | char *num, *acu; | |
19 | { | |
20 | extern errno; | |
f0211bf2 SL |
21 | char *p, *q, phone[40]; |
22 | int child = -1, dn, lt, nw, connected = 1; | |
23 | register int timelim; | |
55e3be1a BJ |
24 | |
25 | if ((dn = open(acu, 1)) < 0) { | |
f0211bf2 | 26 | if (errno == ENXIO) |
55e3be1a | 27 | printf("line busy\n"); |
f0211bf2 SL |
28 | else |
29 | printf("acu open error\n"); | |
55e3be1a BJ |
30 | return(0); |
31 | } | |
f0211bf2 SL |
32 | if (setjmp(jmpbuf)) { |
33 | printf("dn11 write error..."); | |
34 | kill(child, SIGKILL); | |
35 | close(dn); | |
55e3be1a BJ |
36 | return(0); |
37 | } | |
f0211bf2 SL |
38 | signal(SIGALRM, alarmtr); |
39 | timelim = 5 * strlen(num); | |
40 | alarm(timelim < 30 ? 30 : timelim); | |
41 | if ((child = fork()) == 0) { | |
55e3be1a | 42 | signal(SIGALRM, SIG_IGN); |
f0211bf2 SL |
43 | sleep(2); |
44 | nw = write(dn, num, lt = strlen(num)); | |
45 | if (nw != lt) { | |
46 | printf("dn11 write failed..."); | |
47 | exit(1); | |
48 | } | |
49 | exit(0); | |
55e3be1a | 50 | } |
f0211bf2 | 51 | /* open line - will return on carrier */ |
55e3be1a | 52 | FD = open(DV, 2); |
55e3be1a | 53 | if (FD < 0) { |
f0211bf2 SL |
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); | |
55e3be1a | 62 | } |
f0211bf2 SL |
63 | ioctl(dn, TIOCHPCL, 0); |
64 | signal(SIGALRM, SIG_DFL); | |
65 | while ((nw = wait(<)) != child && nw != -1) | |
55e3be1a BJ |
66 | ; |
67 | alarm(0); | |
f0211bf2 SL |
68 | fflush(stdout); |
69 | if (lt != 0) { | |
70 | close(FD); | |
71 | close(dn); | |
72 | return(0); | |
73 | } | |
74 | return(1); | |
55e3be1a BJ |
75 | } |
76 | ||
f0211bf2 SL |
77 | alarmtr() |
78 | { | |
79 | alarm(0); | |
80 | signal(SIGINT, SIG_IGN); | |
81 | signal(SIGQUIT, SIG_IGN); | |
82 | longjmp(jmpbuf, 1); | |
83 | } | |
55e3be1a | 84 | |
f0211bf2 SL |
85 | /* |
86 | * Insurance, for some reason we don't seem to be | |
87 | * hanging up... | |
88 | */ | |
89 | dn_disconnect() | |
90 | { | |
91 | #ifdef VMUNIX | |
92 | if (FD > 0) | |
93 | ioctl(FD, TIOCCDTR, 0); | |
94 | #endif | |
95 | close(FD); | |
96 | } | |
97 | ||
98 | dn_abort() | |
99 | { | |
100 | #ifdef VMUNIX | |
101 | if (FD > 0) | |
102 | ioctl(FD, TIOCCDTR, 0); | |
103 | #endif | |
104 | close(FD); | |
105 | } | |
55e3be1a | 106 | #endif |