]> git.saurik.com Git - apple/security.git/blob - authd/debugging.h
Security-55471.14.tar.gz
[apple/security.git] / authd / debugging.h
1 /* Copyright (c) 2012 Apple Inc. All rights reserved. */
2
3 #ifndef _SECURITY_AUTH_DEBUGGING_H_
4 #define _SECURITY_AUTH_DEBUGGING_H_
5
6 #if defined(__cplusplus)
7 extern "C" {
8 #endif
9
10 enum {
11 AUTH_LOG_NORMAL,
12 AUTH_LOG_VERBOSE,
13 AUTH_LOG_ERROR
14 };
15
16 #define LOG(...) security_auth_log(AUTH_LOG_NORMAL, ##__VA_ARGS__)
17 #define LOGV(...) security_auth_log(AUTH_LOG_VERBOSE, ##__VA_ARGS__)
18 #define LOGE(...) security_auth_log(AUTH_LOG_ERROR, ##__VA_ARGS__)
19 #if DEBUG
20 #define LOGD(...) security_auth_log(AUTH_LOG_VERBOSE, ##__VA_ARGS__)
21 #else
22 #define LOGD(...)
23 #endif
24
25 void security_auth_log(int,const char *,...) __printflike(2, 3);
26
27 #define CFReleaseSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRelease(_cf); }
28 #define CFReleaseNull(CF) { CFTypeRef _cf = (CF); \
29 if (_cf) { (CF) = NULL; CFRelease(_cf); } }
30 #define CFRetainSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRetain(_cf); }
31
32 #define xpc_release_safe(obj) if (obj) { xpc_release(obj); obj = NULL; }
33 #define free_safe(obj) if (obj) { free(obj); obj = NULL; }
34
35 void _show_cf(CFTypeRef);
36
37 #if defined(__cplusplus)
38 }
39 #endif
40
41 #endif /* !_SECURITY_AUTH_DEBUGGING_H_ */