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