home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 3.3 KB | 125 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWLbInit.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #if defined(SYMANTEC_CPLUS) && defined(FW_BUILD_MAC)
- #define ODFCFMINIT PartCFMInit
- #if !FW_LIB_EXPORT_PRAGMAS
- #pragma internal on
- #endif
- #endif
-
- //========================================================================================
- // Prototypes
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- extern "C" pascal OSErr ODFCFMINIT (CFragInitBlockPtr initBlkPtr);
- extern "C" pascal void ODFCFMTERM (void);
-
- #if GENERATINGPOWERPC
-
- #ifdef __MWERKS__
- extern "C" void __sinit();
- extern "C" void __destroy_global_chain(void);
- #elif defined __MRC__
- extern "C" void __CPlusInit();
- #endif
-
- #endif // GENERATINGPOWERPC
-
- #endif // FW_BUILD_MAC
-
- //========================================================================================
- // Global Variable
- //========================================================================================
- // FW_gInstance is initialized in DLLMain for Windows
- // FW_gInstance is defined in FWCFMRes.cpp for the Mac
- #ifdef FW_BUILD_WIN
- FW_Instance FW_gInstance = NULL;
- #endif
-
- //========================================================================================
- // Initialization methods
- //========================================================================================
-
- #ifdef FW_BUILD_WIN32
- //----------------------------------------------------------------------------------------
- // DllMain
- //----------------------------------------------------------------------------------------
- extern "C" BOOL WINAPI DllMain(HINSTANCE hDLL,
- DWORD dwReason,
- LPVOID /* lpReserved */)
- {
- if(dwReason == DLL_PROCESS_ATTACH)
- {
- // Save instance handle for future use
- FW_gInstance = hDLL;
- }
-
- return TRUE;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // ODFCFMINIT
- //----------------------------------------------------------------------------------------
- // Has to be upper case because of the 68K Linker
-
- extern "C" pascal OSErr ODFCFMINIT(CFragInitBlockPtr initBlkPtr)
- {
- #ifdef FW_DEBUG
- #define FW_COMMAND 0x37
-
- KeyMap theKeyMap;
- ::GetKeys(theKeyMap);
- const unsigned char *theKeys = (const unsigned char *) theKeyMap;
- if ((theKeys[FW_COMMAND >> 3] >> (FW_COMMAND & 7)) & 1)
- ::DebugStr("\pODFCFMInit");
- #endif
-
- // Shared libraries don't get there static objects initialized correctly without
- // calling __sinit or __CPlusInit for MetroWerks or MrC respectively.
-
- #if GENERATINGPOWERPC
- #ifdef __MWERKS__
- __sinit();
- #elif defined __MRC__
- __CPlusInit();
- #endif
- #endif
-
- OSErr err = InitLibraryResources(initBlkPtr);
-
- return err;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // ODFCFMTERM
- //----------------------------------------------------------------------------------------
-
- extern "C" pascal void ODFCFMTERM(void)
- {
- #if GENERATINGPOWERPC
- #ifdef __MWERKS__
- __destroy_global_chain();
- #endif
- #endif
- }
- #endif
-
-