home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SampleINIT.c
-
- Contains: Implementation of SampleINIT.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <types.h>
- #include <resources.h>
- #include <events.h>
-
- #include <LibraryManager.h>
- #include <LibraryManagerUtilities.h>
-
- #include "ShowINITLibrary.h"
-
- #define kSampleIconID -4064
-
- /*————————————————————————————————————————————————————————————————————————————————————
- SampleINIT
-
- This is the begining of our INIT, it calls InitLibraryManager and displays an
- ICON for out INIT. But before we call InitLibraryManager, we must first provide an
- A5 world.
- ————————————————————————————————————————————————————————————————————————————————————*/
-
- pascal void SampleINIT()
- {
- /* InitCodeResource should be called before initlializing the LibraryManager
- This create an A5 world for the stand alone code resources( INIT, cdevs,...etec),
- and CleanupLibraryManager will dispose the A5 world */
-
- if( Button() ) /* a way to exit init */
- return;
-
- if (InitCodeResource() != kNoError) /* create & initialize the global world */
- {
- DebugStr("\pInitCodeResource failed.");
- return;
- }
-
-
- /* Now its safe to create a local instance of TLibraryManager if Library Manager
- has been installed. */
-
- if( InitLibraryManager(0, kCurrentZone, kNormalMemory) != kNoError )
- {
- DebugStr("\pInitLibraryManager failed.");
- FreeGlobalWorld();
- return;
- }
-
- // Stand alone code resources should always call EnterCodeResource before
- // making any ASLM or shared library calls just in case an exception
- // is thrown or the call wants to allocate memory of of the current
- // clients pool. It also allows you to access any globals you may have.
- EnterCodeResource();
-
- // We need to do a TRY to catch the exception that will be thrown if
- // the function set that ShowInit is implemented in can't be found
- // or loaded. We could also have done a LoadFunctionSet instead.
- TRY
- ShowInit( kSampleIconID ); /* call our function set here */
- CATCH_ALL
- DebugStr("\pShowInit threw an exception.");
- ENDTRY
-
- CleanupLibraryManager(); /* delete the our local TLibrary Manager instance */
- /* and disposes the A5 world */
-
- LeaveCodeResource();
- }
-