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