root/trunk/PublicUtility/CALogMacros.h

Revision 1, 7.1 kB (checked in by gbooker, 3 years ago)

Initial Import

Line 
1 /*      Copyright:      © Copyright 2004 Apple Computer, Inc. All rights reserved.
2
3         Disclaimer:     IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
4                         ("Apple") in consideration of your agreement to the following terms, and your
5                         use, installation, modification or redistribution of this Apple software
6                         constitutes acceptance of these terms.  If you do not agree with these terms,
7                         please do not use, install, modify or redistribute this Apple software.
8
9                         In consideration of your agreement to abide by the following terms, and subject
10                         to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
11                         copyrights in this original Apple software (the "Apple Software"), to use,
12                         reproduce, modify and redistribute the Apple Software, with or without
13                         modifications, in source and/or binary forms; provided that if you redistribute
14                         the Apple Software in its entirety and without modifications, you must retain
15                         this notice and the following text and disclaimers in all such redistributions of
16                         the Apple Software.  Neither the name, trademarks, service marks or logos of
17                         Apple Computer, Inc. may be used to endorse or promote products derived from the
18                         Apple Software without specific prior written permission from Apple.  Except as
19                         expressly stated in this notice, no other rights or licenses, express or implied,
20                         are granted by Apple herein, including but not limited to any patent rights that
21                         may be infringed by your derivative works or by other works in which the Apple
22                         Software may be incorporated.
23
24                         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
25                         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26                         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27                         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28                         COMBINATION WITH YOUR PRODUCTS.
29
30                         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31                         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32                         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33                         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34                         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35                         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36                         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38 /*=============================================================================
39         CALogMacros.h
40
41 =============================================================================*/
42 #if !defined(__CALogMacros_h__)
43 #define __CALogMacros_h__
44
45 //=============================================================================
46 //      Log Macros
47 //=============================================================================
48
49 #if     CoreAudio_Debug
50
51         #include "CADebugPrintf.h"
52         #include <stdio.h>
53         #include <string.h>
54        
55         #define PrintLine(msg)                                          DebugPrintfRtn(DebugPrintfFile, "%s\n", (msg))
56        
57         #define PrintBool(msg, b)                                       DebugPrintfRtn(DebugPrintfFile, "%s%s\n", (msg), (b) ? "true" : "false")
58         #define PrintIndexedBool(msg, i, b)                     DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %s\n", (msg), (long)(i), (b) ? "true" : "false")
59        
60         #define PrintToggle(msg, b)                                     DebugPrintfRtn(DebugPrintfFile, "%s%s\n", (msg), (b) ? "on" : "off")
61         #define PrintIndexedToggle(msg, i, b)           DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %s\n", (msg), (long)(i), (b) ? "on" : "off")
62        
63         #define PrintInt(msg, n)                                        DebugPrintfRtn(DebugPrintfFile, "%s%ld\n", (msg), (long)(n))
64         #define PrintIndexedInt(msg, i, n)                      DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %ld\n", (msg), (long)(i), (long)(n))
65        
66         #define PrintHex(msg, n)                                        DebugPrintfRtn(DebugPrintfFile, "%s0x%lX\n", (msg), (unsigned long)(n))
67         #define PrintIndexedHex(msg, i, n)                      DebugPrintfRtn(DebugPrintfFile, "  %s %ld: 0x%lX\n", (msg), (long)(i), (unsigned long)(n))
68        
69         #define PrintFloat(msg, f)                                      DebugPrintfRtn(DebugPrintfFile, "%s%.6f\n", (msg), (f))
70         #define PrintIndexedFloat(msg, i, f)            DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %.6f\n", (msg), (long)(i), (f))
71         #define PrintFloatIndexedFloat(msg, i, f)       DebugPrintfRtn(DebugPrintfFile, "  %s %.6f: %.6f\n", (msg), (i), (f))
72        
73         #define PrintString(msg, s)                                     DebugPrintfRtn(DebugPrintfFile, "%s%s\n", (msg), (s))
74         #define PrintIndexedString(msg, i, s)           DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %s\n", (msg), (long)(i), (s))
75        
76         #define PrintPointer(msg, p)                            DebugPrintfRtn(DebugPrintfFile, "%s%p\n", (msg), (p))
77         #define PrintIndexedPointer(msg, i, p)          DebugPrintfRtn(DebugPrintfFile, "  %s %ld: %p\n", (msg), (long)(i), (p))
78        
79         #define Print4CharCode(msg, c)                          {                                                                                                                                                                                               \
80                                                                                                         UInt32 __4CC_number = (c);                                                                                                                                      \
81                                                                                                         char __4CC_string[5];                                                                                                                                           \
82                                                                                                         *((SInt32*)__4CC_string) = __4CC_number;                                                                                                        \
83                                                                                                         __4CC_string[4] = 0;                                                                                                                                            \
84                                                                                                         DebugPrintfRtn(DebugPrintfFile, "%s'%s'\n", (msg), __4CC_string);                                                       \
85                                                                                                 }
86         #define PrintIndexed4CharCode(msg, i, c)        {                                                                                                                                                                                               \
87                                                                                                         UInt32 __4CC_number = (c);                                                                                                                                      \
88                                                                                                         char __4CC_string[5];                                                                                                                                           \
89                                                                                                         *((SInt32*)__4CC_string) = __4CC_number;                                                                                                        \
90                                                                                                         __4CC_string[4] = 0;                                                                                                                                            \
91                                                                                                         DebugPrintfRtn(DebugPrintfFile, "  %s %ld: '%s'\n", (msg), (long)(i), __4CC_string);            \
92                                                                                                 }
93        
94         #define ErrorLine(s)                                            DebugPrintfRtn(DebugPrintfFile, "%s\n", (s))
95         #define OSErrorLine(s, e)                                       {                                                                                                                                                                                               \
96                                                                                                         OSStatus __err_number = (e);                                                                                                                            \
97                                                                                                         char __err_string[5];                                                                                                                                           \
98                                                                                                         memcpy(__err_string, &__err_number, 4);                                                                                                         \
99                                                                                                         __err_string[4] = 0;                                                                                                                                            \
100                                                                                                         DebugPrintfRtn(DebugPrintfFile, "%s, OSStatus code: %s\n", (s), __err_string);                          \
101                                                                                                 }
102        
103         #define FailIfOSError(e, s, l)                          if((e) != 0) { OSErrorLine(s, e); goto l; }
104         #define FailIfNULL(p, s, l)                                     if((p) == 0) { ErrorLine(s); goto l; }
105        
106         #define MessageIfOSError(e, s)                          if((e) != 0) { OSErrorLine(s, e); }
107         #define MessageIfNULL(p, s)                                     if((p) == 0) { ErrorLine(s); }
108
109 #else
110
111         #define PrintLine(msg)                                 
112        
113         #define PrintBool(msg, b)                                       (b)
114         #define PrintIndexedBool(msg, i, b)                     (b)
115        
116         #define PrintInt(msg, n)                                        (n)
117         #define PrintIndexedInt(msg, i, n)                      (n)
118        
119         #define PrintHex(msg, n)                                        (n)
120         #define PrintIndexedHex(msg, i, n)                      (n)
121        
122         #define PrintFloat(msg, f)                                      (f)
123         #define PrintIndexedFloat(msg, i, f)            (f)
124         #define PrintFloatIndexedFloat(msg, i, f)       (f)
125        
126         #define PrintString(msg, s)                                     (s)
127         #define PrintIndexedString(msg, i, s)           (s)
128        
129         #define PrintPointer(msg, p)                            (p)
130         #define PrintIndexedPointer(msg, i, p)          (p)
131        
132         #define Print4CharCode(msg, c)                          (c)
133         #define PrintIndexed4CharCode(msg, i, c)        (c)
134        
135         #define ErrorLine(s)                                            (s)
136         #define OSErrorLine(s, e)                                       (e)
137        
138         #define FailIfOSError(e, s, l)                          if((e) != noErr) { goto l; }
139         #define FailIfNULL(p, s, l)                                     if((p) == NULL) { goto l; }
140        
141         #define MessageIfOSError(e, s)                          (e)
142         #define MessageIfNULL(p, s)                                     (p)
143
144 #endif  //      CoreAudio_Debug
145
146 #endif
Note: See TracBrowser for help on using the browser.