dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / tip / aculib / dn11.c
blob3c941b291c4f65df81627c2336ed27e698c77692
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /*
7 * Copyright (c) 1983 Regents of the University of California.
8 * All rights reserved. The Berkeley software License Agreement
9 * specifies the terms and conditions for redistribution.
12 #pragma ident "%Z%%M% %I% %E% SMI"
15 * Routines for dialing up on DN-11
17 #include "tip.h"
19 void alarmtr(void);
21 static sigjmp_buf jmpbuf;
22 static int child = -1, dn;
24 int
25 dn_dialer(char *num, char *acu)
27 int lt, nw;
28 int timelim;
29 struct termios buf;
31 if (boolean(value(VERBOSE)))
32 (void) printf("\nstarting call...");
33 if ((dn = open(acu, O_WRONLY)) < 0) {
34 if (errno == EBUSY)
35 (void) printf("line busy...");
36 else
37 (void) printf("acu open error...");
38 return (0);
40 if (sigsetjmp(jmpbuf, 1)) {
41 (void) kill(child, SIGKILL);
42 (void) close(dn);
43 return (0);
45 (void) signal(SIGALRM, (sig_handler_t)alarmtr);
46 timelim = 5 * strlen(num);
47 (void) alarm(timelim < 30 ? 30 : timelim);
48 if ((child = fork()) == 0) {
50 * ignore this stuff for aborts
52 (void) signal(SIGALRM, SIG_IGN);
53 (void) signal(SIGINT, SIG_IGN);
54 (void) signal(SIGQUIT, SIG_IGN);
55 (void) sleep(2);
56 nw = write(dn, num, lt = strlen(num));
57 exit(nw != lt);
60 * open line - will return on carrier
62 if ((FD = open(DV, O_RDWR)) < 0) {
63 if (errno == EIO)
64 (void) printf("lost carrier...");
65 else
66 (void) printf("dialup line open failed...");
67 (void) alarm(0);
68 (void) kill(child, SIGKILL);
69 (void) close(dn);
70 return (0);
72 (void) alarm(0);
73 (void) ioctl(dn, TCGETS, &buf);
74 buf.c_cflag |= HUPCL;
75 (void) ioctl(dn, TCSETSF, &buf);
76 (void) signal(SIGALRM, SIG_DFL);
77 while ((nw = wait(&lt)) != child && nw != -1)
79 (void) fflush(stdout);
80 (void) close(dn);
81 if (lt != 0) {
82 (void) close(FD);
83 return (0);
85 return (1);
88 void
89 alarmtr(void)
92 (void) alarm(0);
93 siglongjmp(jmpbuf, 1);
97 * Insurance, for some reason we don't seem to be
98 * hanging up...
100 void
101 dn_disconnect(void)
103 int dtr = TIOCM_DTR;
105 (void) sleep(2);
106 if (FD > 0)
107 (void) ioctl(FD, TIOCMBIC, &dtr);
108 (void) close(FD);
111 void
112 dn_abort(void)
114 int dtr = TIOCM_DTR;
116 (void) sleep(2);
117 if (child > 0)
118 (void) kill(child, SIGKILL);
119 if (dn > 0)
120 (void) close(dn);
121 if (FD > 0)
122 (void) ioctl(FD, TIOCMBIC, &dtr);
123 (void) close(FD);