xref: /illumos-gate/usr/src/cmd/bnu/dkerr.c (revision 1a2d662a91cee3bf82f41cd47c7ae6f3825d9db2)
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  *	Convert an error number from the Common Control into a string
32  */
33 #ifndef DIAL
34 	static char	SCCSID[] = "@(#)dkerr.c	2.6+BNU DKHOST 87/03/05";
35 #endif
36 /*
37  *	COMMKIT(TM) Software - Datakit(R) VCS Interface Release 2.0 V1
38  */
39 
40 #include "dk.h"
41 #include <sysexits.h>
42 
43 GLOBAL
44 char *dk_msgs[] = {
45 	"Call Failed",		/* code 0 - Something is Wrong */
46 	"All channels busy",	/* code 1 - busy */
47 	"Remote node not answering",	/* code 2 - trunk down */
48 	"Server not answering",	/* code 3 - termporary no dest */
49 	"Non-assigned number",	/* code 4 - permonent no dest (INTERT) */
50 	"All trunk channels busy",	/* code 5 - System Overload (REORT) */
51 	"Server already exists",	/* code 6 - already exists */
52 	"Access denied",		/* code 7 - denied by remote server */
53 	"",				/* code 8 - directory assistance req */
54 } ;
55 
56 GLOBAL
57 char 	*dialer_msgs[] = {
58 	"",
59 	"Please supply a valid phone number",	/* code 1 - phone # missing */
60 	"No response from auto-dialer. Try again",	/* code 2- bad port */
61 	"Auto dialer failed to initiate call. Try again", /* code 3 - dial failure */
62 	"No initial dial tone detected",	/* code 4 - bad telephone line */
63 	"No secondary dial tone detected",	/* code 5 - no sec. dial tone */
64 	"Dialed number is busy",	/* code 6 - busy signal detected */
65 	"No answer fron dialed number",	/* code 7 - auto-dialer didn't get ans. */
66 	"No carrier tone was detected",	/* code 8 - no carrier tone det. */
67 	"Could not complete your call. Try again.",	/* code 9 - auto dialer didn't complete */
68 	"Wrong number", /*code 10 - bad number*/
69 };
70 
71 GLOBAL
72 char *dk_hostmsgs[] = {
73 	"Dkserver: Can't open line: See System Administrator", /* Code 130 */
74 	"", /* Code 131 */
75 	"", /* Code 132 */
76 	"Dkserver: Dksrvtab not readable: See System Administrator",		/* Code 133 */
77 	"Dkserver: Can't chroot: See System Administrator",
78 };
79 
80 #define NDKMSGS	(sizeof(dk_msgs)/sizeof(dk_msgs[0]))
81 #define NDKHOMSGS	(sizeof(dk_hostmsgs)/sizeof(dk_hostmsgs[0]))
82 #define DIALERCODE	11
83 
84 	GLOBAL int	dk_verbose = 1;	/* Print error messages on stderr if 1 */
85 	GLOBAL int	dk_errno = 0;	/* Saved error number from iocb.req_error */
86 
87 	static char	generalmsg[32];
88 
89 GLOBAL char *
90 dkerr(err)
91 {
92 
93 	if ((err & 0377) == DIALERCODE)
94 		return(dialer_msgs[err>>8]);
95 
96 	if ((err >= 0 && err <= 99) && err < NDKMSGS && dk_msgs[err] != 0)
97 		return(dk_msgs[err]);
98 	if ((err >= 100) && (err < (NDKHOMSGS + 130)) && (dk_hostmsgs[err-130] != 0))
99 		return(dk_hostmsgs[err-130]);
100 	sprintf(generalmsg, "Error code %d", err) ;
101 	return(generalmsg);
102 }
103 
104 GLOBAL int
105 dkerrmap(dkcode)
106 {
107 	if (dkcode < 0)
108 		return(-dkcode);
109 
110 	switch(dkcode){
111 	case 0:
112 	case 1:
113 	case 2:
114 	case 3:
115 	case 5:
116 		return(EX_TEMPFAIL);
117 
118 	case 4:
119 		return(EX_NOHOST);
120 
121 	case 6:
122 		return(EX_CANTCREAT);
123 
124 	case 7:
125 		return(EX_NOPERM);
126 
127 	default:
128 		return(EX_DATAERR);
129 	}
130 }
131