home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / SpriteFight 2002 v2.0a1 / DebugUtils.c < prev    next >
Encoding:
Text File  |  1994-03-08  |  2.1 KB  |  108 lines  |  [TEXT/KAHL]

  1. ///--------------------------------------------------------------------------------------
  2. //    DebugUtils.c
  3. //
  4. //    Created:    12/17/91 at 12:35:35 AM
  5. //    By:        Tony Myles
  6. //
  7. //    Copyright: © 1991-94 Tony Myles, All rights reserved worldwide.
  8. //
  9. //    Description:    utility routines used for debugging purposes
  10. ///--------------------------------------------------------------------------------------
  11.  
  12.  
  13. #if SW_PPC || __MWERKS__
  14. #ifndef __TEXTUTILS__
  15. #include <TextUtils.h>
  16. #endif
  17. #elif THINK_C
  18. #ifndef __BDC__
  19. #include <BDC.h>
  20. #endif
  21. #elif MPW
  22. #ifndef __PACKAGES__
  23. #include <Packages.h>
  24. #endif
  25. #endif 
  26.  
  27. #ifndef __SEGLOAD__
  28. #include <SegLoad.h>
  29. #endif
  30.  
  31. #ifndef __STRINGUTILS__
  32. #include "StringUtils.h"
  33. #endif
  34.  
  35. #ifndef __DEBUGUTILS__
  36. #include "DebugUtils.h"
  37. #endif
  38.  
  39.  
  40.  
  41. #if MPW
  42. #pragma segment Utils
  43. #endif
  44.  
  45.  
  46. ///--------------------------------------------------------------------------------------
  47. // DebugNum
  48. ///--------------------------------------------------------------------------------------
  49.  
  50. void DebugNum(
  51.     long bugNum)
  52. {
  53.     Str255 bugNumStr;
  54.  
  55.         // convert the bug number to a string
  56.     NumToString(bugNum, bugNumStr);
  57.  
  58.         // do it
  59.     DebugStr(bugNumStr);
  60. }
  61.  
  62.  
  63. ///--------------------------------------------------------------------------------------
  64. // DebugStrNum
  65. ///--------------------------------------------------------------------------------------
  66.  
  67. void DebugStrNum(
  68.     Str255 bugStr,
  69.     long bugNum)
  70. {
  71.     Str255 tmpStr, bugNumStr;
  72.  
  73.         // copy the bugStr to a local str and append a colon+space to it
  74.     PStrCpy(bugStr, tmpStr);
  75.     PStrCat("\p: ", tmpStr);
  76.  
  77.         // convert the bugNum to a string and append it to the local string
  78.     NumToString(bugNum, bugNumStr);
  79.     PStrCat(bugNumStr, tmpStr);
  80.  
  81.         // do it.
  82.     DebugStr(tmpStr);
  83. }
  84.  
  85.  
  86. ///--------------------------------------------------------------------------------------
  87. // FatalError
  88. ///--------------------------------------------------------------------------------------
  89.  
  90. void FatalError(
  91.     OSErr err,
  92.     Str255 errMsgStr)
  93. {
  94.     if (err != noErr)
  95.     {
  96.         if (errMsgStr == NULL)
  97.         {
  98.             DebugNum((long)err);
  99.         }
  100.         else
  101.         {
  102.             DebugStrNum(errMsgStr, (long)err);
  103.         }
  104.  
  105.         ExitToShell();
  106.     }
  107. }
  108.