xref: /illumos-gate/usr/src/cmd/bnu/dkerr.c (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1994 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  *	Convert an error number from the Common Control into a string
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate #ifndef DIAL
34*7c478bd9Sstevel@tonic-gate 	static char	SCCSID[] = "@(#)dkerr.c	2.6+BNU DKHOST 87/03/05";
35*7c478bd9Sstevel@tonic-gate #endif
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  *	COMMKIT(TM) Software - Datakit(R) VCS Interface Release 2.0 V1
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include "dk.h"
41*7c478bd9Sstevel@tonic-gate #include <sysexits.h>
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate GLOBAL
44*7c478bd9Sstevel@tonic-gate char *dk_msgs[] = {
45*7c478bd9Sstevel@tonic-gate 	"Call Failed",		/* code 0 - Something is Wrong */
46*7c478bd9Sstevel@tonic-gate 	"All channels busy",	/* code 1 - busy */
47*7c478bd9Sstevel@tonic-gate 	"Remote node not answering",	/* code 2 - trunk down */
48*7c478bd9Sstevel@tonic-gate 	"Server not answering",	/* code 3 - termporary no dest */
49*7c478bd9Sstevel@tonic-gate 	"Non-assigned number",	/* code 4 - permonent no dest (INTERT) */
50*7c478bd9Sstevel@tonic-gate 	"All trunk channels busy",	/* code 5 - System Overload (REORT) */
51*7c478bd9Sstevel@tonic-gate 	"Server already exists",	/* code 6 - already exists */
52*7c478bd9Sstevel@tonic-gate 	"Access denied",		/* code 7 - denied by remote server */
53*7c478bd9Sstevel@tonic-gate 	"",				/* code 8 - directory assistance req */
54*7c478bd9Sstevel@tonic-gate } ;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate GLOBAL
57*7c478bd9Sstevel@tonic-gate char 	*dialer_msgs[] = {
58*7c478bd9Sstevel@tonic-gate 	"",
59*7c478bd9Sstevel@tonic-gate 	"Please supply a valid phone number",	/* code 1 - phone # missing */
60*7c478bd9Sstevel@tonic-gate 	"No response from auto-dialer. Try again",	/* code 2- bad port */
61*7c478bd9Sstevel@tonic-gate 	"Auto dialer failed to initiate call. Try again", /* code 3 - dial failure */
62*7c478bd9Sstevel@tonic-gate 	"No initial dial tone detected",	/* code 4 - bad telephone line */
63*7c478bd9Sstevel@tonic-gate 	"No secondary dial tone detected",	/* code 5 - no sec. dial tone */
64*7c478bd9Sstevel@tonic-gate 	"Dialed number is busy",	/* code 6 - busy signal detected */
65*7c478bd9Sstevel@tonic-gate 	"No answer fron dialed number",	/* code 7 - auto-dialer didn't get ans. */
66*7c478bd9Sstevel@tonic-gate 	"No carrier tone was detected",	/* code 8 - no carrier tone det. */
67*7c478bd9Sstevel@tonic-gate 	"Could not complete your call. Try again.",	/* code 9 - auto dialer didn't complete */
68*7c478bd9Sstevel@tonic-gate 	"Wrong number", /*code 10 - bad number*/
69*7c478bd9Sstevel@tonic-gate };
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate GLOBAL
72*7c478bd9Sstevel@tonic-gate char *dk_hostmsgs[] = {
73*7c478bd9Sstevel@tonic-gate 	"Dkserver: Can't open line: See System Administrator", /* Code 130 */
74*7c478bd9Sstevel@tonic-gate 	"", /* Code 131 */
75*7c478bd9Sstevel@tonic-gate 	"", /* Code 132 */
76*7c478bd9Sstevel@tonic-gate 	"Dkserver: Dksrvtab not readable: See System Administrator",		/* Code 133 */
77*7c478bd9Sstevel@tonic-gate 	"Dkserver: Can't chroot: See System Administrator",
78*7c478bd9Sstevel@tonic-gate };
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate #define NDKMSGS	(sizeof(dk_msgs)/sizeof(dk_msgs[0]))
81*7c478bd9Sstevel@tonic-gate #define NDKHOMSGS	(sizeof(dk_hostmsgs)/sizeof(dk_hostmsgs[0]))
82*7c478bd9Sstevel@tonic-gate #define DIALERCODE	11
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate 	GLOBAL int	dk_verbose = 1;	/* Print error messages on stderr if 1 */
85*7c478bd9Sstevel@tonic-gate 	GLOBAL int	dk_errno = 0;	/* Saved error number from iocb.req_error */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate 	static char	generalmsg[32];
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate GLOBAL char *
dkerr(err)90*7c478bd9Sstevel@tonic-gate dkerr(err)
91*7c478bd9Sstevel@tonic-gate {
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate 	if ((err & 0377) == DIALERCODE)
94*7c478bd9Sstevel@tonic-gate 		return(dialer_msgs[err>>8]);
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate 	if ((err >= 0 && err <= 99) && err < NDKMSGS && dk_msgs[err] != 0)
97*7c478bd9Sstevel@tonic-gate 		return(dk_msgs[err]);
98*7c478bd9Sstevel@tonic-gate 	if ((err >= 100) && (err < (NDKHOMSGS + 130)) && (dk_hostmsgs[err-130] != 0))
99*7c478bd9Sstevel@tonic-gate 		return(dk_hostmsgs[err-130]);
100*7c478bd9Sstevel@tonic-gate 	sprintf(generalmsg, "Error code %d", err) ;
101*7c478bd9Sstevel@tonic-gate 	return(generalmsg);
102*7c478bd9Sstevel@tonic-gate }
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate GLOBAL int
dkerrmap(dkcode)105*7c478bd9Sstevel@tonic-gate dkerrmap(dkcode)
106*7c478bd9Sstevel@tonic-gate {
107*7c478bd9Sstevel@tonic-gate 	if (dkcode < 0)
108*7c478bd9Sstevel@tonic-gate 		return(-dkcode);
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 	switch(dkcode){
111*7c478bd9Sstevel@tonic-gate 	case 0:
112*7c478bd9Sstevel@tonic-gate 	case 1:
113*7c478bd9Sstevel@tonic-gate 	case 2:
114*7c478bd9Sstevel@tonic-gate 	case 3:
115*7c478bd9Sstevel@tonic-gate 	case 5:
116*7c478bd9Sstevel@tonic-gate 		return(EX_TEMPFAIL);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 	case 4:
119*7c478bd9Sstevel@tonic-gate 		return(EX_NOHOST);
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate 	case 6:
122*7c478bd9Sstevel@tonic-gate 		return(EX_CANTCREAT);
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	case 7:
125*7c478bd9Sstevel@tonic-gate 		return(EX_NOPERM);
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate 	default:
128*7c478bd9Sstevel@tonic-gate 		return(EX_DATAERR);
129*7c478bd9Sstevel@tonic-gate 	}
130*7c478bd9Sstevel@tonic-gate }
131