/****************************************************************************** File: WorkshopModule.c Contains: This file contains the traps for calling functions within Image Workshop. Written by: Brian Powell Copyright: © 1994 by Brian Powell, all rights reserved. WARNING: DO NOT ALTER THIS FILE, IT WILL CERTAINLY GAURANTEE THAT YOUR MODULE WILL NOT WORK WITH IMAGE WORKSHOP. ******************************************************************************/ // Include Files #include "WorkshopModule.h" /****************************************************************************** * main * * This is the entry point of the external code. Here, we figure out where * our code will go. ******************************************************************************/ pascal short main(short command, ExternalProcPtrs functions, Ptr data1, Ptr data2, Handle *myData) { short error=0; // Set up the registers #ifdef __MWERKS__ long oldA4=SetCurrentA4(); #else RememberA0(); SetUpA4(); #endif // Figure out what we're supposed to do switch(command) { case kInitCode: error = ModuleInit(functions, data1, data2, myData); break; case kReadFile: error = ModuleRead(functions, data1, data2, myData); break; case kSaveFile: error = ModuleSave(functions, data1, data2, myData); break; case kExecuteCode: error = ModuleExecute(functions, data1, data2, myData); break; case kDispose: error = ModuleDispose(functions, data1, data2, myData); break; case kProcessTask: error = ModuleProcessTask(functions, data1, data2, myData); break; case kCancelTask: error = ModuleCancelTask(functions, data1, data2, myData); break; default: error = kCommandNotImplemented; break; } // Restore the registers #ifdef __MWERKS__ SetA4(oldA4); // restore A4 to saved value before returning #else RestoreA4(); #endif // Return any errors return (error); }