home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / SoundSwirl / trapavail.c < prev   
Encoding:
C/C++ Source or Header  |  1992-12-13  |  886 b   |  40 lines  |  [TEXT/KAHL]

  1. /**********************
  2. ** trapavail.c
  3. **
  4. ** Checks for the existence of a trap.
  5. **
  6. **********************/
  7.  
  8. #include <Traps.h>
  9.  
  10. Boolean TrapAvailable(int);
  11. static int NumToolboxTraps(void);
  12. static TrapType GetTrapType(int);
  13.  
  14.  
  15. static int NumToolboxTraps(void)
  16. {
  17.     return ( (NGetTrapAddress(_InitGraf, ToolTrap)==
  18.               NGetTrapAddress(0xAA6E, ToolTrap)) ? 0x0200 : 0x0400);
  19. } /* NumToolboxTraps() */
  20.  
  21.  
  22. static TrapType GetTrapType(int theTrap)
  23. {
  24.     unsigned TrapMask = 0x0800;
  25.     return ((theTrap & TrapMask)>0 ? ToolTrap : OSTrap);
  26. } /* GetTrapType() */
  27.  
  28.  
  29. Boolean TrapAvailable(int theTrap)
  30. {
  31.     TrapType tType = GetTrapType( theTrap);
  32.     if (tType == ToolTrap) {
  33.         theTrap = (int)theTrap & (int)0x07FF;
  34.         if (theTrap >= NumToolboxTraps())
  35.             theTrap = _Unimplemented;
  36.     }
  37.     return (Boolean)(NGetTrapAddress(theTrap, tType) !=
  38.             NGetTrapAddress(_Unimplemented, ToolTrap));
  39. } /* TrapAvailable() */
  40.