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