#ifdef __cplusplus extern "C" { #endif #ifndef kGenericError #define kGenericError -1 #endif extern char *gErrorMessage; void SetErrorMessage(const char *theErrorMessage); void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt); void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt); void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr); void AppendCStrToErrorMessage(const char *theErrorMessage); void AppendLongIntToErrorMessage(const long theLongInt); char *GetErrorMessage(void); OSErr GetErrorMessageInNewHandle(Handle *inoutHandle); OSErr GetErrorMessageInExistingHandle(Handle inoutHandle); OSErr AppendErrorMessageToHandle(Handle inoutHandle); #ifdef __EXCEPTIONS_ENABLED__ void ThrowErrorMessageException(void); #endif // A bunch of evil macros that would be uneccessary if I were always using C++ ! #define SetErrorMessageAndBailIfNil(theArg,theMessage) \ { \ if (theArg == nil) \ { \ SetErrorMessage(theMessage); \ errCode = kGenericError; \ goto EXITPOINT; \ } \ } #define SetErrorMessageAndBail(theMessage) \ { \ SetErrorMessage(theMessage); \ errCode = kGenericError; \ goto EXITPOINT; \ } #define SetErrorMessageAndLongIntAndBail(theMessage,theLongInt) \ { \ SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \ errCode = kGenericError; \ goto EXITPOINT; \ } #define SetErrorMessageAndLongIntAndBailIfError(theErrCode,theMessage,theLongInt) \ { \ if (theErrCode != noErr) \ { \ SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \ errCode = theErrCode; \ goto EXITPOINT; \ } \ } #define SetErrorMessageCStrLongIntAndBailIfError(theErrCode,theMessage,theCStr,theLongInt) \ { \ if (theErrCode != noErr) \ { \ SetErrorMessageAndCStrAndLongInt(theMessage,theCStr,theLongInt); \ errCode = theErrCode; \ goto EXITPOINT; \ } \ } #define SetErrorMessageAndCStrAndBail(theMessage,theCStr) \ { \ SetErrorMessageAndCStr(theMessage,theCStr); \ errCode = kGenericError; \ goto EXITPOINT; \ } #define SetErrorMessageAndBailIfError(theErrCode,theMessage) \ { \ if (theErrCode != noErr) \ { \ SetErrorMessage(theMessage); \ errCode = theErrCode; \ goto EXITPOINT; \ } \ } #define SetErrorMessageAndLongIntAndBailIfNil(theArg,theMessage,theLongInt) \ { \ if (theArg == nil) \ { \ SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \ errCode = kGenericError; \ goto EXITPOINT; \ } \ } #define BailIfError(theErrCode) \ { \ if ((theErrCode) != noErr) \ { \ goto EXITPOINT; \ } \ } #define SetErrCodeAndBail(theErrCode) \ { \ errCode = theErrCode; \ \ goto EXITPOINT; \ } #define SetErrorCodeAndMessageAndBail(theErrCode,theMessage) \ { \ SetErrorMessage(theMessage); \ errCode = theErrCode; \ goto EXITPOINT; \ } #define BailNow() \ { \ errCode = kGenericError; \ goto EXITPOINT; \ } #ifdef __cplusplus } #endif f='#n24'>24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141