home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Text Encoding Converter 1.5 / Sample Code / DropEncoder / Headers / Shell.h < prev   
Encoding:
C/C++ Source or Header  |  1997-09-19  |  4.1 KB  |  120 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. #
  3. #    Shell.h
  4. #    
  5. #   This is a simple application shell that we use to handle the standard mac stuff.
  6. #   In general, the routines in this code should be as generic as possible, and any
  7. #   custom code should be included in CustomApp.c instead.  See CustomApp.h for a list
  8. #   of the routines that need to be provided by the custom application.
  9. #   
  10. #   Shell.h also includes all the debugging macros and application conditionals, so
  11. #   is should be included by all project files.
  12. #
  13. #    Author: Timothy Carroll
  14. #    Apple Developer Technical Support
  15. #    timc@apple.com
  16. #
  17. #    Revision: Jason Yeo
  18. #
  19. #    Modification History: 
  20. #
  21. #    2/9/97        TMC     Initial Release
  22. #
  23. #    9/12/97        JY         Updated for:
  24. #                        TEC 1.2.1 
  25. #                        Universal Interfaces 3.0
  26. #                        CodeWarrior 11 projects
  27. #
  28. #    Copyright © 1997 Apple Computer, Inc., All Rights Reserved
  29. #
  30. #
  31. #    You may incorporate this sample code into your applications without
  32. #    restriction, though the sample code has been provided "AS IS" and the
  33. #    responsibility for its operation is 100% yours.  However, what you are
  34. #    not permitted to do is to redistribute the source as "DSC Sample Code"
  35. #    after having made changes. If you're going to re-distribute the source,
  36. #    we require that you make it clear in the source that the code was
  37. #    descended from Apple Sample Code, but that you've made changes.
  38. #
  39. *************************************************************************************/
  40.  
  41. #ifndef __SHELL__
  42. #define __SHELL__
  43.  
  44. #pragma once
  45.  
  46. /*********************************************************************************
  47. #    APP CONDITIONALS
  48. #    These are conditional compiles that affect how the code works.  Here is the
  49. #   list of conditionals:
  50. #
  51. #    qDebugging -- if this is turned on, error handler routines will report an "exception"
  52. #   with a debug string before jumping to the error term routines.  In addition, conditional
  53. #   code to check internal references will be compiled into the project.
  54. #    
  55. *********************************************************************************/
  56.  
  57. #define qDebugging 1
  58.  
  59.  
  60. /*********************************************************************************
  61. #    ERROR HANDLING MACROS
  62. #
  63. #    These macros can be used to implement nice error handling within a function.
  64. #    Essentially, all errors jump to an error handler at the end of the function, which
  65. #    should cleanup  any leftovers and return the appropriate error result.
  66. #
  67. #    Note that the error handlers take a message string.  This should be a good
  68. #    indication of the actual error, and it will appear when debugging is turned on.
  69. #
  70. #    The qDebugging macro can be used to implement sanity checking code that is only
  71. #   compiled into debug builds.
  72. #
  73.     
  74.     #if qDebugging
  75.           // do additional sanity checking here.
  76.     #endif
  77. #
  78. #    This could be used to check the internal validity of an object before acting on it
  79. #    
  80. *********************************************************************************/
  81. #ifndef qDebugging
  82.     #define qDebugging 0
  83. #endif
  84.  
  85. #if qDebugging
  86.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  87. #else
  88.     #define SIGNAL_ERROR(msg)        {goto error;}
  89. #endif
  90.  
  91. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  92. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  93. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  94.  
  95.  
  96. /*********************************************************************************
  97. #    HEADER INCLUDES
  98. #    
  99. *********************************************************************************/
  100. #include "Preferences.h"
  101.  
  102. /*********************************************************************************
  103. #    SHELL GLOBALS
  104. #    
  105. *********************************************************************************/
  106.  
  107. extern Boolean gQuittingApp;
  108. extern Boolean gAppForeGround;
  109. extern TPreferences gPreferences;
  110.  
  111. /*********************************************************************************
  112. #    SHELL Routines
  113. #    
  114. *********************************************************************************/
  115. // returns OSErr because that's what AppleEvents return....
  116. OSErr CheckAppleEventForMissingParams(AppleEvent *event); 
  117. OSStatus DispatchQuitEvent (void);
  118.  
  119. #endif // __SHELL__
  120.