home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-19 | 2.5 KB | 100 lines | [TEXT/CWIE] |
- //*****************************************************************
- //* Error string ('Estr') resource handler
- //* by Mark Sproul
- //* sproul@eos.ap.org
- //*
- //* This is a collection of 'Estr' resources and code to use them
- //*
- //* Simply include the desired resource files in your project and
- //* call the GetErrorString or DisplayErrorCode
- //* as needed with the error number.
- //*
- //* Estr.1.0.rsrc Came from some ftp site someplace, I dont remember
- //* This contains most of the basic error strings for most system stuff
- //* You will probably always need this one,
- //*
- //* The rest are specific to extras that you may or may not be using
- //*
- //* The rest of them I created
- //*
- //* Estr.AOCE.rsrc Error msgs for AOCE
- //* Estr.QuickTake.rsrc Error msgs for QuickTake camera drivers
- //* Estr.QuickTime.rsrc Error msgs for QuickTime
- //* I am working on more and will release them as they are finished
- //* Also, a greatly enhanced version of the AOCE errors will be
- //* available soon. I will also be doing a QD3D version.
- //*
- //* Permission is granted to use this for what ever you like in your applications.
- //* If you distribute this to others, please include this notice.
- //*
- //* If you create more Estr resource files, please forward them to me so I can
- //* keep a collection of them.
- //*****************************************************************
-
- #include <stdio.h>
- #include <string.h>
-
-
- #ifndef __TYPES__
- #include <types.h>
- #endif
- #ifndef __RESOURCES__
- #include <resources.h>
- #endif
- #ifndef __STRINGS__
- #include <strings.h>
- #endif
-
- #include "CtoPfunc.proto.h"
- #include "ErrorString.h"
- #include "utilities.proto.h"
-
- #define kAdviseAlert 9999
-
- //*****************************************************
- static void PutAlertMessage(Str255 alrtMsg)
- {
- InitCursor();
- ParamText(alrtMsg, "\p", "\p", "\p");
- Alert(kAdviseAlert, nil);
- }
-
-
-
- //*****************************************************************
- void GetErrorString(OSErr theError, Str255 returnString)
- {
- Handle rHandle;
- long byteCount;
- char *strPtr;
-
- rHandle = GetResource('Estr', theError);
- if (rHandle)
- {
- strPtr = *rHandle;
- byteCount = strPtr[0] + 1;
-
- BlockMove(strPtr, returnString, byteCount);
-
- ReleaseResource(rHandle);
- }
- else
- {
- sprintf((char *)returnString, "Unknown Error (%d), Error msg Not Found", theError);
- CtoPstr((char *)returnString);
- }
- }
-
-
- //*****************************************************************
- void DisplayErrorCode(OSErr theError)
- {
- Str255 errMsg;
-
- if (theError != 0)
- {
- GetErrorString(theError, errMsg);
-
- PutAlertMessage(errMsg);
- }
- }