#ifndef _SECURITY_SECINTERNAL_H_
#define _SECURITY_SECINTERNAL_H_
#include <assert.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFString.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define CFReleaseSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRelease(_cf); }
#define CFReleaseNull(CF) { CFTypeRef _cf = (CF); \
if (_cf) { (CF) = NULL; CFRelease(_cf); } }
#define CFRetainSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRetain(_cf); }
#define DICT_DECLARE(MAXVALUES) \
CFIndex numValues = 0, maxValues = (MAXVALUES); \
const void *keys[maxValues]; \
const void *values[maxValues];
#define DICT_ADDPAIR(KEY,VALUE) do { \
if (numValues < maxValues) { \
keys[numValues] = (KEY); \
values[numValues] = (VALUE); \
numValues++; \
} else \
assert(false); \
} while(0)
#define DICT_CREATE(ALLOCATOR) CFDictionaryCreate((ALLOCATOR), keys, values, \
numValues, NULL, &kCFTypeDictionaryValueCallBacks)
#define NULL_TIME 0.0
static inline CFIndex getIntValue(CFTypeRef cf) {
if (cf) {
if (CFGetTypeID(cf) == CFNumberGetTypeID()) {
CFIndex value;
CFNumberGetValue(cf, kCFNumberCFIndexType, &value);
return value;
} else if (CFGetTypeID(cf) == CFStringGetTypeID()) {
return CFStringGetIntValue(cf);
}
}
return -1;
}
#if defined(__cplusplus)
}
#endif
#endif