1*34449Sbostic /* $Header: errmsg.c,v 2.3 87/05/12 11:46:32 ed Exp $ */
2*34449Sbostic 
3*34449Sbostic /* $Log:	errmsg.c,v $
4*34449Sbostic  * Revision 2.3  87/05/12  11:46:32  ed
5*34449Sbostic  * Change to use FilingSubset1_defs.h, new AuthenticationError problems.
6*34449Sbostic  *
7*34449Sbostic  * Revision 2.2  87/03/07  14:44:42  jqj
8*34449Sbostic  * set problem correctly.  Cardinal != Enum on most UNIX systems
9*34449Sbostic  *
10*34449Sbostic  * Revision 2.1  86/06/02  07:10:30  jqj
11*34449Sbostic  * print more information on unspecifiedError
12*34449Sbostic  *
13*34449Sbostic  * Revision 2.0  85/11/21  07:22:44  jqj
14*34449Sbostic  * 4.3BSD standard release
15*34449Sbostic  *
16*34449Sbostic  * Revision 1.1  85/11/20  14:19:04  jqj
17*34449Sbostic  * Initial revision
18*34449Sbostic  *
19*34449Sbostic  */
20*34449Sbostic #include "FilingSubset1_defs.h"
21*34449Sbostic 
22*34449Sbostic FilingErrMsg(Code, Message)
23*34449Sbostic 	int Code;
24*34449Sbostic 	char *Message;
25*34449Sbostic {
26*34449Sbostic 	static char *errmsgs[] = {
27*34449Sbostic 		"AttributeTypeError",
28*34449Sbostic 		"AttributeValueError",
29*34449Sbostic 		"ControlTypeError",
30*34449Sbostic 		"ControlValueError",
31*34449Sbostic 		"ScopeTypeError",
32*34449Sbostic 		"ScopeValueError",
33*34449Sbostic 		"AccessError",
34*34449Sbostic 		"AuthenticationError",
35*34449Sbostic 		"ConnectionError",
36*34449Sbostic 		"HandleError",
37*34449Sbostic 		"InsertionError",
38*34449Sbostic 		"ServiceError",
39*34449Sbostic 		"SessionError",
40*34449Sbostic 		"SpaceError",
41*34449Sbostic 		"TransferError",
42*34449Sbostic 		"UndefinedError",
43*34449Sbostic 		"RangeError" };
44*34449Sbostic 	static char *argproblems[] = {
45*34449Sbostic 	"illegal",
46*34449Sbostic 		"disallowed",
47*34449Sbostic 		"unreasonable",
48*34449Sbostic 		"unimplemented",
49*34449Sbostic 		"duplicated",
50*34449Sbostic 		"missing" };
51*34449Sbostic 	static char *accessproblems[] = {
52*34449Sbostic 		"accessRightsInsufficient",
53*34449Sbostic 		"accessRightsIndeterminate",
54*34449Sbostic 		"fileChanged",
55*34449Sbostic 		"fileDamaged",
56*34449Sbostic 		"fileInUse",
57*34449Sbostic 		"fileNotFound",
58*34449Sbostic 		"fileOpen" };
59*34449Sbostic 	static char *connectionproblems[] = {
60*34449Sbostic 		"noRoute",
61*34449Sbostic 		"noResponse",
62*34449Sbostic 		"transmissionHardware",
63*34449Sbostic 		"transportTimeout",
64*34449Sbostic 		"tooManyLocalConnections",
65*34449Sbostic 		"tooManyRemoteConnections",
66*34449Sbostic 		"missingCourier",
67*34449Sbostic 		"missingProgram",
68*34449Sbostic 		"missingProcedure",
69*34449Sbostic 		"protocolMismatch",
70*34449Sbostic 		"parameterInconsistency",
71*34449Sbostic 		"invalidMessage",
72*34449Sbostic 		"returnTimedOut",
73*34449Sbostic 		"otherCallProblem" };
74*34449Sbostic 	static char* handleproblems[] = {
75*34449Sbostic 		"invalid",
76*34449Sbostic 		"nullDisallowed",
77*34449Sbostic 		"directoryRequired" };
78*34449Sbostic 	static char *insertionproblems[] = {
79*34449Sbostic 		"positionUnavailable",
80*34449Sbostic 		"fileNotUnique",
81*34449Sbostic 		"loopInHierarchy" };
82*34449Sbostic 	static char *serviceproblems[] = {
83*34449Sbostic 		"cannotAuthenticate",
84*34449Sbostic 		"serviceFull",
85*34449Sbostic 		"serviceUnavailable",
86*34449Sbostic 		"sessionInUse" };
87*34449Sbostic 	static char *sessionproblems[] = {
88*34449Sbostic 		"tokenInvalid",
89*34449Sbostic 		"serviceAlreadySet" };
90*34449Sbostic 	static char *spaceproblems[] = {
91*34449Sbostic 		"allocationExceeded",
92*34449Sbostic 		"attributeAreadFull",
93*34449Sbostic 		"mediumFull" };
94*34449Sbostic 	static char *transferproblems[] = {
95*34449Sbostic 		"aborted",
96*34449Sbostic 		"checksumIncorrect",
97*34449Sbostic 		"formatIncorrect",
98*34449Sbostic 		"noRendevous",
99*34449Sbostic 		"wrongDirection" };
100*34449Sbostic 	static char *authenticationproblems[] = {
101*34449Sbostic 		"primaryCredentialsInvalid",
102*34449Sbostic 		"verifierInvalid",
103*34449Sbostic 		"verifierExpired",
104*34449Sbostic 		"verifierReused",
105*34449Sbostic 		"primaryCredentialsExpired",
106*34449Sbostic 		"inappropriatePrimaryCredentials",
107*34449Sbostic 		"secondaryCredentialsRequired",
108*34449Sbostic 		"secondaryCredentialsTypeInvalid",
109*34449Sbostic 		"secondaryCredentialsValueInvalid" };
110*34449Sbostic 	static char *rejectproblem[] = {
111*34449Sbostic 		"noSuchProgramNumber",
112*34449Sbostic 		"noSuchVersionNumber",
113*34449Sbostic 		"noSuchProcedureValue",
114*34449Sbostic 		"invalidArgument" };
115*34449Sbostic 	char *msg, *problemstr;
116*34449Sbostic 	int problem;
117*34449Sbostic 	char tempbuf[40];
118*34449Sbostic 
119*34449Sbostic 	if (Code < 1000) {
120*34449Sbostic 		if (Message != (char *) 0)
121*34449Sbostic 		  printf("ERROR: %s\n", Message);
122*34449Sbostic 		return;
123*34449Sbostic 	}
124*34449Sbostic 
125*34449Sbostic 	msg = "";
126*34449Sbostic 	problem = 0;
127*34449Sbostic 	if (Code-ERROR_OFFSET >= 0 && Code-ERROR_OFFSET <= 16) {
128*34449Sbostic 		msg = errmsgs[Code-ERROR_OFFSET];
129*34449Sbostic 	}
130*34449Sbostic 	switch (Code) {
131*34449Sbostic 	case AttributeTypeError:
132*34449Sbostic 	case AttributeValueError:
133*34449Sbostic 	case ControlTypeError:
134*34449Sbostic 	case ControlValueError:
135*34449Sbostic 	case ScopeTypeError:
136*34449Sbostic 	case ScopeValueError:
137*34449Sbostic /* the following fails because "type" is defined as "Filing4_type".  Argh!!
138*34449Sbostic /*		problem = (int) (((ScopeTypeErrorArgs *) Message)->problem);
139*34449Sbostic /*		problemstr = sprintf(tempbuf,"problem: %s; type: %d",
140*34449Sbostic /*				argproblems[problem],
141*34449Sbostic /*				((ScopeTypeErrorArgs *) Message)->type);
142*34449Sbostic /*		break;
143*34449Sbostic  */
144*34449Sbostic 	case RangeError:
145*34449Sbostic 		problem = (int) (((RangeErrorArgs *) Message)->problem);
146*34449Sbostic 		problemstr = argproblems[problem];
147*34449Sbostic 		break;
148*34449Sbostic 	case AccessError:
149*34449Sbostic 		problem = (int) (((AccessErrorArgs *) Message)->problem);
150*34449Sbostic 		problemstr = accessproblems[problem];
151*34449Sbostic 		  break;
152*34449Sbostic 	case AuthenticationError:
153*34449Sbostic 		problem = (int) (((AuthenticationErrorArgs *) Message)->problem);
154*34449Sbostic 		problemstr = authenticationproblems[problem];
155*34449Sbostic 		break;
156*34449Sbostic 	case ConnectionError:
157*34449Sbostic 		problem = (int) (((ConnectionErrorArgs *) Message)->problem);
158*34449Sbostic 		problemstr = connectionproblems[problem];
159*34449Sbostic 		break;
160*34449Sbostic 	case HandleError:
161*34449Sbostic 		problem = (int) (((HandleErrorArgs *) Message)->problem);
162*34449Sbostic 		problemstr = handleproblems[problem];
163*34449Sbostic 		break;
164*34449Sbostic 	case InsertionError:
165*34449Sbostic 		problem = (int) (((InsertionErrorArgs *) Message)->problem);
166*34449Sbostic 		problemstr = insertionproblems[problem];
167*34449Sbostic 		break;
168*34449Sbostic 	case ServiceError:
169*34449Sbostic 		problem = (int) (((ServiceErrorArgs *) Message)->problem);
170*34449Sbostic 		problemstr = serviceproblems[problem];
171*34449Sbostic 		break;
172*34449Sbostic 	case SessionError:
173*34449Sbostic 		problem = (int) (((SessionErrorArgs *) Message)->problem);
174*34449Sbostic 		problemstr = sessionproblems[problem];
175*34449Sbostic 		break;
176*34449Sbostic 	case SpaceError:
177*34449Sbostic 		problem = (int) (((SpaceErrorArgs *) Message)->problem);
178*34449Sbostic 		problemstr = spaceproblems[problem];
179*34449Sbostic 		break;
180*34449Sbostic 	case TransferError:
181*34449Sbostic 		problem = (int) (((TransferErrorArgs *) Message)->problem);
182*34449Sbostic 		problemstr = transferproblems[problem];
183*34449Sbostic 		break;
184*34449Sbostic 	case UndefinedError:
185*34449Sbostic 		problem = (int) (((UndefinedErrorArgs *) Message)->problem);
186*34449Sbostic 		problemstr = tempbuf;
187*34449Sbostic 		sprintf(problemstr,"number %d",problem);
188*34449Sbostic 		break;
189*34449Sbostic 	case REJECT_ERROR:
190*34449Sbostic 		msg = "Courier REJECT";
191*34449Sbostic 		problem = (int) (((rejectionDetails *) Message)->designator);
192*34449Sbostic 		if (problem <= 3)
193*34449Sbostic 			problemstr = rejectproblem[problem];
194*34449Sbostic 		else {
195*34449Sbostic 			problemstr = tempbuf;
196*34449Sbostic 			sprintf(problemstr,"unspecifiedError (%d)", problem);
197*34449Sbostic 		}
198*34449Sbostic 		break;
199*34449Sbostic 	case PROTOCOL_VIOLATION:
200*34449Sbostic 		problemstr = "Courier protocol violation";
201*34449Sbostic 		break;
202*34449Sbostic 	default:
203*34449Sbostic 		problemstr = tempbuf;
204*34449Sbostic 		sprintf(problemstr,"unexpected error number %d", Code);
205*34449Sbostic 		break;
206*34449Sbostic 	}
207*34449Sbostic 	printf("ERROR: %s, %s\n", msg, problemstr);
208*34449Sbostic }
209