home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- *
- * CustomGetFile Dialog Demo
- *
- * TrapUtils.c
- *
- * Written in CodeWarrior Gold 5.5
- * August 31, 1995
- *
- * Copyright © 1995 Carl B. Constantine
- * Some portions Copyright © 1995 MetroWerks, Inc.
- * Some portions Copyright © 1995 Apple Computer, Inc.
- *
- **********************************************************************/
-
- /*------------------------------------------------------------------
- #
- # File History
- #
- # Date Description of Change
- # ---- ---------------------
- # Aug 31/93 — Original creation of file
- #
- #
- -------------------------------------------------------------------*/
-
- #include <Traps.h>
- #include <GestaltEqu.h>
-
- #include "AppGlobals.h"
- #include "TrapUtils.h"
-
-
- /*======================== Checking for Gestalt ===========================*/
-
- /* Call GestaltAvailable to determine whether the system software version is
- 6.04 or higher. If Gestalt is not available, then we are running on a system
- that we don't want to. If Gestalt is available, then we can find out what
- system we are running on. */
-
- Boolean GestaltAvailable( void )
- {
- if ( !TrapAvailable( _Gestalt ) )
- return( false );
- else
- return( true );
- }
-
- /*==================== Checking for Gestalt Attributes =======================*/
-
- /* Call HasGestaltAttr to determine if the system software version supports
- certain capabilities. Handy routine checks to see if the specified bit in
- the result of the specifed Gestalt Selector is set or not. This routine comes
- directly from "Macintosh Programming Secrets, 3rd Ed." by Scott Knaster &
- Keith Rollin Chapter 10 page 509. */
-
- Boolean HasGestaltAttr( OSType itsAttr, short itsBit )
- {
- long response;
-
- return( Gestalt( itsAttr, &response) == noErr ) &&
- (((response >> itsBit) & 1L) != 0 );
- }
-
-
- /*========================= Checking for System 7 =============================*/
-
- /* Call System607Available to determine whether the system software version is
- 7 or higher. If not, tell the user and exit gracefully. */
-
- Boolean System7Available( void )
- {
- long sysVersion;
-
-
- Gestalt( gestaltSystemVersion, &sysVersion );
- return( sysVersion >= 0x0700 );
-
- }
-
- // Everything from this point on shouldn't be new to anyone. You can find
- // similar routines in almost any code you look at (particularlly shell code).
- // With that assumtion, here is the rest of the code for this file.
-
-
- /*----------------------------------------------------------------------------*/
-
- Boolean TrapAvailable( short theTrap )
- {
- TrapType tType;
-
- tType = GetTrapType( theTrap );
-
- if ( tType == ToolTrap )
- {
- theTrap = ( theTrap & 0x07FF );
- if ( theTrap >= NumToolboxTraps() ) theTrap = _Unimplemented;
- }
- return( NGetTrapAddress( theTrap, tType ) !=
- NGetTrapAddress( _Unimplemented, ToolTrap ) );
- }
-
- /*----------------------------------------------------------------------------*/
-
- TrapType GetTrapType( short theTrap )
- {
- if ( ( theTrap & 0x0800 ) > 0 )
- {
- return( ToolTrap );
- } else
- {
- return( OSTrap );
- }
- }
-
- /*----------------------------------------------------------------------------*/
-
- short NumToolboxTraps( void )
- {
- if ( NGetTrapAddress( _InitGraf, ToolTrap ) ==
- NGetTrapAddress( 0xAA6E, ToolTrap ) )
- {
- return( 0x0200 );
- } else
- {
- return( 0x0400 );
- }
- }
-
- /*============================ End of File ===================================*/
-