134452Sbostic /* $Header: errmsg.c,v 2.2 87/03/07 14:44:42 jqj Exp $ */
234452Sbostic 
334452Sbostic /* $Log:	errmsg.c,v $
434452Sbostic  * Revision 2.2  87/03/07  14:44:42  jqj
534452Sbostic  * set problem correctly.  Cardinal != Enum on most UNIX systems
634452Sbostic  *
734452Sbostic  * Revision 2.1  86/06/02  07:10:30  jqj
834452Sbostic  * print more information on unspecifiedError
934452Sbostic  *
1034452Sbostic  * Revision 2.0  85/11/21  07:22:44  jqj
1134452Sbostic  * 4.3BSD standard release
1234452Sbostic  *
1334452Sbostic  * Revision 1.1  85/11/20  14:19:04  jqj
1434452Sbostic  * Initial revision
1534452Sbostic  *
1634452Sbostic  */
1734452Sbostic #include "Filing4_defs.h"
1834452Sbostic 
FilingErrMsg(Code,Message)1934452Sbostic FilingErrMsg(Code, Message)
2034452Sbostic 	int Code;
2134452Sbostic 	char *Message;
2234452Sbostic {
2334452Sbostic 	static char *errmsgs[] = {
2434452Sbostic 		"AttributeTypeError",
2534452Sbostic 		"AttributeValueError",
2634452Sbostic 		"ControlTypeError",
2734452Sbostic 		"ControlValueError",
2834452Sbostic 		"ScopeTypeError",
2934452Sbostic 		"ScopeValueError",
3034452Sbostic 		"AccessError",
3134452Sbostic 		"AuthenticationError",
3234452Sbostic 		"ConnectionError",
3334452Sbostic 		"HandleError",
3434452Sbostic 		"InsertionError",
3534452Sbostic 		"ServiceError",
3634452Sbostic 		"SessionError",
3734452Sbostic 		"SpaceError",
3834452Sbostic 		"TransferError",
3934452Sbostic 		"UndefinedError",
4034452Sbostic 		"RangeError" };
4134452Sbostic 	static char *argproblems[] = {
4234452Sbostic 	"illegal",
4334452Sbostic 		"disallowed",
4434452Sbostic 		"unreasonable",
4534452Sbostic 		"unimplemented",
4634452Sbostic 		"duplicated",
4734452Sbostic 		"missing" };
4834452Sbostic 	static char *accessproblems[] = {
4934452Sbostic 		"accessRightsInsufficient",
5034452Sbostic 		"accessRightsIndeterminate",
5134452Sbostic 		"fileChanged",
5234452Sbostic 		"fileDamaged",
5334452Sbostic 		"fileInUse",
5434452Sbostic 		"fileNotFound",
5534452Sbostic 		"fileOpen" };
5634452Sbostic 	static char *connectionproblems[] = {
5734452Sbostic 		"noRoute",
5834452Sbostic 		"noResponse",
5934452Sbostic 		"transmissionHardware",
6034452Sbostic 		"transportTimeout",
6134452Sbostic 		"tooManyLocalConnections",
6234452Sbostic 		"tooManyRemoteConnections",
6334452Sbostic 		"missingCourier",
6434452Sbostic 		"missingProgram",
6534452Sbostic 		"missingProcedure",
6634452Sbostic 		"protocolMismatch",
6734452Sbostic 		"parameterInconsistency",
6834452Sbostic 		"invalidMessage",
6934452Sbostic 		"returnTimedOut",
7034452Sbostic 		"otherCallProblem" };
7134452Sbostic 	static char* handleproblems[] = {
7234452Sbostic 		"invalid",
7334452Sbostic 		"nullDisallowed",
7434452Sbostic 		"directoryRequired" };
7534452Sbostic 	static char *insertionproblems[] = {
7634452Sbostic 		"positionUnavailable",
7734452Sbostic 		"fileNotUnique",
7834452Sbostic 		"loopInHierarchy" };
7934452Sbostic 	static char *serviceproblems[] = {
8034452Sbostic 		"cannotAuthenticate",
8134452Sbostic 		"serviceFull",
8234452Sbostic 		"serviceUnavailable",
8334452Sbostic 		"sessionInUse" };
8434452Sbostic 	static char *sessionproblems[] = {
8534452Sbostic 		"tokenInvalid",
8634452Sbostic 		"serviceAlreadySet" };
8734452Sbostic 	static char *spaceproblems[] = {
8834452Sbostic 		"allocationExceeded",
8934452Sbostic 		"attributeAreadFull",
9034452Sbostic 		"mediumFull" };
9134452Sbostic 	static char *transferproblems[] = {
9234452Sbostic 		"aborted",
9334452Sbostic 		"checksumIncorrect",
9434452Sbostic 		"formatIncorrect",
9534452Sbostic 		"noRendevous",
9634452Sbostic 		"wrongDirection" };
9734452Sbostic 	static char *authenticationproblems[] = {
9834452Sbostic 		"credentialsInvalid",
9934452Sbostic 		"verifierInvalid",
10034452Sbostic 		"verifierExpiered",
10134452Sbostic 		"verifierReused",
10234452Sbostic 		"credentialsExpired",
10334452Sbostic 		"inappropriateCredentials" };
10434452Sbostic 	static char *rejectproblem[] = {
10534452Sbostic 		"noSuchProgramNumber",
10634452Sbostic 		"noSuchVersionNumber",
10734452Sbostic 		"noSuchProcedureValue",
10834452Sbostic 		"invalidArgument" };
10934452Sbostic 	char *msg, *problemstr;
11034452Sbostic 	int problem;
11134452Sbostic 	char tempbuf[40];
11234452Sbostic 
11334452Sbostic 	if (Code < 1000) {
11434452Sbostic 		if (Message != (char *) 0)
11534452Sbostic 		  printf("ERROR: %s\n", Message);
11634452Sbostic 		return;
11734452Sbostic 	}
11834452Sbostic 
11934452Sbostic 	msg = "";
12034452Sbostic 	problem = 0;
12134452Sbostic 	if (Code-ERROR_OFFSET >= 0 && Code-ERROR_OFFSET <= 16) {
12234452Sbostic 		msg = errmsgs[Code-ERROR_OFFSET];
12334452Sbostic 	}
12434452Sbostic 	switch (Code) {
12534452Sbostic 	case AttributeTypeError:
12634452Sbostic 	case AttributeValueError:
12734452Sbostic 	case ControlTypeError:
12834452Sbostic 	case ControlValueError:
12934452Sbostic 	case ScopeTypeError:
13034452Sbostic 	case ScopeValueError:
13134452Sbostic /* the following fails because "type" is defined as "Filing4_type".  Argh!!
13234452Sbostic /*		problem = (int) (((ScopeTypeErrorArgs *) Message)->problem);
133*34453Sbostic /*		(void)sprintf(tempbuf,"problem: %s; type: %d",
13434452Sbostic /*				argproblems[problem],
13534452Sbostic /*				((ScopeTypeErrorArgs *) Message)->type);
136*34453Sbostic /*		problemstr = tempbuf;
13734452Sbostic /*		break;
13834452Sbostic  */
13934452Sbostic 	case RangeError:
14034452Sbostic 		problem = (int) (((RangeErrorArgs *) Message)->problem);
14134452Sbostic 		problemstr = argproblems[problem];
14234452Sbostic 		break;
14334452Sbostic 	case AccessError:
14434452Sbostic 		problem = (int) (((AccessErrorArgs *) Message)->problem);
14534452Sbostic 		problemstr = accessproblems[problem];
14634452Sbostic 		  break;
14734452Sbostic 	case AuthenticationError:
14834452Sbostic 		problem = (int) (((AuthenticationErrorArgs *) Message)->problem);
14934452Sbostic 		problemstr = authenticationproblems[problem];
15034452Sbostic 		break;
15134452Sbostic 	case ConnectionError:
15234452Sbostic 		problem = (int) (((ConnectionErrorArgs *) Message)->problem);
15334452Sbostic 		problemstr = connectionproblems[problem];
15434452Sbostic 		break;
15534452Sbostic 	case HandleError:
15634452Sbostic 		problem = (int) (((HandleErrorArgs *) Message)->problem);
15734452Sbostic 		problemstr = handleproblems[problem];
15834452Sbostic 		break;
15934452Sbostic 	case InsertionError:
16034452Sbostic 		problem = (int) (((InsertionErrorArgs *) Message)->problem);
16134452Sbostic 		problemstr = insertionproblems[problem];
16234452Sbostic 		break;
16334452Sbostic 	case ServiceError:
16434452Sbostic 		problem = (int) (((ServiceErrorArgs *) Message)->problem);
16534452Sbostic 		problemstr = serviceproblems[problem];
16634452Sbostic 		break;
16734452Sbostic 	case SessionError:
16834452Sbostic 		problem = (int) (((SessionErrorArgs *) Message)->problem);
16934452Sbostic 		problemstr = sessionproblems[problem];
17034452Sbostic 		break;
17134452Sbostic 	case SpaceError:
17234452Sbostic 		problem = (int) (((SpaceErrorArgs *) Message)->problem);
17334452Sbostic 		problemstr = spaceproblems[problem];
17434452Sbostic 		break;
17534452Sbostic 	case TransferError:
17634452Sbostic 		problem = (int) (((TransferErrorArgs *) Message)->problem);
17734452Sbostic 		problemstr = transferproblems[problem];
17834452Sbostic 		break;
17934452Sbostic 	case UndefinedError:
18034452Sbostic 		problem = (int) (((UndefinedErrorArgs *) Message)->problem);
18134452Sbostic 		problemstr = tempbuf;
18234452Sbostic 		sprintf(problemstr,"number %d",problem);
18334452Sbostic 		break;
18434452Sbostic 	case REJECT_ERROR:
18534452Sbostic 		msg = "Courier REJECT";
18634452Sbostic 		problem = (int) (((rejectionDetails *) Message)->designator);
18734452Sbostic 		if (problem <= 3)
18834452Sbostic 			problemstr = rejectproblem[problem];
18934452Sbostic 		else {
19034452Sbostic 			problemstr = tempbuf;
19134452Sbostic 			sprintf(problemstr,"unspecifiedError (%d)", problem);
19234452Sbostic 		}
19334452Sbostic 		break;
19434452Sbostic 	case PROTOCOL_VIOLATION:
19534452Sbostic 		problemstr = "Courier protocol violation";
19634452Sbostic 		break;
19734452Sbostic 	default:
19834452Sbostic 		problemstr = tempbuf;
19934452Sbostic 		sprintf(problemstr,"unexpected error number %d", Code);
20034452Sbostic 		break;
20134452Sbostic 	}
20234452Sbostic 	printf("ERROR: %s, %s\n", msg, problemstr);
20334452Sbostic }
204