home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MyGestalt.c
-
- Contains: Routines demonstrating how to call Gestalt.
-
- Written by: Mark Cookson
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/31/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include "MyGestalt.h"
-
- OSErr InterrogateSystem (sGlobalsPtr globals)
- {
- long attrib = nil;
- OSErr theErr = noErr;
-
- if (TrapAvailable (_Gestalt)) {
- if (Gestalt (gestaltSoundAttr, &attrib) == noErr) {
- globals->ggestaltSoundAttr = attrib;
- }
- if (Gestalt (gestaltStandardFileAttr, &attrib) == noErr) {
- globals->ggestaltStandardFileAttr = attrib;
- }
- if (Gestalt (gestaltTranslationAttr, &attrib) == noErr) {
- globals->ggestaltTranslationAttr = attrib;
- }
- }
- else {
- theErr = kInitErr;
- }
-
- return theErr;
- }
-
- Boolean TrapAvailable (short trapWord)
- {
- TrapType tType;
- Boolean returnValue;
-
- if (BitAnd(trapWord, 0x0800)) {
- tType = ToolTrap;
- }
- else {
- tType = OSTrap;
- }
- if (tType == ToolTrap && (BitAnd(trapWord, 0x03FF) >= 0x200) &&
- GetToolboxTrapAddress(0xA86E) == GetToolboxTrapAddress(0xAA6E)) {
- returnValue = false;
- }
- else {
- returnValue = (NGetTrapAddress(trapWord, tType) != GetToolboxTrapAddress(_Unimplemented));
- }
-
- return returnValue;
- }
-