home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / SafeLauncher 1.0 / Source / TrapAvailable.c < prev   
Encoding:
Text File  |  1994-10-12  |  879 b   |  51 lines  |  [TEXT/MMCC]

  1. //
  2. // TrapAvailable.c
  3. //
  4. //    From Symantec's THINK Reference, which in turn got the code from an Apple Tech note.
  5. //
  6.  
  7. #include<Traps.h>
  8. #include<OSUtils.h>
  9.  
  10. #define TrapMask 0x0800
  11.  
  12. short NumToolboxTraps( void ) ;
  13. TrapType GetTrapType(short theTrap) ;
  14. Boolean TrapAvailable(short theTrap) ;
  15.  
  16.  
  17. short NumToolboxTraps( void )
  18. {
  19.     if (NGetTrapAddress(_InitGraf, ToolTrap) ==
  20.             NGetTrapAddress(0xAA6E, ToolTrap))
  21.         return(0x0200) ;
  22.     else
  23.         return(0x0400) ;
  24. }
  25.  
  26. TrapType GetTrapType(short theTrap)
  27. {
  28.  
  29.     if ((theTrap & TrapMask) > 0)
  30.         return(ToolTrap) ;
  31.     else
  32.         return(OSTrap) ;
  33.  
  34. }
  35.  
  36. Boolean TrapAvailable(short theTrap)
  37. {
  38.  
  39.     TrapType    tType ;
  40.  
  41.     tType = GetTrapType(theTrap) ;
  42.     if (tType == ToolTrap)
  43.     theTrap = theTrap & 0x07FF ;
  44.     if (theTrap >= NumToolboxTraps())
  45.         theTrap = _Unimplemented ;
  46.  
  47.     return (NGetTrapAddress(theTrap, tType) !=
  48.             NGetTrapAddress(_Unimplemented, ToolTrap)) ;
  49. }
  50.  
  51.