2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 Contains: Debugging macros.
24 Written by: Doug Mitchell
26 Copyright: (c) 1998, 1999 by Apple Computer, Inc., all rights reserved.
28 Change History (most recent first):
37 #include "sslBuildFlags.h"
39 #if SSL_DEBUG || ERROR_LOG_ENABLE
42 #define LOG_VIA_PRINTF 1
48 #error Hey, figure out a debug mechanism
51 #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
52 #include <TextUtils.h>
54 /* common log macros */
56 /* remaining ones can take constant strings */
62 extern void dblog0(char *str
);
63 extern void dblog1(char *str
, void * arg1
);
64 extern void dblog2(char *str
, void * arg1
, void * arg2
);
65 extern void dblog3(char *str
, void * arg1
, void * arg2
, void * arg3
);
66 extern void dblog4(char *str
, void * arg1
, void * arg2
, void * arg3
, void * arg4
);
73 #else /* LOG_VIA_PRINTF */
75 #define dblog0(str) printf(str)
76 #define dblog1(str, arg1) printf(str, arg1)
77 #define dblog2(str, arg1, arg2) printf(str, arg1, arg2)
78 #define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3)
79 #define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4)
81 #endif /* LOG_VIA_PRINTF */
83 #else /* log macros disabled */
86 #define dblog1(str, arg1)
87 #define dblog2(str, arg1, arg2)
88 #define dblog3(str, arg1, arg2, arg3)
89 #define dblog4(str, arg1, arg2, arg3, arg4)
91 #endif /* SSL_DEBUG || ERROR_LOG_ENABLE */
95 #define dprintf0(str) dblog0(str)
96 #define dprintf1(str, arg1) dblog1(str, arg1)
97 #define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2)
98 #define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
99 #define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
105 static inline volatile void sslPanic(const char *str
)
115 #define CASSERT(expression) \
116 ((expression) ? (void)0 : \
117 (dprintf1 ("Assertion failed: " #expression \
118 ", file " __FILE__ ", line %d.\n", __LINE__), \
119 sslPanic("Assertion Failure")))
121 #else /* SSL_DEBUG */
123 #define dprintf0(str)
124 #define dprintf1(str, arg1)
125 #define dprintf2(str, arg1, arg2)
126 #define dprintf3(str, arg1, arg2, arg3)
127 #define dprintf4(str, arg1, arg2, arg3, arg4)
129 #define CASSERT(expression)
131 #endif /* SSL_DEBUG */
134 * Error logging. This may well be platform dependent.
137 #define errorLog0(str) dblog0(str);
138 #define errorLog1(str, arg1) dblog1(str, arg1)
139 #define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2)
140 #define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
141 #define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
143 #else /* ERROR_LOG_ENABLE */
145 #define errorLog0(str)
146 #define errorLog1(str, arg1)
147 #define errorLog2(str, arg1, arg2)
148 #define errorLog3(str, arg1, arg2, arg3)
149 #define errorLog4(str, arg1, arg2, arg3, arg4)
151 #endif /* ERROR_LOG_ENABLE */
154 * Override SSLRef macros
157 #define DUMP_BUFFER_NAME(name, buf)
158 #define DUMP_DATA_NAME(name, p, len)
159 #define ASSERTMSG(m) sslPanic(m)
160 #define DEBUGVAL1(str, arg) errorLog1(str, arg)
162 /*** SSL-Specific debugging ***/
168 /* Logging Enable Flags */
172 /* log changes in handshake state */
173 #define LOG_HDSK_STATE 0
175 /* log handshake messages */
176 #define LOG_HDSK_MSG 0
178 /* log negotiated handshake paramters */
179 #define LOG_NEGOTIATE 0
181 /* log received protocol messsages */
182 #define LOG_RX_PROTOCOL 0
184 #else /* !SSL_DEBUG - normal build - all flags disabled */
185 #define LOG_HDSK_STATE 0
186 #define LOG_HDSK_MSG 0
187 #define LOG_NEGOTIATE 0
188 #endif /* SSL_DEBUG */
191 extern void SSLChangeHdskState(SSLContext
*ctx
, SSLHandshakeState newState
);
192 #else /* LOG_HDSK_STATE */
193 #define SSLChangeHdskState(ctx, newState) { ctx->state=newState; }
194 #endif /* LOG_HDSK_STATE */
197 extern void SSLLogHdskMsg(SSLHandshakeType msg
, char sent
);
198 extern char *hdskStateToStr(SSLHandshakeState state
);
199 #else /* LOG_HDSK_STATE */
200 #define SSLLogHdskMsg(msg, sent)
201 #endif /* LOG_HDSK_STATE */
204 * A crufty little routine to write cert blobs to disk.
205 * Implemented in appleCdsa.c.
208 extern void writeBufBlob(const SSLBuffer
*blob
,
209 const char *fileName
);
212 #endif /* _SSL_DEBUG_H_ */