ForFoundationOnly.h [plain text]
#if !CF_BUILDING_CF && !NSBUILDINGFOUNDATION
#error The header file ForFoundationOnly.h is for the exclusive use of the
#error CoreFoundation and Foundation projects. No other project should include it.
#endif
#if !defined(__COREFOUNDATION_FORFOUNDATIONONLY__)
#define __COREFOUNDATION_FORFOUNDATIONONLY__ 1
#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFArray.h>
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFPriv.h>
#include <CoreFoundation/CFPropertyList.h>
#if defined(__cplusplus)
extern "C" {
#endif
#include <malloc/malloc.h>
CF_EXPORT
void __CFSetupFoundationBridging(void *, void *, void *, void *);
#if defined(__cplusplus)
}
#endif
#include <CoreFoundation/CFBundlePriv.h>
#if defined(__cplusplus)
extern "C" {
#endif
CF_EXPORT const CFStringRef _kCFBundleExecutablePathKey;
CF_EXPORT const CFStringRef _kCFBundleInfoPlistURLKey;
CF_EXPORT const CFStringRef _kCFBundleNumericVersionKey;
CF_EXPORT const CFStringRef _kCFBundleResourcesFileMappedKey;
CF_EXPORT const CFStringRef _kCFBundleCFMLoadAsBundleKey;
CF_EXPORT const CFStringRef _kCFBundleAllowMixedLocalizationsKey;
CF_EXPORT CFArrayRef _CFFindBundleResources(CFBundleRef bundle, CFURLRef bundleURL, CFStringRef subDirName, CFArrayRef searchLanguages, CFStringRef resName, CFArrayRef resTypes, CFIndex limit, UInt8 version);
CF_EXPORT UInt8 _CFBundleLayoutVersion(CFBundleRef bundle);
CF_EXPORT CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version);
CF_EXPORT CFArrayRef _CFBundleGetLanguageSearchList(CFBundleRef bundle);
#if defined(__cplusplus)
}
#endif
#if defined(__MACH__)
#define DEBUG_PREFERENCES_MEMORY 0
#if DEBUG_PREFERENCES_MEMORY
#include "../Tests/CFCountingAllocator.h"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
extern void _CFPreferencesPurgeDomainCache(void);
typedef struct {
void * (*createDomain)(CFAllocatorRef allocator, CFTypeRef context);
void (*freeDomain)(CFAllocatorRef allocator, CFTypeRef context, void *domain);
CFTypeRef (*fetchValue)(CFTypeRef context, void *domain, CFStringRef key); void (*writeValue)(CFTypeRef context, void *domain, CFStringRef key, CFTypeRef value);
Boolean (*synchronize)(CFTypeRef context, void *domain);
void (*getKeysAndValues)(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs);
CFDictionaryRef (*copyDomainDictionary)(CFTypeRef context, void *domain);
void (*setIsWorldReadable)(CFTypeRef context, void *domain, Boolean isWorldReadable);
} _CFPreferencesDomainCallBacks;
CF_EXPORT CFAllocatorRef __CFPreferencesAllocator(void);
CF_EXPORT const _CFPreferencesDomainCallBacks __kCFVolatileDomainCallBacks;
#if defined(__WIN32__)
CF_EXPORT const _CFPreferencesDomainCallBacks __kCFWindowsRegistryDomainCallBacks;
#else
CF_EXPORT const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks;
#endif
typedef struct __CFPreferencesDomain * CFPreferencesDomainRef;
CF_EXPORT CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef context, const _CFPreferencesDomainCallBacks *callBacks);
CF_EXPORT CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName);
CF_EXPORT CFTypeRef _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key);
CF_EXPORT void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef key, CFTypeRef value);
CF_EXPORT Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain);
CF_EXPORT void _CFPreferencesDomainGetKeysAndValues(CFAllocatorRef alloc, CFPreferencesDomainRef domain, void **buf[], CFIndex *numKeyValuePairs);
CF_EXPORT CFArrayRef _CFPreferencesCreateDomainList(CFStringRef userName, CFStringRef hostName);
CF_EXPORT Boolean _CFSynchronizeDomainCache(void);
CF_EXPORT void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict);
CF_EXPORT CFDictionaryRef _CFPreferencesDomainCopyDictionary(CFPreferencesDomainRef domain);
CF_EXPORT CFDictionaryRef _CFPreferencesDomainDeepCopyDictionary(CFPreferencesDomainRef domain);
CF_EXPORT Boolean _CFPreferencesDomainExists(CFStringRef domainName, CFStringRef userName, CFStringRef hostName);
CF_EXPORT void _CFPreferencesDomainSetIsWorldReadable(CFPreferencesDomainRef domain, Boolean isWorldReadable);
typedef struct {
CFMutableArrayRef _search; CFMutableDictionaryRef _dictRep; CFStringRef _appName;
} _CFApplicationPreferences;
CF_EXPORT _CFApplicationPreferences *_CFStandardApplicationPreferences(CFStringRef appName);
CF_EXPORT _CFApplicationPreferences *_CFApplicationPreferencesCreateWithUser(CFStringRef userName, CFStringRef appName);
CF_EXPORT void _CFDeallocateApplicationPreferences(_CFApplicationPreferences *self);
CF_EXPORT CFTypeRef _CFApplicationPreferencesCreateValueForKey(_CFApplicationPreferences *prefs, CFStringRef key);
CF_EXPORT void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef defaultName, CFTypeRef value);
CF_EXPORT void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName);
CF_EXPORT Boolean _CFApplicationPreferencesSynchronize(_CFApplicationPreferences *self);
CF_EXPORT void _CFApplicationPreferencesUpdate(_CFApplicationPreferences *self); CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentation3(_CFApplicationPreferences *self, CFDictionaryRef hint, CFDictionaryRef insertion, CFPreferencesDomainRef afterDomain);
CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentationWithHint(_CFApplicationPreferences *self, CFDictionaryRef hint); CF_EXPORT void _CFApplicationPreferencesSetStandardSearchList(_CFApplicationPreferences *appPreferences);
CF_EXPORT void _CFApplicationPreferencesSetSearchList(_CFApplicationPreferences *self, CFArrayRef newSearchList);
CF_EXPORT void _CFApplicationPreferencesSetCacheForApp(_CFApplicationPreferences *appPrefs, CFStringRef appName);
CF_EXPORT void _CFApplicationPreferencesAddSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName);
CF_EXPORT void _CFApplicationPreferencesRemoveSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName);
CF_EXPORT void _CFApplicationPreferencesAddDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain, Boolean addAtTop);
CF_EXPORT Boolean _CFApplicationPreferencesContainsDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain);
CF_EXPORT void _CFApplicationPreferencesRemoveDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain);
CF_EXPORT CFTypeRef _CFApplicationPreferencesSearchDownToDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef stopper, CFStringRef key);
#if defined(__cplusplus)
}
#endif
#endif // __MACH__
#if defined(__cplusplus)
extern "C" {
#endif
CF_EXPORT CFIndex __CFStringEncodeByteStream(CFStringRef string, CFIndex rangeLoc, CFIndex rangeLen, Boolean generatingExternalFile, CFStringEncoding encoding, char lossByte, UInt8 *buffer, CFIndex max, CFIndex *usedBufLen);
CF_EXPORT CFStringRef __CFStringCreateImmutableFunnel2(CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy, CFAllocatorRef contentsDeallocator);
CF_INLINE Boolean __CFStringEncodingIsSupersetOfASCII(CFStringEncoding encoding) {
switch (encoding & 0x0000FF00) {
case 0x100: if (encoding != kCFStringEncodingUTF8) return false;
return true;
case 0x600: if (encoding != kCFStringEncodingASCII) return false;
return true;
case 0x800: return false;
case 0xB00:
if (encoding == kCFStringEncodingNonLossyASCII) return false;
return true;
case 0xC00: return false;
default:
return ((encoding & 0x0000FF00) > 0x0C00 ? false : true);
}
}
CF_EXPORT CFStringEncoding __CFDefaultEightBitStringEncoding;
CF_EXPORT CFStringEncoding __CFStringComputeEightBitStringEncoding(void);
CF_INLINE CFStringEncoding __CFStringGetEightBitStringEncoding(void) {
if (__CFDefaultEightBitStringEncoding == kCFStringEncodingInvalidId) __CFStringComputeEightBitStringEncoding();
return __CFDefaultEightBitStringEncoding;
}
enum {
__kCFVarWidthLocalBufferSize = 1008
};
typedef struct {
union {
UInt8 *ascii;
UniChar *unicode;
} chars;
Boolean isASCII;
Boolean shouldFreeChars;
Boolean _unused1;
Boolean _unused2;
CFAllocatorRef allocator;
UInt32 numChars;
UInt8 localBuffer[__kCFVarWidthLocalBufferSize];
} CFVarWidthCharBuffer;
CF_EXPORT Boolean __CFStringDecodeByteStream2(const UInt8 *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr);
CF_EXPORT Boolean __CFStringDecodeByteStream3(const UInt8 *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr, UInt32 converterFlags);
CF_EXPORT Boolean (*__CFCharToUniCharFunc)(UInt32 flags, UInt8 ch, UniChar *unicodeChar);
CF_EXPORT void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar));
CF_EXPORT UniChar __CFCharToUniCharTable[256];
CF_INLINE Boolean __CFIsWhitespace(UniChar theChar) {
return ((theChar < 0x21) || (theChar > 0x7E && theChar < 0xA1) || (theChar >= 0x2000 && theChar <= 0x200B) || (theChar == 0x3000)) ? true : false;
}
CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferAux(CFStringInlineBuffer *buf, CFIndex idx) {
if (buf->directBuffer) {
if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
return buf->directBuffer[idx + buf->rangeToBuffer.location];
}
if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
}
return buf->buffer[idx - buf->bufferedRangeStart];
}
CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferQuick(CFStringInlineBuffer *buf, CFIndex idx) {
if (buf->directBuffer) return buf->directBuffer[idx + buf->rangeToBuffer.location];
if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
}
return buf->buffer[idx - buf->bufferedRangeStart];
}
CF_EXPORT void _CFStringAppendFormatAndArgumentsAux(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, CFDictionaryRef), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args);
CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, CFDictionaryRef), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
enum {_CFStringErrNone = 0, _CFStringErrNotMutable = 1, _CFStringErrNilArg = 2, _CFStringErrBounds = 3};
CF_EXPORT int __CFStringCheckAndReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement);
CF_EXPORT Boolean __CFStringNoteErrors(void);
CF_EXPORT Boolean __CFStringIsEightBit(CFStringRef str);
CF_EXPORT int _CFStringCheckAndGetCharacterAtIndex(CFStringRef str, CFIndex idx, UniChar *ch);
CF_EXPORT int _CFStringCheckAndGetCharacters(CFStringRef str, CFRange range, UniChar *buffer);
CF_EXPORT CFIndex _CFStringGetLength2(CFStringRef str);
CF_EXPORT CFHashCode __CFStringHash(CFTypeRef cf);
CF_EXPORT CFHashCode CFStringHashISOLatin1CString(const uint8_t *bytes, CFIndex len);
CF_EXPORT CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len);
CF_EXPORT CFHashCode CFStringHashCharacters(const UniChar *characters, CFIndex len);
CF_EXPORT CFHashCode CFStringHashNSString(CFStringRef str);
#if defined(__cplusplus)
}
#endif
typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef;
extern CFTypeID _CFKeyedArchiverUIDGetTypeID(void);
extern CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value);
extern uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid);
enum {
kCFBinaryPlistMarkerNull = 0x00,
kCFBinaryPlistMarkerFalse = 0x08,
kCFBinaryPlistMarkerTrue = 0x09,
kCFBinaryPlistMarkerFill = 0x0F,
kCFBinaryPlistMarkerInt = 0x10,
kCFBinaryPlistMarkerReal = 0x20,
kCFBinaryPlistMarkerDate = 0x33,
kCFBinaryPlistMarkerData = 0x40,
kCFBinaryPlistMarkerASCIIString = 0x50,
kCFBinaryPlistMarkerUnicode16String = 0x60,
kCFBinaryPlistMarkerUID = 0x80,
kCFBinaryPlistMarkerArray = 0xA0,
kCFBinaryPlistMarkerDict = 0xD0
};
typedef struct {
uint8_t _magic[6];
uint8_t _version[2];
} CFBinaryPlistHeader;
typedef struct {
uint8_t _unused[6];
uint8_t _offsetIntSize;
uint8_t _objectRefSize;
uint64_t _numObjects;
uint64_t _topObject;
uint64_t _offsetTableOffset;
} CFBinaryPlistTrailer;
extern bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer);
extern bool __CFBinaryPlistGetOffsetForValueFromArray(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset);
extern bool __CFBinaryPlistGetOffsetForValueFromDictionary(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset);
extern bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist);
extern CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream);
extern CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format);
#include <CoreFoundation/CFBag.h>
#include <CoreFoundation/CFSet.h>
#include <math.h>
#if defined(__cplusplus)
extern "C" {
#endif
CF_EXPORT CFTypeID CFTypeGetTypeID(void);
CF_EXPORT CFTypeRef _CFRetainGC(CFTypeRef cf);
CF_EXPORT void _CFReleaseGC(CFTypeRef cf);
CF_EXPORT void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap);
CF_EXPORT void _CFBagSetCapacity(CFMutableBagRef bag, CFIndex cap);
CF_EXPORT void _CFDictionarySetCapacity(CFMutableDictionaryRef dict, CFIndex cap);
CF_EXPORT void _CFSetSetCapacity(CFMutableSetRef set, CFIndex cap);
CF_EXPORT void CFCharacterSetCompact(CFMutableCharacterSetRef theSet);
CF_EXPORT void CFCharacterSetFast(CFMutableCharacterSetRef theSet);
CF_EXPORT const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx);
CF_EXPORT void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount);
typedef CFIndex CFSearchPathEnumerationState;
CF_EXPORT CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask);
CF_EXPORT CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, UInt8 *path, CFIndex pathSize);
CF_INLINE CFHashCode _CFHashInt(int i) {
return (i > 0) ? (CFHashCode)(i) : (CFHashCode)(-i);
}
CF_INLINE CFHashCode _CFHashDouble(double d) {
double dInt;
if (d < 0) d = -d;
dInt = rint(d);
return (CFHashCode)(fmod(dInt, (double)0xFFFFFFFF) + ((d - dInt) * 0xFFFFFFFF));
}
CF_EXPORT CFURLRef _CFURLAlloc(CFAllocatorRef allocator);
CF_EXPORT void _CFURLInitWithString(CFURLRef url, CFStringRef string, CFURLRef baseURL);
CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path);
CF_EXPORT Boolean _CFStringIsLegalURLString(CFStringRef string);
CF_EXPORT void *__CFURLReservedPtr(CFURLRef url);
CF_EXPORT void __CFURLSetReservedPtr(CFURLRef url, void *ptr);
typedef void (*CFRunLoopPerformCallBack)(void *info);
CF_EXPORT void _CFRunLoopPerformEnqueue(CFRunLoopRef rl, CFStringRef mode, CFRunLoopPerformCallBack callout, void *info);
CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode);
#if defined(__MACH__)
#if !defined(__CFReadTSR)
#include <mach/mach_time.h>
#define __CFReadTSR() mach_absolute_time()
#endif
#elif defined(__WIN32__)
CF_INLINE UInt64 __CFReadTSR(void) {
LARGE_INTEGER freq;
QueryPerformanceCounter(&freq);
return freq.QuadPart;
}
#else
CF_INLINE UInt64 __CFReadTSR(void) {
union {
UInt64 time64;
UInt32 word[2];
} now;
#if defined(__i386__)
__asm__ volatile("rdtsc" : : : "eax", "edx");
__asm__ volatile("movl %%eax,%0" : "=m" (now.word[0]) : : "eax");
__asm__ volatile("movl %%edx,%0" : "=m" (now.word[1]) : : "edx");
#elif defined(__ppc__) || defined(__ppc64__)
UInt32 t3;
do {
__asm__ volatile("mftbu %0" : "=r" (now.word[0]));
__asm__ volatile("mftb %0" : "=r" (now.word[1]));
__asm__ volatile("mftbu %0" : "=r" (t3));
} while (now.word[0] != t3);
#else
#error Do not know how to read a time stamp register on this architecture
now.time64 = (uint64_t)0;
#endif
return now.time64;
}
#endif
#if defined(__cplusplus)
}
#endif
#endif