home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / DockStrip / SdevStub.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  1.3 KB  |  60 lines

  1. #include <Gestalt.h>
  2. #include <DCon.h>
  3. #include <QuickDraw.h>
  4. #include <MixedMode.h>
  5. #include <A4Stuff.h>
  6. #include <ControlStrip.h>
  7.  
  8. #include "DockStrip.h"
  9.  
  10. ProcInfoType __procinfo = sdevMain_ProcInfo;
  11.  
  12. SdevMainUPP*        gCallThroughSdevMain = (SdevMainUPP*) 0xDEADBEEF;
  13. SDockStripGlobals*    gGlobalsPtr = nil;
  14.  
  15. pascal long main (
  16.     unsigned long message,
  17.     Handle prefsHandle,
  18.     Rect *statusRect,
  19.     GrafPtr statusPort)
  20. {
  21.     Rect copy;
  22.     long result;
  23.     Boolean runModule;
  24.  
  25.     static Boolean gotIndex = false;
  26.     static UInt32 index;
  27.  
  28.     if (gGlobalsPtr == nil) {
  29.         Gestalt (dockStripGestalt, (SInt32*)&(gGlobalsPtr));
  30.     }
  31.     if (gGlobalsPtr == nil) {
  32.         DebugStr ("\pGlobals not found in Gestalt");
  33.     }
  34.  
  35. //    DebugStr ("\pSdev stub main");
  36.  
  37.     if (!gotIndex) {
  38.         for (index = 0; index < StubListSize; index++) {
  39.             if (gGlobalsPtr -> moduleList [index].module.handle == (Handle) gCallThroughSdevMain) {
  40.                 gotIndex = true;
  41.                 break;
  42.             }
  43.         }
  44.     }
  45.     
  46.     if (!gotIndex) {
  47.         DebugStr ("\pModule not found in the list");
  48.     }
  49.     
  50.     result = BeforeModule (gGlobalsPtr, index, message, prefsHandle, statusRect, statusPort, &runModule);
  51.  
  52.     if (runModule) {
  53.         copy = *statusRect;
  54.         result = CallSdevMainProc (*gCallThroughSdevMain, message, prefsHandle, ©, statusPort);
  55.         
  56.         result = AfterModule (gGlobalsPtr, index, message, prefsHandle, statusRect, statusPort, result);
  57.     } 
  58.     
  59.     return result;
  60. }