home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
- #
- # Shell.h
- #
- # This is a simple application shell that we use to handle the standard mac stuff.
- # In general, the routines in this code should be as generic as possible, and any
- # custom code should be included in CustomApp.c instead. See CustomApp.h for a list
- # of the routines that need to be provided by the custom application.
- #
- # Shell.h also includes all the debugging macros and application conditionals, so
- # is should be included by all project files.
- #
- # Author: Timothy Carroll
- # Apple Developer Technical Support
- # timc@apple.com
- #
- # Revision: Jason Yeo
- #
- # Modification History:
- #
- # 2/9/97 TMC Initial Release
- #
- # 9/12/97 JY Updated for:
- # TEC 1.2.1
- # Universal Interfaces 3.0
- # CodeWarrior 11 projects
- #
- # Copyright © 1997 Apple Computer, Inc., All Rights Reserved
- #
- #
- # You may incorporate this sample code into your applications without
- # restriction, though the sample code has been provided "AS IS" and the
- # responsibility for its operation is 100% yours. However, what you are
- # not permitted to do is to redistribute the source as "DSC Sample 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 Code, but that you've made changes.
- #
- *************************************************************************************/
-
- #ifndef __SHELL__
- #define __SHELL__
-
- #pragma once
-
- /*********************************************************************************
- # APP CONDITIONALS
- # These are conditional compiles that affect how the code works. Here is the
- # list of conditionals:
- #
- # qDebugging -- if this is turned on, error handler routines will report an "exception"
- # with a debug string before jumping to the error term routines. In addition, conditional
- # code to check internal references will be compiled into the project.
- #
- *********************************************************************************/
-
- #define qDebugging 1
-
-
- /*********************************************************************************
- # ERROR HANDLING MACROS
- #
- # These macros can be used to implement nice error handling within a function.
- # Essentially, all errors jump to an error handler at the end of the function, which
- # should cleanup any leftovers and return the appropriate error result.
- #
- # Note that the error handlers take a message string. This should be a good
- # indication of the actual error, and it will appear when debugging is turned on.
- #
- # The qDebugging macro can be used to implement sanity checking code that is only
- # compiled into debug builds.
- #
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
- #
- # This could be used to check the internal validity of an object before acting on it
- #
- *********************************************************************************/
- #ifndef qDebugging
- #define qDebugging 0
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-
-
- /*********************************************************************************
- # HEADER INCLUDES
- #
- *********************************************************************************/
- #include "Preferences.h"
-
- /*********************************************************************************
- # SHELL GLOBALS
- #
- *********************************************************************************/
-
- extern Boolean gQuittingApp;
- extern Boolean gAppForeGround;
- extern TPreferences gPreferences;
-
- /*********************************************************************************
- # SHELL Routines
- #
- *********************************************************************************/
- // returns OSErr because that's what AppleEvents return....
- OSErr CheckAppleEventForMissingParams(AppleEvent *event);
- OSStatus DispatchQuitEvent (void);
-
- #endif // __SHELL__
-