2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
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.
14 extern acu_t acutable
[];
16 static acu_t
*acu
= NOACU
;
18 static void acuabort(int);
19 static acu_t
*acutype(char *);
20 static sigjmp_buf jmpbuf
;
23 * Establish connection for tip
25 * If DU is true, we should dial an ACU whose type is AT.
26 * The phone numbers are in PN, and the call unit is in CU.
28 * If the PN is an '@', then we consult the PHONES file for
29 * the phone numbers. This file is /etc/phones, unless overriden
30 * by an exported shell variable.
32 * The data base files must be in the format:
33 * host-name[ \t]*phone-number
34 * with the possibility of multiple phone numbers
35 * for a single host acting as a rotary (in the order
42 char *phnum
, string
[256];
48 * @ =>'s use data base in PHONES environment variable
49 * otherwise, use /etc/phones
51 if (sigsetjmp(jmpbuf
, 1)) {
52 (void) signal(SIGINT
, SIG_IGN
);
53 (void) signal(SIGQUIT
, SIG_IGN
);
54 (void) printf("\ncall aborted\n");
55 logent(value(HOST
), "", "", "call aborted");
57 boolean(value(VERBOSE
)) = FALSE
;
67 (void) signal(SIGINT
, acuabort
);
68 (void) signal(SIGQUIT
, acuabort
);
69 if ((acu
= acutype(AT
)) == NOACU
)
70 return ("unknown ACU type");
73 for (phnum
= cp
; *cp
&& *cp
!= '|'; cp
++)
78 if (conflag
= (*acu
->acu_dialer
)(phnum
, CU
)) {
79 logent(value(HOST
), phnum
, acu
->acu_name
,
83 logent(value(HOST
), phnum
, acu
->acu_name
,
89 (void) printf("%s: ", PH
);
90 return ("can't open phone number file");
93 while (fgets(string
, sizeof (string
), phfd
) != NOSTR
) {
96 for (cp
= string
; !any(*cp
, " \t\n"); cp
++)
99 return ("unrecognizable host name");
101 if (!equal(string
, value(HOST
)))
103 while (any(*cp
, " \t"))
106 return ("missing phone number");
107 for (phnum
= cp
; *cp
&& *cp
!= '|' && *cp
!= '\n'; cp
++)
111 if (conflag
= (*acu
->acu_dialer
)(phnum
, CU
)) {
112 logent(value(HOST
), phnum
, acu
->acu_name
,
116 logent(value(HOST
), phnum
, acu
->acu_name
,
122 logent(value(HOST
), "", acu
->acu_name
, "missing phone number");
125 return (tried
? "call failed" : "missing phone number");
129 disconnect(char *reason
)
133 if (reason
== NOSTR
) {
134 logent(value(HOST
), "", acu
->acu_name
, "call terminated");
135 if (boolean(value(VERBOSE
)))
136 (void) printf("\r\ndisconnecting...");
138 logent(value(HOST
), "", acu
->acu_name
, reason
);
139 (*acu
->acu_disconnect
)();
145 (void) signal(s
, SIG_IGN
);
146 siglongjmp(jmpbuf
, 1);
155 for (p
= acutable
; p
->acu_name
!= NULL
; p
++)
156 if (equal(s
, p
->acu_name
))