├── APPLE_LICENSE ├── CFApplicationPreferences.c ├── CFArray.c ├── CFArray.h ├── CFAvailability.h ├── CFBag.c ├── CFBag.h ├── CFBase.c ├── CFBase.h ├── CFBasicHash.c ├── CFBasicHash.h ├── CFBasicHashFindBucket.m ├── CFBigNumber.c ├── CFBigNumber.h ├── CFBinaryHeap.c ├── CFBinaryHeap.h ├── CFBinaryPList.c ├── CFBitVector.c ├── CFBitVector.h ├── CFBuiltinConverters.c ├── CFBundle.c ├── CFBundle.h ├── CFBundlePriv.h ├── CFBundle_Binary.c ├── CFBundle_BinaryTypes.h ├── CFBundle_Grok.c ├── CFBundle_InfoPlist.c ├── CFBundle_Internal.h ├── CFBundle_Locale.c ├── CFBundle_Resources.c ├── CFBundle_Strings.c ├── CFBurstTrie.c ├── CFBurstTrie.h ├── CFByteOrder.h ├── CFCalendar.c ├── CFCalendar.h ├── CFCharacterSet.c ├── CFCharacterSet.h ├── CFCharacterSetBitmaps.bitmap ├── CFCharacterSetPriv.h ├── CFConcreteStreams.c ├── CFData.c ├── CFData.h ├── CFDate.c ├── CFDate.h ├── CFDateFormatter.c ├── CFDateFormatter.h ├── CFDictionary.c ├── CFDictionary.h ├── CFError.c ├── CFError.h ├── CFError_Private.h ├── CFFileUtilities.c ├── CFICUConverters.c ├── CFICUConverters.h ├── CFICULogging.h ├── CFInternal.h ├── CFLocale.c ├── CFLocale.h ├── CFLocaleIdentifier.c ├── CFLocaleInternal.h ├── CFLocaleKeys.c ├── CFLogUtilities.h ├── CFMachPort.c ├── CFMachPort.h ├── CFMessagePort.c ├── CFMessagePort.h ├── CFNumber.c ├── CFNumber.h ├── CFNumberFormatter.c ├── CFNumberFormatter.h ├── CFOldStylePList.c ├── CFPlatform.c ├── CFPlatformConverters.c ├── CFPlugIn.c ├── CFPlugIn.h ├── CFPlugInCOM.h ├── CFPlugIn_Factory.c ├── CFPlugIn_Factory.h ├── CFPlugIn_Instance.c ├── CFPlugIn_PlugIn.c ├── CFPreferences.c ├── CFPreferences.h ├── CFPriv.h ├── CFPropertyList.c ├── CFPropertyList.h ├── CFRunLoop.c ├── CFRunLoop.h ├── CFRuntime.c ├── CFRuntime.h ├── CFSet.c ├── CFSet.h ├── CFSocket.c ├── CFSocket.h ├── CFSocketStream.c ├── CFSortFunctions.c ├── CFStorage.c ├── CFStorage.h ├── CFStream.c ├── CFStream.h ├── CFStreamAbstract.h ├── CFStreamInternal.h ├── CFStreamPriv.h ├── CFString.c ├── CFString.h ├── CFStringDefaultEncoding.h ├── CFStringEncodingConverter.c ├── CFStringEncodingConverter.h ├── CFStringEncodingConverterExt.h ├── CFStringEncodingConverterPriv.h ├── CFStringEncodingDatabase.c ├── CFStringEncodingDatabase.h ├── CFStringEncodingExt.h ├── CFStringEncodings.c ├── CFStringScanner.c ├── CFStringUtilities.c ├── CFSystemDirectories.c ├── CFTimeZone.c ├── CFTimeZone.h ├── CFTree.c ├── CFTree.h ├── CFURL.c ├── CFURL.h ├── CFURL.inc.h ├── CFURLAccess.c ├── CFURLAccess.h ├── CFURLPriv.h ├── CFUUID.c ├── CFUUID.h ├── CFUniChar.c ├── CFUniChar.h ├── CFUniCharPriv.h ├── CFUniCharPropertyDatabase.data ├── CFUnicodeData-B.mapping ├── CFUnicodeData-L.mapping ├── CFUnicodeDecomposition.c ├── CFUnicodeDecomposition.h ├── CFUnicodePrecomposition.c ├── CFUnicodePrecomposition.h ├── CFUserNotification.c ├── CFUserNotification.h ├── CFUtilities.c ├── CFUtilities.h ├── CFVersion.c ├── CFWindowsUtilities.c ├── CFXMLInputStream.c ├── CFXMLInputStream.h ├── CFXMLNode.c ├── CFXMLNode.h ├── CFXMLParser.c ├── CFXMLParser.h ├── CFXMLPreferencesDomain.c ├── CFXMLTree.c ├── CoreFoundation.h ├── CoreFoundation_Prefix.h ├── Examples └── plconvert.c ├── ForFoundationOnly.h ├── Info.plist ├── Makefile ├── MakefileLinux ├── MakefileVersion ├── PropertyList.dtd ├── README_CFLITE ├── SymbolAliases ├── TargetConditionals.h └── plconvert.c /CFBag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBag.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFBAG__) 29 | #define __COREFOUNDATION_CFBAG__ 1 30 | 31 | #include 32 | 33 | CF_IMPLICIT_BRIDGING_ENABLED 34 | CF_EXTERN_C_BEGIN 35 | 36 | typedef const void * (*CFBagRetainCallBack)(CFAllocatorRef allocator, const void *value); 37 | typedef void (*CFBagReleaseCallBack)(CFAllocatorRef allocator, const void *value); 38 | typedef CFStringRef (*CFBagCopyDescriptionCallBack)(const void *value); 39 | typedef Boolean (*CFBagEqualCallBack)(const void *value1, const void *value2); 40 | typedef CFHashCode (*CFBagHashCallBack)(const void *value); 41 | typedef struct { 42 | CFIndex version; 43 | CFBagRetainCallBack retain; 44 | CFBagReleaseCallBack release; 45 | CFBagCopyDescriptionCallBack copyDescription; 46 | CFBagEqualCallBack equal; 47 | CFBagHashCallBack hash; 48 | } CFBagCallBacks; 49 | 50 | CF_EXPORT 51 | const CFBagCallBacks kCFTypeBagCallBacks; 52 | CF_EXPORT 53 | const CFBagCallBacks kCFCopyStringBagCallBacks; 54 | 55 | typedef void (*CFBagApplierFunction)(const void *value, void *context); 56 | 57 | typedef const struct __CFBag * CFBagRef; 58 | typedef struct __CFBag * CFMutableBagRef; 59 | 60 | CF_EXPORT 61 | CFTypeID CFBagGetTypeID(void); 62 | 63 | CF_EXPORT 64 | CFBagRef CFBagCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFBagCallBacks *callBacks); 65 | 66 | CF_EXPORT 67 | CFBagRef CFBagCreateCopy(CFAllocatorRef allocator, CFBagRef theBag); 68 | 69 | CF_EXPORT 70 | CFMutableBagRef CFBagCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFBagCallBacks *callBacks); 71 | 72 | CF_EXPORT 73 | CFMutableBagRef CFBagCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBagRef theBag); 74 | 75 | CF_EXPORT 76 | CFIndex CFBagGetCount(CFBagRef theBag); 77 | 78 | CF_EXPORT 79 | CFIndex CFBagGetCountOfValue(CFBagRef theBag, const void *value); 80 | 81 | CF_EXPORT 82 | Boolean CFBagContainsValue(CFBagRef theBag, const void *value); 83 | 84 | CF_EXPORT 85 | const void *CFBagGetValue(CFBagRef theBag, const void *value); 86 | 87 | CF_EXPORT 88 | Boolean CFBagGetValueIfPresent(CFBagRef theBag, const void *candidate, const void **value); 89 | 90 | CF_EXPORT 91 | void CFBagGetValues(CFBagRef theBag, const void **values); 92 | 93 | CF_EXPORT 94 | void CFBagApplyFunction(CFBagRef theBag, CFBagApplierFunction applier, void *context); 95 | 96 | CF_EXPORT 97 | void CFBagAddValue(CFMutableBagRef theBag, const void *value); 98 | 99 | CF_EXPORT 100 | void CFBagReplaceValue(CFMutableBagRef theBag, const void *value); 101 | 102 | CF_EXPORT 103 | void CFBagSetValue(CFMutableBagRef theBag, const void *value); 104 | 105 | CF_EXPORT 106 | void CFBagRemoveValue(CFMutableBagRef theBag, const void *value); 107 | 108 | CF_EXPORT 109 | void CFBagRemoveAllValues(CFMutableBagRef theBag); 110 | 111 | CF_EXTERN_C_END 112 | CF_IMPLICIT_BRIDGING_DISABLED 113 | 114 | #endif /* ! __COREFOUNDATION_CFBAG__ */ 115 | 116 | -------------------------------------------------------------------------------- /CFBasicHash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBasicHash.h 25 | Copyright (c) 2008-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #include 29 | #include 30 | #include "CFInternal.h" 31 | 32 | CF_EXTERN_C_BEGIN 33 | 34 | struct __objcFastEnumerationStateEquivalent2 { 35 | unsigned long state; 36 | unsigned long *itemsPtr; 37 | unsigned long *mutationsPtr; 38 | unsigned long extra[5]; 39 | }; 40 | 41 | enum { 42 | __kCFBasicHashLinearHashingValue = 1, 43 | __kCFBasicHashDoubleHashingValue = 2, 44 | __kCFBasicHashExponentialHashingValue = 3, 45 | }; 46 | 47 | enum { 48 | kCFBasicHashHasKeys = (1UL << 0), 49 | kCFBasicHashHasCounts = (1UL << 1), 50 | kCFBasicHashHasHashCache = (1UL << 2), 51 | 52 | kCFBasicHashIntegerValues = (1UL << 6), 53 | kCFBasicHashIntegerKeys = (1UL << 7), 54 | 55 | kCFBasicHashStrongValues = (1UL << 8), 56 | kCFBasicHashStrongKeys = (1UL << 9), 57 | 58 | kCFBasicHashWeakValues = (1UL << 10), 59 | kCFBasicHashWeakKeys = (1UL << 11), 60 | 61 | kCFBasicHashIndirectKeys = (1UL << 12), 62 | 63 | kCFBasicHashLinearHashing = (__kCFBasicHashLinearHashingValue << 13), // bits 13-14 64 | kCFBasicHashDoubleHashing = (__kCFBasicHashDoubleHashingValue << 13), 65 | kCFBasicHashExponentialHashing = (__kCFBasicHashExponentialHashingValue << 13), 66 | 67 | kCFBasicHashAggressiveGrowth = (1UL << 15), 68 | }; 69 | 70 | // Note that for a hash table without keys, the value is treated as the key, 71 | // and the value should be passed in as the key for operations which take a key. 72 | 73 | typedef struct { 74 | CFIndex idx; 75 | uintptr_t weak_key; 76 | uintptr_t weak_value; 77 | uintptr_t count; 78 | } CFBasicHashBucket; 79 | 80 | typedef struct __CFBasicHash *CFBasicHashRef; 81 | typedef const struct __CFBasicHash *CFConstBasicHashRef; 82 | 83 | // Bit 6 in the CF_INFO_BITS of the CFRuntimeBase inside the CFBasicHashRef is the "is immutable" bit 84 | CF_INLINE Boolean CFBasicHashIsMutable(CFConstBasicHashRef ht) { 85 | return __CFBitfieldGetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6) ? false : true; 86 | } 87 | 88 | CF_INLINE void CFBasicHashMakeImmutable(CFBasicHashRef ht) { 89 | __CFBitfieldSetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6, 1); 90 | } 91 | 92 | 93 | typedef struct __CFBasicHashCallbacks CFBasicHashCallbacks; 94 | 95 | struct __CFBasicHashCallbacks { 96 | uintptr_t (*retainValue)(CFAllocatorRef alloc, uintptr_t stack_value); // Return 2nd arg or new value 97 | uintptr_t (*retainKey)(CFAllocatorRef alloc, uintptr_t stack_key); // Return 2nd arg or new key 98 | void (*releaseValue)(CFAllocatorRef alloc, uintptr_t stack_value); 99 | void (*releaseKey)(CFAllocatorRef alloc, uintptr_t stack_key); 100 | Boolean (*equateValues)(uintptr_t coll_value1, uintptr_t stack_value2); // 1st arg is in-collection value, 2nd arg is probe parameter OR in-collection value for a second collection 101 | Boolean (*equateKeys)(uintptr_t coll_key1, uintptr_t stack_key2); // 1st arg is in-collection key, 2nd arg is probe parameter 102 | CFHashCode (*hashKey)(uintptr_t stack_key); 103 | uintptr_t (*getIndirectKey)(uintptr_t coll_value); // Return key; 1st arg is in-collection value 104 | CFStringRef (*copyValueDescription)(uintptr_t stack_value); 105 | CFStringRef (*copyKeyDescription)(uintptr_t stack_key); 106 | }; 107 | 108 | Boolean CFBasicHashHasStrongValues(CFConstBasicHashRef ht); 109 | Boolean CFBasicHashHasStrongKeys(CFConstBasicHashRef ht); 110 | 111 | CFOptionFlags CFBasicHashGetFlags(CFConstBasicHashRef ht); 112 | CFIndex CFBasicHashGetNumBuckets(CFConstBasicHashRef ht); 113 | CFIndex CFBasicHashGetCapacity(CFConstBasicHashRef ht); 114 | void CFBasicHashSetCapacity(CFBasicHashRef ht, CFIndex capacity); 115 | 116 | CFIndex CFBasicHashGetCount(CFConstBasicHashRef ht); 117 | CFBasicHashBucket CFBasicHashGetBucket(CFConstBasicHashRef ht, CFIndex idx); 118 | CFBasicHashBucket CFBasicHashFindBucket(CFConstBasicHashRef ht, uintptr_t stack_key); 119 | CFIndex CFBasicHashGetCountOfKey(CFConstBasicHashRef ht, uintptr_t stack_key); 120 | CFIndex CFBasicHashGetCountOfValue(CFConstBasicHashRef ht, uintptr_t stack_value); 121 | Boolean CFBasicHashesAreEqual(CFConstBasicHashRef ht1, CFConstBasicHashRef ht2); 122 | void CFBasicHashApply(CFConstBasicHashRef ht, Boolean (^block)(CFBasicHashBucket)); 123 | void CFBasicHashApplyIndexed(CFConstBasicHashRef ht, CFRange range, Boolean (^block)(CFBasicHashBucket)); 124 | void CFBasicHashGetElements(CFConstBasicHashRef ht, CFIndex bufferslen, uintptr_t *weak_values, uintptr_t *weak_keys); 125 | 126 | Boolean CFBasicHashAddValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); 127 | void CFBasicHashReplaceValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); 128 | void CFBasicHashSetValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); 129 | CFIndex CFBasicHashRemoveValue(CFBasicHashRef ht, uintptr_t stack_key); 130 | CFIndex CFBasicHashRemoveValueAtIndex(CFBasicHashRef ht, CFIndex idx); 131 | void CFBasicHashRemoveAllValues(CFBasicHashRef ht); 132 | 133 | Boolean CFBasicHashAddIntValueAndInc(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t int_value); 134 | void CFBasicHashRemoveIntValueAndDec(CFBasicHashRef ht, uintptr_t int_value); 135 | 136 | size_t CFBasicHashGetSize(CFConstBasicHashRef ht, Boolean total); 137 | void CFBasicHashSuppressRC(CFBasicHashRef ht); 138 | void CFBasicHashUnsuppressRC(CFBasicHashRef ht); 139 | 140 | CFStringRef CFBasicHashCopyDescription(CFConstBasicHashRef ht, Boolean detailed, CFStringRef linePrefix, CFStringRef entryLinePrefix, Boolean describeElements); 141 | 142 | CFTypeID CFBasicHashGetTypeID(void); 143 | 144 | extern Boolean __CFBasicHashEqual(CFTypeRef cf1, CFTypeRef cf2); 145 | extern CFHashCode __CFBasicHashHash(CFTypeRef cf); 146 | extern CFStringRef __CFBasicHashCopyDescription(CFTypeRef cf); 147 | extern void __CFBasicHashDeallocate(CFTypeRef cf); 148 | extern unsigned long __CFBasicHashFastEnumeration(CFConstBasicHashRef ht, struct __objcFastEnumerationStateEquivalent2 *state, void *stackbuffer, unsigned long count); 149 | 150 | // creation functions create mutable CFBasicHashRefs 151 | CFBasicHashRef CFBasicHashCreate(CFAllocatorRef allocator, CFOptionFlags flags, const CFBasicHashCallbacks *cb); 152 | CFBasicHashRef CFBasicHashCreateCopy(CFAllocatorRef allocator, CFConstBasicHashRef ht); 153 | 154 | 155 | CF_EXTERN_C_END 156 | 157 | -------------------------------------------------------------------------------- /CFBasicHashFindBucket.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBasicHashFindBucket.m 25 | Copyright (c) 2009-2014, Apple Inc. All rights reserved. 26 | Responsibility: Christopher Kane 27 | */ 28 | 29 | 30 | #if !defined(FIND_BUCKET_NAME) || !defined(FIND_BUCKET_HASH_STYLE) || !defined(FIND_BUCKET_FOR_REHASH) || !defined(FIND_BUCKET_FOR_INDIRECT_KEY) 31 | #error All of FIND_BUCKET_NAME, FIND_BUCKET_HASH_STYLE, FIND_BUCKET_FOR_REHASH, and FIND_BUCKET_FOR_INDIRECT_KEY must be defined before #including this file. 32 | #endif 33 | 34 | 35 | // During rehashing of a mutable CFBasicHash, we know that there are no 36 | // deleted slots and the keys have already been uniqued. When rehashing, 37 | // if key_hash is non-0, we use it as the hash code. 38 | static 39 | #if FIND_BUCKET_FOR_REHASH 40 | CFIndex 41 | #else 42 | CFBasicHashBucket 43 | #endif 44 | FIND_BUCKET_NAME (CFConstBasicHashRef ht, uintptr_t stack_key 45 | #if FIND_BUCKET_FOR_REHASH 46 | , uintptr_t key_hash 47 | #endif 48 | ) { 49 | uint8_t num_buckets_idx = ht->bits.num_buckets_idx; 50 | uintptr_t num_buckets = __CFBasicHashTableSizes[num_buckets_idx]; 51 | #if FIND_BUCKET_FOR_REHASH 52 | CFHashCode hash_code = key_hash ? key_hash : __CFBasicHashHashKey(ht, stack_key); 53 | #else 54 | CFHashCode hash_code = __CFBasicHashHashKey(ht, stack_key); 55 | #endif 56 | 57 | #if FIND_BUCKET_HASH_STYLE == 1 // __kCFBasicHashLinearHashingValue 58 | // Linear probing, with c = 1 59 | // probe[0] = h1(k) 60 | // probe[i] = (h1(k) + i * c) mod num_buckets, i = 1 .. num_buckets - 1 61 | // h1(k) = k mod num_buckets 62 | #if defined(__arm__) 63 | uintptr_t h1 = __CFBasicHashFold(hash_code, num_buckets_idx); 64 | #else 65 | uintptr_t h1 = hash_code % num_buckets; 66 | #endif 67 | #elif FIND_BUCKET_HASH_STYLE == 2 // __kCFBasicHashDoubleHashingValue 68 | // Double hashing 69 | // probe[0] = h1(k) 70 | // probe[i] = (h1(k) + i * h2(k)) mod num_buckets, i = 1 .. num_buckets - 1 71 | // h1(k) = k mod num_buckets 72 | // h2(k) = floor(k / num_buckets) mod num_buckets 73 | #if defined(__arm__) 74 | uintptr_t h1 = __CFBasicHashFold(hash_code, num_buckets_idx); 75 | uintptr_t h2 = __CFBasicHashFold(hash_code / num_buckets, num_buckets_idx); 76 | #else 77 | uintptr_t h1 = hash_code % num_buckets; 78 | uintptr_t h2 = (hash_code / num_buckets) % num_buckets; 79 | #endif 80 | if (0 == h2) h2 = num_buckets - 1; 81 | #elif FIND_BUCKET_HASH_STYLE == 3 // __kCFBasicHashExponentialHashingValue 82 | // Improved exponential hashing 83 | // probe[0] = h1(k) 84 | // probe[i] = (h1(k) + pr(k)^i * h2(k)) mod num_buckets, i = 1 .. num_buckets - 1 85 | // h1(k) = k mod num_buckets 86 | // h2(k) = floor(k / num_buckets) mod num_buckets 87 | // note: h2(k) has the effect of rotating the sequence if it is constant 88 | // note: pr(k) is any primitive root of num_buckets, varying this gives different sequences 89 | #if defined(__arm__) 90 | uintptr_t h1 = __CFBasicHashFold(hash_code, num_buckets_idx); 91 | uintptr_t h2 = __CFBasicHashFold(hash_code / num_buckets, num_buckets_idx); 92 | #else 93 | uintptr_t h1 = hash_code % num_buckets; 94 | uintptr_t h2 = (hash_code / num_buckets) % num_buckets; 95 | #endif 96 | if (0 == h2) h2 = num_buckets - 1; 97 | uintptr_t pr = __CFBasicHashPrimitiveRoots[num_buckets_idx]; 98 | #endif 99 | 100 | COCOA_HASHTABLE_PROBING_START(ht, num_buckets); 101 | CFBasicHashValue *keys = (ht->bits.keys_offset) ? __CFBasicHashGetKeys(ht) : __CFBasicHashGetValues(ht); 102 | #if !FIND_BUCKET_FOR_REHASH 103 | uintptr_t *hashes = (__CFBasicHashHasHashCache(ht)) ? __CFBasicHashGetHashes(ht) : NULL; 104 | #endif 105 | CFIndex deleted_idx = kCFNotFound; 106 | uintptr_t probe = h1; 107 | #if FIND_BUCKET_HASH_STYLE == 3 // __kCFBasicHashExponentialHashingValue 108 | uintptr_t acc = pr; 109 | #endif 110 | for (CFIndex idx = 0; idx < num_buckets; idx++) { 111 | uintptr_t curr_key = keys[probe].neutral; 112 | if (curr_key == 0UL) { 113 | COCOA_HASHTABLE_PROBE_EMPTY(ht, probe); 114 | #if FIND_BUCKET_FOR_REHASH 115 | CFIndex result = (kCFNotFound == deleted_idx) ? probe : deleted_idx; 116 | #else 117 | CFBasicHashBucket result; 118 | result.idx = (kCFNotFound == deleted_idx) ? probe : deleted_idx; 119 | result.count = 0; 120 | #endif 121 | COCOA_HASHTABLE_PROBING_END(ht, idx + 1); 122 | return result; 123 | #if !FIND_BUCKET_FOR_REHASH 124 | } else if (curr_key == ~0UL) { 125 | COCOA_HASHTABLE_PROBE_DELETED(ht, probe); 126 | if (kCFNotFound == deleted_idx) { 127 | deleted_idx = probe; 128 | } 129 | } else { 130 | COCOA_HASHTABLE_PROBE_VALID(ht, probe); 131 | if (__CFBasicHashSubABZero == curr_key) curr_key = 0UL; 132 | if (__CFBasicHashSubABOne == curr_key) curr_key = ~0UL; 133 | #if FIND_BUCKET_FOR_INDIRECT_KEY 134 | // curr_key holds the value coming in here 135 | curr_key = __CFBasicHashGetIndirectKey(ht, curr_key); 136 | #endif 137 | if (curr_key == stack_key || ((!hashes || hashes[probe] == hash_code) && __CFBasicHashTestEqualKey(ht, curr_key, stack_key))) { 138 | COCOA_HASHTABLE_PROBING_END(ht, idx + 1); 139 | #if FIND_BUCKET_FOR_REHASH 140 | CFIndex result = probe; 141 | #else 142 | CFBasicHashBucket result; 143 | result.idx = probe; 144 | result.weak_value = __CFBasicHashGetValue(ht, probe); 145 | result.weak_key = curr_key; 146 | result.count = (ht->bits.counts_offset) ? __CFBasicHashGetSlotCount(ht, probe) : 1; 147 | #endif 148 | return result; 149 | } 150 | #endif 151 | } 152 | 153 | #if FIND_BUCKET_HASH_STYLE == 1 // __kCFBasicHashLinearHashingValue 154 | probe += 1; 155 | if (num_buckets <= probe) { 156 | probe -= num_buckets; 157 | } 158 | #elif FIND_BUCKET_HASH_STYLE == 2 // __kCFBasicHashDoubleHashingValue 159 | probe += h2; 160 | if (num_buckets <= probe) { 161 | probe -= num_buckets; 162 | } 163 | #elif FIND_BUCKET_HASH_STYLE == 3 // __kCFBasicHashExponentialHashingValue 164 | probe = h1 + h2 * acc; 165 | if (num_buckets <= probe) { 166 | #if defined(__arm__) 167 | probe = __CFBasicHashFold(probe, num_buckets_idx); 168 | #else 169 | probe = probe % num_buckets; 170 | #endif 171 | } 172 | acc = acc * pr; 173 | if (num_buckets <= acc) { 174 | #if defined(__arm__) 175 | acc = __CFBasicHashFold(acc, num_buckets_idx); 176 | #else 177 | acc = acc % num_buckets; 178 | #endif 179 | } 180 | #endif 181 | 182 | } 183 | COCOA_HASHTABLE_PROBING_END(ht, num_buckets); 184 | #if FIND_BUCKET_FOR_REHASH 185 | CFIndex result = deleted_idx; 186 | #else 187 | CFBasicHashBucket result; 188 | result.idx = deleted_idx; 189 | result.count = 0; 190 | #endif 191 | return result; // all buckets full or deleted, return first deleted element which was found 192 | } 193 | 194 | #undef FIND_BUCKET_NAME 195 | #undef FIND_BUCKET_HASH_STYLE 196 | #undef FIND_BUCKET_FOR_REHASH 197 | #undef FIND_BUCKET_FOR_INDIRECT_KEY 198 | 199 | -------------------------------------------------------------------------------- /CFBigNumber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBigNumber.h 25 | Copyright (c) 2012-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFBIGNUMBER__) 29 | #define __COREFOUNDATION_CFBIGNUMBER__ 1 30 | 31 | #include 32 | #include 33 | 34 | 35 | // Base 1 billion number: each digit represents 0 to 999999999 36 | typedef struct { 37 | uint32_t digits[5]; 38 | int32_t sign:8; 39 | uint32_t __:24; 40 | } _CFBigNum; 41 | 42 | void _CFBigNumInitWithInt8(_CFBigNum *r, int8_t inNum); 43 | void _CFBigNumInitWithInt16(_CFBigNum *r, int16_t inNum); 44 | void _CFBigNumInitWithInt32(_CFBigNum *r, int32_t inNum); 45 | void _CFBigNumInitWithInt64(_CFBigNum *r, int64_t inNum); 46 | #ifdef __LP64__ 47 | void _CFBigNumInitWithInt128(_CFBigNum *r, __int128_t inNum); 48 | #endif 49 | 50 | void _CFBigNumInitWithUInt8(_CFBigNum *r, uint8_t inNum); 51 | void _CFBigNumInitWithUInt16(_CFBigNum *r, uint16_t inNum); 52 | void _CFBigNumInitWithUInt32(_CFBigNum *r, uint32_t inNum); 53 | void _CFBigNumInitWithUInt64(_CFBigNum *r, uint64_t inNum); 54 | #ifdef __LP64__ 55 | void _CFBigNumInitWithUInt128(_CFBigNum *r, __uint128_t inNum); 56 | #endif 57 | 58 | int8_t _CFBigNumGetInt8(const _CFBigNum *num); 59 | int16_t _CFBigNumGetInt16(const _CFBigNum *num); 60 | int32_t _CFBigNumGetInt32(const _CFBigNum *num); 61 | int64_t _CFBigNumGetInt64(const _CFBigNum *num); 62 | #ifdef __LP64__ 63 | __int128_t _CFBigNumGetInt128(const _CFBigNum *num); 64 | #endif 65 | 66 | uint8_t _CFBigNumGetUInt8(const _CFBigNum *num); 67 | uint16_t _CFBigNumGetUInt16(const _CFBigNum *num); 68 | uint32_t _CFBigNumGetUInt32(const _CFBigNum *num); 69 | uint64_t _CFBigNumGetUInt64(const _CFBigNum *num); 70 | #ifdef __LP64__ 71 | __uint128_t _CFBigNumGetUInt128(const _CFBigNum *num); 72 | #endif 73 | 74 | void _CFBigNumInitWithCFNumber(_CFBigNum *r, CFNumberRef input); 75 | void _CFBigNumInitWithBytes(_CFBigNum *r, const void *bytes, CFNumberType type); 76 | CFNumberRef _CFNumberCreateWithBigNum(const _CFBigNum *input); 77 | 78 | 79 | CFComparisonResult _CFBigNumCompare(const _CFBigNum *a, const _CFBigNum *b); 80 | 81 | void _CFBigNumNeg(_CFBigNum *r, const _CFBigNum *a); 82 | uint8_t _CFBigNumAdd(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); 83 | uint8_t _CFBigNumSub(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); 84 | 85 | 86 | void _CFBigNumToCString(const _CFBigNum *vp, Boolean leading_zeros, Boolean leading_plus, char *buffer, size_t buflen); 87 | void _CFBigNumFromCString(_CFBigNum *r, const char *string); 88 | 89 | char *_CFBigNumCopyDescription(const _CFBigNum *num); // caller must free() returned ptr 90 | 91 | 92 | #endif /* ! __COREFOUNDATION_CFBIGNUMBER__ */ 93 | 94 | -------------------------------------------------------------------------------- /CFBitVector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBitVector.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFBITVECTOR__) 29 | #define __COREFOUNDATION_CFBITVECTOR__ 1 30 | 31 | #include 32 | 33 | CF_IMPLICIT_BRIDGING_ENABLED 34 | CF_EXTERN_C_BEGIN 35 | 36 | typedef UInt32 CFBit; 37 | 38 | typedef const struct __CFBitVector * CFBitVectorRef; 39 | typedef struct __CFBitVector * CFMutableBitVectorRef; 40 | 41 | CF_EXPORT CFTypeID CFBitVectorGetTypeID(void); 42 | 43 | CF_EXPORT CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex numBits); 44 | CF_EXPORT CFBitVectorRef CFBitVectorCreateCopy(CFAllocatorRef allocator, CFBitVectorRef bv); 45 | CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutable(CFAllocatorRef allocator, CFIndex capacity); 46 | CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBitVectorRef bv); 47 | 48 | CF_EXPORT CFIndex CFBitVectorGetCount(CFBitVectorRef bv); 49 | CF_EXPORT CFIndex CFBitVectorGetCountOfBit(CFBitVectorRef bv, CFRange range, CFBit value); 50 | CF_EXPORT Boolean CFBitVectorContainsBit(CFBitVectorRef bv, CFRange range, CFBit value); 51 | CF_EXPORT CFBit CFBitVectorGetBitAtIndex(CFBitVectorRef bv, CFIndex idx); 52 | CF_EXPORT void CFBitVectorGetBits(CFBitVectorRef bv, CFRange range, UInt8 *bytes); 53 | CF_EXPORT CFIndex CFBitVectorGetFirstIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); 54 | CF_EXPORT CFIndex CFBitVectorGetLastIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); 55 | 56 | CF_EXPORT void CFBitVectorSetCount(CFMutableBitVectorRef bv, CFIndex count); 57 | CF_EXPORT void CFBitVectorFlipBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx); 58 | CF_EXPORT void CFBitVectorFlipBits(CFMutableBitVectorRef bv, CFRange range); 59 | CF_EXPORT void CFBitVectorSetBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx, CFBit value); 60 | CF_EXPORT void CFBitVectorSetBits(CFMutableBitVectorRef bv, CFRange range, CFBit value); 61 | CF_EXPORT void CFBitVectorSetAllBits(CFMutableBitVectorRef bv, CFBit value); 62 | 63 | CF_EXTERN_C_END 64 | CF_IMPLICIT_BRIDGING_DISABLED 65 | 66 | #endif /* ! __COREFOUNDATION_CFBITVECTOR__ */ 67 | 68 | -------------------------------------------------------------------------------- /CFBundle_BinaryTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBundle_BinaryTypes.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFBUNDLE_BINARYTYPES__) 29 | #define __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ 1 30 | 31 | CF_EXTERN_C_BEGIN 32 | 33 | #if DEPLOYMENT_TARGET_MACOSX 34 | #define BINARY_SUPPORT_DYLD 1 35 | #define BINARY_SUPPORT_DLFCN 1 36 | #define USE_DYLD_PRIV 1 37 | #elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI 38 | #define BINARY_SUPPORT_DYLD 1 39 | #define BINARY_SUPPORT_DLFCN 1 40 | #define USE_DYLD_PRIV 1 41 | #elif DEPLOYMENT_TARGET_WINDOWS 42 | #define BINARY_SUPPORT_DLL 1 43 | #else 44 | #error Unknown or unspecified DEPLOYMENT_TARGET 45 | #endif 46 | 47 | 48 | typedef enum { 49 | __CFBundleUnknownBinary, 50 | __CFBundleCFMBinary, 51 | __CFBundleDYLDExecutableBinary, 52 | __CFBundleDYLDBundleBinary, 53 | __CFBundleDYLDFrameworkBinary, 54 | __CFBundleDLLBinary, 55 | __CFBundleUnreadableBinary, 56 | __CFBundleNoBinary, 57 | __CFBundleELFBinary 58 | } __CFPBinaryType; 59 | 60 | /* Intended for eventual public consumption */ 61 | typedef enum { 62 | kCFBundleOtherExecutableType = 0, 63 | kCFBundleMachOExecutableType, 64 | kCFBundlePEFExecutableType, 65 | kCFBundleELFExecutableType, 66 | kCFBundleDLLExecutableType 67 | } CFBundleExecutableType; 68 | 69 | CF_EXTERN_C_END 70 | 71 | #endif /* ! __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ */ 72 | 73 | -------------------------------------------------------------------------------- /CFBundle_Strings.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFBundle_Strings.c 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | Responsibility: Tony Parker 27 | */ 28 | 29 | #include "CFBundle_Internal.h" 30 | #if DEPLOYMENT_TARGET_MACOSX 31 | 32 | #endif 33 | 34 | #include 35 | #include 36 | 37 | #pragma mark - 38 | #pragma mark Localized Strings 39 | 40 | 41 | CF_EXPORT CFStringRef CFBundleCopyLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName) { 42 | return CFBundleCopyLocalizedStringForLocalization(bundle, key, value, tableName, NULL); 43 | } 44 | 45 | CF_EXPORT CFStringRef CFBundleCopyLocalizedStringForLocalization(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName, CFStringRef localizationName) { 46 | CFStringRef result = NULL; 47 | CFDictionaryRef stringTable = NULL; 48 | 49 | if (!key) return (value ? (CFStringRef)CFRetain(value) : (CFStringRef)CFRetain(CFSTR(""))); 50 | 51 | // Make sure to check the mixed localizations key early -- if the main bundle has not yet been cached, then we need to create the cache of the Info.plist before we start asking for resources (11172381) 52 | (void)CFBundleAllowMixedLocalizations(); 53 | 54 | if (!tableName || CFEqual(tableName, CFSTR(""))) tableName = _CFBundleDefaultStringTableName; 55 | 56 | __CFLock(&bundle->_lock); 57 | // Only consult the cache when a specific localization has not been requested. We only cache results for the preferred language as determined by normal bundle lookup rules. 58 | if (!localizationName && bundle->_stringTable) { 59 | stringTable = (CFDictionaryRef)CFDictionaryGetValue(bundle->_stringTable, tableName); 60 | if (stringTable) CFRetain(stringTable); 61 | } 62 | 63 | if (!stringTable) { 64 | // Go load the table. First, unlock so we don't hold the lock across file system access. 65 | __CFUnlock(&bundle->_lock); 66 | 67 | CFURLRef tableURL = NULL; 68 | if (localizationName) { 69 | tableURL = CFBundleCopyResourceURLForLocalization(bundle, tableName, _CFBundleStringTableType, NULL, localizationName); 70 | } else { 71 | tableURL = CFBundleCopyResourceURL(bundle, tableName, _CFBundleStringTableType, NULL); 72 | } 73 | 74 | if (tableURL) { 75 | CFStringRef nameForSharing = NULL; 76 | if (!stringTable) { 77 | CFDataRef tableData = NULL; 78 | SInt32 errCode; 79 | #pragma GCC diagnostic push 80 | #pragma GCC diagnostic ignored "-Wdeprecated" 81 | if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorSystemDefault, tableURL, &tableData, NULL, NULL, &errCode)) { 82 | #pragma GCC diagnostic pop 83 | CFErrorRef error = NULL; 84 | stringTable = (CFDictionaryRef)CFPropertyListCreateWithData(CFGetAllocator(bundle), tableData, kCFPropertyListImmutable, NULL, &error); 85 | if (stringTable && CFDictionaryGetTypeID() != CFGetTypeID(stringTable)) { 86 | CFRelease(stringTable); 87 | stringTable = NULL; 88 | } 89 | if (!stringTable && error) { 90 | CFLog(kCFLogLevelError, CFSTR("Unable to load string table file: %@ / %@: %@"), bundle, tableName, error); 91 | CFRelease(error); 92 | error = NULL; 93 | } 94 | CFRelease(tableData); 95 | 96 | } 97 | } 98 | if (nameForSharing) CFRelease(nameForSharing); 99 | if (tableURL) CFRelease(tableURL); 100 | } 101 | if (!stringTable) stringTable = CFDictionaryCreate(CFGetAllocator(bundle), NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 102 | 103 | if ((!CFStringHasSuffix(tableName, CFSTR(".nocache")) || !_CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard)) && localizationName == NULL) { 104 | // Take lock again, because this we will unlock after getting the value out of the table. 105 | __CFLock(&bundle->_lock); 106 | if (!bundle->_stringTable) bundle->_stringTable = CFDictionaryCreateMutable(CFGetAllocator(bundle), 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 107 | 108 | // If another thread beat us to setting this tableName, then we'll just replace it here. 109 | CFDictionarySetValue(bundle->_stringTable, tableName, stringTable); 110 | } else { 111 | // Take lock again, because this we will unlock after getting the value out of the table. 112 | __CFLock(&bundle->_lock); 113 | } 114 | } 115 | 116 | result = (CFStringRef)CFDictionaryGetValue(stringTable, key); 117 | if (result) { 118 | CFRetain(result); 119 | } 120 | 121 | __CFUnlock(&bundle->_lock); 122 | CFRelease(stringTable); 123 | 124 | if (!result) { 125 | if (!value) { 126 | result = (CFStringRef)CFRetain(key); 127 | } else if (CFEqual(value, CFSTR(""))) { 128 | result = (CFStringRef)CFRetain(key); 129 | } else { 130 | result = (CFStringRef)CFRetain(value); 131 | } 132 | static Boolean capitalize = false; 133 | if (capitalize) { 134 | CFMutableStringRef capitalizedResult = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, result); 135 | CFLog(__kCFLogBundle, CFSTR("Localizable string \"%@\" not found in strings table \"%@\" of bundle %@."), key, tableName, bundle); 136 | CFStringUppercase(capitalizedResult, NULL); 137 | CFRelease(result); 138 | result = capitalizedResult; 139 | } 140 | } 141 | 142 | return result; 143 | } 144 | 145 | -------------------------------------------------------------------------------- /CFCalendar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFCalendar.h 25 | Copyright (c) 2004-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFCALENDAR__) 29 | #define __COREFOUNDATION_CFCALENDAR__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | CF_IMPLICIT_BRIDGING_ENABLED 37 | CF_EXTERN_C_BEGIN 38 | 39 | typedef struct CF_BRIDGED_MUTABLE_TYPE(NSCalendar) __CFCalendar * CFCalendarRef; 40 | 41 | CF_EXPORT 42 | CFTypeID CFCalendarGetTypeID(void); 43 | 44 | CF_EXPORT 45 | CFCalendarRef CFCalendarCopyCurrent(void); 46 | 47 | CF_EXPORT 48 | CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier); 49 | // Create a calendar. The identifiers are the kCF*Calendar 50 | // constants in CFLocale.h. 51 | 52 | CF_EXPORT 53 | CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar); 54 | // Returns the calendar's identifier. 55 | 56 | CF_EXPORT 57 | CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar); 58 | 59 | CF_EXPORT 60 | void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale); 61 | 62 | CF_EXPORT 63 | CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar); 64 | 65 | CF_EXPORT 66 | void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz); 67 | 68 | CF_EXPORT 69 | CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar); 70 | 71 | CF_EXPORT 72 | void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy); 73 | 74 | CF_EXPORT 75 | CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar); 76 | 77 | CF_EXPORT 78 | void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd); 79 | 80 | 81 | typedef CF_OPTIONS(CFOptionFlags, CFCalendarUnit) { 82 | kCFCalendarUnitEra = (1UL << 1), 83 | kCFCalendarUnitYear = (1UL << 2), 84 | kCFCalendarUnitMonth = (1UL << 3), 85 | kCFCalendarUnitDay = (1UL << 4), 86 | kCFCalendarUnitHour = (1UL << 5), 87 | kCFCalendarUnitMinute = (1UL << 6), 88 | kCFCalendarUnitSecond = (1UL << 7), 89 | kCFCalendarUnitWeek CF_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0) = (1UL << 8), 90 | kCFCalendarUnitWeekday = (1UL << 9), 91 | kCFCalendarUnitWeekdayOrdinal = (1UL << 10), 92 | kCFCalendarUnitQuarter CF_ENUM_AVAILABLE(10_6, 4_0) = (1UL << 11), 93 | kCFCalendarUnitWeekOfMonth CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 12), 94 | kCFCalendarUnitWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 13), 95 | kCFCalendarUnitYearForWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 14), 96 | }; 97 | 98 | CF_EXPORT 99 | CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); 100 | 101 | CF_EXPORT 102 | CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); 103 | 104 | CF_EXPORT 105 | CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); 106 | 107 | CF_EXPORT 108 | CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); 109 | 110 | CF_EXPORT 111 | Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) CF_AVAILABLE(10_5, 2_0); 112 | 113 | CF_EXPORT 114 | Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...); 115 | 116 | CF_EXPORT 117 | Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...); 118 | 119 | 120 | enum { 121 | kCFCalendarComponentsWrap = (1UL << 0) // option for adding 122 | }; 123 | 124 | CF_EXPORT 125 | Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...); 126 | 127 | CF_EXPORT 128 | Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...); 129 | 130 | 131 | CF_EXTERN_C_END 132 | CF_IMPLICIT_BRIDGING_DISABLED 133 | 134 | #endif /* ! __COREFOUNDATION_CFCALENDAR__ */ 135 | 136 | -------------------------------------------------------------------------------- /CFCharacterSetBitmaps.bitmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensource-apple/CF/3cc41a76b1491f50813e28a4ec09954ffa359e6f/CFCharacterSetBitmaps.bitmap -------------------------------------------------------------------------------- /CFCharacterSetPriv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFCharacterSetPriv.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFCHARACTERSETPRIV__) 29 | #define __COREFOUNDATION_CFCHARACTERSETPRIV__ 1 30 | 31 | #include 32 | 33 | CF_EXTERN_C_BEGIN 34 | 35 | /*! 36 | @function CFCharacterSetIsSurrogateHighCharacter 37 | Reports whether or not the character is a high surrogate. 38 | @param character The character to be checked. 39 | @result true, if character is a high surrogate, otherwise false. 40 | */ 41 | CF_INLINE Boolean CFCharacterSetIsSurrogateHighCharacter(UniChar character) { 42 | return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); 43 | } 44 | 45 | /*! 46 | @function CFCharacterSetIsSurrogateLowCharacter 47 | Reports whether or not the character is a low surrogate. 48 | @param character The character to be checked. 49 | @result true, if character is a low surrogate, otherwise false. 50 | */ 51 | CF_INLINE Boolean CFCharacterSetIsSurrogateLowCharacter(UniChar character) { 52 | return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); 53 | } 54 | 55 | /*! 56 | @function CFCharacterSetGetLongCharacterForSurrogatePair 57 | Returns the UTF-32 value corresponding to the surrogate pair passed in. 58 | @param surrogateHigh The high surrogate character. If this parameter 59 | is not a valid high surrogate character, the behavior is undefined. 60 | @param surrogateLow The low surrogate character. If this parameter 61 | is not a valid low surrogate character, the behavior is undefined. 62 | @result The UTF-32 value for the surrogate pair. 63 | */ 64 | CF_INLINE UTF32Char CFCharacterSetGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { 65 | return (UTF32Char)(((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL); 66 | } 67 | 68 | /* Check to see if the character represented by the surrogate pair surrogateHigh & surrogateLow is in the chraracter set */ 69 | CF_EXPORT Boolean CFCharacterSetIsSurrogatePairMember(CFCharacterSetRef theSet, UniChar surrogateHigh, UniChar surrogateLow) ; 70 | 71 | /* Keyed-coding support 72 | */ 73 | typedef CF_ENUM(CFIndex, CFCharacterSetKeyedCodingType) { 74 | kCFCharacterSetKeyedCodingTypeBitmap = 1, 75 | kCFCharacterSetKeyedCodingTypeBuiltin = 2, 76 | kCFCharacterSetKeyedCodingTypeRange = 3, 77 | kCFCharacterSetKeyedCodingTypeString = 4, 78 | kCFCharacterSetKeyedCodingTypeBuiltinAndBitmap = 5 79 | }; 80 | 81 | CF_EXPORT CFCharacterSetKeyedCodingType _CFCharacterSetGetKeyedCodingType(CFCharacterSetRef cset); 82 | CF_EXPORT CFCharacterSetPredefinedSet _CFCharacterSetGetKeyedCodingBuiltinType(CFCharacterSetRef cset); 83 | CF_EXPORT CFRange _CFCharacterSetGetKeyedCodingRange(CFCharacterSetRef cset); 84 | CF_EXPORT CFStringRef _CFCharacterSetCreateKeyedCodingString(CFCharacterSetRef cset); 85 | CF_EXPORT bool _CFCharacterSetIsInverted(CFCharacterSetRef cset); 86 | CF_EXPORT void _CFCharacterSetSetIsInverted(CFCharacterSetRef cset, bool flag); 87 | 88 | CF_EXTERN_C_END 89 | 90 | #endif /* ! __COREFOUNDATION_CFCHARACTERSETPRIV__ */ 91 | 92 | -------------------------------------------------------------------------------- /CFData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFData.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFDATA__) 29 | #define __COREFOUNDATION_CFDATA__ 1 30 | 31 | #include 32 | 33 | CF_IMPLICIT_BRIDGING_ENABLED 34 | CF_EXTERN_C_BEGIN 35 | 36 | typedef const struct CF_BRIDGED_TYPE(NSData) __CFData * CFDataRef; 37 | typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableData) __CFData * CFMutableDataRef; 38 | 39 | CF_EXPORT 40 | CFTypeID CFDataGetTypeID(void); 41 | 42 | CF_EXPORT 43 | CFDataRef CFDataCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length); 44 | 45 | CF_EXPORT 46 | CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator); 47 | /* Pass kCFAllocatorNull as bytesDeallocator to assure the bytes aren't freed */ 48 | 49 | CF_EXPORT 50 | CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef theData); 51 | 52 | CF_EXPORT 53 | CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity); 54 | 55 | CF_EXPORT 56 | CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef theData); 57 | 58 | CF_EXPORT 59 | CFIndex CFDataGetLength(CFDataRef theData); 60 | 61 | CF_EXPORT 62 | const UInt8 *CFDataGetBytePtr(CFDataRef theData); 63 | 64 | CF_EXPORT 65 | UInt8 *CFDataGetMutableBytePtr(CFMutableDataRef theData); 66 | 67 | CF_EXPORT 68 | void CFDataGetBytes(CFDataRef theData, CFRange range, UInt8 *buffer); 69 | 70 | CF_EXPORT 71 | void CFDataSetLength(CFMutableDataRef theData, CFIndex length); 72 | 73 | CF_EXPORT 74 | void CFDataIncreaseLength(CFMutableDataRef theData, CFIndex extraLength); 75 | 76 | CF_EXPORT 77 | void CFDataAppendBytes(CFMutableDataRef theData, const UInt8 *bytes, CFIndex length); 78 | 79 | CF_EXPORT 80 | void CFDataReplaceBytes(CFMutableDataRef theData, CFRange range, const UInt8 *newBytes, CFIndex newLength); 81 | 82 | CF_EXPORT 83 | void CFDataDeleteBytes(CFMutableDataRef theData, CFRange range); 84 | 85 | typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags) { 86 | kCFDataSearchBackwards = 1UL << 0, 87 | kCFDataSearchAnchored = 1UL << 1 88 | } CF_ENUM_AVAILABLE(10_6, 4_0); 89 | 90 | CF_EXPORT 91 | CFRange CFDataFind(CFDataRef theData, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions) CF_AVAILABLE(10_6, 4_0); 92 | 93 | CF_EXTERN_C_END 94 | CF_IMPLICIT_BRIDGING_DISABLED 95 | 96 | #endif /* ! __COREFOUNDATION_CFDATA__ */ 97 | 98 | -------------------------------------------------------------------------------- /CFDate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFDate.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFDATE__) 29 | #define __COREFOUNDATION_CFDATE__ 1 30 | 31 | #include 32 | 33 | CF_IMPLICIT_BRIDGING_ENABLED 34 | CF_EXTERN_C_BEGIN 35 | 36 | typedef double CFTimeInterval; 37 | typedef CFTimeInterval CFAbsoluteTime; 38 | /* absolute time is the time interval since the reference date */ 39 | /* the reference date (epoch) is 00:00:00 1 January 2001. */ 40 | 41 | CF_EXPORT 42 | CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); 43 | 44 | CF_EXPORT 45 | const CFTimeInterval kCFAbsoluteTimeIntervalSince1970; 46 | CF_EXPORT 47 | const CFTimeInterval kCFAbsoluteTimeIntervalSince1904; 48 | 49 | typedef const struct CF_BRIDGED_TYPE(NSDate) __CFDate * CFDateRef; 50 | 51 | CF_EXPORT 52 | CFTypeID CFDateGetTypeID(void); 53 | 54 | CF_EXPORT 55 | CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); 56 | 57 | CF_EXPORT 58 | CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); 59 | 60 | CF_EXPORT 61 | CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef theDate, CFDateRef otherDate); 62 | 63 | CF_EXPORT 64 | CFComparisonResult CFDateCompare(CFDateRef theDate, CFDateRef otherDate, void *context); 65 | 66 | CF_IMPLICIT_BRIDGING_DISABLED 67 | 68 | typedef const struct CF_BRIDGED_TYPE(NSTimeZone) __CFTimeZone * CFTimeZoneRef; 69 | 70 | 71 | #if !defined(CF_CALENDAR_ENUM_DEPRECATED) 72 | #define CF_CALENDAR_ENUM_DEPRECATED(A, B, C, D, ...) CF_ENUM_DEPRECATED(A, B, C, D, __VA_ARGS__) 73 | #define CF_CALENDAR_DEPRECATED(A, B, C, D, ...) CF_DEPRECATED(A, B, C, D, __VA_ARGS__) 74 | #endif 75 | 76 | typedef struct { 77 | SInt32 year; 78 | SInt8 month; 79 | SInt8 day; 80 | SInt8 hour; 81 | SInt8 minute; 82 | double second; 83 | } CFGregorianDate CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 84 | 85 | typedef struct { 86 | SInt32 years; 87 | SInt32 months; 88 | SInt32 days; 89 | SInt32 hours; 90 | SInt32 minutes; 91 | double seconds; 92 | } CFGregorianUnits CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 93 | 94 | typedef CF_OPTIONS(CFOptionFlags, CFGregorianUnitFlags) { 95 | kCFGregorianUnitsYears CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 0), 96 | kCFGregorianUnitsMonths CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 1), 97 | kCFGregorianUnitsDays CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 2), 98 | kCFGregorianUnitsHours CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 3), 99 | kCFGregorianUnitsMinutes CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 4), 100 | kCFGregorianUnitsSeconds CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 5), 101 | kCFGregorianAllUnits CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = 0x00FFFFFF 102 | }; 103 | 104 | CF_EXPORT 105 | Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 106 | 107 | CF_EXPORT 108 | CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 109 | 110 | CF_EXPORT 111 | CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 112 | 113 | CF_EXPORT 114 | CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits(CFAbsoluteTime at, CFTimeZoneRef tz, CFGregorianUnits units) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 115 | 116 | CF_EXPORT 117 | CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits(CFAbsoluteTime at1, CFAbsoluteTime at2, CFTimeZoneRef tz, CFOptionFlags unitFlags) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 118 | 119 | CF_EXPORT 120 | SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 121 | 122 | CF_EXPORT 123 | SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 124 | 125 | CF_EXPORT 126 | SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); 127 | 128 | CF_EXTERN_C_END 129 | 130 | #endif /* ! __COREFOUNDATION_CFDATE__ */ 131 | 132 | -------------------------------------------------------------------------------- /CFError_Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFError_Private.h 25 | Copyright (c) 2006-2014, Apple Inc. All rights reserved. 26 | 27 | This is Apple-internal SPI for CFError. 28 | */ 29 | 30 | #if !defined(__COREFOUNDATION_CFERRORPRIVATE__) 31 | #define __COREFOUNDATION_CFERRORPRIVATE__ 1 32 | 33 | #include 34 | 35 | CF_EXTERN_C_BEGIN 36 | 37 | /* This callback function is consulted if a key is not present in the userInfo dictionary. Note that setting a callback for the same domain again simply replaces the previous callback. Set NULL as the callback to remove it. 38 | */ 39 | typedef CFTypeRef (*CFErrorUserInfoKeyCallBack)(CFErrorRef err, CFStringRef key); 40 | CF_EXPORT void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack callBack) CF_AVAILABLE(10_5, 2_0); 41 | CF_EXPORT CFErrorUserInfoKeyCallBack CFErrorGetCallBackForDomain(CFStringRef domainName) CF_AVAILABLE(10_5, 2_0); 42 | 43 | 44 | /* A key for "true" debugging descriptions which should never be shown to the user. It's only used when the CFError is shown to the console, and nothing else is available. For instance the rather terse and techie OSStatus descriptions are in this boat. 45 | */ 46 | CF_EXPORT const CFStringRef kCFErrorDebugDescriptionKey CF_AVAILABLE(10_5, 2_0); 47 | 48 | 49 | CF_EXTERN_C_END 50 | 51 | #endif /* ! __COREFOUNDATION_CFERRORPRIVATE__ */ 52 | 53 | -------------------------------------------------------------------------------- /CFICUConverters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * CFICUConverters.h 26 | * CoreFoundation 27 | * 28 | * Created by Aki Inoue on 07/12/04. 29 | * Copyright (c) 2007-2014, Apple Inc. All rights reserved. 30 | * 31 | */ 32 | 33 | #include 34 | 35 | CF_PRIVATE const char *__CFStringEncodingGetICUName(CFStringEncoding encoding); 36 | 37 | CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromICUName(const char *icuName); 38 | 39 | 40 | CF_PRIVATE CFIndex __CFStringEncodingICUToBytes(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 41 | CF_PRIVATE CFIndex __CFStringEncodingICUToUnicode(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); 42 | CF_PRIVATE CFIndex __CFStringEncodingICUCharLength(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); 43 | CF_PRIVATE CFIndex __CFStringEncodingICUByteLength(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars); 44 | 45 | // The caller is responsible for freeing the memory (use CFAllocatorDeallocate) 46 | CF_PRIVATE CFStringEncoding *__CFStringEncodingCreateICUEncodings(CFAllocatorRef allocator, CFIndex *numberOfIndex); 47 | 48 | 49 | -------------------------------------------------------------------------------- /CFICULogging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | CFICULogging.h 26 | Copyright (c) 2008-2014, Apple Inc. All rights reserved. 27 | */ 28 | 29 | /* 30 | This file is for the use of the CoreFoundation project only. 31 | */ 32 | 33 | #if !defined(__COREFOUNDATION_CFICULOGGING__) 34 | #define __COREFOUNDATION_CFICULOGGING__ 1 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | // ucal 44 | 45 | 46 | // ucal 47 | #define __cficu_ucal_open ucal_open 48 | #define __cficu_ucal_close ucal_close 49 | #define __cficu_ucal_clone ucal_clone 50 | #define __cficu_ucal_setAttribute ucal_setAttribute 51 | #define __cficu_ucal_getAttribute ucal_getAttribute 52 | #define __cficu_ucal_setGregorianChange ucal_setGregorianChange 53 | #define __cficu_ucal_getGregorianChange ucal_getGregorianChange 54 | #define __cficu_ucal_getMillis ucal_getMillis 55 | #define __cficu_ucal_setMillis ucal_setMillis 56 | #define __cficu_ucal_set ucal_set 57 | #define __cficu_ucal_get ucal_get 58 | #define __cficu_ucal_getDayOfWeekType ucal_getDayOfWeekType 59 | #define __cficu_ucal_getWeekendTransition ucal_getWeekendTransition 60 | #define __cficu_ucal_isWeekend ucal_isWeekend 61 | #define __cficu_ucal_clear ucal_clear 62 | #define __cficu_ucal_getLimit ucal_getLimit 63 | #define __cficu_ucal_add ucal_add 64 | #define __cficu_ucal_roll ucal_roll 65 | #define __cficu_ucal_getFieldDifference ucal_getFieldDifference 66 | #define __cficu_ucal_getNow ucal_getNow 67 | #define __cficu_ucal_setTimeZone ucal_setTimeZone 68 | // udatpg 69 | #define __cficu_udatpg_open udatpg_open 70 | #define __cficu_udatpg_close udatpg_close 71 | #define __cficu_udatpg_getSkeleton udatpg_getSkeleton 72 | #define __cficu_udatpg_getBestPattern udatpg_getBestPattern 73 | // udat 74 | #define __cficu_udat_applyPattern udat_applyPattern 75 | #define __cficu_udat_applyPatternRelative udat_applyPatternRelative 76 | #define __cficu_udat_clone udat_clone 77 | #define __cficu_udat_close udat_close 78 | #define __cficu_udat_countSymbols udat_countSymbols 79 | #define __cficu_udat_format udat_format 80 | #define __cficu_udat_get2DigitYearStart udat_get2DigitYearStart 81 | #define __cficu_udat_getCalendar udat_getCalendar 82 | #define __cficu_udat_getSymbols udat_getSymbols 83 | #define __cficu_udat_isLenient udat_isLenient 84 | #define __cficu_udat_open udat_open 85 | #define __cficu_udat_parseCalendar udat_parseCalendar 86 | #define __cficu_udat_set2DigitYearStart udat_set2DigitYearStart 87 | #define __cficu_udat_setCalendar udat_setCalendar 88 | #define __cficu_udat_setLenient udat_setLenient 89 | #define __cficu_udat_setSymbols udat_setSymbols 90 | #define __cficu_udat_toPattern udat_toPattern 91 | #define __cficu_udat_toPatternRelativeDate udat_toPatternRelativeDate 92 | #define __cficu_udat_toPatternRelativeTime udat_toPatternRelativeTime 93 | #define __cficu_unum_applyPattern unum_applyPattern 94 | #define __cficu_unum_close unum_close 95 | #define __cficu_unum_formatDecimal unum_formatDecimal 96 | #define __cficu_unum_formatDouble unum_formatDouble 97 | #define __cficu_unum_getAttribute unum_getAttribute 98 | #define __cficu_unum_getDoubleAttribute unum_getDoubleAttribute 99 | #define __cficu_unum_getSymbol unum_getSymbol 100 | #define __cficu_unum_getTextAttribute unum_getTextAttribute 101 | #define __cficu_unum_open unum_open 102 | #define __cficu_unum_parse unum_parse 103 | #define __cficu_unum_parseDecimal unum_parseDecimal 104 | #define __cficu_unum_setAttribute unum_setAttribute 105 | #define __cficu_unum_setDoubleAttribute unum_setDoubleAttribute 106 | #define __cficu_unum_setSymbol unum_setSymbol 107 | #define __cficu_unum_setTextAttribute unum_setTextAttribute 108 | #define __cficu_unum_toPattern unum_toPattern 109 | #define __cficu_udat_setContext udat_setContext 110 | #define __cficu_udat_getContext udat_getContext 111 | // ucurr 112 | #define __cficu_ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits 113 | #define __cficu_ucurr_getRoundingIncrement ucurr_getRoundingIncrement 114 | // unum 115 | #define __cficu_unum_setContext unum_setContext 116 | #define __cficu_unum_getContext unum_getContext 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /CFLogUtilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFLogUtilities.h 25 | Copyright (c) 2004-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | /* 29 | APPLE SPI: NOT TO BE USED OUTSIDE APPLE! 30 | */ 31 | 32 | #if !defined(__COREFOUNDATION_CFLOGUTILITIES__) 33 | #define __COREFOUNDATION_CFLOGUTILITIES__ 1 34 | 35 | #include 36 | #include 37 | 38 | CF_EXTERN_C_BEGIN 39 | 40 | 41 | enum { // Legal level values for CFLog() 42 | kCFLogLevelEmergency = 0, 43 | kCFLogLevelAlert = 1, 44 | kCFLogLevelCritical = 2, 45 | kCFLogLevelError = 3, 46 | kCFLogLevelWarning = 4, 47 | kCFLogLevelNotice = 5, 48 | kCFLogLevelInfo = 6, 49 | kCFLogLevelDebug = 7, 50 | }; 51 | 52 | CF_EXPORT void CFLog(int32_t level, CFStringRef format, ...); 53 | /* Passing in a level value which is outside the range of 0-7 will cause the the call to do nothing. 54 | CFLog() logs the message using the asl.h API, and uses the level parameter as the log level. 55 | Note that the asl subsystem ignores some log levels by default. 56 | CFLog() is not fast, and is not going to be guaranteed to be fast. 57 | Even "no-op" CFLogs are not necessarily fast. 58 | If you care about performance, you shouldn't be logging. 59 | */ 60 | 61 | CF_EXTERN_C_END 62 | 63 | #endif /* ! __COREFOUNDATION_CFLOGUTILITIES__ */ 64 | 65 | -------------------------------------------------------------------------------- /CFMachPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFMachPort.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFMACHPORT__) 29 | #define __COREFOUNDATION_CFMACHPORT__ 1 30 | 31 | #include 32 | #include 33 | 34 | CF_IMPLICIT_BRIDGING_ENABLED 35 | CF_EXTERN_C_BEGIN 36 | 37 | typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMachPort) __CFMachPort * CFMachPortRef; 38 | 39 | typedef struct { 40 | CFIndex version; 41 | void * info; 42 | const void *(*retain)(const void *info); 43 | void (*release)(const void *info); 44 | CFStringRef (*copyDescription)(const void *info); 45 | } CFMachPortContext; 46 | 47 | typedef void (*CFMachPortCallBack)(CFMachPortRef port, void *msg, CFIndex size, void *info); 48 | typedef void (*CFMachPortInvalidationCallBack)(CFMachPortRef port, void *info); 49 | 50 | CF_EXPORT CFTypeID CFMachPortGetTypeID(void); 51 | 52 | CF_EXPORT CFMachPortRef CFMachPortCreate(CFAllocatorRef allocator, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); 53 | CF_EXPORT CFMachPortRef CFMachPortCreateWithPort(CFAllocatorRef allocator, mach_port_t portNum, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); 54 | 55 | CF_EXPORT mach_port_t CFMachPortGetPort(CFMachPortRef port); 56 | CF_EXPORT void CFMachPortGetContext(CFMachPortRef port, CFMachPortContext *context); 57 | CF_EXPORT void CFMachPortInvalidate(CFMachPortRef port); 58 | CF_EXPORT Boolean CFMachPortIsValid(CFMachPortRef port); 59 | CF_EXPORT CFMachPortInvalidationCallBack CFMachPortGetInvalidationCallBack(CFMachPortRef port); 60 | CF_EXPORT void CFMachPortSetInvalidationCallBack(CFMachPortRef port, CFMachPortInvalidationCallBack callout); 61 | 62 | CF_EXPORT CFRunLoopSourceRef CFMachPortCreateRunLoopSource(CFAllocatorRef allocator, CFMachPortRef port, CFIndex order); 63 | 64 | CF_EXTERN_C_END 65 | CF_IMPLICIT_BRIDGING_DISABLED 66 | 67 | #endif /* ! __COREFOUNDATION_CFMACHPORT__ */ 68 | 69 | -------------------------------------------------------------------------------- /CFMessagePort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFMessagePort.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFMESSAGEPORT__) 29 | #define __COREFOUNDATION_CFMESSAGEPORT__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | CF_IMPLICIT_BRIDGING_ENABLED 37 | CF_EXTERN_C_BEGIN 38 | 39 | typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMessagePort) __CFMessagePort * CFMessagePortRef; 40 | 41 | enum { 42 | kCFMessagePortSuccess = 0, 43 | kCFMessagePortSendTimeout = -1, 44 | kCFMessagePortReceiveTimeout = -2, 45 | kCFMessagePortIsInvalid = -3, 46 | kCFMessagePortTransportError = -4, 47 | kCFMessagePortBecameInvalidError = -5 48 | }; 49 | 50 | typedef struct { 51 | CFIndex version; 52 | void * info; 53 | const void *(*retain)(const void *info); 54 | void (*release)(const void *info); 55 | CFStringRef (*copyDescription)(const void *info); 56 | } CFMessagePortContext; 57 | 58 | typedef CFDataRef (*CFMessagePortCallBack)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info); 59 | /* If callout wants to keep a hold of the data past the return of the callout, it must COPY the data. This includes the case where the data is given to some routine which _might_ keep a hold of it; System will release returned CFData. */ 60 | typedef void (*CFMessagePortInvalidationCallBack)(CFMessagePortRef ms, void *info); 61 | 62 | CF_EXPORT CFTypeID CFMessagePortGetTypeID(void); 63 | 64 | CF_EXPORT CFMessagePortRef CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo); 65 | CF_EXPORT CFMessagePortRef CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name); 66 | 67 | CF_EXPORT Boolean CFMessagePortIsRemote(CFMessagePortRef ms); 68 | CF_EXPORT CFStringRef CFMessagePortGetName(CFMessagePortRef ms); 69 | CF_EXPORT Boolean CFMessagePortSetName(CFMessagePortRef ms, CFStringRef newName); 70 | CF_EXPORT void CFMessagePortGetContext(CFMessagePortRef ms, CFMessagePortContext *context); 71 | CF_EXPORT void CFMessagePortInvalidate(CFMessagePortRef ms); 72 | CF_EXPORT Boolean CFMessagePortIsValid(CFMessagePortRef ms); 73 | CF_EXPORT CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack(CFMessagePortRef ms); 74 | CF_EXPORT void CFMessagePortSetInvalidationCallBack(CFMessagePortRef ms, CFMessagePortInvalidationCallBack callout); 75 | 76 | /* NULL replyMode argument means no return value expected, dont wait for it */ 77 | CF_EXPORT SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef data, CFTimeInterval sendTimeout, CFTimeInterval rcvTimeout, CFStringRef replyMode, CFDataRef *returnData); 78 | 79 | CF_EXPORT CFRunLoopSourceRef CFMessagePortCreateRunLoopSource(CFAllocatorRef allocator, CFMessagePortRef local, CFIndex order); 80 | 81 | CF_EXPORT void CFMessagePortSetDispatchQueue(CFMessagePortRef ms, dispatch_queue_t queue) CF_AVAILABLE(10_6, 4_0); 82 | 83 | CF_EXTERN_C_END 84 | CF_IMPLICIT_BRIDGING_DISABLED 85 | 86 | #endif /* ! __COREFOUNDATION_CFMESSAGEPORT__ */ 87 | 88 | -------------------------------------------------------------------------------- /CFNumber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFNumber.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFNUMBER__) 29 | #define __COREFOUNDATION_CFNUMBER__ 1 30 | 31 | #include 32 | 33 | CF_IMPLICIT_BRIDGING_ENABLED 34 | CF_EXTERN_C_BEGIN 35 | 36 | typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFBoolean * CFBooleanRef; 37 | 38 | CF_EXPORT 39 | const CFBooleanRef kCFBooleanTrue; 40 | CF_EXPORT 41 | const CFBooleanRef kCFBooleanFalse; 42 | 43 | CF_EXPORT 44 | CFTypeID CFBooleanGetTypeID(void); 45 | 46 | CF_EXPORT 47 | Boolean CFBooleanGetValue(CFBooleanRef boolean); 48 | 49 | typedef CF_ENUM(CFIndex, CFNumberType) { 50 | /* Fixed-width types */ 51 | kCFNumberSInt8Type = 1, 52 | kCFNumberSInt16Type = 2, 53 | kCFNumberSInt32Type = 3, 54 | kCFNumberSInt64Type = 4, 55 | kCFNumberFloat32Type = 5, 56 | kCFNumberFloat64Type = 6, /* 64-bit IEEE 754 */ 57 | /* Basic C types */ 58 | kCFNumberCharType = 7, 59 | kCFNumberShortType = 8, 60 | kCFNumberIntType = 9, 61 | kCFNumberLongType = 10, 62 | kCFNumberLongLongType = 11, 63 | kCFNumberFloatType = 12, 64 | kCFNumberDoubleType = 13, 65 | /* Other */ 66 | kCFNumberCFIndexType = 14, 67 | kCFNumberNSIntegerType CF_ENUM_AVAILABLE(10_5, 2_0) = 15, 68 | kCFNumberCGFloatType CF_ENUM_AVAILABLE(10_5, 2_0) = 16, 69 | kCFNumberMaxType = 16 70 | }; 71 | 72 | typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFNumber * CFNumberRef; 73 | 74 | CF_EXPORT 75 | const CFNumberRef kCFNumberPositiveInfinity; 76 | CF_EXPORT 77 | const CFNumberRef kCFNumberNegativeInfinity; 78 | CF_EXPORT 79 | const CFNumberRef kCFNumberNaN; 80 | 81 | CF_EXPORT 82 | CFTypeID CFNumberGetTypeID(void); 83 | 84 | /* 85 | Creates a CFNumber with the given value. The type of number pointed 86 | to by the valuePtr is specified by type. If type is a floating point 87 | type and the value represents one of the infinities or NaN, the 88 | well-defined CFNumber for that value is returned. If either of 89 | valuePtr or type is an invalid value, the result is undefined. 90 | */ 91 | CF_EXPORT 92 | CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); 93 | 94 | /* 95 | Returns the storage format of the CFNumber's value. Note that 96 | this is not necessarily the type provided in CFNumberCreate(). 97 | */ 98 | CF_EXPORT 99 | CFNumberType CFNumberGetType(CFNumberRef number); 100 | 101 | /* 102 | Returns the size in bytes of the type of the number. 103 | */ 104 | CF_EXPORT 105 | CFIndex CFNumberGetByteSize(CFNumberRef number); 106 | 107 | /* 108 | Returns true if the type of the CFNumber's value is one of 109 | the defined floating point types. 110 | */ 111 | CF_EXPORT 112 | Boolean CFNumberIsFloatType(CFNumberRef number); 113 | 114 | /* 115 | Copies the CFNumber's value into the space pointed to by 116 | valuePtr, as the specified type. If conversion needs to take 117 | place, the conversion rules follow human expectation and not 118 | C's promotion and truncation rules. If the conversion is 119 | lossy, or the value is out of range, false is returned. Best 120 | attempt at conversion will still be in *valuePtr. 121 | */ 122 | CF_EXPORT 123 | Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr); 124 | 125 | /* 126 | Compares the two CFNumber instances. If conversion of the 127 | types of the values is needed, the conversion and comparison 128 | follow human expectations and not C's promotion and comparison 129 | rules. Negative zero compares less than positive zero. 130 | Positive infinity compares greater than everything except 131 | itself, to which it compares equal. Negative infinity compares 132 | less than everything except itself, to which it compares equal. 133 | Unlike standard practice, if both numbers are NaN, then they 134 | compare equal; if only one of the numbers is NaN, then the NaN 135 | compares greater than the other number if it is negative, and 136 | smaller than the other number if it is positive. (Note that in 137 | CFEqual() with two CFNumbers, if either or both of the numbers 138 | is NaN, true is returned.) 139 | */ 140 | CF_EXPORT 141 | CFComparisonResult CFNumberCompare(CFNumberRef number, CFNumberRef otherNumber, void *context); 142 | 143 | CF_EXTERN_C_END 144 | CF_IMPLICIT_BRIDGING_DISABLED 145 | 146 | #endif /* ! __COREFOUNDATION_CFNUMBER__ */ 147 | 148 | -------------------------------------------------------------------------------- /CFPlugIn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPlugIn.c 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | Responsibility: Tony Parker 27 | */ 28 | 29 | #include "CFBundle_Internal.h" 30 | #include "CFInternal.h" 31 | 32 | CONST_STRING_DECL(kCFPlugInDynamicRegistrationKey, "CFPlugInDynamicRegistration") 33 | CONST_STRING_DECL(kCFPlugInDynamicRegisterFunctionKey, "CFPlugInDynamicRegisterFunction") 34 | CONST_STRING_DECL(kCFPlugInUnloadFunctionKey, "CFPlugInUnloadFunction") 35 | CONST_STRING_DECL(kCFPlugInFactoriesKey, "CFPlugInFactories") 36 | CONST_STRING_DECL(kCFPlugInTypesKey, "CFPlugInTypes") 37 | 38 | CF_PRIVATE void __CFPlugInInitialize(void) { 39 | } 40 | 41 | /* ===================== Finding factories and creating instances ===================== */ 42 | /* For plugIn hosts. */ 43 | /* Functions for finding factories to create specific types and actually creating instances of a type. */ 44 | 45 | CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeID) { 46 | CFArrayRef array = _CFPFactoryFindCopyForType(typeID); 47 | CFMutableArrayRef result = NULL; 48 | 49 | if (array) { 50 | SInt32 i, c = CFArrayGetCount(array); 51 | result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); 52 | for (i = 0; i < c; i++) { 53 | CFUUIDRef factoryId = _CFPFactoryCopyFactoryID((_CFPFactoryRef)CFArrayGetValueAtIndex(array, i)); 54 | if (factoryId) { 55 | CFArrayAppendValue(result, factoryId); 56 | CFRelease(factoryId); 57 | } 58 | } 59 | CFRelease(array); 60 | } 61 | return result; 62 | } 63 | 64 | CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeID, CFPlugInRef plugIn) { 65 | CFArrayRef array = _CFPFactoryFindCopyForType(typeID); 66 | CFMutableArrayRef result = NULL; 67 | 68 | if (array) { 69 | SInt32 i, c = CFArrayGetCount(array); 70 | _CFPFactoryRef factory; 71 | result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); 72 | for (i = 0; i < c; i++) { 73 | factory = (_CFPFactoryRef )CFArrayGetValueAtIndex(array, i); 74 | CFPlugInRef factoryPlugIn = _CFPFactoryCopyPlugIn(factory); 75 | if (factoryPlugIn == plugIn) { 76 | CFUUIDRef factoryId = _CFPFactoryCopyFactoryID(factory); 77 | CFArrayAppendValue(result, factoryId); 78 | CFRelease(factoryId); 79 | } 80 | if (factoryPlugIn) CFRelease(factoryPlugIn); 81 | } 82 | CFRelease(array); 83 | } 84 | return result; 85 | } 86 | 87 | CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFUUIDRef typeID) { 88 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 89 | void *result = NULL; 90 | if (!factory) { 91 | /* MF:!!! No such factory. */ 92 | CFLog(__kCFLogPlugIn, CFSTR("Cannot find factory %@"), factoryID); 93 | } else { 94 | if (!_CFPFactorySupportsType(factory, typeID)) { 95 | /* MF:!!! Factory does not support type. */ 96 | CFLog(__kCFLogPlugIn, CFSTR("Factory %@ does not support type %@"), factoryID, typeID); 97 | } else { 98 | result = _CFPFactoryCreateInstance(allocator, factory, typeID); 99 | } 100 | } 101 | return result; 102 | } 103 | 104 | /* ===================== Registering factories and types ===================== */ 105 | /* For plugIn writers who must dynamically register things. */ 106 | /* Functions to register factory functions and to associate factories with types. */ 107 | 108 | CF_EXPORT Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryID, CFPlugInFactoryFunction func) { 109 | // Create factories without plugIns from default allocator 110 | // MF:!!! Should probably check that this worked, and maybe do some pre-checking to see if it already exists 111 | // _CFPFactoryRef factory = 112 | (void)_CFPFactoryCreate(kCFAllocatorSystemDefault, factoryID, func); 113 | return true; 114 | } 115 | 116 | CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef functionName) { 117 | // Create factories with plugIns from plugIn's allocator 118 | // MF:!!! Should probably check that this worked, and maybe do some pre-checking to see if it already exists 119 | // _CFPFactoryRef factory = 120 | (void)_CFPFactoryCreateByName(CFGetAllocator(plugIn), factoryID, plugIn, functionName); 121 | return true; 122 | } 123 | 124 | CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryID) { 125 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 126 | 127 | if (!factory) { 128 | /* MF:!!! Error. No factory registered for this ID. */ 129 | } else { 130 | _CFPFactoryDisable(factory); 131 | } 132 | return true; 133 | } 134 | 135 | CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryID, CFUUIDRef typeID) { 136 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 137 | 138 | if (!factory) { 139 | /* MF:!!! Error. Factory must be registered (and not disabled) before types can be associated with it. */ 140 | } else { 141 | _CFPFactoryAddType(factory, typeID); 142 | } 143 | return true; 144 | } 145 | 146 | CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryID, CFUUIDRef typeID) { 147 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 148 | 149 | if (!factory) { 150 | /* MF:!!! Error. Could not find factory. */ 151 | } else { 152 | _CFPFactoryRemoveType(factory, typeID); 153 | } 154 | return true; 155 | } 156 | 157 | 158 | /* ================= Registering instances ================= */ 159 | /* When a new instance of a type is created, the instance is responsible for registering itself with the factory that created it and unregistering when it deallocates. */ 160 | /* This means that an instance must keep track of the CFUUIDRef of the factory that created it so it can unregister when it goes away. */ 161 | 162 | CF_EXPORT void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID) { 163 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 164 | 165 | if (!factory) { 166 | /* MF:!!! Error. Could not find factory. */ 167 | } else { 168 | _CFPFactoryAddInstance(factory); 169 | } 170 | } 171 | 172 | CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID) { 173 | _CFPFactoryRef factory = _CFPFactoryFind(factoryID, true); 174 | 175 | if (!factory) { 176 | /* MF:!!! Error. Could not find factory. */ 177 | } else { 178 | _CFPFactoryRemoveInstance(factory); 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /CFPlugIn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPlugIn.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFPLUGIN__) 29 | #define __COREFOUNDATION_CFPLUGIN__ 1 30 | 31 | #if !defined(COREFOUNDATION_CFPLUGINCOM_SEPARATE) 32 | #define COREFOUNDATION_CFPLUGINCOM_SEPARATE 1 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | CF_IMPLICIT_BRIDGING_ENABLED 43 | CF_EXTERN_C_BEGIN 44 | 45 | /* ================ Standard Info.plist keys for plugIns ================ */ 46 | 47 | CF_EXPORT const CFStringRef kCFPlugInDynamicRegistrationKey; 48 | CF_EXPORT const CFStringRef kCFPlugInDynamicRegisterFunctionKey; 49 | CF_EXPORT const CFStringRef kCFPlugInUnloadFunctionKey; 50 | CF_EXPORT const CFStringRef kCFPlugInFactoriesKey; 51 | CF_EXPORT const CFStringRef kCFPlugInTypesKey; 52 | 53 | /* ================= Function prototypes for various callbacks ================= */ 54 | /* Function types that plugIn authors can implement for various purposes. */ 55 | 56 | typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn); 57 | typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn); 58 | typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID); 59 | 60 | /* ================= Creating PlugIns ================= */ 61 | 62 | CF_EXPORT CFTypeID CFPlugInGetTypeID(void); 63 | 64 | CF_EXPORT CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL); 65 | /* Might return an existing instance with the ref-count bumped. */ 66 | 67 | CF_EXPORT CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn); 68 | 69 | /* ================= Controlling load on demand ================= */ 70 | /* For plugIns. */ 71 | /* PlugIns that do static registration are load on demand by default. */ 72 | /* PlugIns that do dynamic registration are not load on demand by default. */ 73 | /* A dynamic registration function can call CFPlugInSetLoadOnDemand(). */ 74 | 75 | CF_EXPORT void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag); 76 | 77 | CF_EXPORT Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn); 78 | 79 | /* ================= Finding factories and creating instances ================= */ 80 | /* For plugIn hosts. */ 81 | /* Functions for finding factories to create specific types and actually creating instances of a type. */ 82 | 83 | /* This function finds all the factories from any plugin for the given type. Returns an array that the caller must release. */ 84 | CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID) CF_RETURNS_RETAINED; 85 | 86 | 87 | /* This function restricts the result to factories from the given plug-in that can create the given type. Returns an array that the caller must release. */ 88 | CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn) CF_RETURNS_RETAINED; 89 | 90 | /* This function returns the IUnknown interface for the new instance. */ 91 | CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); 92 | 93 | /* ================= Registering factories and types ================= */ 94 | /* For plugIn writers who must dynamically register things. */ 95 | /* Functions to register factory functions and to associate factories with types. */ 96 | 97 | CF_EXPORT Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func); 98 | 99 | CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName); 100 | 101 | CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID); 102 | 103 | CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); 104 | 105 | CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); 106 | 107 | /* ================= Registering instances ================= */ 108 | /* When a new instance of a type is created, the instance is responsible for registering itself with the factory that created it and unregistering when it deallocates. */ 109 | /* This means that an instance must keep track of the CFUUIDRef of the factory that created it so it can unregister when it goes away. */ 110 | 111 | CF_EXPORT void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID); 112 | 113 | CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID); 114 | 115 | 116 | /* Obsolete API */ 117 | 118 | typedef struct __CFPlugInInstance *CFPlugInInstanceRef; 119 | 120 | typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); 121 | typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData); 122 | 123 | CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); 124 | 125 | /* This function returns a retained object on 10.8 or later. */ 126 | CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) CF_RETURNS_RETAINED; 127 | 128 | CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance); 129 | 130 | CF_EXPORT CFTypeID CFPlugInInstanceGetTypeID(void); 131 | 132 | CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction); 133 | 134 | CF_EXTERN_C_END 135 | CF_IMPLICIT_BRIDGING_DISABLED 136 | 137 | #if !COREFOUNDATION_CFPLUGINCOM_SEPARATE 138 | #include 139 | #endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */ 140 | 141 | #endif /* ! __COREFOUNDATION_CFPLUGIN__ */ 142 | 143 | -------------------------------------------------------------------------------- /CFPlugInCOM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPlugInCOM.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFPLUGINCOM__) 29 | #define __COREFOUNDATION_CFPLUGINCOM__ 1 30 | 31 | #include 32 | 33 | CF_EXTERN_C_BEGIN 34 | 35 | /* ================= IUnknown definition (C struct) ================= */ 36 | 37 | /* All interface structs must have an IUnknownStruct at the beginning. */ 38 | /* The _reserved field is part of the Microsoft COM binary standard on Macintosh. */ 39 | /* You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. */ 40 | 41 | typedef SInt32 HRESULT; 42 | typedef UInt32 ULONG; 43 | typedef void *LPVOID; 44 | typedef CFUUIDBytes REFIID; 45 | 46 | #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) 47 | #define FAILED(Status) ((HRESULT)(Status)<0) 48 | 49 | /* Macros for more detailed HRESULT analysis */ 50 | #define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR) 51 | #define HRESULT_CODE(hr) ((hr) & 0xFFFF) 52 | #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff) 53 | #define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) 54 | #define SEVERITY_SUCCESS 0 55 | #define SEVERITY_ERROR 1 56 | 57 | /* Creating an HRESULT from its component pieces */ 58 | #define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) 59 | 60 | /* Pre-defined success HRESULTS */ 61 | #define S_OK ((HRESULT)0x00000000L) 62 | #define S_FALSE ((HRESULT)0x00000001L) 63 | 64 | /* Common error HRESULTS */ 65 | #define E_UNEXPECTED ((HRESULT)0x8000FFFFL) 66 | #define E_NOTIMPL ((HRESULT)0x80000001L) 67 | #define E_OUTOFMEMORY ((HRESULT)0x80000002L) 68 | #define E_INVALIDARG ((HRESULT)0x80000003L) 69 | #define E_NOINTERFACE ((HRESULT)0x80000004L) 70 | #define E_POINTER ((HRESULT)0x80000005L) 71 | #define E_HANDLE ((HRESULT)0x80000006L) 72 | #define E_ABORT ((HRESULT)0x80000007L) 73 | #define E_FAIL ((HRESULT)0x80000008L) 74 | #define E_ACCESSDENIED ((HRESULT)0x80000009L) 75 | 76 | /* This macro should be used when defining all interface functions (as it is for the IUnknown functions below). */ 77 | #define STDMETHODCALLTYPE 78 | 79 | /* The __RPC_FAR macro is for COM source compatibility only. This macro is used a lot in COM interface definitions. If your CFPlugIn interfaces need to be COM interfaces as well, you can use this macro to get better source compatibility. It is not used in the IUnknown definition below, because when doing COM, you will be using the Microsoft supplied IUnknown interface anyway. */ 80 | #define __RPC_FAR 81 | 82 | /* The IUnknown interface */ 83 | #define IUnknownUUID CFUUIDGetConstantUUIDWithBytes(kCFAllocatorSystemDefault, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) 84 | 85 | #define IUNKNOWN_C_GUTS \ 86 | void *_reserved; \ 87 | HRESULT (STDMETHODCALLTYPE *QueryInterface)(void *thisPointer, REFIID iid, LPVOID *ppv); \ 88 | ULONG (STDMETHODCALLTYPE *AddRef)(void *thisPointer); \ 89 | ULONG (STDMETHODCALLTYPE *Release)(void *thisPointer) 90 | 91 | typedef struct IUnknownVTbl { 92 | IUNKNOWN_C_GUTS; 93 | } IUnknownVTbl; 94 | 95 | CF_EXTERN_C_END 96 | 97 | 98 | /* C++ specific stuff */ 99 | #if defined(__cplusplus) 100 | /* ================= IUnknown definition (C++ class) ================= */ 101 | 102 | /* This is a definition of IUnknown as a pure abstract virtual C++ class. This class will work only with compilers that can produce COM-compatible object layouts for C++ classes. egcs can not do this. MetroWerks can do this (if you subclass from __comobject) */ 103 | 104 | class IUnknown 105 | #if defined(__MWERKS__) && TARGET_OS_WIN32 106 | : __comobject 107 | #endif 108 | { 109 | public: 110 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) = 0; 111 | virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; 112 | virtual ULONG STDMETHODCALLTYPE Release(void) = 0; 113 | }; 114 | 115 | #endif /* __cplusplus */ 116 | 117 | #endif /* ! __COREFOUNDATION_CFPLUGINCOM__ */ 118 | 119 | -------------------------------------------------------------------------------- /CFPlugIn_Factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPlugIn_Factory.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFPLUGIN_FACTORY__) 29 | #define __COREFOUNDATION_CFPLUGIN_FACTORY__ 1 30 | 31 | #include "CFBundle_Internal.h" 32 | 33 | CF_EXTERN_C_BEGIN 34 | 35 | typedef struct __CFPFactory *_CFPFactoryRef; 36 | 37 | extern _CFPFactoryRef _CFPFactoryCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInFactoryFunction func); 38 | extern _CFPFactoryRef _CFPFactoryCreateByName(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef funcName); 39 | 40 | extern _CFPFactoryRef _CFPFactoryFind(CFUUIDRef factoryID, Boolean enabled); 41 | 42 | extern CFUUIDRef _CFPFactoryCopyFactoryID(_CFPFactoryRef factory); 43 | extern CFPlugInRef _CFPFactoryCopyPlugIn(_CFPFactoryRef factory); 44 | 45 | extern void *_CFPFactoryCreateInstance(CFAllocatorRef allocator, _CFPFactoryRef factory, CFUUIDRef typeID); 46 | extern void _CFPFactoryDisable(_CFPFactoryRef factory); 47 | 48 | extern void _CFPFactoryFlushFunctionCache(_CFPFactoryRef factory); 49 | 50 | extern void _CFPFactoryAddType(_CFPFactoryRef factory, CFUUIDRef typeID); 51 | extern void _CFPFactoryRemoveType(_CFPFactoryRef factory, CFUUIDRef typeID); 52 | 53 | extern Boolean _CFPFactorySupportsType(_CFPFactoryRef factory, CFUUIDRef typeID); 54 | extern CFArrayRef _CFPFactoryFindCopyForType(CFUUIDRef typeID); 55 | 56 | /* These methods are called by CFPlugInInstance when an instance is created or destroyed. If a factory's instance count goes to 0 and the factory has been disabled, the factory is destroyed. */ 57 | extern void _CFPFactoryAddInstance(_CFPFactoryRef factory); 58 | extern void _CFPFactoryRemoveInstance(_CFPFactoryRef factory); 59 | 60 | CF_EXTERN_C_END 61 | 62 | #endif /* ! __COREFOUNDATION_CFPLUGIN_FACTORY__ */ 63 | 64 | -------------------------------------------------------------------------------- /CFPlugIn_Instance.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPlugIn_Instance.c 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | Responsibility: Tony Parker 27 | */ 28 | 29 | #include "CFBundle_Internal.h" 30 | #include "CFInternal.h" 31 | 32 | static CFTypeID __kCFPlugInInstanceTypeID = _kCFRuntimeNotATypeID; 33 | 34 | struct __CFPlugInInstance { 35 | CFRuntimeBase _base; 36 | 37 | _CFPFactoryRef factory; 38 | 39 | CFPlugInInstanceGetInterfaceFunction getInterfaceFunction; 40 | CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceDataFunction; 41 | 42 | #ifdef _MSC_VER 43 | #pragma warning(push) 44 | #pragma warning(disable : 4200) 45 | #endif //_MSC_VER 46 | uint8_t _instanceData[0]; 47 | #ifdef _MSC_VER 48 | #pragma warning(pop) 49 | #endif //_MSC_VER 50 | }; 51 | 52 | static CFStringRef __CFPlugInInstanceCopyDescription(CFTypeRef cf) { 53 | /* MF:!!! Implement me */ 54 | return CFSTR("Some CFPlugInInstance"); 55 | } 56 | 57 | static void __CFPlugInInstanceDeallocate(CFTypeRef cf) { 58 | CFPlugInInstanceRef instance = (CFPlugInInstanceRef)cf; 59 | 60 | __CFGenericValidateType(cf, CFPlugInInstanceGetTypeID()); 61 | 62 | if (instance->deallocateInstanceDataFunction) { 63 | FAULT_CALLBACK((void **)&(instance->deallocateInstanceDataFunction)); 64 | (void)INVOKE_CALLBACK1(instance->deallocateInstanceDataFunction, (void *)(&instance->_instanceData[0])); 65 | } 66 | 67 | if (instance->factory) _CFPFactoryRemoveInstance(instance->factory); 68 | } 69 | 70 | static const CFRuntimeClass __CFPlugInInstanceClass = { 71 | 0, 72 | "CFPlugInInstance", 73 | NULL, // init 74 | NULL, // copy 75 | __CFPlugInInstanceDeallocate, 76 | NULL, // equal 77 | NULL, // hash 78 | NULL, // 79 | __CFPlugInInstanceCopyDescription 80 | }; 81 | 82 | CFTypeID CFPlugInInstanceGetTypeID(void) { 83 | static dispatch_once_t initOnce; 84 | dispatch_once(&initOnce, ^{ __kCFPlugInInstanceTypeID = _CFRuntimeRegisterClass(&__CFPlugInInstanceClass); }); 85 | return __kCFPlugInInstanceTypeID; 86 | } 87 | 88 | CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction) { 89 | CFPlugInInstanceRef instance; 90 | UInt32 size; 91 | size = sizeof(struct __CFPlugInInstance) + instanceDataSize - sizeof(CFRuntimeBase); 92 | instance = (CFPlugInInstanceRef)_CFRuntimeCreateInstance(allocator, CFPlugInInstanceGetTypeID(), size, NULL); 93 | if (!instance) return NULL; 94 | 95 | instance->factory = _CFPFactoryFind((CFUUIDRef)factoryName, true); 96 | if (instance->factory) _CFPFactoryAddInstance(instance->factory); 97 | instance->getInterfaceFunction = getInterfaceFunction; 98 | instance->deallocateInstanceDataFunction = deallocateInstanceFunction; 99 | 100 | return instance; 101 | } 102 | 103 | CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl) { 104 | void *myFtbl; 105 | Boolean result = false; 106 | 107 | if (instance->getInterfaceFunction) { 108 | FAULT_CALLBACK((void **)&(instance->getInterfaceFunction)); 109 | result = INVOKE_CALLBACK3(instance->getInterfaceFunction, instance, interfaceName, &myFtbl) ? true : false; 110 | } 111 | if (ftbl) *ftbl = (result ? myFtbl : NULL); 112 | return result; 113 | } 114 | 115 | CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) { 116 | // This function leaks, but it's the only safe way to access the factory name (on 10.8 or later). 117 | // On 10.9 we added the CF_RETURNS_RETAINED annotation to the header. 118 | CFUUIDRef factoryId = _CFPFactoryCopyFactoryID(instance->factory); 119 | return (CFStringRef)factoryId; 120 | } 121 | 122 | CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance) { 123 | return (void *)(&instance->_instanceData[0]); 124 | } 125 | 126 | -------------------------------------------------------------------------------- /CFPreferences.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFPreferences.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFPREFERENCES__) 29 | #define __COREFOUNDATION_CFPREFERENCES__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | CF_IMPLICIT_BRIDGING_ENABLED 36 | CF_EXTERN_C_BEGIN 37 | 38 | CF_EXPORT 39 | const CFStringRef kCFPreferencesAnyApplication; 40 | CF_EXPORT 41 | const CFStringRef kCFPreferencesCurrentApplication; 42 | CF_EXPORT 43 | const CFStringRef kCFPreferencesAnyHost; 44 | CF_EXPORT 45 | const CFStringRef kCFPreferencesCurrentHost; 46 | CF_EXPORT 47 | const CFStringRef kCFPreferencesAnyUser; 48 | CF_EXPORT 49 | const CFStringRef kCFPreferencesCurrentUser; 50 | 51 | /* NOTE: All CFPropertyListRef values returned from 52 | CFPreferences API should be assumed to be immutable. 53 | */ 54 | 55 | /* The "App" functions search the various sources of defaults that 56 | apply to the given application, and should never be called with 57 | kCFPreferencesAnyApplication - only kCFPreferencesCurrentApplication 58 | or an application's ID (its bundle identifier). 59 | */ 60 | 61 | /* Searches the various sources of application defaults to find the 62 | value for the given key. key must not be NULL. If a value is found, 63 | it returns it; otherwise returns NULL. Caller must release the 64 | returned value */ 65 | CF_EXPORT 66 | CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef applicationID); 67 | 68 | /* Convenience to interpret a preferences value as a boolean directly. 69 | Returns false if the key doesn't exist, or has an improper format; under 70 | those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ 71 | CF_EXPORT 72 | Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); 73 | 74 | /* Convenience to interpret a preferences value as an integer directly. 75 | Returns 0 if the key doesn't exist, or has an improper format; under 76 | those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ 77 | CF_EXPORT 78 | CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); 79 | 80 | /* Sets the given value for the given key in the "normal" place for 81 | application preferences. key must not be NULL. If value is NULL, 82 | key is removed instead. */ 83 | CF_EXPORT 84 | void CFPreferencesSetAppValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID); 85 | 86 | /* Adds the preferences for the given suite to the app preferences for 87 | the specified application. To write to the suite domain, use 88 | CFPreferencesSetValue(), below, using the suiteName in place 89 | of the appName */ 90 | CF_EXPORT 91 | void CFPreferencesAddSuitePreferencesToApp(CFStringRef applicationID, CFStringRef suiteID); 92 | 93 | CF_EXPORT 94 | void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef applicationID, CFStringRef suiteID); 95 | 96 | /* Writes all changes in all sources of application defaults. 97 | Returns success or failure. */ 98 | CF_EXPORT 99 | Boolean CFPreferencesAppSynchronize(CFStringRef applicationID); 100 | 101 | /* The primitive get mechanism; all arguments must be non-NULL 102 | (use the constants above for common values). Only the exact 103 | location specified by app-user-host is searched. The returned 104 | CFType must be released by the caller when it is finished with it. */ 105 | CF_EXPORT 106 | CFPropertyListRef CFPreferencesCopyValue(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 107 | 108 | /* Convenience to fetch multiple keys at once. Keys in 109 | keysToFetch that are not present in the returned dictionary 110 | are not present in the domain. If keysToFetch is NULL, all 111 | keys are fetched. */ 112 | CF_EXPORT 113 | CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 114 | 115 | /* The primitive set function; all arguments except value must be 116 | non-NULL. If value is NULL, the given key is removed */ 117 | CF_EXPORT 118 | void CFPreferencesSetValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 119 | 120 | /* Convenience to set multiple values at once. Behavior is undefined 121 | if a key is in both keysToSet and keysToRemove */ 122 | CF_EXPORT 123 | void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 124 | 125 | CF_EXPORT 126 | Boolean CFPreferencesSynchronize(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 127 | 128 | /* Constructs and returns the list of the name of all applications 129 | which have preferences in the scope of the given user and host. 130 | The returned value must be released by the caller; neither argument 131 | may be NULL. */ 132 | CF_EXPORT 133 | CFArrayRef CFPreferencesCopyApplicationList(CFStringRef userName, CFStringRef hostName) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0); 134 | 135 | /* Constructs and returns the list of all keys set in the given 136 | location. The returned value must be released by the caller; 137 | all arguments must be non-NULL */ 138 | CF_EXPORT 139 | CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); 140 | 141 | 142 | CF_EXTERN_C_END 143 | CF_IMPLICIT_BRIDGING_DISABLED 144 | 145 | #endif /* ! __COREFOUNDATION_CFPREFERENCES__ */ 146 | 147 | -------------------------------------------------------------------------------- /CFStreamInternal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #if !defined(__COREFOUNDATION_CFSTREAMINTERNAL__) 25 | #define __COREFOUNDATION_CFSTREAMINTERNAL__ 1 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | CF_EXTERN_C_BEGIN 33 | 34 | 35 | // Older versions of the callbacks; v0 callbacks match v1 callbacks, except that create, finalize, and copyDescription are missing. 36 | typedef Boolean (*_CFStreamCBOpenV1)(struct _CFStream *stream, CFStreamError *error, Boolean *openComplete, void *info); 37 | typedef Boolean (*_CFStreamCBOpenCompletedV1)(struct _CFStream *stream, CFStreamError *error, void *info); 38 | typedef CFIndex (*_CFStreamCBReadV1)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); 39 | typedef const UInt8 *(*_CFStreamCBGetBufferV1)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); 40 | typedef Boolean (*_CFStreamCBCanReadV1)(CFReadStreamRef, void *info); 41 | typedef CFIndex (*_CFStreamCBWriteV1)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); 42 | typedef Boolean (*_CFStreamCBCanWriteV1)(CFWriteStreamRef, void *info); 43 | 44 | struct _CFStreamCallBacksV1 { 45 | CFIndex version; 46 | void *(*create)(struct _CFStream *stream, void *info); 47 | void (*finalize)(struct _CFStream *stream, void *info); 48 | CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); 49 | 50 | _CFStreamCBOpenV1 open; 51 | _CFStreamCBOpenCompletedV1 openCompleted; 52 | _CFStreamCBReadV1 read; 53 | _CFStreamCBGetBufferV1 getBuffer; 54 | _CFStreamCBCanReadV1 canRead; 55 | _CFStreamCBWriteV1 write; 56 | _CFStreamCBCanWriteV1 canWrite; 57 | void (*close)(struct _CFStream *stream, void *info); 58 | 59 | CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); 60 | Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); 61 | void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); 62 | void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); 63 | void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); 64 | }; 65 | 66 | // These two are defined in CFSocketStream.c because that's where the glue for CFNetwork is. 67 | CF_PRIVATE CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *err); 68 | CF_PRIVATE CFStreamError _CFStreamErrorFromError(CFErrorRef error); 69 | 70 | CF_EXTERN_C_END 71 | 72 | #endif /* ! __COREFOUNDATION_CFSTREAMINTERNAL__ */ 73 | 74 | 75 | -------------------------------------------------------------------------------- /CFStreamPriv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFStreamPriv.h 25 | Copyright (c) 2000-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFSTREAMPRIV__) 29 | #define __COREFOUNDATION_CFSTREAMPRIV__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | CF_EXTERN_C_BEGIN 36 | 37 | struct _CFStream; 38 | struct _CFStreamClient { 39 | CFStreamClientContext cbContext; 40 | void (*cb)(struct _CFStream *, CFStreamEventType, void *); 41 | CFOptionFlags when; 42 | CFRunLoopSourceRef rlSource; 43 | CFMutableArrayRef runLoopsAndModes; 44 | CFOptionFlags whatToSignal; 45 | }; 46 | 47 | #define CFStreamCurrentVersion 2 48 | 49 | // A unified set of callbacks so we can use a single structure for all struct _CFStreams. 50 | struct _CFStreamCallBacks { 51 | CFIndex version; 52 | void *(*create)(struct _CFStream *stream, void *info); 53 | void (*finalize)(struct _CFStream *stream, void *info); 54 | CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); 55 | 56 | Boolean (*open)(struct _CFStream *stream, CFErrorRef *error, Boolean *openComplete, void *info); 57 | Boolean (*openCompleted)(struct _CFStream *stream, CFErrorRef *error, void *info); 58 | CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); 59 | const UInt8 *(*getBuffer)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); 60 | Boolean (*canRead)(CFReadStreamRef, CFErrorRef *error, void *info); 61 | CFIndex (*write)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); 62 | Boolean (*canWrite)(CFWriteStreamRef, CFErrorRef *error, void *info); 63 | void (*close)(struct _CFStream *stream, void *info); 64 | 65 | CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); 66 | Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); 67 | void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); 68 | void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); 69 | void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); 70 | }; 71 | 72 | struct _CFStream; 73 | 74 | CF_EXPORT void* _CFStreamGetInfoPointer(struct _CFStream* stream); 75 | 76 | // cb version must be > 0 77 | CF_EXPORT struct _CFStream *_CFStreamCreateWithConstantCallbacks(CFAllocatorRef alloc, void *info, const struct _CFStreamCallBacks *cb, Boolean isReading); 78 | 79 | // Only available for streams created with _CFStreamCreateWithConstantCallbacks, above. cb's version must be 1 80 | CF_EXPORT void _CFStreamSetInfoPointer(struct _CFStream *stream, void *info, const struct _CFStreamCallBacks *cb); 81 | 82 | /* 83 | ** _CFStreamSourceScheduleWithRunLoop 84 | ** 85 | ** Schedules the given run loop source on the given run loop and mode. It then 86 | ** adds the loop and mode pair to the runLoopsAndModes list. The list is 87 | ** simply a linear list of a loop reference followed by a mode reference. 88 | ** 89 | ** source Run loop source to be scheduled 90 | ** 91 | ** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled 92 | ** 93 | ** runLoop Run loop on which the source is being scheduled 94 | ** 95 | ** runLoopMode Run loop mode on which the source is being scheduled 96 | */ 97 | CF_EXPORT 98 | void _CFStreamSourceScheduleWithRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); 99 | 100 | 101 | /* 102 | ** _CFStreamSourceUnscheduleFromRunLoop 103 | ** 104 | ** Unschedule the given source from the given run loop and mode. It then will 105 | ** guarantee that the source remains scheduled on the list of run loop and mode 106 | ** pairs in the runLoopsAndModes list. The list is simply a linear list of a 107 | ** loop reference followed by a mode reference. 108 | ** 109 | ** source Run loop source to be unscheduled 110 | ** 111 | ** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled 112 | ** 113 | ** runLoop Run loop from which the source is being unscheduled 114 | ** 115 | ** runLoopMode Run loop mode from which the source is being unscheduled 116 | */ 117 | CF_EXPORT 118 | void _CFStreamSourceUnscheduleFromRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); 119 | 120 | 121 | /* 122 | ** _CFStreamSourceScheduleWithAllRunLoops 123 | ** 124 | ** Schedules the given run loop source on all the run loops and modes in the list. 125 | ** The list is simply a linear list of a loop reference followed by a mode reference. 126 | ** 127 | ** source Run loop source to be unscheduled 128 | ** 129 | ** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled 130 | */ 131 | CF_EXPORT 132 | void _CFStreamSourceScheduleWithAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); 133 | 134 | 135 | /* 136 | ** _CFStreamSourceUnscheduleFromRunLoop 137 | ** 138 | ** Unschedule the given source from all the run loops and modes in the list. 139 | ** The list is simply a linear list of a loop reference followed by a mode 140 | ** reference. 141 | ** 142 | ** source Run loop source to be unscheduled 143 | ** 144 | ** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled 145 | */ 146 | CF_EXPORT 147 | void _CFStreamSourceUncheduleFromAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); 148 | 149 | CF_EXPORT 150 | CFReadStreamRef _CFReadStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); 151 | 152 | CF_EXPORT 153 | CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); 154 | 155 | 156 | 157 | #define SECURITY_NONE (0) 158 | #define SECURITY_SSLv2 (1) 159 | #define SECURITY_SSLv3 (2) 160 | #define SECURITY_SSLv32 (3) 161 | #define SECURITY_TLS (4) 162 | 163 | #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) 164 | // This symbol is exported from CFNetwork (see CFSocketStream.i). Only __MACH__ systems will 165 | // get this symbol from CoreFoundation. 166 | extern const int kCFStreamErrorDomainSSL; 167 | #endif 168 | 169 | /* 170 | * Additional SPI for CFNetwork for select side read buffering 171 | */ 172 | CF_EXPORT 173 | Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable); 174 | 175 | CF_EXPORT 176 | CFIndex __CFSocketRead(CFSocketRef s, UInt8* buffer, CFIndex length, int* error); 177 | 178 | /* 179 | * This define can be removed once 6030579 is removed 180 | */ 181 | #define CFNETWORK_6030579 1 182 | 183 | CF_EXPORT 184 | void __CFSocketSetSocketReadBufferAttrs(CFSocketRef s, CFTimeInterval timeout, CFIndex length); 185 | 186 | CF_EXTERN_C_END 187 | 188 | /* 189 | * for CF{Read/Write}StreamCopyProperty created from a file. The 190 | * result is a CFDataRef containing sizeof(int) bytes in machine byte 191 | * ordering representing the file descriptor of the underlying open 192 | * file. If the underlying file descriptor is not open, the property 193 | * value will be NULL (as opposed to containing ((int) -1)). 194 | */ 195 | CF_EXPORT const CFStringRef _kCFStreamPropertyFileNativeHandle CF_AVAILABLE_IOS(5_0); 196 | 197 | #endif /* ! __COREFOUNDATION_CFSTREAMPRIV__ */ 198 | 199 | -------------------------------------------------------------------------------- /CFStringDefaultEncoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFStringDefaultEncoding.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFSTRINGDEFAULTENCODING__) 29 | #define __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ 1 30 | 31 | #include 32 | 33 | #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | CF_EXTERN_C_BEGIN 44 | 45 | #define __kCFUserEncodingEnvVariableName ("__CF_USER_TEXT_ENCODING") 46 | #define __kCFMaxDefaultEncodingFileLength (64) 47 | #define __kCFUserEncodingFileName ("/.CFUserTextEncoding") 48 | 49 | CF_EXPORT void _CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue); 50 | CF_EXPORT void _CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region); 51 | CF_EXPORT Boolean _CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue); 52 | 53 | CF_INLINE void __CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue) { _CFStringGetUserDefaultEncoding(oScriptValue, oRegionValue); } 54 | CF_INLINE void __CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region) { _CFStringGetInstallationEncodingAndRegion(encoding, region); } 55 | CF_INLINE void __CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue) { _CFStringSaveUserDefaultEncoding(iScriptValue, iRegionValue); } 56 | 57 | CF_EXTERN_C_END 58 | 59 | #endif 60 | 61 | #endif /* ! __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ */ 62 | 63 | 64 | -------------------------------------------------------------------------------- /CFStringEncodingConverter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFStringEncodingConverter.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTER__) 29 | #define __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ 1 30 | 31 | #include 32 | 33 | 34 | CF_EXTERN_C_BEGIN 35 | 36 | /* Values for flags argument for the conversion functions below. These can be combined, but the three NonSpacing behavior flags are exclusive. 37 | */ 38 | // kCFStringEncodingBasicDirectionLeftToRight ~ kCFStringEncodingPrependBOM will probably be deprecated and superceded by kCFStringEncodingPartialInput flag 39 | enum { 40 | kCFStringEncodingAllowLossyConversion = (1UL << 0), // Uses fallback functions to substitutes non mappable chars 41 | kCFStringEncodingBasicDirectionLeftToRight = (1UL << 1), // Converted with original direction left-to-right. 42 | kCFStringEncodingBasicDirectionRightToLeft = (1UL << 2), // Converted with original direction right-to-left. 43 | kCFStringEncodingSubstituteCombinings = (1UL << 3), // Uses fallback function to combining chars. 44 | kCFStringEncodingComposeCombinings = (1UL << 4), // Checks mappable precomposed equivalents for decomposed sequences. This is the default behavior. 45 | kCFStringEncodingIgnoreCombinings = (1UL << 5), // Ignores combining chars. 46 | kCFStringEncodingUseCanonical = (1UL << 6), // Always use canonical form 47 | kCFStringEncodingUseHFSPlusCanonical = (1UL << 7), // Always use canonical form but leaves 0x2000 ranges 48 | kCFStringEncodingPrependBOM = (1UL << 8), // Prepend BOM sequence (i.e. ISO2022KR) 49 | kCFStringEncodingDisableCorporateArea = (1UL << 9), // Disable the usage of 0xF8xx area for Apple proprietary chars in converting to UniChar, resulting loosely mapping. 50 | kCFStringEncodingASCIICompatibleConversion = (1UL << 10), // This flag forces strict ASCII compatible converion. i.e. MacJapanese 0x5C maps to Unicode 0x5C. 51 | kCFStringEncodingLenientUTF8Conversion = (1UL << 11), // 10.1 (Puma) compatible lenient UTF-8 conversion. 52 | kCFStringEncodingPartialInput = (1UL << 12), // input buffer is a part of stream 53 | kCFStringEncodingPartialOutput = (1UL << 13) // output buffer streaming 54 | }; 55 | 56 | /* Return values for CFStringEncodingUnicodeToBytes & CFStringEncodingBytesToUnicode functions 57 | */ 58 | enum { 59 | kCFStringEncodingConversionSuccess = 0, 60 | kCFStringEncodingInvalidInputStream = 1, 61 | kCFStringEncodingInsufficientOutputBufferLength = 2, 62 | kCFStringEncodingConverterUnavailable = 3 63 | }; 64 | 65 | /* Macro to shift lossByte argument. 66 | */ 67 | #define CFStringEncodingLossyByteToMask(lossByte) ((uint32_t)(lossByte << 24)|kCFStringEncodingAllowLossyConversion) 68 | #define CFStringEncodingMaskToLossyByte(flags) ((uint8_t)(flags >> 24)) 69 | 70 | /* Macros for streaming support 71 | */ 72 | #define CFStringEncodingStreamIDMask (0x00FF0000) 73 | #define CFStringEncodingStreamIDFromMask(mask) ((mask >> 16) & 0xFF) 74 | #define CFStringEncodingStreamIDToMask(identifier) ((uint32_t)((identifier & 0xFF) << 16)) 75 | 76 | /* Converts characters into the specified encoding. Returns the constants defined above. 77 | If maxByteLen is 0, bytes is ignored. You can pass lossyByte by passing the value in flags argument. 78 | i.e. CFStringEncodingUnicodeToBytes(encoding, CFStringEncodingLossyByteToMask(lossByte), ....) 79 | */ 80 | CF_EXPORT uint32_t CFStringEncodingUnicodeToBytes(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 81 | 82 | /* Converts bytes in the specified encoding into unicode. Returns the constants defined above. 83 | maxCharLen & usdCharLen are in UniChar length, not byte length. 84 | If maxCharLen is 0, characters is ignored. 85 | */ 86 | CF_EXPORT uint32_t CFStringEncodingBytesToUnicode(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); 87 | 88 | /* Fallback functions used when allowLossy 89 | */ 90 | typedef CFIndex (*CFStringEncodingToBytesFallbackProc)(const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 91 | typedef CFIndex (*CFStringEncodingToUnicodeFallbackProc)(const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); 92 | 93 | CF_EXPORT bool CFStringEncodingIsValidEncoding(uint32_t encoding); 94 | 95 | /* Returns kCFStringEncodingInvalidId terminated encoding list 96 | */ 97 | CF_EXPORT const CFStringEncoding *CFStringEncodingListOfAvailableEncodings(void); 98 | 99 | /* Returns required length of destination buffer for conversion. These functions are faster than specifying 0 to maxByteLen (maxCharLen), but unnecessarily optimal length 100 | */ 101 | CF_EXPORT CFIndex CFStringEncodingCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); 102 | CF_EXPORT CFIndex CFStringEncodingByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); 103 | 104 | /* Can register functions used for lossy conversion. Reregisters default procs if NULL 105 | */ 106 | CF_EXPORT void CFStringEncodingRegisterFallbackProcedures(uint32_t encoding, CFStringEncodingToBytesFallbackProc toBytes, CFStringEncodingToUnicodeFallbackProc toUnicode); 107 | 108 | CF_EXTERN_C_END 109 | 110 | #endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ */ 111 | 112 | -------------------------------------------------------------------------------- /CFStringEncodingConverterExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFStringEncodingConverterExt.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__) 29 | #define __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ 1 30 | 31 | #include 32 | 33 | CF_EXTERN_C_BEGIN 34 | 35 | #define MAX_DECOMPOSED_LENGTH (10) 36 | 37 | enum { 38 | kCFStringEncodingConverterStandard = 0, 39 | kCFStringEncodingConverterCheapEightBit = 1, 40 | kCFStringEncodingConverterStandardEightBit = 2, 41 | kCFStringEncodingConverterCheapMultiByte = 3, 42 | kCFStringEncodingConverterPlatformSpecific = 4, // Other fields are ignored 43 | kCFStringEncodingConverterICU = 5 // Other fields are ignored 44 | }; 45 | 46 | /* kCFStringEncodingConverterStandard */ 47 | typedef CFIndex (*CFStringEncodingToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 48 | typedef CFIndex (*CFStringEncodingToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); 49 | /* kCFStringEncodingConverterCheapEightBit */ 50 | typedef bool (*CFStringEncodingCheapEightBitToBytesProc)(uint32_t flags, UniChar character, uint8_t *byte); 51 | typedef bool (*CFStringEncodingCheapEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *character); 52 | /* kCFStringEncodingConverterStandardEightBit */ 53 | typedef uint16_t (*CFStringEncodingStandardEightBitToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *byte); 54 | typedef uint16_t (*CFStringEncodingStandardEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *characters); 55 | /* kCFStringEncodingConverterCheapMultiByte */ 56 | typedef uint16_t (*CFStringEncodingCheapMultiByteToBytesProc)(uint32_t flags, UniChar character, uint8_t *bytes); 57 | typedef uint16_t (*CFStringEncodingCheapMultiByteToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *character); 58 | 59 | typedef CFIndex (*CFStringEncodingToBytesLenProc)(uint32_t flags, const UniChar *characters, CFIndex numChars); 60 | typedef CFIndex (*CFStringEncodingToUnicodeLenProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes); 61 | 62 | typedef CFIndex (*CFStringEncodingToBytesPrecomposeProc)(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 63 | typedef bool (*CFStringEncodingIsValidCombiningCharacterProc)(UniChar character); 64 | 65 | typedef struct { 66 | void *toBytes; 67 | void *toUnicode; 68 | uint16_t maxBytesPerChar; 69 | uint16_t maxDecomposedCharLen; 70 | uint8_t encodingClass; 71 | uint32_t :24; 72 | CFStringEncodingToBytesLenProc toBytesLen; 73 | CFStringEncodingToUnicodeLenProc toUnicodeLen; 74 | CFStringEncodingToBytesFallbackProc toBytesFallback; 75 | CFStringEncodingToUnicodeFallbackProc toUnicodeFallback; 76 | CFStringEncodingToBytesPrecomposeProc toBytesPrecompose; 77 | CFStringEncodingIsValidCombiningCharacterProc isValidCombiningChar; 78 | } CFStringEncodingConverter; 79 | 80 | extern const CFStringEncodingConverter *CFStringEncodingGetConverter(uint32_t encoding); 81 | 82 | enum { 83 | kCFStringEncodingGetConverterSelector = 0, 84 | kCFStringEncodingIsDecomposableCharacterSelector = 1, 85 | kCFStringEncodingDecomposeCharacterSelector = 2, 86 | kCFStringEncodingIsValidLatin1CombiningCharacterSelector = 3, 87 | kCFStringEncodingPrecomposeLatin1CharacterSelector = 4 88 | }; 89 | 90 | extern const void *CFStringEncodingGetAddressForSelector(uint32_t selector); 91 | 92 | #define BOOTSTRAPFUNC_NAME CFStringEncodingBootstrap 93 | typedef const CFStringEncodingConverter* (*CFStringEncodingBootstrapProc)(uint32_t encoding, const void *getSelector); 94 | 95 | /* Latin precomposition */ 96 | /* This function does not precompose recursively nor to U+01E0 and U+01E1. 97 | */ 98 | extern bool CFStringEncodingIsValidCombiningCharacterForLatin1(UniChar character); 99 | extern UniChar CFStringEncodingPrecomposeLatinCharacter(const UniChar *character, CFIndex numChars, CFIndex *usedChars); 100 | 101 | /* Convenience functions for converter development */ 102 | typedef struct _CFStringEncodingUnicodeTo8BitCharMap { 103 | UniChar _u; 104 | uint8_t _c; 105 | uint8_t :8; 106 | } CFStringEncodingUnicodeTo8BitCharMap; 107 | 108 | /* Binary searches CFStringEncodingUnicodeTo8BitCharMap */ 109 | CF_INLINE bool CFStringEncodingUnicodeTo8BitEncoding(const CFStringEncodingUnicodeTo8BitCharMap *theTable, CFIndex numElem, UniChar character, uint8_t *ch) { 110 | const CFStringEncodingUnicodeTo8BitCharMap *p, *q, *divider; 111 | 112 | if ((character < theTable[0]._u) || (character > theTable[numElem-1]._u)) { 113 | return 0; 114 | } 115 | p = theTable; 116 | q = p + (numElem-1); 117 | while (p <= q) { 118 | divider = p + ((q - p) >> 1); /* divide by 2 */ 119 | if (character < divider->_u) { q = divider - 1; } 120 | else if (character > divider->_u) { p = divider + 1; } 121 | else { *ch = divider->_c; return 1; } 122 | } 123 | return 0; 124 | } 125 | 126 | 127 | CF_EXTERN_C_END 128 | 129 | #endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ */ 130 | 131 | -------------------------------------------------------------------------------- /CFStringEncodingConverterPriv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFStringEncodingConverterPriv.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__) 29 | #define __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ 1 30 | 31 | #include 32 | #include "CFStringEncodingConverterExt.h" 33 | 34 | extern const CFStringEncodingConverter __CFConverterASCII; 35 | extern const CFStringEncodingConverter __CFConverterISOLatin1; 36 | extern const CFStringEncodingConverter __CFConverterMacRoman; 37 | extern const CFStringEncodingConverter __CFConverterWinLatin1; 38 | extern const CFStringEncodingConverter __CFConverterNextStepLatin; 39 | extern const CFStringEncodingConverter __CFConverterUTF8; 40 | 41 | extern CFStringEncoding *__CFStringEncodingCreateListOfAvailablePlatformConverters(CFAllocatorRef allocator, CFIndex *numberOfConverters); 42 | extern const CFStringEncodingConverter *__CFStringEncodingGetExternalConverter(uint32_t encoding); 43 | extern CFIndex __CFStringEncodingPlatformUnicodeToBytes(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); 44 | extern CFIndex __CFStringEncodingPlatformBytesToUnicode(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); 45 | extern CFIndex __CFStringEncodingPlatformCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); 46 | extern CFIndex __CFStringEncodingPlatformByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); 47 | 48 | #endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ */ 49 | 50 | -------------------------------------------------------------------------------- /CFStringEncodingDatabase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * CFStringEncodingDatabase.h 26 | * CoreFoundation 27 | * 28 | * Created by Aki Inoue on 07/12/05. 29 | * Copyright (c) 2007-2014, Apple Inc. All rights reserved. 30 | * 31 | */ 32 | 33 | #include 34 | 35 | CF_PRIVATE uint16_t __CFStringEncodingGetWindowsCodePage(CFStringEncoding encoding); 36 | CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromWindowsCodePage(uint16_t codepage); 37 | 38 | CF_PRIVATE bool __CFStringEncodingGetCanonicalName(CFStringEncoding encoding, char *buffer, CFIndex bufferSize); 39 | CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromCanonicalName(const char *canonicalName); 40 | 41 | CF_PRIVATE CFStringEncoding __CFStringEncodingGetMostCompatibleMacScript(CFStringEncoding encoding); 42 | 43 | CF_PRIVATE const char *__CFStringEncodingGetName(CFStringEncoding encoding); // Returns simple non-localizd name 44 | -------------------------------------------------------------------------------- /CFSystemDirectories.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFSystemDirectories.c 25 | Copyright (c) 1997-2014, Apple Inc. All rights reserved. 26 | Responsibility: Kevin Perry 27 | */ 28 | 29 | /* 30 | This file defines CFCopySearchPathForDirectoriesInDomains(). 31 | On MacOS 8, this function returns empty array. 32 | On Mach, it calls the System.framework enumeration functions. 33 | On Windows, it calls the enumeration functions defined here. 34 | */ 35 | 36 | #include 37 | #include "CFInternal.h" 38 | 39 | #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED 40 | 41 | /* We use the System framework implementation on Mach. 42 | */ 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask) { 50 | return NSStartSearchPathEnumeration(dir, domainMask); 51 | } 52 | 53 | CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, uint8_t *path, CFIndex pathSize) { 54 | CFSearchPathEnumerationState result; 55 | // NSGetNextSearchPathEnumeration requires a MAX_PATH size 56 | if (pathSize < PATH_MAX) { 57 | uint8_t tempPath[PATH_MAX]; 58 | result = NSGetNextSearchPathEnumeration(state, (char *)tempPath); 59 | strlcpy((char *)path, (char *)tempPath, pathSize); 60 | } else { 61 | result = NSGetNextSearchPathEnumeration(state, (char *)path); 62 | } 63 | return result; 64 | } 65 | 66 | #endif 67 | 68 | 69 | #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS 70 | 71 | CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde) { 72 | CFMutableArrayRef array; 73 | CFSearchPathEnumerationState state; 74 | CFIndex homeLen = -1; 75 | char cPath[CFMaxPathSize], home[CFMaxPathSize]; 76 | 77 | array = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); 78 | state = __CFStartSearchPathEnumeration(directory, domainMask); 79 | while ((state = __CFGetNextSearchPathEnumeration(state, (uint8_t *)cPath, sizeof(cPath)))) { 80 | CFURLRef url = NULL; 81 | if (expandTilde && (cPath[0] == '~')) { 82 | if (homeLen < 0) { 83 | CFURLRef homeURL = CFCopyHomeDirectoryURLForUser(NULL); 84 | if (homeURL) { 85 | CFURLGetFileSystemRepresentation(homeURL, true, (uint8_t *)home, CFMaxPathSize); 86 | homeLen = strlen(home); 87 | CFRelease(homeURL); 88 | } 89 | } 90 | if (homeLen + strlen(cPath) < CFMaxPathSize) { 91 | home[homeLen] = '\0'; 92 | strlcat(home, &cPath[1], sizeof(home)); 93 | url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)home, strlen(home), true); 94 | } 95 | } else { 96 | url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)cPath, strlen(cPath), true); 97 | } 98 | if (url) { 99 | CFArrayAppendValue(array, url); 100 | CFRelease(url); 101 | } 102 | } 103 | return array; 104 | } 105 | 106 | #endif 107 | 108 | 109 | #undef numDirs 110 | #undef numApplicationDirs 111 | #undef numLibraryDirs 112 | #undef numDomains 113 | #undef invalidDomains 114 | #undef invalidDomains 115 | 116 | -------------------------------------------------------------------------------- /CFTimeZone.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFTimeZone.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFTIMEZONE__) 29 | #define __COREFOUNDATION_CFTIMEZONE__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | CF_IMPLICIT_BRIDGING_ENABLED 39 | CF_EXTERN_C_BEGIN 40 | 41 | CF_EXPORT 42 | CFTypeID CFTimeZoneGetTypeID(void); 43 | 44 | CF_EXPORT 45 | CFTimeZoneRef CFTimeZoneCopySystem(void); 46 | 47 | CF_EXPORT 48 | void CFTimeZoneResetSystem(void); 49 | 50 | CF_EXPORT 51 | CFTimeZoneRef CFTimeZoneCopyDefault(void); 52 | 53 | CF_EXPORT 54 | void CFTimeZoneSetDefault(CFTimeZoneRef tz); 55 | 56 | CF_EXPORT 57 | CFArrayRef CFTimeZoneCopyKnownNames(void); 58 | 59 | CF_EXPORT 60 | CFDictionaryRef CFTimeZoneCopyAbbreviationDictionary(void); 61 | 62 | CF_EXPORT 63 | void CFTimeZoneSetAbbreviationDictionary(CFDictionaryRef dict); 64 | 65 | CF_EXPORT 66 | CFTimeZoneRef CFTimeZoneCreate(CFAllocatorRef allocator, CFStringRef name, CFDataRef data); 67 | 68 | CF_EXPORT 69 | CFTimeZoneRef CFTimeZoneCreateWithTimeIntervalFromGMT(CFAllocatorRef allocator, CFTimeInterval ti); 70 | 71 | CF_EXPORT 72 | CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef name, Boolean tryAbbrev); 73 | 74 | CF_EXPORT 75 | CFStringRef CFTimeZoneGetName(CFTimeZoneRef tz); 76 | 77 | CF_EXPORT 78 | CFDataRef CFTimeZoneGetData(CFTimeZoneRef tz); 79 | 80 | CF_EXPORT 81 | CFTimeInterval CFTimeZoneGetSecondsFromGMT(CFTimeZoneRef tz, CFAbsoluteTime at); 82 | 83 | CF_EXPORT 84 | CFStringRef CFTimeZoneCopyAbbreviation(CFTimeZoneRef tz, CFAbsoluteTime at); 85 | 86 | CF_EXPORT 87 | Boolean CFTimeZoneIsDaylightSavingTime(CFTimeZoneRef tz, CFAbsoluteTime at); 88 | 89 | CF_EXPORT 90 | CFTimeInterval CFTimeZoneGetDaylightSavingTimeOffset(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); 91 | 92 | CF_EXPORT 93 | CFAbsoluteTime CFTimeZoneGetNextDaylightSavingTimeTransition(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); 94 | 95 | typedef CF_ENUM(CFIndex, CFTimeZoneNameStyle) { 96 | kCFTimeZoneNameStyleStandard, 97 | kCFTimeZoneNameStyleShortStandard, 98 | kCFTimeZoneNameStyleDaylightSaving, 99 | kCFTimeZoneNameStyleShortDaylightSaving, 100 | kCFTimeZoneNameStyleGeneric, 101 | kCFTimeZoneNameStyleShortGeneric 102 | } CF_ENUM_AVAILABLE(10_5, 2_0); 103 | 104 | CF_EXPORT 105 | CFStringRef CFTimeZoneCopyLocalizedName(CFTimeZoneRef tz, CFTimeZoneNameStyle style, CFLocaleRef locale) CF_AVAILABLE(10_5, 2_0); 106 | 107 | CF_EXPORT 108 | const CFStringRef kCFTimeZoneSystemTimeZoneDidChangeNotification CF_AVAILABLE(10_5, 2_0); 109 | 110 | CF_EXTERN_C_END 111 | CF_IMPLICIT_BRIDGING_DISABLED 112 | 113 | #endif /* ! __COREFOUNDATION_CFTIMEZONE__ */ 114 | 115 | -------------------------------------------------------------------------------- /CFURLAccess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFURLAccess.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | 27 | CFURLAccess is deprecated as of Mac OS X 10.9 and iOS 7.0. The suggested replacement for URLs with network schemes (http, https, ftp, data) are the NSURLSession or NSURLConnection classes. The suggested replacement for URLs with the file scheme are the foundation classes NSFileManager, NSFileHandle and NSURL, or the CoreFoundation classes CFStream and CFURL. 28 | */ 29 | 30 | #if !defined(__COREFOUNDATION_CFURLACCESS__) 31 | #define __COREFOUNDATION_CFURLACCESS__ 1 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | CF_IMPLICIT_BRIDGING_ENABLED 42 | CF_EXTERN_C_BEGIN 43 | 44 | 45 | 46 | /* Attempts to read the data and properties for the given URL. If 47 | only interested in one of the resourceData and properties, pass NULL 48 | for the other. If properties is non-NULL and desiredProperties is 49 | NULL, then all properties are fetched. Returns success or failure; 50 | note that as much work as possible is done even if false is returned. 51 | So for instance if one property is not available, the others are 52 | fetched anyway. errorCode is set to 0 on success, and some other 53 | value on failure. If non-NULL, it is the caller 's responsibility 54 | to release resourceData and properties. 55 | 56 | Apple reserves for its use all negative error code values; these 57 | values represent errors common to any scheme. Scheme-specific error 58 | codes should be positive, non-zero, and should be used only if one of 59 | the predefined Apple error codes does not apply. Error codes should 60 | be publicized and documented with the scheme-specific properties. 61 | 62 | NOTE: When asking for the resource data, this call will allocate the entire 63 | resource in memory. This can be very expensive, depending on the size of the 64 | resource (file). Please use CFStream or other techniques if you are downloading 65 | large files. 66 | 67 | */ 68 | /* Deprecated -- see top of this file for suggested replacement classes */ 69 | CF_EXPORT 70 | Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *resourceData, CFDictionaryRef *properties, CFArrayRef desiredProperties, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "For resource data, use the CFReadStream API. For file resource properties, use CFURLCopyResourcePropertiesForKeys."); 71 | 72 | /* Attempts to write the given data and properties to the given URL. 73 | If dataToWrite is NULL, only properties are written out (use 74 | CFURLDestroyResource() to delete a resource). Properties not present 75 | in propertiesToWrite are left unchanged, hence if propertiesToWrite 76 | is NULL or empty, the URL's properties are not changed at all. 77 | Returns success or failure; errorCode is set as for 78 | CFURLCreateDataAndPropertiesFromResource(), above. 79 | */ 80 | /* Deprecated -- see top of this file for suggested replacement classes */ 81 | CF_EXPORT 82 | Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef dataToWrite, CFDictionaryRef propertiesToWrite, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "For resource data, use the CFWriteStream API. For file resource properties, use CFURLSetResourcePropertiesForKeys."); 83 | 84 | /* Destroys the resource indicated by url. 85 | Returns success or failure; errorCode set as above. 86 | */ 87 | /* Deprecated -- see top of this file for suggested replacement classes */ 88 | CF_EXPORT 89 | Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLGetFileSystemRepresentation and removefile(3) instead."); 90 | 91 | /* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). 92 | Returns NULL on error and sets errorCode accordingly. 93 | */ 94 | /* Deprecated -- see top of this file for suggested replacement classes */ 95 | CF_EXPORT 96 | CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "For file resource properties, use CFURLCopyResourcePropertyForKey."); 97 | 98 | 99 | /* Common error codes (returned only by the older APIs that predate CFError) */ 100 | typedef CF_ENUM(CFIndex, CFURLError) { 101 | kCFURLUnknownError = -10L, 102 | kCFURLUnknownSchemeError = -11L, 103 | kCFURLResourceNotFoundError = -12L, 104 | kCFURLResourceAccessViolationError = -13L, 105 | kCFURLRemoteHostUnavailableError = -14L, 106 | kCFURLImproperArgumentsError = -15L, 107 | kCFURLUnknownPropertyKeyError = -16L, 108 | kCFURLPropertyKeyUnavailableError = -17L, 109 | kCFURLTimeoutError = -18L 110 | } CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0); 111 | 112 | /* Older property keys */ 113 | 114 | CF_EXPORT 115 | const CFStringRef kCFURLFileExists CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLResourceIsReachable instead."); 116 | CF_EXPORT 117 | const CFStringRef kCFURLFileDirectoryContents CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use the CFURLEnumerator API instead."); 118 | CF_EXPORT 119 | const CFStringRef kCFURLFileLength CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSizeKey instead."); 120 | CF_EXPORT 121 | const CFStringRef kCFURLFileLastModificationTime CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLContentModificationDateKey instead."); 122 | CF_EXPORT 123 | const CFStringRef kCFURLFilePOSIXMode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); 124 | CF_EXPORT 125 | const CFStringRef kCFURLFileOwnerID CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); 126 | CF_EXPORT 127 | const CFStringRef kCFURLHTTPStatusCode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); 128 | CF_EXPORT 129 | const CFStringRef kCFURLHTTPStatusLine CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); 130 | 131 | /* The value of kCFURLFileExists is a CFBoolean */ 132 | /* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */ 133 | /* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */ 134 | /* The value of kCFURLFileLastModificationTime is a CFDate */ 135 | /* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */ 136 | /* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */ 137 | 138 | /* Properties for the http: scheme. Except for the common error codes, above, errorCode will be set to the HTTP response status code upon failure. Any HTTP header name can also be used as a property */ 139 | /* The value of kCFURLHTTPStatusCode is a CFNumber */ 140 | /* The value of kCFURLHTTPStatusLine is a CFString */ 141 | 142 | CF_EXTERN_C_END 143 | CF_IMPLICIT_BRIDGING_DISABLED 144 | 145 | #endif /* ! __COREFOUNDATION_CFURLACCESS__ */ 146 | 147 | -------------------------------------------------------------------------------- /CFUUID.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFUUID.h 25 | Copyright (c) 1999-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFUUID__) 29 | #define __COREFOUNDATION_CFUUID__ 1 30 | 31 | #include 32 | #include 33 | 34 | CF_IMPLICIT_BRIDGING_ENABLED 35 | CF_EXTERN_C_BEGIN 36 | 37 | typedef const struct __CFUUID * CFUUIDRef; 38 | 39 | typedef struct { 40 | UInt8 byte0; 41 | UInt8 byte1; 42 | UInt8 byte2; 43 | UInt8 byte3; 44 | UInt8 byte4; 45 | UInt8 byte5; 46 | UInt8 byte6; 47 | UInt8 byte7; 48 | UInt8 byte8; 49 | UInt8 byte9; 50 | UInt8 byte10; 51 | UInt8 byte11; 52 | UInt8 byte12; 53 | UInt8 byte13; 54 | UInt8 byte14; 55 | UInt8 byte15; 56 | } CFUUIDBytes; 57 | /* The CFUUIDBytes struct is a 128-bit struct that contains the 58 | raw UUID. A CFUUIDRef can provide such a struct from the 59 | CFUUIDGetUUIDBytes() function. This struct is suitable for 60 | passing to APIs that expect a raw UUID. 61 | */ 62 | 63 | CF_EXPORT 64 | CFTypeID CFUUIDGetTypeID(void); 65 | 66 | CF_EXPORT 67 | CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc); 68 | /* Create and return a brand new unique identifier */ 69 | 70 | CF_EXPORT 71 | CFUUIDRef CFUUIDCreateWithBytes(CFAllocatorRef alloc, UInt8 byte0, UInt8 byte1, UInt8 byte2, UInt8 byte3, UInt8 byte4, UInt8 byte5, UInt8 byte6, UInt8 byte7, UInt8 byte8, UInt8 byte9, UInt8 byte10, UInt8 byte11, UInt8 byte12, UInt8 byte13, UInt8 byte14, UInt8 byte15); 72 | /* Create and return an identifier with the given contents. This may return an existing instance with its ref count bumped because of uniquing. */ 73 | 74 | CF_EXPORT 75 | CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef alloc, CFStringRef uuidStr); 76 | /* Converts from a string representation to the UUID. This may return an existing instance with its ref count bumped because of uniquing. */ 77 | 78 | CF_EXPORT 79 | CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); 80 | /* Converts from a UUID to its string representation. */ 81 | 82 | CF_EXPORT 83 | CFUUIDRef CFUUIDGetConstantUUIDWithBytes(CFAllocatorRef alloc, UInt8 byte0, UInt8 byte1, UInt8 byte2, UInt8 byte3, UInt8 byte4, UInt8 byte5, UInt8 byte6, UInt8 byte7, UInt8 byte8, UInt8 byte9, UInt8 byte10, UInt8 byte11, UInt8 byte12, UInt8 byte13, UInt8 byte14, UInt8 byte15); 84 | /* This returns an immortal CFUUIDRef that should not be released. It can be used in headers to declare UUID constants with #define. */ 85 | 86 | CF_EXPORT 87 | CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid); 88 | 89 | CF_EXPORT 90 | CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes); 91 | 92 | CF_EXTERN_C_END 93 | CF_IMPLICIT_BRIDGING_DISABLED 94 | 95 | #endif /* ! __COREFOUNDATION_CFUUID__ */ 96 | 97 | -------------------------------------------------------------------------------- /CFUniCharPriv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFUniCharPriv.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFUNICHARPRIV__) 29 | #define __COREFOUNDATION_CFUNICHARPRIV__ 1 30 | 31 | #include 32 | #include 33 | 34 | #define kCFUniCharRecursiveDecompositionFlag (1UL << 30) 35 | #define kCFUniCharNonBmpFlag (1UL << 31) 36 | #define CFUniCharConvertCountToFlag(count) ((count & 0x1F) << 24) 37 | #define CFUniCharConvertFlagToCount(flag) ((flag >> 24) & 0x1F) 38 | 39 | enum { 40 | kCFUniCharCanonicalDecompMapping = (kCFUniCharCaseFold + 1), 41 | kCFUniCharCanonicalPrecompMapping, 42 | kCFUniCharCompatibilityDecompMapping 43 | }; 44 | 45 | CF_EXPORT const void *CFUniCharGetMappingData(uint32_t type); 46 | 47 | #endif /* ! __COREFOUNDATION_CFUNICHARPRIV__ */ 48 | 49 | -------------------------------------------------------------------------------- /CFUniCharPropertyDatabase.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensource-apple/CF/3cc41a76b1491f50813e28a4ec09954ffa359e6f/CFUniCharPropertyDatabase.data -------------------------------------------------------------------------------- /CFUnicodeData-B.mapping: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensource-apple/CF/3cc41a76b1491f50813e28a4ec09954ffa359e6f/CFUnicodeData-B.mapping -------------------------------------------------------------------------------- /CFUnicodeData-L.mapping: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensource-apple/CF/3cc41a76b1491f50813e28a4ec09954ffa359e6f/CFUnicodeData-L.mapping -------------------------------------------------------------------------------- /CFUnicodeDecomposition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * CFUnicodeDecomposition.h 26 | * CoreFoundation 27 | * 28 | * Created by aki on Wed Oct 03 2001. 29 | * Copyright (c) 2001-2014, Apple Inc. All rights reserved. 30 | * 31 | */ 32 | 33 | #if !defined(__COREFOUNDATION_CFUNICODEDECOMPOSITION__) 34 | #define __COREFOUNDATION_CFUNICODEDECOMPOSITION__ 1 35 | 36 | #include 37 | 38 | CF_EXTERN_C_BEGIN 39 | 40 | CF_INLINE bool CFUniCharIsDecomposableCharacter(UTF32Char character, bool isHFSPlusCanonical) { 41 | if (isHFSPlusCanonical && !isHFSPlusCanonical) return false; // hack to get rid of "unused" warning 42 | if (character < 0x80) return false; 43 | return CFUniCharIsMemberOf(character, kCFUniCharHFSPlusDecomposableCharacterSet); 44 | } 45 | 46 | CF_EXPORT CFIndex CFUniCharDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars, CFIndex maxBufferLength); 47 | CF_EXPORT CFIndex CFUniCharCompatibilityDecompose(UTF32Char *convertedChars, CFIndex length, CFIndex maxBufferLength); 48 | 49 | CF_EXPORT bool CFUniCharDecompose(const UTF16Char *src, CFIndex length, CFIndex *consumedLength, void *dst, CFIndex maxLength, CFIndex *filledLength, bool needToReorder, uint32_t dstFormat, bool isHFSPlus); 50 | 51 | CF_EXPORT void CFUniCharPrioritySort(UTF32Char *characters, CFIndex length); 52 | 53 | CF_EXTERN_C_END 54 | 55 | #endif /* ! __COREFOUNDATION_CFUNICODEDECOMPOSITION__ */ 56 | 57 | -------------------------------------------------------------------------------- /CFUnicodePrecomposition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * CFUnicodePrecomposition.h 26 | * CoreFoundation 27 | * 28 | * Created by aki on Wed Oct 03 2001. 29 | * Copyright (c) 2001-2014, Apple Inc. All rights reserved. 30 | * 31 | */ 32 | 33 | #if !defined(__COREFOUNDATION_CFUNICODEPRECOMPOSITION__) 34 | #define __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ 1 35 | 36 | #include 37 | 38 | CF_EXTERN_C_BEGIN 39 | 40 | // As you can see, this function cannot precompose Hangul Jamo 41 | CF_EXPORT UTF32Char CFUniCharPrecomposeCharacter(UTF32Char base, UTF32Char combining); 42 | 43 | CF_EXPORT bool CFUniCharPrecompose(const UTF16Char *characters, CFIndex length, CFIndex *consumedLength, UTF16Char *precomposed, CFIndex maxLength, CFIndex *filledLength); 44 | 45 | CF_EXTERN_C_END 46 | 47 | #endif /* ! __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ */ 48 | 49 | -------------------------------------------------------------------------------- /CFUtilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFUtilities.h 25 | Copyright (c) 2005-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFUTILITIES__) 29 | #define __COREFOUNDATION_CFUTILITIES__ 1 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | CF_IMPLICIT_BRIDGING_ENABLED 36 | CF_EXTERN_C_BEGIN 37 | 38 | CF_EXPORT 39 | CFURLRef CFCopyHomeDirectoryURL(void) CF_AVAILABLE_IOS(5_0); 40 | 41 | CF_EXTERN_C_END 42 | CF_IMPLICIT_BRIDGING_DISABLED 43 | 44 | #endif /* ! __COREFOUNDATION_CFUTILITIES__ */ 45 | 46 | -------------------------------------------------------------------------------- /CFVersion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFVersion.c 25 | Copyright 2009-2014, Apple Inc. All rights reserved. 26 | Responsibility: CFLite Team 27 | */ 28 | const unsigned char kCFCoreFoundationVersionString[] = "@(#)PROGRAM:CoreFoundation PROJECT:CoreFoundation-1153.18 SYSTEM:Darwin DEVELOPER:unknown BUILT:" __DATE__ " " __TIME__ "\n"; 29 | double kCFCoreFoundationVersionNumber = (double)1153.18; 30 | -------------------------------------------------------------------------------- /CFWindowsUtilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | CFWindowsUtilities.c 26 | Copyright (c) 2008-2014, Apple Inc. All rights reserved. 27 | Responsibility: Tony Parker 28 | */ 29 | 30 | #if DEPLOYMENT_TARGET_WINDOWS 31 | 32 | #include 33 | #include 34 | #include "CFInternal.h" 35 | #include "CFPriv.h" 36 | 37 | #include 38 | 39 | #include 40 | 41 | CF_EXPORT bool OSAtomicCompareAndSwapPtr(void *oldp, void *newp, void *volatile *dst) 42 | { 43 | return oldp == InterlockedCompareExchangePointer(dst, newp, oldp); 44 | } 45 | 46 | CF_EXPORT bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst) 47 | { 48 | return oldl == InterlockedCompareExchange(dst, newl, oldl); 49 | } 50 | 51 | CF_EXPORT bool OSAtomicCompareAndSwapPtrBarrier(void *oldp, void *newp, void *volatile *dst) 52 | { 53 | return oldp == InterlockedCompareExchangePointer(dst, newp, oldp); 54 | } 55 | 56 | CF_EXPORT int32_t OSAtomicDecrement32Barrier(volatile int32_t *dst) 57 | { 58 | return InterlockedDecrement((volatile long *)dst); 59 | } 60 | 61 | CF_EXPORT int32_t OSAtomicIncrement32Barrier(volatile int32_t *dst) 62 | { 63 | return InterlockedIncrement((volatile long *)dst); 64 | } 65 | 66 | CF_EXPORT int32_t OSAtomicAdd32Barrier( int32_t theAmount, volatile int32_t *theValue ) { 67 | return (InterlockedExchangeAdd((volatile LONG *)theValue, theAmount) + theAmount); 68 | } 69 | 70 | CF_EXPORT bool OSAtomicCompareAndSwap32Barrier(int32_t oldValue, int32_t newValue, volatile int32_t *theValue) { 71 | return oldValue == InterlockedCompareExchange((long *)theValue, newValue, oldValue); 72 | } 73 | 74 | CF_EXPORT int32_t OSAtomicAdd32( int32_t theAmount, volatile int32_t *theValue ) { 75 | return (InterlockedExchangeAdd((volatile LONG *)theValue, theAmount) + theAmount); 76 | } 77 | 78 | CF_EXPORT int32_t OSAtomicIncrement32(volatile int32_t *theValue) { 79 | return InterlockedIncrement((volatile long *)theValue); 80 | } 81 | 82 | CF_EXPORT int32_t OSAtomicDecrement32(volatile int32_t *theValue) { 83 | return InterlockedDecrement((volatile long *)theValue); 84 | } 85 | 86 | // These 64-bit versions of InterlockedCompareExchange are only available on client Vista and later, so we can't use them (yet). 87 | /* 88 | CF_EXPORT bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ) { 89 | return __oldValue == InterlockedCompareExchange64((volatile LONGLONG *)__theValue, __newValue, __oldValue); 90 | } 91 | 92 | CF_EXPORT bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ) { 93 | return __oldValue == InterlockedCompareExchange64((volatile LONGLONG *)__theValue, __newValue, __oldValue); 94 | } 95 | 96 | CF_EXPORT int64_t OSAtomicAdd64( int64_t __theAmount, volatile int64_t *__theValue ) { 97 | return (InterlockedExchangeAdd64((volatile LONGLONG *)__theValue, __theAmount) + __theAmount); 98 | } 99 | 100 | CF_EXPORT int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue ) { 101 | retun (InterlockedExchangeAdd64((volatile LONGLONG *)__theValue, __theAmount) + __theAmount); 102 | } 103 | */ 104 | 105 | void OSMemoryBarrier() { 106 | MemoryBarrier(); 107 | } 108 | 109 | void _CFGetFrameworkPath(wchar_t *path, int maxLength) { 110 | #ifdef _DEBUG 111 | // might be nice to get this from the project file at some point 112 | wchar_t *DLLFileName = L"CoreFoundation_debug.dll"; 113 | #else 114 | wchar_t *DLLFileName = L"CoreFoundation.dll"; 115 | #endif 116 | path[0] = path[1] = 0; 117 | DWORD wResult; 118 | CFIndex idx; 119 | HMODULE ourModule = GetModuleHandleW(DLLFileName); 120 | 121 | CFAssert(ourModule, __kCFLogAssertion, "GetModuleHandle failed"); 122 | 123 | wResult = GetModuleFileNameW(ourModule, path, maxLength); 124 | CFAssert1(wResult > 0, __kCFLogAssertion, "GetModuleFileName failed: %d", GetLastError()); 125 | CFAssert1(wResult < maxLength, __kCFLogAssertion, "GetModuleFileName result truncated: %s", path); 126 | 127 | // strip off last component, the DLL name 128 | for (idx = wResult - 1; idx; idx--) { 129 | if ('\\' == path[idx]) { 130 | path[idx] = '\0'; 131 | break; 132 | } 133 | } 134 | } 135 | 136 | 137 | #endif 138 | 139 | -------------------------------------------------------------------------------- /CFXMLInputStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CFXMLInputStream.h 25 | Copyright (c) 2000-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_CFXMLINPUTSTREAM__) 29 | #define __COREFOUNDATION_CFXMLINPUTSTREAM__ 1 30 | 31 | #include 32 | #include "CFInternal.h" 33 | #include 34 | #include 35 | #include 36 | 37 | struct __CFXMLNode { 38 | // additionalData currently always points off the bottom of this struct; we could just eliminate it. Also, we may want to add a flags/version argument, and could use it to mark whether the node was the special one that CFXMLParser mucks with, as well as whether the allocator was "special" (could save us the alloc instance variable, below) -- REW, 3/8/2000 39 | CFRuntimeBase _cfBase; 40 | CFIndex version; 41 | CFXMLNodeTypeCode dataTypeID; 42 | CFStringRef dataString; 43 | void *additionalData; 44 | }; 45 | 46 | struct __CFXMLInputStream { 47 | CFDataRef data; // The XML data 48 | CFURLRef url; // the source URL for the data 49 | CFStringEncoding encoding; // the data's encoding 50 | const UInt8 *currentByte; // pointer into data at the first byte not yet translated to a character 51 | 52 | UniChar *charBuffer; // the buffer of characters translated from data 53 | UniChar *currentChar; // pointer into charBuffer at the current stream location. MUST be NULL if there are no more characters in charBuffer to consume. 54 | UniChar *mark; // The point at which the mark was dropped. NULL if the mark is currently unset. 55 | UniChar *parserMark; // mark available only for the parser's use 56 | CFIndex bufferLength; // The number of meaningful characters in charBuffer 57 | CFIndex bufferCapacity; // The current maximum capacity of charBuffer in UniChars 58 | 59 | CFIndex charIndex, lineNum; // location in the file 60 | UInt32 flags; // See #defines below for bit flag meanings 61 | CFMutableSetRef nameSet; // set of all names we've encountered; used for uniquing 62 | CFMutableStringRef tempString; 63 | 64 | CFAllocatorRef allocator; // This is unfortunate; this is always the same as the parser's allocator. We'd like to get rid of it at some point, but that would mean adding an allocator to all the function calls, which means risking that the allocator passed in gets out-of-sync. Maybe once we have CFStreams, we can encapsulate it all in that. REW, 5/22/2000 65 | }; 66 | 67 | // whether the stream has been opened for reading 68 | #define STREAM_OPEN 0x1 69 | // whether the encoding matches ASCII over 0x0-0x7F 70 | #define ENCODING_MATCHES_ASCII 0x2 71 | // whether the encoding is Unicode with the "natural" byte ordering 72 | #define ENCODING_IS_UNICODE_NATURAL 0x4 73 | // whether the encoding is Unicode with the bytes swapped 74 | #define ENCODING_IS_UNICODE_SWAPPED 0x8 75 | // whether the stream has encountered an error in encodings. 76 | #define ENCODING_COMPOSITION_ERROR 0x10 77 | 78 | typedef struct __CFXMLInputStream _CFXMLInputStream; 79 | 80 | void _initializeInputStream(_CFXMLInputStream *stream, CFAllocatorRef alloc, CFURLRef dataSource, CFDataRef xmlData); 81 | Boolean _openInputStream(_CFXMLInputStream *stream); // None of the subsequent calls will work until the input stream has been opened 82 | void _freeInputStream(_CFXMLInputStream *stream); 83 | 84 | CFStringEncoding _inputStreamGetEncoding(_CFXMLInputStream *stream); 85 | CFIndex _inputStreamCurrentLocation(_CFXMLInputStream *stream); 86 | CFIndex _inputStreamCurrentLine(_CFXMLInputStream *stream); 87 | Boolean _inputStreamAtEOF(_CFXMLInputStream *stream); 88 | Boolean _inputStreamComposingErrorOccurred(_CFXMLInputStream *stream); 89 | 90 | Boolean _inputStreamPeekCharacter(_CFXMLInputStream *stream, UniChar *ch); 91 | Boolean _inputStreamGetCharacter(_CFXMLInputStream *stream, UniChar *ch); 92 | Boolean _inputStreamReturnCharacter(_CFXMLInputStream *stream, UniChar ch); 93 | void _inputStreamSetMark(_CFXMLInputStream *stream); 94 | void _inputStreamClearMark(_CFXMLInputStream *stream); 95 | void _inputStreamGetCharactersFromMark(_CFXMLInputStream *stream, CFMutableStringRef string); 96 | void _inputStreamBackUpToMark(_CFXMLInputStream *stream); 97 | void _inputStringInitialize(_CFXMLInputStream *stream, UniChar *characters, CFIndex length); 98 | CFIndex _inputStreamSkipWhitespace(_CFXMLInputStream *stream, CFMutableStringRef str); 99 | Boolean _inputStreamScanToCharacters(_CFXMLInputStream *stream, const UniChar *scanChars, CFIndex numChars, CFMutableStringRef str); 100 | Boolean _inputStreamMatchString(_CFXMLInputStream *stream, const UniChar *stringToMatch, CFIndex length); 101 | Boolean _inputStreamScanQuotedString(_CFXMLInputStream *stream, CFMutableStringRef str); 102 | Boolean _inputStreamScanXMLName(_CFXMLInputStream *stream, Boolean isNMToken, CFStringRef *str); 103 | 104 | /* Returns the character index within the current line of the current parse location */ 105 | /* To add someday -- CF_EXPORT 106 | CFIndex CFXMLParserGetOffsetInCurrentLine(CFXMLParserRef parser); */ 107 | 108 | #endif /* ! __COREFOUNDATION_CFXMLINPUTSTREAM__ */ 109 | 110 | -------------------------------------------------------------------------------- /CoreFoundation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* CoreFoundation.h 25 | Copyright (c) 1998-2014, Apple Inc. All rights reserved. 26 | */ 27 | 28 | #if !defined(__COREFOUNDATION_COREFOUNDATION__) 29 | #define __COREFOUNDATION_COREFOUNDATION__ 1 30 | #define __COREFOUNDATION__ 1 31 | 32 | #if !defined(CF_EXCLUDE_CSTD_HEADERS) 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #if defined(__STDC_VERSION__) && (199901L <= __STDC_VERSION__) 52 | 53 | #include 54 | #include 55 | #include 56 | 57 | #endif 58 | 59 | #endif 60 | 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #include 88 | 89 | #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 90 | #include 91 | #include 92 | #include 93 | #include 94 | #include 95 | #include 96 | 97 | 98 | #endif 99 | 100 | #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) 101 | #endif 102 | 103 | #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) 104 | #include 105 | #include 106 | #include 107 | #endif 108 | 109 | 110 | #endif /* ! __COREFOUNDATION_COREFOUNDATION__ */ 111 | 112 | -------------------------------------------------------------------------------- /Examples/plconvert.c: -------------------------------------------------------------------------------- 1 | // Mac OS X: clang -F -framework CoreFoundation Examples/plconvert.c -o plconvert 2 | // note: When running this sample, be sure to set the environment variable DYLD_FRAMEWORK_PATH to point to the directory containing your new version of CoreFoundation. 3 | // e.g. 4 | // DYLD_FRAMEWORK_PATH=/tmp/CF-Root ./plconvert 5 | // 6 | // Linux: clang -I/usr/local/include -L/usr/local/lib -lCoreFoundation plconvert.c -o plconvert 7 | 8 | /* 9 | This example shows usage of CFString, CFData, and other CFPropertyList types. It takes two arguments: 10 | 1. A property list file to read, in either binary or XML property list format. 11 | 2. A file name to write a converted property list file to. 12 | If the first input is binary, the output is XML and vice-versa. 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | static void logIt(CFStringRef format, ...) { 25 | va_list args; 26 | va_start(args, format); 27 | CFStringRef str = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, NULL, format, args); 28 | if (!str) return; 29 | 30 | CFIndex blen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); 31 | char *buf = str ? (char *)malloc(blen + 1) : 0; 32 | if (buf) { 33 | Boolean converted = CFStringGetCString(str, buf, blen, kCFStringEncodingUTF8); 34 | if (converted) { 35 | // null-terminate 36 | buf[blen] = 0; 37 | printf("%s\n", buf); 38 | } 39 | } 40 | if (buf) free(buf); 41 | if (str) CFRelease(str); va_end(args); 42 | } 43 | 44 | static CFMutableDataRef createDataFromFile(const char *fname) { 45 | int fd = open(fname, O_RDONLY); 46 | CFMutableDataRef res = CFDataCreateMutable(kCFAllocatorSystemDefault, 0); 47 | char buf[4096]; 48 | 49 | ssize_t amountRead; 50 | while ((amountRead = read(fd, buf, 4096)) > 0) { 51 | CFDataAppendBytes(res, (const UInt8 *)buf, amountRead); 52 | } 53 | 54 | close(fd); 55 | return res; 56 | } 57 | 58 | static bool writeDataToFile(CFDataRef data, const char *fname) { 59 | int fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666); 60 | if (fd < 0) { 61 | printf("There was an error creating the file: %d", errno); 62 | return false; 63 | } 64 | int dataLen = CFDataGetLength(data); 65 | int w = write(fd, CFDataGetBytePtr(data), dataLen); 66 | fsync(fd); 67 | close(fd); 68 | if (w != dataLen) return false; 69 | return true; 70 | } 71 | 72 | int main(int argc, char **argv) { 73 | 74 | if (argc != 3) { 75 | printf("Usage: plconvert \nIf the in file is an XML property list, convert to binary property list in out file. If the in file is a binary property list, convert to XML property list in out file.\n"); 76 | } else { 77 | CFMutableDataRef plistData = createDataFromFile(argv[1]); 78 | if (!plistData) { 79 | printf("Unable to create data from file name: %s", argv[1]); 80 | } else { 81 | CFPropertyListFormat fmt; 82 | CFErrorRef err; 83 | CFPropertyListRef plist = CFPropertyListCreateWithData(kCFAllocatorSystemDefault, (CFDataRef)plistData, 0, &fmt, &err); 84 | if (!plist) { 85 | logIt(CFSTR("Unable to create property list from data: %@"), err); 86 | } else { 87 | logIt(CFSTR("Property list contents:\n%@"), plist); 88 | if (fmt == kCFPropertyListBinaryFormat_v1_0) { 89 | logIt(CFSTR("Converting to XML property list at: %s"), argv[2]); 90 | fmt = kCFPropertyListXMLFormat_v1_0; 91 | } else if (fmt == kCFPropertyListXMLFormat_v1_0) { 92 | logIt(CFSTR("Converting to binary property list at: %s"), argv[2]); 93 | fmt = kCFPropertyListBinaryFormat_v1_0; 94 | } else { 95 | logIt(CFSTR("Unknown property list format! Not converting output format.")); 96 | } 97 | 98 | CFDataRef outputData = CFPropertyListCreateData(kCFAllocatorSystemDefault, plist, fmt, 0, &err); 99 | if (!outputData) { 100 | logIt(CFSTR("Unable to write property list to data: %@"), err); 101 | } else { 102 | bool success = writeDataToFile(outputData, argv[2]); 103 | if (!success) { 104 | logIt(CFSTR("Unable to write data to file")); 105 | } 106 | CFRelease(outputData); 107 | } 108 | CFRelease(plist); 109 | } 110 | CFRelease(plistData); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en_US 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.apple.CoreFoundation 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | CoreFoundation 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 6.9 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | 24 | 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | include MakefileVersion 3 | 4 | MIN_MACOSX_VERSION=10.10 5 | MAX_MACOSX_VERSION=MAC_OS_X_VERSION_10_10 6 | 7 | OBJECTS = $(patsubst %.c,%.o,$(wildcard *.c)) 8 | OBJECTS += CFBasicHash.o 9 | HFILES = $(wildcard *.h) 10 | INTERMEDIATE_HFILES = $(addprefix $(OBJBASE)/CoreFoundation/,$(HFILES)) 11 | 12 | PUBLIC_HEADERS=CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFBundle.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMessagePort.h CFNumber.h CFNumberFormatter.h CFPlugIn.h CFPlugInCOM.h CFPreferences.h CFPropertyList.h CFRunLoop.h CFSet.h CFSocket.h CFStream.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFUserNotification.h CFXMLNode.h CFXMLParser.h CFAvailability.h CFUtilities.h CoreFoundation.h 13 | 14 | PRIVATE_HEADERS=CFBundlePriv.h CFCharacterSetPriv.h CFError_Private.h CFLogUtilities.h CFPriv.h CFRuntime.h CFStorage.h CFStreamAbstract.h CFStreamPriv.h CFStreamInternal.h CFStringDefaultEncoding.h CFStringEncodingConverter.h CFStringEncodingConverterExt.h CFUniChar.h CFUnicodeDecomposition.h CFUnicodePrecomposition.h ForFoundationOnly.h CFBurstTrie.h CFICULogging.h 15 | 16 | MACHINE_TYPE := $(shell uname -p) 17 | unicode_data_file_name = $(if $(or $(findstring i386,$(1)),$(findstring i686,$(1)),$(findstring x86_64,$(1))),CFUnicodeData-L.mapping,CFUnicodeData-B.mapping) 18 | 19 | OBJBASE_ROOT = CF-Objects 20 | OBJBASE = $(OBJBASE_ROOT)/$(STYLE) 21 | DSTBASE = $(if $(DSTROOT),$(DSTROOT)/System/Library/Frameworks,../CF-Root) 22 | 23 | STYLE=normal 24 | STYLE_CFLAGS=-O2 25 | STYLE_LFLAGS= 26 | ARCHFLAGS=-arch i386 -arch x86_64 27 | INSTALLNAME=/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation_$(STYLE) 28 | 29 | CC = /usr/bin/clang 30 | 31 | CFLAGS=-c -x c -pipe -std=gnu99 -Wmost -Wno-trigraphs -Wno-deprecated -mmacosx-version-min=$(MIN_MACOSX_VERSION) -fconstant-cfstrings -fexceptions -DCF_BUILDING_CF=1 -DDEPLOYMENT_TARGET_MACOSX=1 -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MAX_MACOSX_VERSION) -DU_SHOW_DRAFT_API=1 -DU_SHOW_CPLUSPLUS_API=0 -I$(OBJBASE) -DVERSION=$(VERSION) -include CoreFoundation_Prefix.h 32 | 33 | LFLAGS=-dynamiclib -mmacosx-version-min=$(MIN_MACOSX_VERSION) -twolevel_namespace -fexceptions -init ___CFInitialize -compatibility_version 150 -current_version $(VERSION) -Wl,-alias_list,SymbolAliases -sectcreate __UNICODE __csbitmaps CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data $(call unicode_data_file_name,$(MACHINE_TYPE)) -segprot __UNICODE r r 34 | 35 | 36 | .PHONY: all install clean 37 | .PRECIOUS: $(OBJBASE)/CoreFoundation/%.h 38 | 39 | all: install 40 | 41 | clean: 42 | -/bin/rm -rf $(OBJBASE_ROOT) 43 | 44 | $(OBJBASE)/CoreFoundation: 45 | /bin/mkdir -p $(OBJBASE)/CoreFoundation 46 | 47 | $(OBJBASE)/CoreFoundation/%.h: %.h $(OBJBASE)/CoreFoundation 48 | /bin/cp $< $@ 49 | 50 | $(OBJBASE)/%.o: %.c $(INTERMEDIATE_HFILES) 51 | $(CC) $(STYLE_CFLAGS) $(ARCHFLAGS) $(CFLAGS) $< -o $@ 52 | 53 | $(OBJBASE)/%.o: %.m $(INTERMEDIATE_HFILES) 54 | $(CC) $(STYLE_CFLAGS) $(ARCHFLAGS) $(CFLAGS) $< -o $@ 55 | 56 | $(OBJBASE)/CoreFoundation_$(STYLE): $(addprefix $(OBJBASE)/,$(OBJECTS)) 57 | $(CC) $(STYLE_LFLAGS) -install_name $(INSTALLNAME) $(ARCHFLAGS) $(LFLAGS) $^ -licucore.A -o $(OBJBASE)/CoreFoundation_$(STYLE) 58 | 59 | install: $(OBJBASE)/CoreFoundation_$(STYLE) 60 | /bin/rm -rf $(DSTBASE)/CoreFoundation.framework 61 | /bin/mkdir -p $(DSTBASE)/CoreFoundation.framework/Versions/A/Resources 62 | /bin/mkdir -p $(DSTBASE)/CoreFoundation.framework/Versions/A/Headers 63 | /bin/mkdir -p $(DSTBASE)/CoreFoundation.framework/Versions/A/PrivateHeaders 64 | /bin/ln -sf A $(DSTBASE)/CoreFoundation.framework/Versions/Current 65 | /bin/ln -sf Versions/Current/Resources $(DSTBASE)/CoreFoundation.framework/Resources 66 | /bin/ln -sf Versions/Current/Headers $(DSTBASE)/CoreFoundation.framework/Headers 67 | /bin/ln -sf Versions/Current/PrivateHeaders $(DSTBASE)/CoreFoundation.framework/PrivateHeaders 68 | /bin/ln -sf Versions/Current/CoreFoundation $(DSTBASE)/CoreFoundation.framework/CoreFoundation 69 | /bin/cp Info.plist $(DSTBASE)/CoreFoundation.framework/Versions/A/Resources 70 | /bin/mkdir -p $(DSTBASE)/CoreFoundation.framework/Versions/A/Resources/en.lproj 71 | /bin/cp $(PUBLIC_HEADERS) $(DSTBASE)/CoreFoundation.framework/Versions/A/Headers 72 | /bin/cp $(PRIVATE_HEADERS) $(DSTBASE)/CoreFoundation.framework/Versions/A/PrivateHeaders 73 | #/usr/bin/strip -S -o $(DSTBASE)/CoreFoundation.framework/Versions/A/CoreFoundation $(OBJBASE)/CoreFoundation_$(STYLE) 74 | /bin/cp $(OBJBASE)/CoreFoundation_$(STYLE) $(DSTBASE)/CoreFoundation.framework/Versions/A/CoreFoundation 75 | /usr/bin/dsymutil $(DSTBASE)/CoreFoundation.framework/Versions/A/CoreFoundation -o $(DSTBASE)/CoreFoundation.framework.dSYM 76 | /usr/sbin/chown -RH -f root:wheel $(DSTBASE)/CoreFoundation.framework 77 | /bin/chmod -RH a-w,a+rX $(DSTBASE)/CoreFoundation.framework 78 | /bin/chmod -RH u+w $(DSTBASE) 79 | install_name_tool -id /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation $(DSTBASE)/CoreFoundation.framework/Versions/A/CoreFoundation 80 | @echo "Installing done. The framework is in $(DSTBASE)" 81 | 82 | -------------------------------------------------------------------------------- /MakefileLinux: -------------------------------------------------------------------------------- 1 | 2 | include MakefileVersion 3 | 4 | MIN_MACOSX_VERSION=10.9 5 | MAX_MACOSX_VERSION=MAC_OS_X_VERSION_10_9 6 | 7 | OBJECTS = CFCharacterSet.o CFPreferences.o CFApplicationPreferences.o CFXMLPreferencesDomain.o CFStringEncodingConverter.o CFUniChar.o CFArray.o CFOldStylePList.o CFPropertyList.o CFStringEncodingDatabase.o CFUnicodeDecomposition.o CFBag.o CFData.o CFStringEncodings.o CFUnicodePrecomposition.o CFBase.o CFDate.o CFNumber.o CFRuntime.o CFStringScanner.o CFBinaryHeap.o CFDateFormatter.o CFNumberFormatter.o CFSet.o CFStringUtilities.o CFUtilities.o CFBinaryPList.o CFDictionary.o CFPlatform.o CFSystemDirectories.o CFVersion.o CFBitVector.o CFError.o CFPlatformConverters.o CFTimeZone.o CFBuiltinConverters.o CFFileUtilities.o CFSortFunctions.o CFTree.o CFICUConverters.o CFURL.o CFLocale.o CFURLAccess.o CFCalendar.o CFLocaleIdentifier.o CFString.o CFUUID.o CFStorage.o CFLocaleKeys.o 8 | OBJECTS += CFBasicHash.o 9 | HFILES = $(wildcard *.h) 10 | INTERMEDIATE_HFILES = $(addprefix $(OBJBASE)/CoreFoundation/,$(HFILES)) 11 | 12 | PUBLIC_HEADERS=CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMachPort.h CFNumber.h CFNumberFormatter.h CFPreferences.h CFPropertyList.h CFSet.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFAvailability.h CFUtilities.h CoreFoundation.h TargetConditionals.h 13 | 14 | PRIVATE_HEADERS= CFCharacterSetPriv.h CFError_Private.h CFLogUtilities.h CFPriv.h CFRuntime.h CFStorage.h CFStringDefaultEncoding.h CFStringEncodingConverter.h CFStringEncodingConverterExt.h CFUniChar.h CFUnicodeDecomposition.h CFUnicodePrecomposition.h ForFoundationOnly.h CFICULogging.h 15 | 16 | RESOURCES = CFCharacterSetBitmaps.bitmap CFUnicodeData-L.mapping CFUnicodeData-B.mapping 17 | 18 | OBJBASE_ROOT = CF-Objects 19 | OBJBASE = $(OBJBASE_ROOT)/$(STYLE) 20 | DSTBASE = /usr/local 21 | 22 | STYLE=normal 23 | STYLE_CFLAGS=-O0 -g 24 | STYLE_LFLAGS= 25 | 26 | CC = /usr/bin/clang 27 | 28 | CFLAGS=-c -x c -fblocks -fpic -pipe -std=gnu99 -Wno-trigraphs -fexceptions -DCF_BUILDING_CF=1 -DDEPLOYMENT_TARGET_LINUX=1 -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MAX_MACOSX_VERSION) -DU_SHOW_DRAFT_API=1 -DU_SHOW_CPLUSPLUS_API=0 -I$(OBJBASE) -I$(OBJBASE)/CoreFoundation -DVERSION=$(VERSION) -include CoreFoundation_Prefix.h 29 | 30 | LFLAGS=-shared -fpic -init=___CFInitialize -Wl,--no-undefined,-soname,libCoreFoundation.so 31 | 32 | # Libs for open source version of ICU 33 | LIBS=-lc -lpthread -lm -lrt -licuuc -licudata -licui18n -lBlocksRuntime 34 | 35 | .PHONY: all install clean 36 | .PRECIOUS: $(OBJBASE)/CoreFoundation/%.h 37 | 38 | all: $(OBJBASE)/libCoreFoundation.so 39 | 40 | clean: 41 | -/bin/rm -rf $(OBJBASE_ROOT) 42 | 43 | $(OBJBASE)/CoreFoundation: 44 | /bin/mkdir -p $(OBJBASE)/CoreFoundation 45 | 46 | $(OBJBASE)/CoreFoundation/%.h: %.h $(OBJBASE)/CoreFoundation 47 | /bin/cp $< $@ 48 | 49 | $(OBJBASE)/%.o: %.c $(INTERMEDIATE_HFILES) 50 | $(CC) $(STYLE_CFLAGS) $(CFLAGS) $< -o $@ 51 | 52 | $(OBJBASE)/%.o: %.m $(INTERMEDIATE_HFILES) 53 | $(CC) $(STYLE_CFLAGS) $(CFLAGS) $< -o $@ 54 | 55 | $(OBJBASE)/libCoreFoundation.so: $(addprefix $(OBJBASE)/,$(OBJECTS)) 56 | $(CC) $(STYLE_LFLAGS) $(LFLAGS) $^ -L/usr/local/lib $(LIBS) -o $(OBJBASE)/libCoreFoundation.so 57 | @echo "Building done. 'sudo make install' to put the result into $(DSTBASE)/lib and $(DSTBASE)/include." 58 | 59 | install: $(OBJBASE)/libCoreFoundation.so 60 | /bin/mkdir -p $(DSTBASE) 61 | /bin/mkdir -p $(DSTBASE)/include/CoreFoundation 62 | /bin/mkdir -p $(DSTBASE)/share/CoreFoundation 63 | -/bin/rm $(DSTBASE)/include/CoreFoundation/*.h 64 | /bin/mkdir -p $(DSTBASE)/lib 65 | /bin/cp $(PRIVATE_HEADERS) $(DSTBASE)/include/CoreFoundation 66 | /bin/cp $(PUBLIC_HEADERS) $(DSTBASE)/include/CoreFoundation 67 | /bin/cp $(OBJBASE)/libCoreFoundation.so $(DSTBASE)/lib 68 | /bin/cp $(RESOURCES) $(DSTBASE)/share/CoreFoundation 69 | # this one goes outside the base directory 70 | /bin/cp TargetConditionals.h $(DSTBASE)/include 71 | /sbin/ldconfig -n $(DSTBASE)/lib 72 | @echo "Installing done. The library is in $(DSTBASE)/lib and the headers are in $(DSTBASE)/include/CoreFoundation" 73 | -------------------------------------------------------------------------------- /MakefileVersion: -------------------------------------------------------------------------------- 1 | VERSION=1153.18 2 | -------------------------------------------------------------------------------- /PropertyList.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README_CFLITE: -------------------------------------------------------------------------------- 1 | What is CFLite? 2 | **** **** **** **** **** 3 | 4 | CFLite is an open source version of the CoreFoundation framework found on Mac OS X and iOS. It is designed to be simple and portable. For example, it can be used on other platforms to read and write property lists that may come from Mac OS X or iOS. 5 | 6 | It is important to note that this version is not the exact same version as is used on Mac OS X or iOS, but they do share a significant amount of code. 7 | 8 | How to Contact the CFLite Team 9 | **** **** **** **** **** 10 | 11 | If you have patches, or enhancement requests, please file a bug report here: 12 | https://bugreport.apple.com 13 | 14 | Please include as much detail as possible in your bug report, including platform, compiler, CFLite version, and a test case if appropriate. Mention that the bug should be sent to CoreFoundation in your descriptioon. 15 | 16 | 17 | Building and Installing CFLite 18 | **** **** **** **** **** 19 | 20 | On Mac OS X / Darwin 21 | ---- ---- ---- ---- ---- 22 | 23 | Use the default Makefile: 24 | 25 | % make 26 | 27 | This will create a CoreFoundation.framework, containing the shared library, header files, and resources. You can link to this library and use it at runtime by setting the DYLD_FRAMEWORK_PATH environment variable. 'man dyld' will give more information about this. 28 | 29 | An application must not link both this version of CFLite and the installed version of CoreFoundation. They are not compatible. CFLite will also not work with Foundation or any higher-level Cocoa framework that depends on the installed CoreFoundation. 30 | 31 | On Linux 32 | ---- ---- ---- ---- ---- 33 | 34 | First, you will need to fetch a few dependencies of CoreFoundation. 35 | 36 | * clang compiler 2.8 or later 37 | http://clang.llvm.org/ 38 | 39 | CoreFoundation use the clang compiler to support modern features like Blocks. 40 | 41 | * libBlocksRuntime 42 | http://compiler-rt.llvm.org/ 43 | 44 | This small shared library supports Blocks at runtime. You will need the 'cmake' utility (http://www.cmake.org/) to build this. It is recommended to install this library in /usr/local/lib and put the headers in /usr/local/include. 45 | 46 | * ICU 4.4 or later (ICU4C, the C version, not ICU4J, the Java version) 47 | http://site.icu-project.org/download 48 | 49 | ICU is used for locales, time zones, calendars, and unicode support in CoreFoundation. Again, it is recommended to install this library in /usr/local/lib. 50 | 51 | Once you have the dependencies in place, build CFLite using the Linux Makefile: 52 | 53 | % sudo make -f MakefileLinux install 54 | 55 | This will create and install these files: 56 | 57 | /usr/local/lib/libCoreFoundation.so 58 | /usr/local/include/CoreFoundation/
59 | /usr/local/include/TargetConditionals.h 60 | /usr/local/share/CoreFoundation/ 61 | 62 | Make sure to set LD_LIBRARY_PATH environment variable to include /usr/local/lib when using an executable that has linked CFLite. 63 | 64 | On Windows 65 | ---- ---- ---- ---- ---- 66 | 67 | CFLite does not yet fully support Windows. The primary missing dependency is a version of clang that can build a dynamically linked library (.DLL) that supports the Windows executable format. 68 | 69 | Using CFLite 70 | **** **** **** **** **** 71 | 72 | The Mac OS X version of CFLite supports most of the functionality of the full CoreFoundation. The Linux version of CFLite focuses on strings, dates, collections, and other property-list related items. 73 | 74 | There is an example of using CFLite on linux to process property lists in the 'plconvert.c' file. 75 | -------------------------------------------------------------------------------- /SymbolAliases: -------------------------------------------------------------------------------- 1 | _kCFCalendarIdentifierBuddhist _kCFBuddhistCalendar 2 | _kCFCalendarIdentifierChinese _kCFChineseCalendar 3 | _kCFCalendarIdentifierGregorian _kCFGregorianCalendar 4 | _kCFCalendarIdentifierHebrew _kCFHebrewCalendar 5 | _kCFCalendarIdentifierISO8601 _kCFISO8601Calendar 6 | _kCFCalendarIdentifierIndian _kCFIndianCalendar 7 | _kCFCalendarIdentifierIslamic _kCFIslamicCalendar 8 | _kCFCalendarIdentifierIslamicCivil _kCFIslamicCivilCalendar 9 | _kCFCalendarIdentifierJapanese _kCFJapaneseCalendar 10 | _kCFCalendarIdentifierPersian _kCFPersianCalendar 11 | _kCFCalendarIdentifierRepublicOfChina _kCFRepublicOfChinaCalendar 12 | _kCFCalendarIdentifierIslamicTabular _kCFIslamicTabularCalendar 13 | _kCFCalendarIdentifierIslamicUmmAlQura _kCFIslamicUmmAlQuraCalendar 14 | 15 | 16 | _kCFLocaleCalendarIdentifierKey _kCFLocaleCalendarIdentifier 17 | _kCFLocaleCalendarKey _kCFLocaleCalendar 18 | _kCFLocaleCollationIdentifierKey _kCFLocaleCollationIdentifier 19 | _kCFLocaleCollatorIdentifierKey _kCFLocaleCollatorIdentifier 20 | _kCFLocaleCountryCodeKey _kCFLocaleCountryCode 21 | _kCFLocaleCurrencyCodeKey _kCFLocaleCurrencyCode 22 | _kCFLocaleCurrencySymbolKey _kCFLocaleCurrencySymbol 23 | _kCFLocaleDecimalSeparatorKey _kCFLocaleDecimalSeparator 24 | _kCFLocaleExemplarCharacterSetKey _kCFLocaleExemplarCharacterSet 25 | _kCFLocaleGroupingSeparatorKey _kCFLocaleGroupingSeparator 26 | _kCFLocaleIdentifierKey _kCFLocaleIdentifier 27 | _kCFLocaleLanguageCodeKey _kCFLocaleLanguageCode 28 | _kCFLocaleMeasurementSystemKey _kCFLocaleMeasurementSystem 29 | _kCFLocaleScriptCodeKey _kCFLocaleScriptCode 30 | _kCFLocaleUsesMetricSystemKey _kCFLocaleUsesMetricSystem 31 | _kCFLocaleVariantCodeKey _kCFLocaleVariantCode 32 | _kCFDateFormatterAMSymbolKey _kCFDateFormatterAMSymbol 33 | _kCFDateFormatterCalendarKey _kCFDateFormatterCalendar 34 | _kCFDateFormatterCalendarIdentifierKey _kCFDateFormatterCalendarIdentifier 35 | _kCFDateFormatterDefaultDateKey _kCFDateFormatterDefaultDate 36 | _kCFDateFormatterDefaultFormatKey _kCFDateFormatterDefaultFormat 37 | _kCFDateFormatterEraSymbolsKey _kCFDateFormatterEraSymbols 38 | _kCFDateFormatterGregorianStartDateKey _kCFDateFormatterGregorianStartDate 39 | _kCFDateFormatterIsLenientKey _kCFDateFormatterIsLenient 40 | _kCFDateFormatterLongEraSymbolsKey _kCFDateFormatterLongEraSymbols 41 | _kCFDateFormatterMonthSymbolsKey _kCFDateFormatterMonthSymbols 42 | _kCFDateFormatterPMSymbolKey _kCFDateFormatterPMSymbol 43 | _kCFDateFormatterQuarterSymbolsKey _kCFDateFormatterQuarterSymbols 44 | _kCFDateFormatterShortMonthSymbolsKey _kCFDateFormatterShortMonthSymbols 45 | _kCFDateFormatterShortQuarterSymbolsKey _kCFDateFormatterShortQuarterSymbols 46 | _kCFDateFormatterShortStandaloneMonthSymbolsKey _kCFDateFormatterShortStandaloneMonthSymbols 47 | _kCFDateFormatterShortStandaloneQuarterSymbolsKey _kCFDateFormatterShortStandaloneQuarterSymbols 48 | _kCFDateFormatterShortStandaloneWeekdaySymbolsKey _kCFDateFormatterShortStandaloneWeekdaySymbols 49 | _kCFDateFormatterShortWeekdaySymbolsKey _kCFDateFormatterShortWeekdaySymbols 50 | _kCFDateFormatterStandaloneMonthSymbolsKey _kCFDateFormatterStandaloneMonthSymbols 51 | _kCFDateFormatterStandaloneQuarterSymbolsKey _kCFDateFormatterStandaloneQuarterSymbols 52 | _kCFDateFormatterStandaloneWeekdaySymbolsKey _kCFDateFormatterStandaloneWeekdaySymbols 53 | _kCFDateFormatterTimeZoneKey _kCFDateFormatterTimeZone 54 | _kCFDateFormatterTwoDigitStartDateKey _kCFDateFormatterTwoDigitStartDate 55 | _kCFDateFormatterVeryShortMonthSymbolsKey _kCFDateFormatterVeryShortMonthSymbols 56 | _kCFDateFormatterVeryShortStandaloneMonthSymbolsKey _kCFDateFormatterVeryShortStandaloneMonthSymbols 57 | _kCFDateFormatterVeryShortStandaloneWeekdaySymbolsKey _kCFDateFormatterVeryShortStandaloneWeekdaySymbols 58 | _kCFDateFormatterVeryShortWeekdaySymbolsKey _kCFDateFormatterVeryShortWeekdaySymbols 59 | _kCFDateFormatterWeekdaySymbolsKey _kCFDateFormatterWeekdaySymbols 60 | _kCFNumberFormatterAlwaysShowDecimalSeparatorKey _kCFNumberFormatterAlwaysShowDecimalSeparator 61 | _kCFNumberFormatterCurrencyCodeKey _kCFNumberFormatterCurrencyCode 62 | _kCFNumberFormatterCurrencyDecimalSeparatorKey _kCFNumberFormatterCurrencyDecimalSeparator 63 | _kCFNumberFormatterCurrencyGroupingSeparatorKey _kCFNumberFormatterCurrencyGroupingSeparator 64 | _kCFNumberFormatterCurrencySymbolKey _kCFNumberFormatterCurrencySymbol 65 | _kCFNumberFormatterDecimalSeparatorKey _kCFNumberFormatterDecimalSeparator 66 | _kCFNumberFormatterDefaultFormatKey _kCFNumberFormatterDefaultFormat 67 | _kCFNumberFormatterExponentSymbolKey _kCFNumberFormatterExponentSymbol 68 | _kCFNumberFormatterFormatWidthKey _kCFNumberFormatterFormatWidth 69 | _kCFNumberFormatterGroupingSeparatorKey _kCFNumberFormatterGroupingSeparator 70 | _kCFNumberFormatterGroupingSizeKey _kCFNumberFormatterGroupingSize 71 | _kCFNumberFormatterInfinitySymbolKey _kCFNumberFormatterInfinitySymbol 72 | _kCFNumberFormatterInternationalCurrencySymbolKey _kCFNumberFormatterInternationalCurrencySymbol 73 | _kCFNumberFormatterIsLenientKey _kCFNumberFormatterIsLenient 74 | _kCFNumberFormatterMaxFractionDigitsKey _kCFNumberFormatterMaxFractionDigits 75 | _kCFNumberFormatterMaxIntegerDigitsKey _kCFNumberFormatterMaxIntegerDigits 76 | _kCFNumberFormatterMaxSignificantDigitsKey _kCFNumberFormatterMaxSignificantDigits 77 | _kCFNumberFormatterMinFractionDigitsKey _kCFNumberFormatterMinFractionDigits 78 | _kCFNumberFormatterMinIntegerDigitsKey _kCFNumberFormatterMinIntegerDigits 79 | _kCFNumberFormatterMinSignificantDigitsKey _kCFNumberFormatterMinSignificantDigits 80 | _kCFNumberFormatterMinusSignKey _kCFNumberFormatterMinusSign 81 | _kCFNumberFormatterMultiplierKey _kCFNumberFormatterMultiplier 82 | _kCFNumberFormatterNaNSymbolKey _kCFNumberFormatterNaNSymbol 83 | _kCFNumberFormatterNegativePrefixKey _kCFNumberFormatterNegativePrefix 84 | _kCFNumberFormatterNegativeSuffixKey _kCFNumberFormatterNegativeSuffix 85 | _kCFNumberFormatterPaddingCharacterKey _kCFNumberFormatterPaddingCharacter 86 | _kCFNumberFormatterPaddingPositionKey _kCFNumberFormatterPaddingPosition 87 | _kCFNumberFormatterPerMillSymbolKey _kCFNumberFormatterPerMillSymbol 88 | _kCFNumberFormatterPercentSymbolKey _kCFNumberFormatterPercentSymbol 89 | _kCFNumberFormatterPlusSignKey _kCFNumberFormatterPlusSign 90 | _kCFNumberFormatterPositivePrefixKey _kCFNumberFormatterPositivePrefix 91 | _kCFNumberFormatterPositiveSuffixKey _kCFNumberFormatterPositiveSuffix 92 | _kCFNumberFormatterRoundingIncrementKey _kCFNumberFormatterRoundingIncrement 93 | _kCFNumberFormatterRoundingModeKey _kCFNumberFormatterRoundingMode 94 | _kCFNumberFormatterSecondaryGroupingSizeKey _kCFNumberFormatterSecondaryGroupingSize 95 | _kCFNumberFormatterUseGroupingSeparatorKey _kCFNumberFormatterUseGroupingSeparator 96 | _kCFNumberFormatterUseSignificantDigitsKey _kCFNumberFormatterUseSignificantDigits 97 | _kCFNumberFormatterZeroSymbolKey _kCFNumberFormatterZeroSymbol 98 | _kCFNumberFormatterUsesCharacterDirectionKey _kCFNumberFormatterUsesCharacterDirection 99 | _kCFDateFormatterUsesCharacterDirectionKey _kCFDateFormatterUsesCharacterDirection 100 | _kCFDateFormatterCalendarIdentifierKey _kCFDateFormatterCalendarName 101 | -------------------------------------------------------------------------------- /TargetConditionals.h: -------------------------------------------------------------------------------- 1 | /* TargetConditionals.h 2 | Copyright (c) 2010-2014, Apple Inc. All rights reserved. 3 | For CF on Linux ONLY 4 | */ 5 | 6 | #ifndef __TARGETCONDITIONALS__ 7 | #define __TARGETCONDITIONALS__ 8 | 9 | #define TARGET_OS_MAC 0 10 | #define TARGET_OS_WIN32 0 11 | #define TARGET_OS_UNIX 0 12 | #define TARGET_OS_EMBEDDED 0 13 | #define TARGET_OS_IPHONE 0 14 | #define TARGET_IPHONE_SIMULATOR 0 15 | #define TARGET_OS_LINUX 1 16 | 17 | #endif /* __TARGETCONDITIONALS__ */ 18 | -------------------------------------------------------------------------------- /plconvert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | // Mac OS X: clang -F -framework CoreFoundation Examples/plconvert.c -o plconvert 25 | // note: When running this sample, be sure to set the environment variable DYLD_FRAMEWORK_PATH to point to the directory containing your new version of CoreFoundation. 26 | // e.g. 27 | // DYLD_FRAMEWORK_PATH=/tmp/CF-Root ./plconvert 28 | // 29 | // Linux: clang -I/usr/local/include -L/usr/local/lib -lCoreFoundation plconvert.c -o plconvert 30 | 31 | /* 32 | This example shows usage of CFString, CFData, and other CFPropertyList types. It takes two arguments: 33 | 1. A property list file to read, in either binary or XML property list format. 34 | 2. A file name to write a converted property list file to. 35 | If the first input is binary, the output is XML and vice-versa. 36 | */ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | 47 | static void logIt(CFStringRef format, ...) { 48 | va_list args; 49 | va_start(args, format); 50 | CFStringRef str = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, NULL, format, args); 51 | if (!str) return; 52 | 53 | CFIndex blen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); 54 | char *buf = str ? (char *)malloc(blen + 1) : 0; 55 | if (buf) { 56 | Boolean converted = CFStringGetCString(str, buf, blen, kCFStringEncodingUTF8); 57 | if (converted) { 58 | // null-terminate 59 | buf[blen] = 0; 60 | printf("%s\n", buf); 61 | } 62 | } 63 | if (buf) free(buf); 64 | if (str) CFRelease(str); va_end(args); 65 | } 66 | 67 | static CFMutableDataRef createDataFromFile(const char *fname) { 68 | int fd = open(fname, O_RDONLY); 69 | CFMutableDataRef res = CFDataCreateMutable(kCFAllocatorSystemDefault, 0); 70 | char buf[4096]; 71 | 72 | ssize_t amountRead; 73 | while ((amountRead = read(fd, buf, 4096)) > 0) { 74 | CFDataAppendBytes(res, (const UInt8 *)buf, amountRead); 75 | } 76 | 77 | close(fd); 78 | return res; 79 | } 80 | 81 | static bool writeDataToFile(CFDataRef data, const char *fname) { 82 | int fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666); 83 | if (fd < 0) { 84 | printf("There was an error creating the file: %d", errno); 85 | return false; 86 | } 87 | int dataLen = CFDataGetLength(data); 88 | int w = write(fd, CFDataGetBytePtr(data), dataLen); 89 | fsync(fd); 90 | close(fd); 91 | if (w != dataLen) return false; 92 | return true; 93 | } 94 | 95 | int main(int argc, char **argv) { 96 | 97 | if (argc != 3) { 98 | printf("Usage: plconvert \nIf the in file is an XML property list, convert to binary property list in out file. If the in file is a binary property list, convert to XML property list in out file.\n"); 99 | } else { 100 | CFMutableDataRef plistData = createDataFromFile(argv[1]); 101 | if (!plistData) { 102 | printf("Unable to create data from file name: %s", argv[1]); 103 | } else { 104 | CFPropertyListFormat fmt; 105 | CFErrorRef err; 106 | CFPropertyListRef plist = CFPropertyListCreateWithData(kCFAllocatorSystemDefault, (CFDataRef)plistData, 0, &fmt, &err); 107 | if (!plist) { 108 | logIt(CFSTR("Unable to create property list from data: %@"), err); 109 | } else { 110 | logIt(CFSTR("Property list contents:\n%@"), plist); 111 | if (fmt == kCFPropertyListBinaryFormat_v1_0) { 112 | logIt(CFSTR("Converting to XML property list at: %s"), argv[2]); 113 | fmt = kCFPropertyListXMLFormat_v1_0; 114 | } else if (fmt == kCFPropertyListXMLFormat_v1_0) { 115 | logIt(CFSTR("Converting to binary property list at: %s"), argv[2]); 116 | fmt = kCFPropertyListBinaryFormat_v1_0; 117 | } else { 118 | logIt(CFSTR("Unknown property list format! Not converting output format.")); 119 | } 120 | 121 | CFDataRef outputData = CFPropertyListCreateData(kCFAllocatorSystemDefault, plist, fmt, 0, &err); 122 | if (!outputData) { 123 | logIt(CFSTR("Unable to write property list to data: %@"), err); 124 | } else { 125 | bool success = writeDataToFile(outputData, argv[2]); 126 | if (!success) { 127 | logIt(CFSTR("Unable to write data to file")); 128 | } 129 | CFRelease(outputData); 130 | } 131 | CFRelease(plist); 132 | } 133 | CFRelease(plistData); 134 | } 135 | } 136 | } 137 | --------------------------------------------------------------------------------