home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 August: Tool Chest / Apple_Developer_Group_August_1996_Tool_Chest.iso / Sample Code / Snippets / Files / SFGetFolder C / trapavail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  694 b   |  38 lines  |  [TEXT/KAHL]

  1. #include <Traps.h>
  2. #include <GestaltEqu.h>
  3. #include "trapavail.h"
  4.  
  5. short NumToolboxTraps(void);
  6. TrapType GetTrapType(short theTrap);
  7.     
  8. short NumToolboxTraps(void)
  9. {
  10.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  11.         return 0x0200;
  12.     else
  13.         return 0x0400;
  14. }
  15.  
  16.  
  17. TrapType GetTrapType(short theTrap)
  18. {
  19.     if ((theTrap & 0x0800) > 0)
  20.         return ToolTrap;
  21.     else
  22.         return OSTrap;
  23. }
  24.  
  25.  
  26. Boolean    TrapAvailable(short theTrap)
  27. {
  28.     TrapType tType;
  29.     
  30.     tType = GetTrapType(theTrap);
  31.     if (tType == ToolTrap) {
  32.         theTrap &= 0x07FF;
  33.         if (theTrap >= NumToolboxTraps())
  34.             theTrap = _Unimplemented;
  35.     }
  36.     
  37.     return NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  38. }