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