#ifndef _SECURITY_SECINTERNAL_H_
#define _SECURITY_SECINTERNAL_H_
#include <assert.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFString.h>
#include <Security/SecBase.h>
__BEGIN_DECLS
#include "utilities/SecCFRelease.h"
#define AssignOrReleaseResult(CF,OUT) { \
CFTypeRef _cf = (CF), *_out = (OUT); \
if (_out) { *_out = _cf; } else { if (_cf) CFRelease(_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
#if SEC_OS_IPHONE
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;
}
#endif // SEC_OS_IPHONE
__END_DECLS
#endif