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
49 #error Hey, figure out a debug mechanism
52 #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
53 #include <TextUtils.h>
55 /* common log macros */
57 /* remaining ones can take constant strings */
63 extern void dblog0(char *str
);
64 extern void dblog1(char *str
, void * arg1
);
65 extern void dblog2(char *str
, void * arg1
, void * arg2
);
66 extern void dblog3(char *str
, void * arg1
, void * arg2
, void * arg3
);
67 extern void dblog4(char *str
, void * arg1
, void * arg2
, void * arg3
, void * arg4
);
74 #else /* LOG_VIA_PRINTF */
76 #define dblog0(str) printf(str)
77 #define dblog1(str, arg1) printf(str, arg1)
78 #define dblog2(str, arg1, arg2) printf(str, arg1, arg2)
79 #define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3)
80 #define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4)
82 #endif /* LOG_VIA_PRINTF */
84 #else /* log macros disabled */
87 #define dblog1(str, arg1)
88 #define dblog2(str, arg1, arg2)
89 #define dblog3(str, arg1, arg2, arg3)
90 #define dblog4(str, arg1, arg2, arg3, arg4)
92 #endif /* SSL_DEBUG || ERROR_LOG_ENABLE */
96 #define dprintf0(str) dblog0(str)
97 #define dprintf1(str, arg1) dblog1(str, arg1)
98 #define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2)
99 #define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
100 #define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
106 static inline volatile void sslPanic(const char *str
)
116 #define CASSERT(expression) \
117 ((expression) ? (void)0 : \
118 (dprintf1 ("Assertion failed: " #expression \
119 ", file " __FILE__ ", line %d.\n", __LINE__), \
120 sslPanic("Assertion Failure")))
122 #else /* SSL_DEBUG */
124 #define dprintf0(str)
125 #define dprintf1(str, arg1)
126 #define dprintf2(str, arg1, arg2)
127 #define dprintf3(str, arg1, arg2, arg3)
128 #define dprintf4(str, arg1, arg2, arg3, arg4)
130 #define CASSERT(expression)
132 #endif /* SSL_DEBUG */
135 * Error logging. This may well be platform dependent.
138 #define errorLog0(str) dblog0(str);
139 #define errorLog1(str, arg1) dblog1(str, arg1)
140 #define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2)
141 #define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
142 #define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
144 #else /* ERROR_LOG_ENABLE */
146 #define errorLog0(str)
147 #define errorLog1(str, arg1)
148 #define errorLog2(str, arg1, arg2)
149 #define errorLog3(str, arg1, arg2, arg3)
150 #define errorLog4(str, arg1, arg2, arg3, arg4)
152 #endif /* ERROR_LOG_ENABLE */
155 * Override SSLRef macros
158 #define DUMP_BUFFER_NAME(name, buf)
159 #define DUMP_DATA_NAME(name, p, len)
160 #define ASSERTMSG(m) sslPanic(m)
161 #define DEBUGVAL1(str, arg) errorLog1(str, arg)
163 /*** SSL-Specific debugging ***/
169 /* Logging Enable Flags */
173 /* log changes in handshake state */
174 #define LOG_HDSK_STATE 0
176 /* log handshake messages */
177 #define LOG_HDSK_MSG 0
179 /* log negotiated handshake parameters */
180 #define LOG_NEGOTIATE 0
182 /* log received protocol messsages */
183 #define LOG_RX_PROTOCOL 0
185 /* log resumable session info */
186 #define LOG_RESUM_SESSION 0
188 #else /* !SSL_DEBUG - normal build - all flags disabled */
189 #define LOG_HDSK_STATE 0
190 #define LOG_HDSK_MSG 0
191 #define LOG_NEGOTIATE 0
192 #define LOG_RX_PROTOCOL 0
193 #define LOG_RESUM_SESSION 0
194 #endif /* SSL_DEBUG */
197 extern void SSLChangeHdskState(SSLContext
*ctx
, SSLHandshakeState newState
);
198 #else /* LOG_HDSK_STATE */
199 #define SSLChangeHdskState(ctx, newState) { ctx->state=newState; }
200 #endif /* LOG_HDSK_STATE */
203 extern void SSLLogHdskMsg(SSLHandshakeType msg
, char sent
);
204 extern char *hdskStateToStr(SSLHandshakeState state
);
205 #else /* LOG_HDSK_STATE */
206 #define SSLLogHdskMsg(msg, sent)
207 #endif /* LOG_HDSK_STATE */
209 #if LOG_RESUM_SESSION
210 #define SSLLogResumSess(m) printf(m)
212 #define SSLLogResumSess(m)
213 #endif /* LOG_RESUM_SESSION */
216 * A crufty little routine to write cert blobs to disk.
217 * Implemented in appleCdsa.c.
220 extern void writeBufBlob(const SSLBuffer
*blob
,
221 const char *fileName
);
224 #endif /* _SSL_DEBUG_H_ */