home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 1.4 KB | 75 lines | [TEXT/MPS ] |
- /*
- File: Debug.c
-
- Contains: xxx put contents here xxx
-
- Written by: Tim Harnett
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <6> 2/21/95 TMH metrowerks change, add func prototypes
- <5> 12/19/94 TMH fix so ASSERTPRINT works with arguments
- <4> 12/15/94 TMH added use of gAssertsEnabled
- <3> 10/11/94 TMH removed calls to puts
- <2> 10/6/94 TMH added ASSERTNOERR
- <1> 9/21/94 TMH new, gotta have this stuff
- 9/21/94 TMH xxx put comment here xxx
-
- To Do:
- */
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- #ifndef __STDARG__
- #include <stdarg.h>
- #endif
-
- #ifndef __STRING__
- #include <string.h>
- #endif
-
- #ifndef __STRINGS__
- #include <Strings.h>
- #endif
-
-
- #ifndef __Debug__
- #include "Debug.h"
- #endif
-
- Boolean gAssertsEnabled = true;
-
- void dbgAssert(const char* filename, int line)
- {
- if( gAssertsEnabled ) {
- char msg[256];
- msg[0] = sprintf(&msg[1], "Assertion failed # %s: %d", filename, line);
- DebugStr((StringPtr)msg);
- }
- }
-
- void dbgAssertPrint(const char* fmt, ...)
- {
- if( gAssertsEnabled ) {
- char msg[256];
- va_list ap;
- va_start(ap, fmt);
- msg[0] = vsprintf(&msg[1], fmt, ap);
- va_end(ap);
- DebugStr((StringPtr)msg);
- }
- }
-
- void dbgAssertNoErr(const char* filename, int line,OSErr osErr)
- {
- if( gAssertsEnabled ) {
- char msg[256];
- msg[0] = sprintf(&msg[1], "ASSERT ERROR %d AT: %s, %d", osErr, filename, line);
- DebugStr((StringPtr)msg);
- }
- }
-