|
|
1.1 root 1: /*
2: * Copyright (c) 1983 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)dn11.c 5.3 (Berkeley) 6/1/90";
22: #endif /* not lint */
23:
24: /*
25: * Routines for dialing up on DN-11
26: */
27: #include "tip.h"
28:
29: int dn_abort(), alarmtr();
30: static jmp_buf jmpbuf;
31: static int child = -1, dn;
32:
33: dn_dialer(num, acu)
34: char *num, *acu;
35: {
36: extern errno;
37: char *p, *q, phone[40];
38: int lt, nw, connected = 1;
39: register int timelim;
40:
41: if (boolean(value(VERBOSE)))
42: printf("\nstarting call...");
43: if ((dn = open(acu, 1)) < 0) {
44: if (errno == EBUSY)
45: printf("line busy...");
46: else
47: printf("acu open error...");
48: return (0);
49: }
50: if (setjmp(jmpbuf)) {
51: kill(child, SIGKILL);
52: close(dn);
53: return (0);
54: }
55: signal(SIGALRM, alarmtr);
56: timelim = 5 * strlen(num);
57: alarm(timelim < 30 ? 30 : timelim);
58: if ((child = fork()) == 0) {
59: /*
60: * ignore this stuff for aborts
61: */
62: signal(SIGALRM, SIG_IGN);
63: signal(SIGINT, SIG_IGN);
64: signal(SIGQUIT, SIG_IGN);
65: sleep(2);
66: nw = write(dn, num, lt = strlen(num));
67: exit(nw != lt);
68: }
69: /*
70: * open line - will return on carrier
71: */
72: if ((FD = open(DV, 2)) < 0) {
73: if (errno == EIO)
74: printf("lost carrier...");
75: else
76: printf("dialup line open failed...");
77: alarm(0);
78: kill(child, SIGKILL);
79: close(dn);
80: return (0);
81: }
82: alarm(0);
83: ioctl(dn, TIOCHPCL, 0);
84: signal(SIGALRM, SIG_DFL);
85: while ((nw = wait(<)) != child && nw != -1)
86: ;
87: fflush(stdout);
88: close(dn);
89: if (lt != 0) {
90: close(FD);
91: return (0);
92: }
93: return (1);
94: }
95:
96: alarmtr()
97: {
98:
99: alarm(0);
100: longjmp(jmpbuf, 1);
101: }
102:
103: /*
104: * Insurance, for some reason we don't seem to be
105: * hanging up...
106: */
107: dn_disconnect()
108: {
109:
110: sleep(2);
111: if (FD > 0)
112: ioctl(FD, TIOCCDTR, 0);
113: close(FD);
114: }
115:
116: dn_abort()
117: {
118:
119: sleep(2);
120: if (child > 0)
121: kill(child, SIGKILL);
122: if (dn > 0)
123: close(dn);
124: if (FD > 0)
125: ioctl(FD, TIOCCDTR, 0);
126: close(FD);
127: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.