home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Program Name: Stiletto */
- /* */
- /* File Name: TestModule.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-07-10 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "Aliases.h"
- #include "Resources.h"
- #include "string.h"
-
- #ifndef __CALLBACKROUTINES__
- #include "CallBackRoutines.h"
- #endif
-
- #ifndef __LOGWINDOW__
- #include "LogWindow.h"
- #endif
-
- #ifndef __TERMWINDOW__
- #include "TermWindow.h"
- #endif
-
- #include "TestModule.h"
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
- /****************************************** DEFINITIONS *****************************************/
-
- /****************************************** PROTOTYPES ******************************************/
-
- /******************************************** GLOBALS *******************************************/
-
- extern LogWindowPtr gLogWindow;
- extern TelWindowPtr gTelWindow;
-
- extern EntryPointUPP gEntryPointUPP;
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- void ExecuteAnyModule (void)
- {
- short numOfTypes = 1;
- StandardFileReply reply;
- SFTypeList typeList;
-
- typeList[0] = kModuleType;
-
- StandardGetFile (nil, numOfTypes, typeList, &reply);
-
- if (reply.sfGood)
- ExecuteModule (&reply.sfFile);
- }
-
-
- void ExecuteModule (FSSpecPtr theFile)
- {
- Handle theModule = nil;
- CHRSBlock *paramBlock;
- short savedResFile;
- short errCode;
- short moduleRefNum;
- Boolean targetIsFolder, wasAliased;
- Str255 name;
-
- if (paramBlock = (CHRSBlock *) NewPtrClear (sizeof (CHRSBlock)))
- {
- errCode = ResolveAliasFile (theFile, true, &targetIsFolder, &wasAliased);
-
- moduleRefNum = FSpOpenResFile (theFile, fsRdPerm);
-
- if (moduleRefNum != -1)
- {
- savedResFile = CurResFile ();
- UseResFile (moduleRefNum);
-
- theModule = Get1Resource (kModuleType, kModuleID);
- if (theModule != nil) {
- HLock (theModule);
-
- paramBlock->version = kTestModuleVersion;
-
- paramBlock->entryPoint = (UniversalProcPtr) gEntryPointUPP;
-
- (void) strncpy ((char *) name, (char *) &theFile->name[1], theFile->name[0]);
- name[theFile->name[0]] = '\0';
-
- PutLine (gLogWindow, "••••• %s started •••••", name);
-
- errCode = CallTestModuleProc ((TestModuleProcPtr) *theModule, paramBlock);
-
- switch (errCode)
- {
- case noErr :
- break;
- case kWrongVersion :
- PutLine (gLogWindow, "Incompatible module version");
- break;
- default :
- PutLine (gLogWindow, "Unable to execute test module : %d", errCode);
- }
- PutLine (gLogWindow, "••••• %s ended •••••", name);
-
- HUnlock (theModule);
- ReleaseResource (theModule);
- }
- else
- AlertUser ("\pUnable to find the CHRS resource", ResError());
-
- UseResFile (savedResFile);
- CloseResFile (moduleRefNum);
- }
- }
- }