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.
12 #pragma ident "%Z%%M% %I% %E% SMI"
16 extern acu_t acutable
[];
18 static acu_t
*acu
= NOACU
;
20 static void acuabort(int);
21 static acu_t
*acutype(char *);
22 static sigjmp_buf jmpbuf
;
25 * Establish connection for tip
27 * If DU is true, we should dial an ACU whose type is AT.
28 * The phone numbers are in PN, and the call unit is in CU.
30 * If the PN is an '@', then we consult the PHONES file for
31 * the phone numbers. This file is /etc/phones, unless overriden
32 * by an exported shell variable.
34 * The data base files must be in the format:
35 * host-name[ \t]*phone-number
36 * with the possibility of multiple phone numbers
37 * for a single host acting as a rotary (in the order
44 char *phnum
, string
[256];
50 * @ =>'s use data base in PHONES environment variable
51 * otherwise, use /etc/phones
53 if (sigsetjmp(jmpbuf
, 1)) {
54 (void) signal(SIGINT
, SIG_IGN
);
55 (void) signal(SIGQUIT
, SIG_IGN
);
56 (void) printf("\ncall aborted\n");
57 logent(value(HOST
), "", "", "call aborted");
59 boolean(value(VERBOSE
)) = FALSE
;
69 (void) signal(SIGINT
, acuabort
);
70 (void) signal(SIGQUIT
, acuabort
);
71 if ((acu
= acutype(AT
)) == NOACU
)
72 return ("unknown ACU type");
75 for (phnum
= cp
; *cp
&& *cp
!= '|'; cp
++)
80 if (conflag
= (*acu
->acu_dialer
)(phnum
, CU
)) {
81 logent(value(HOST
), phnum
, acu
->acu_name
,
85 logent(value(HOST
), phnum
, acu
->acu_name
,
91 (void) printf("%s: ", PH
);
92 return ("can't open phone number file");
95 while (fgets(string
, sizeof (string
), phfd
) != NOSTR
) {
98 for (cp
= string
; !any(*cp
, " \t\n"); cp
++)
101 return ("unrecognizable host name");
103 if (!equal(string
, value(HOST
)))
105 while (any(*cp
, " \t"))
108 return ("missing phone number");
109 for (phnum
= cp
; *cp
&& *cp
!= '|' && *cp
!= '\n'; cp
++)
113 if (conflag
= (*acu
->acu_dialer
)(phnum
, CU
)) {
114 logent(value(HOST
), phnum
, acu
->acu_name
,
118 logent(value(HOST
), phnum
, acu
->acu_name
,
124 logent(value(HOST
), "", acu
->acu_name
, "missing phone number");
127 return (tried
? "call failed" : "missing phone number");
131 disconnect(char *reason
)
135 if (reason
== NOSTR
) {
136 logent(value(HOST
), "", acu
->acu_name
, "call terminated");
137 if (boolean(value(VERBOSE
)))
138 (void) printf("\r\ndisconnecting...");
140 logent(value(HOST
), "", acu
->acu_name
, reason
);
141 (*acu
->acu_disconnect
)();
147 (void) signal(s
, SIG_IGN
);
148 siglongjmp(jmpbuf
, 1);
157 for (p
= acutable
; p
->acu_name
!= '\0'; p
++)
158 if (equal(s
, p
->acu_name
))